Davide Italiano fa15de34b7 [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
2017-04-21 04:25:00 +00:00

39 lines
867 B
LLVM

; 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
}