aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/SimplifyCFG.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-02-24 00:05:16 +0000
committerDevang Patel <dpatel@apple.com>2009-02-24 00:05:16 +0000
commit5622f07a21b799964dc172925b9ebc38191859f6 (patch)
tree16e82835e5409da8dd61f099e209b8d9fdfac1ee /lib/Transforms/Utils/SimplifyCFG.cpp
parent53cac18cca61265304056de670cea39870f28315 (diff)
While folding unconditional return move DbgRegionEndInst into the predecessor, instead of removing it. This fixes following tests from llvmgcc42 testsuite.
gcc.c-torture/execute/20000605-3.c gcc.c-torture/execute/20020619-1.c gcc.c-torture/execute/20030920-1.c gcc.c-torture/execute/loop-ivopts-1.c git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65353 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index 86d4a7508c..6c14a643e8 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1789,6 +1789,13 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
Instruction *NewRet = RI->clone();
Pred->getInstList().push_back(NewRet);
+ BasicBlock::iterator BBI = RI;
+ if (BBI != BB->begin()) {
+ // Move region end info into the predecessor.
+ if (DbgRegionEndInst *DREI = dyn_cast<DbgRegionEndInst>(--BBI))
+ DREI->moveBefore(NewRet);
+ }
+
// If the return instruction returns a value, and if the value was a
// PHI node in "BB", propagate the right value into the return.
for (User::op_iterator i = NewRet->op_begin(), e = NewRet->op_end();
@@ -1806,7 +1813,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
// If we eliminated all predecessors of the block, delete the block now.
if (pred_begin(BB) == pred_end(BB))
// We know there are no successors, so just nuke the block.
- DeleteDeadBlock(BB);
+ M->getBasicBlockList().erase(BB);
return true;
}