[Attributor][FIX] Move assertion to make it not trivially fail
authorJohannes Doerfert <johannes@jdoerfert.de>
Wed, 9 Sep 2020 21:08:20 +0000 (16:08 -0500)
committerJohannes Doerfert <johannes@jdoerfert.de>
Tue, 6 Oct 2020 14:32:18 +0000 (09:32 -0500)
The idea of this assertion was to check the simplified value before we
assign it, not after, which caused this to trivially fail all the time.

llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/test/Transforms/Attributor/value-simplify.ll

index 6e31625..3f85d96 100644 (file)
@@ -4774,10 +4774,10 @@ struct AAValueSimplifyFloating : AAValueSimplifyImpl {
     if (Op0IsNull && Op1IsNull) {
       Value *NewVal = ConstantInt::get(
           Type::getInt1Ty(Ctx), ICmp->getPredicate() == CmpInst::ICMP_EQ);
-      SimplifiedAssociatedValue = NewVal;
-      indicateOptimisticFixpoint();
       assert(!SimplifiedAssociatedValue.hasValue() &&
              "Did not expect non-fixed value for constant comparison");
+      SimplifiedAssociatedValue = NewVal;
+      indicateOptimisticFixpoint();
       Changed = ChangeStatus::CHANGED;
       return true;
     }
index 174fd79..8fc34cd 100644 (file)
@@ -788,3 +788,18 @@ define internal i8 @callee(i8 %a) {
   ret i8 %c
 }
 
+
+define i1 @icmp() {
+; IS__TUNIT____: Function Attrs: nofree nosync nounwind readnone willreturn
+; IS__TUNIT____-LABEL: define {{[^@]+}}@icmp
+; IS__TUNIT____-SAME: () [[ATTR1]] {
+; IS__TUNIT____-NEXT:    ret i1 true
+;
+; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readnone willreturn
+; IS__CGSCC____-LABEL: define {{[^@]+}}@icmp
+; IS__CGSCC____-SAME: () [[ATTR1]] {
+; IS__CGSCC____-NEXT:    ret i1 true
+;
+  %c = icmp eq i8* null, null
+  ret i1 %c
+}