From: Tyker Date: Mon, 17 Aug 2020 18:47:02 +0000 (+0200) Subject: [AssumeBundles] Fix Bug in Assume Queries X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a79e604462ea26c73b6869d71b41667819f90281;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/llvm/lib/Analysis/AssumeBundleQueries.cpp b/llvm/lib/Analysis/AssumeBundleQueries.cpp index 972d0d3..9539af6 100644 --- a/llvm/lib/Analysis/AssumeBundleQueries.cpp +++ b/llvm/lib/Analysis/AssumeBundleQueries.cpp @@ -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(); } diff --git a/llvm/test/Transforms/PhaseOrdering/d83507-knowledge-retention-bug.ll b/llvm/test/Transforms/PhaseOrdering/d83507-knowledge-retention-bug.ll index 9681361..d0f85cd 100644 --- a/llvm/test/Transforms/PhaseOrdering/d83507-knowledge-retention-bug.ll +++ b/llvm/test/Transforms/PhaseOrdering/d83507-knowledge-retention-bug.ll @@ -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