summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/SimplifyCFG
diff options
context:
space:
mode:
authorJonas Paulsson <paulsson@linux.vnet.ibm.com>2020-03-04 17:11:40 +0100
committerTom Stellard <tstellar@redhat.com>2020-04-16 11:12:13 -0700
commit5fbba36cbe93f12da5c4d6063db21cf35ecc9bfc (patch)
tree624cb0f685d0c9644cec8f7c8e60f02148600baa /llvm/test/Transforms/SimplifyCFG
parent71c3f57326cf956330f47f9061104e0f299cb7cf (diff)
downloadbcm5719-llvm-5fbba36cbe93f12da5c4d6063db21cf35ecc9bfc.tar.gz
bcm5719-llvm-5fbba36cbe93f12da5c4d6063db21cf35ecc9bfc.zip
[SimplifyCFG] Skip merging return blocks if it would break a CallBr.
SimplifyCFG should not merge empty return blocks and leave a CallBr behind with a duplicated destination since the verifier will then trigger an assert. This patch checks for this case and avoids the transformation. CodeGenPrepare has a similar check which also has a FIXME comment about why this is needed. It seems perhaps better if these two passes would eventually instead update the CallBr instruction instead of just checking and avoiding. This fixes https://bugs.llvm.org/show_bug.cgi?id=45062. Review: Craig Topper Differential Revision: https://reviews.llvm.org/D75620 (cherry picked from commit c2dafe12dc24f7f1326f5c4c6a3b23f1485f1bd6)
Diffstat (limited to 'llvm/test/Transforms/SimplifyCFG')
-rw-r--r--llvm/test/Transforms/SimplifyCFG/callbr-destinations.ll28
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/test/Transforms/SimplifyCFG/callbr-destinations.ll b/llvm/test/Transforms/SimplifyCFG/callbr-destinations.ll
new file mode 100644
index 00000000000..18210e5e0b0
--- /dev/null
+++ b/llvm/test/Transforms/SimplifyCFG/callbr-destinations.ll
@@ -0,0 +1,28 @@
+; RUN: opt < %s -simplifycfg -disable-output
+;
+; Test that SimplifyCFG does not cause CallBr instructions to have duplicate
+; destinations, which will cause the verifier to assert.
+
+define void @fun0() {
+entry:
+ callbr void asm sideeffect "", "X"(i8* blockaddress(@fun0, %bb1))
+ to label %bb2 [label %bb1]
+
+bb1: ; preds = %bb
+ ret void
+
+bb2: ; preds = %bb
+ ret void
+}
+
+define void @fun1() {
+entry:
+ callbr void asm sideeffect "", "X"(i8* blockaddress(@fun1, %bb1))
+ to label %bb2 [label %bb1]
+
+bb2: ; preds = %bb
+ ret void
+
+bb1: ; preds = %bb
+ ret void
+}
OpenPOWER on IntegriCloud