[llvm] a79e604 - [AssumeBundles] Fix Bug in Assume Queries
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 17 12:37:30 PDT 2020
Author: Tyker
Date: 2020-08-17T21:36:53+02:00
New Revision: a79e604462ea26c73b6869d71b41667819f90281
URL: https://github.com/llvm/llvm-project/commit/a79e604462ea26c73b6869d71b41667819f90281
DIFF: https://github.com/llvm/llvm-project/commit/a79e604462ea26c73b6869d71b41667819f90281.diff
LOG: [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
Added:
Modified:
llvm/lib/Analysis/AssumeBundleQueries.cpp
llvm/test/Transforms/PhaseOrdering/d83507-knowledge-retention-bug.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/AssumeBundleQueries.cpp b/llvm/lib/Analysis/AssumeBundleQueries.cpp
index 972d0d3ea7f2..9539af6d9d45 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 968136108f92..d0f85cd67d9d 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
More information about the llvm-commits
mailing list