mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Perform an intelligent splice of the predecessor with the single successor.
If the predecessor's being spliced into a landing pad, then we need the PHIs to come first and the rest of the predecessor's code to come *after* the landing pad instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193035 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4805bf59b9
commit
d5b7f2b62c
@ -503,7 +503,19 @@ void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB, Pass *P) {
|
||||
|
||||
// Splice all the instructions from PredBB to DestBB.
|
||||
PredBB->getTerminator()->eraseFromParent();
|
||||
DestBB->getInstList().splice(DestBB->begin(), PredBB->getInstList());
|
||||
|
||||
// First splice over the PHI nodes.
|
||||
BasicBlock::iterator PI = PredBB->begin();
|
||||
while (isa<PHINode>(PI))
|
||||
++PI;
|
||||
|
||||
if (PI != PredBB->begin())
|
||||
DestBB->getInstList().splice(DestBB->begin(), PredBB->getInstList(),
|
||||
PredBB->begin(), PI);
|
||||
|
||||
// Now splice over the rest of the instructions.
|
||||
DestBB->getInstList().splice(DestBB->getFirstInsertionPt(),
|
||||
PredBB->getInstList(), PI, PredBB->end());
|
||||
|
||||
if (P) {
|
||||
DominatorTree *DT = P->getAnalysisIfAvailable<DominatorTree>();
|
||||
@ -513,6 +525,7 @@ void llvm::MergeBasicBlockIntoOnlyPred(BasicBlock *DestBB, Pass *P) {
|
||||
DT->eraseNode(PredBB);
|
||||
}
|
||||
}
|
||||
|
||||
// Nuke BB.
|
||||
PredBB->eraseFromParent();
|
||||
}
|
||||
|
43
test/Transforms/JumpThreading/landing-pad-splicing.ll
Normal file
43
test/Transforms/JumpThreading/landing-pad-splicing.ll
Normal file
@ -0,0 +1,43 @@
|
||||
; RUN: opt -S -jump-threading < %s -disable-output
|
||||
; PR17621
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-apple-macosx10.8.0"
|
||||
|
||||
declare void @_ZN1F7doApplyEv() unnamed_addr readnone align 2
|
||||
|
||||
define void @_Z3fn1v() uwtable {
|
||||
entry:
|
||||
store i32 0, i32* undef, align 4
|
||||
invoke void @_ZN1F7doApplyEv()
|
||||
to label %_ZN1D5applyEv.exit unwind label %lpad1
|
||||
|
||||
_ZN1D5applyEv.exit:
|
||||
invoke void @_ZN1F10insertTextEv()
|
||||
to label %invoke.cont7 unwind label %lpad1
|
||||
|
||||
invoke.cont7:
|
||||
ret void
|
||||
|
||||
lpad1:
|
||||
%tmp1 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
|
||||
cleanup
|
||||
%tmp2 = load i32* undef, align 4
|
||||
%tobool.i.i.i = icmp eq i32 %tmp2, 0
|
||||
br i1 %tobool.i.i.i, label %_ZN1BI1FED1Ev.exit, label %if.then.i.i.i
|
||||
|
||||
if.then.i.i.i:
|
||||
br i1 undef, label %_ZN1BI1FED1Ev.exit, label %delete.notnull.i.i.i
|
||||
|
||||
delete.notnull.i.i.i:
|
||||
unreachable
|
||||
|
||||
_ZN1BI1FED1Ev.exit:
|
||||
br label %eh.resume
|
||||
|
||||
eh.resume:
|
||||
resume { i8*, i32 } undef
|
||||
}
|
||||
|
||||
declare i32 @__gxx_personality_v0(...)
|
||||
|
||||
declare void @_ZN1F10insertTextEv()
|
Loading…
Reference in New Issue
Block a user