summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Transforms/Utils/LocalTest.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2019-10-02 19:38:24 +0000
committerFlorian Hahn <flo@fhahn.com>2019-10-02 19:38:24 +0000
commita80b6c15425f82521c624ff24c5c0a34cd534d54 (patch)
tree5f75a320b55c57aa95d69c6f652f76a3579cf2f8 /llvm/unittests/Transforms/Utils/LocalTest.cpp
parentc78c0e08be2192b3bc33f449f26480a58e89032b (diff)
downloadbcm5719-llvm-a80b6c15425f82521c624ff24c5c0a34cd534d54.tar.gz
bcm5719-llvm-a80b6c15425f82521c624ff24c5c0a34cd534d54.zip
[Local] Handle terminators with users in removeUnreachableBlocks.
Terminators like invoke can have users outside the current basic block. We have to replace those users with undef, before replacing the terminator. This fixes a crash exposed by rL373430. Reviewers: brzycki, asbirlea, davide, spatel Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D68327 llvm-svn: 373513
Diffstat (limited to 'llvm/unittests/Transforms/Utils/LocalTest.cpp')
-rw-r--r--llvm/unittests/Transforms/Utils/LocalTest.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/unittests/Transforms/Utils/LocalTest.cpp b/llvm/unittests/Transforms/Utils/LocalTest.cpp
index ff2eda1cec0..1f67a1ec84c 100644
--- a/llvm/unittests/Transforms/Utils/LocalTest.cpp
+++ b/llvm/unittests/Transforms/Utils/LocalTest.cpp
@@ -867,6 +867,36 @@ TEST(Local, RemoveUnreachableBlocks) {
bb2:
br label %bb1
}
+
+ declare i32 @__gxx_personality_v0(...)
+
+ define void @invoke_terminator() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+ entry:
+ br i1 undef, label %invoke.block, label %exit
+
+ invoke.block:
+ %cond = invoke zeroext i1 @invokable()
+ to label %continue.block unwind label %lpad.block
+
+ continue.block:
+ br i1 %cond, label %if.then, label %if.end
+
+ if.then:
+ unreachable
+
+ if.end:
+ unreachable
+
+ lpad.block:
+ %lp = landingpad { i8*, i32 }
+ catch i8* null
+ br label %exit
+
+ exit:
+ ret void
+ }
+
+ declare i1 @invokable()
)");
auto runEager = [&](Function &F, DominatorTree *DT) {
@@ -890,12 +920,14 @@ TEST(Local, RemoveUnreachableBlocks) {
runWithDomTree(*M, "br_self_loop", runEager);
runWithDomTree(*M, "br_constant", runEager);
runWithDomTree(*M, "br_loop", runEager);
+ runWithDomTree(*M, "invoke_terminator", runEager);
// Test removeUnreachableBlocks under Lazy UpdateStrategy.
runWithDomTree(*M, "br_simple", runLazy);
runWithDomTree(*M, "br_self_loop", runLazy);
runWithDomTree(*M, "br_constant", runLazy);
runWithDomTree(*M, "br_loop", runLazy);
+ runWithDomTree(*M, "invoke_terminator", runLazy);
M = parseIR(C,
R"(
OpenPOWER on IntegriCloud