From 4a7a988442dfa40309b34746218c07ebf758b378 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Wed, 9 Sep 2020 16:08:20 -0500 Subject: [PATCH] [Attributor][FIX] Move assertion to make it not trivially fail 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 | 4 ++-- llvm/test/Transforms/Attributor/value-simplify.ll | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp index 6e31625..3f85d96 100644 --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -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; } diff --git a/llvm/test/Transforms/Attributor/value-simplify.ll b/llvm/test/Transforms/Attributor/value-simplify.ll index 174fd79..8fc34cd 100644 --- a/llvm/test/Transforms/Attributor/value-simplify.ll +++ b/llvm/test/Transforms/Attributor/value-simplify.ll @@ -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 +} -- 2.7.4