mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-15 09:33:39 +00:00
Use IRBuilder while simplifying unreachable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131607 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7205d431f1
commit
1aa89a2f91
@ -2270,7 +2270,7 @@ bool SimplifyCFGOpt::SimplifyUnreachable(UnreachableInst *UI) {
|
|||||||
SmallVector<BasicBlock*, 8> Preds(pred_begin(BB), pred_end(BB));
|
SmallVector<BasicBlock*, 8> Preds(pred_begin(BB), pred_end(BB));
|
||||||
for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
|
for (unsigned i = 0, e = Preds.size(); i != e; ++i) {
|
||||||
TerminatorInst *TI = Preds[i]->getTerminator();
|
TerminatorInst *TI = Preds[i]->getTerminator();
|
||||||
|
IRBuilder<> Builder(TI);
|
||||||
if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
|
if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
|
||||||
if (BI->isUnconditional()) {
|
if (BI->isUnconditional()) {
|
||||||
if (BI->getSuccessor(0) == BB) {
|
if (BI->getSuccessor(0) == BB) {
|
||||||
@ -2280,10 +2280,10 @@ bool SimplifyCFGOpt::SimplifyUnreachable(UnreachableInst *UI) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (BI->getSuccessor(0) == BB) {
|
if (BI->getSuccessor(0) == BB) {
|
||||||
BranchInst::Create(BI->getSuccessor(1), BI);
|
Builder.CreateBr(BI->getSuccessor(1));
|
||||||
EraseTerminatorInstAndDCECond(BI);
|
EraseTerminatorInstAndDCECond(BI);
|
||||||
} else if (BI->getSuccessor(1) == BB) {
|
} else if (BI->getSuccessor(1) == BB) {
|
||||||
BranchInst::Create(BI->getSuccessor(0), BI);
|
Builder.CreateBr(BI->getSuccessor(0));
|
||||||
EraseTerminatorInstAndDCECond(BI);
|
EraseTerminatorInstAndDCECond(BI);
|
||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
@ -2347,14 +2347,15 @@ bool SimplifyCFGOpt::SimplifyUnreachable(UnreachableInst *UI) {
|
|||||||
if (II->getUnwindDest() == BB) {
|
if (II->getUnwindDest() == BB) {
|
||||||
// Convert the invoke to a call instruction. This would be a good
|
// Convert the invoke to a call instruction. This would be a good
|
||||||
// place to note that the call does not throw though.
|
// place to note that the call does not throw though.
|
||||||
BranchInst *BI = BranchInst::Create(II->getNormalDest(), II);
|
BranchInst *BI = Builder.CreateBr(II->getNormalDest());
|
||||||
II->removeFromParent(); // Take out of symbol table
|
II->removeFromParent(); // Take out of symbol table
|
||||||
|
|
||||||
// Insert the call now...
|
// Insert the call now...
|
||||||
SmallVector<Value*, 8> Args(II->op_begin(), II->op_end()-3);
|
SmallVector<Value*, 8> Args(II->op_begin(), II->op_end()-3);
|
||||||
CallInst *CI = CallInst::Create(II->getCalledValue(),
|
Builder.SetInsertPoint(BI);
|
||||||
Args.begin(), Args.end(),
|
CallInst *CI = Builder.CreateCall(II->getCalledValue(),
|
||||||
II->getName(), BI);
|
Args.begin(), Args.end(),
|
||||||
|
II->getName());
|
||||||
CI->setCallingConv(II->getCallingConv());
|
CI->setCallingConv(II->getCallingConv());
|
||||||
CI->setAttributes(II->getAttributes());
|
CI->setAttributes(II->getAttributes());
|
||||||
// If the invoke produced a value, the call does now instead.
|
// If the invoke produced a value, the call does now instead.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user