[AssumeBundles] Fix Bug in Assume Queries

this bug was causing miscompile.
now clang cant properly selfhost with -mllvm --enable-knowledge-retention

Reviewed By: jdoerfert, lebedev.ri

Differential Revision: https://reviews.llvm.org/D83507
This commit is contained in:
Tyker 2020-08-17 20:47:02 +02:00
parent 38b9cda6d0
commit dfa36c6cdf
2 changed files with 8 additions and 2 deletions

View File

@ -172,12 +172,15 @@ llvm::getKnowledgeForValue(const Value *V,
if (!II || Elem.Index == AssumptionCache::ExprResultIdx)
continue;
if (RetainedKnowledge RK = getKnowledgeFromBundle(
*II, II->bundle_op_info_begin()[Elem.Index]))
*II, II->bundle_op_info_begin()[Elem.Index])) {
if (V != RK.WasOn)
continue;
if (is_contained(AttrKinds, RK.AttrKind) &&
Filter(RK, II, &II->bundle_op_info_begin()[Elem.Index])) {
NumUsefullAssumeQueries++;
return RK;
}
}
}
return RetainedKnowledge::none();
}

View File

@ -13,7 +13,10 @@ define %0* @f1() local_unnamed_addr {
; ANY-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(%0* [[I1]]) ]
; ANY-NEXT: [[I4:%.*]] = getelementptr inbounds [[TMP0:%.*]], %0* [[I1]], i64 0, i32 0
; ANY-NEXT: [[I5]] = load %0*, %0** [[I4]], align 8
; ANY-NEXT: br label [[BB3]]
; ANY-NEXT: [[I2:%.*]] = icmp eq %0* [[I5]], null
; ANY-NEXT: br i1 [[I2]], label [[BB6:%.*]], label [[BB3]]
; ANY: bb6:
; ANY-NEXT: ret %0* undef
;
bb:
br label %bb1