From bbbe1d3307e50574284d497d6ab6bfe98ae9b5db Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Tue, 31 Dec 2019 13:25:47 -0600 Subject: [PATCH] [Attributor][FIX] Return CHANGED once a pessimistic fixpoint is reached. --- lib/Transforms/IPO/Attributor.cpp | 3 +- test/Transforms/Attributor/value-simplify.ll | 49 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/IPO/Attributor.cpp b/lib/Transforms/IPO/Attributor.cpp index a09a46e642f..5f9dccad060 100644 --- a/lib/Transforms/IPO/Attributor.cpp +++ b/lib/Transforms/IPO/Attributor.cpp @@ -4275,7 +4275,8 @@ struct AAValueSimplifyImpl : AAValueSimplify { // NOTE: Associated value will be returned in a pessimistic fixpoint and is // regarded as known. That's why`indicateOptimisticFixpoint` is called. SimplifiedAssociatedValue = &getAssociatedValue(); - return indicateOptimisticFixpoint(); + indicateOptimisticFixpoint(); + return ChangeStatus::CHANGED; } protected: diff --git a/test/Transforms/Attributor/value-simplify.ll b/test/Transforms/Attributor/value-simplify.ll index c7bce0ad9fe..c2fa65284eb 100644 --- a/test/Transforms/Attributor/value-simplify.ll +++ b/test/Transforms/Attributor/value-simplify.ll @@ -273,4 +273,53 @@ define void @complicated_args_byval() { ret void } +define void @fixpoint_changed(i32* %p) { +; CHECK-LABEL: define {{[^@]+}}@fixpoint_changed +; CHECK-SAME: (i32* nocapture nofree writeonly [[P:%.*]]) +; CHECK-NEXT: entry: +; CHECK-NEXT: br label [[FOR_COND:%.*]] +; CHECK: for.cond: +; CHECK-NEXT: [[J_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[SW_EPILOG:%.*]] ] +; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[J_0]], 30 +; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_END:%.*]] +; CHECK: for.body: +; CHECK-NEXT: switch i32 [[J_0]], label [[SW_EPILOG]] [ +; CHECK-NEXT: i32 1, label [[SW_BB:%.*]] +; CHECK-NEXT: ] +; CHECK: sw.bb: +; CHECK-NEXT: br label [[SW_EPILOG]] +; CHECK: sw.epilog: +; CHECK-NEXT: [[X_0:%.*]] = phi i32 [ 255, [[FOR_BODY]] ], [ 253, [[SW_BB]] ] +; CHECK-NEXT: store i32 [[X_0]], i32* [[P]] +; CHECK-NEXT: [[INC]] = add nsw i32 [[J_0]], 1 +; CHECK-NEXT: br label [[FOR_COND]] +; CHECK: for.end: +; CHECK-NEXT: ret void +; +entry: + br label %for.cond + +for.cond: + %j.0 = phi i32 [ 0, %entry ], [ %inc, %sw.epilog ] + %cmp = icmp slt i32 %j.0, 30 + br i1 %cmp, label %for.body, label %for.end + +for.body: + switch i32 %j.0, label %sw.epilog [ + i32 1, label %sw.bb + ] + +sw.bb: + br label %sw.epilog + +sw.epilog: + %x.0 = phi i32 [ 255, %for.body ], [ 253, %sw.bb ] + store i32 %x.0, i32* %p + %inc = add nsw i32 %j.0, 1 + br label %for.cond + +for.end: + ret void +} + ; UTC_ARGS: --turn off