From 631c7c3e442e06dfab7a2a417b1d4f8a989bfdd8 Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Wed, 6 Jul 2016 19:05:41 +0000 Subject: [PATCH] Work around PR28400 a bit harder. We were still crashing in the "no change" case because LVI was not getting invalidated. See the thread "Should analyses be able to hold AssertingVH to IR? (related to PR28400)" for more discussion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274656 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/JumpThreading.cpp | 7 +++++-- .../JumpThreading/crash-assertingvh.ll | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 test/Transforms/JumpThreading/crash-assertingvh.ll diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp index 8e6020bb22e1..d0266b8bf7e2 100644 --- a/lib/Transforms/Scalar/JumpThreading.cpp +++ b/lib/Transforms/Scalar/JumpThreading.cpp @@ -148,11 +148,14 @@ PreservedAnalyses JumpThreadingPass::run(Function &F, } bool Changed = runImpl(F, &TLI, &LVI, HasProfileData, std::move(BFI), std::move(BPI)); + + // FIXME: We need to invalidate LVI to avoid PR28400. Is there a better + // solution? + AM.invalidate(F); + if (!Changed) return PreservedAnalyses::all(); PreservedAnalyses PA; - // FIXME: Not preserving LVI! We need it to be invalidated so that we - // don't run into issues like PR28400. Is there a better solution? PA.preserve(); return PA; } diff --git a/test/Transforms/JumpThreading/crash-assertingvh.ll b/test/Transforms/JumpThreading/crash-assertingvh.ll new file mode 100644 index 000000000000..e78431992239 --- /dev/null +++ b/test/Transforms/JumpThreading/crash-assertingvh.ll @@ -0,0 +1,19 @@ +; RUN: opt -disable-output < %s -passes='module(function(jump-threading),globaldce)' + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +declare i32 @bar() + +define internal i32 @foo() { +entry: + %call4 = call i32 @bar() + %cmp5 = icmp eq i32 %call4, 0 + br i1 %cmp5, label %if.then6, label %if.end8 + +if.then6: + ret i32 0 + +if.end8: + ret i32 1 +}