summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/CodeExtractor
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2017-04-21 04:25:00 +0000
committerDavide Italiano <davide@freebsd.org>2017-04-21 04:25:00 +0000
commitfa15de34b7a837619fd651af2021dc867175e336 (patch)
treeb4f3ae0581010fc64610d8902531f124927fdd30 /llvm/test/Transforms/CodeExtractor
parent5b817d02bfde6e896f1668712a583d4eb3587725 (diff)
downloadbcm5719-llvm-fa15de34b7a837619fd651af2021dc867175e336.tar.gz
bcm5719-llvm-fa15de34b7a837619fd651af2021dc867175e336.zip
[PartialInliner] Fix crash when inlining functions with unreachable blocks.
CodeExtractor looks up the dominator node corresponding to return blocks when splitting them. If one of these blocks is unreachable, there's no node in the Dom and CodeExtractor crashes because it doesn't check for domtree node validity. In theory, we could add just a check for skipping null DTNodes in `splitReturnBlock` but the fix I propose here is slightly different. To the best of my knowledge, unreachable blocks are irrelevant for the algorithm, therefore we can just skip them when building the candidate set in the constructor. Differential Revision: https://reviews.llvm.org/D32335 llvm-svn: 300946
Diffstat (limited to 'llvm/test/Transforms/CodeExtractor')
-rw-r--r--llvm/test/Transforms/CodeExtractor/unreachable-block.ll38
1 files changed, 38 insertions, 0 deletions
diff --git a/llvm/test/Transforms/CodeExtractor/unreachable-block.ll b/llvm/test/Transforms/CodeExtractor/unreachable-block.ll
new file mode 100644
index 00000000000..d20a35718e6
--- /dev/null
+++ b/llvm/test/Transforms/CodeExtractor/unreachable-block.ll
@@ -0,0 +1,38 @@
+; RUN: opt -S -partial-inliner %s | FileCheck %s
+
+; CHECK-LABEL: define void @dipsy(
+; CHECK-NEXT: call void @tinkywinky.1_ontrue()
+; CHECK-NEXT: call void @patatuccio()
+; CHECK-NEXT: ret void
+; CHECK-NEXT: }
+
+; CHECK-LABEL: define internal void @tinkywinky.1_ontrue() {
+; CHECK-NEXT: newFuncRoot:
+; CHECK-NEXT: br label %ontrue
+; CHECK: .exitStub:
+; CHECK-NEXT: ret void
+; CHECK: ontrue:
+; CHECK-NEXT: call void @patatino()
+; CHECK-NEXT: br label %onfalse
+; CHECK: onfalse:
+; CHECK-NEXT: br label %.exitStub
+; CHECK-NEXT: }
+
+declare void @patatino()
+declare void @patatuccio()
+
+define fastcc void @tinkywinky() {
+ br i1 true, label %ontrue, label %onfalse
+ontrue:
+ call void @patatino()
+ br label %onfalse
+onfalse:
+ call void @patatuccio()
+ ret void
+cantreachme:
+ ret void
+}
+define void @dipsy() {
+ call fastcc void @tinkywinky()
+ ret void
+}
OpenPOWER on IntegriCloud