summaryrefslogtreecommitdiff
path: root/lib
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
parent53cac18cca61265304056de670cea39870f28315 (diff)
downloadllvm-5622f07a21b799964dc172925b9ebc38191859f6.tar.gz
llvm-5622f07a21b799964dc172925b9ebc38191859f6.tar.bz2
llvm-5622f07a21b799964dc172925b9ebc38191859f6.tar.xz
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')
-rw-r--r--lib/Transforms/Utils/BasicBlockUtils.cpp24
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp9
2 files changed, 10 insertions, 23 deletions
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp
index 964fcc083d..7b633b2007 100644
--- a/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -15,7 +15,6 @@
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
-#include "llvm/IntrinsicInst.h"
#include "llvm/Constant.h"
#include "llvm/Type.h"
#include "llvm/Analysis/AliasAnalysis.h"
@@ -32,7 +31,7 @@ void llvm::DeleteDeadBlock(BasicBlock *BB) {
// Can delete self loop.
BB->getSinglePredecessor() == BB) && "Block is not dead!");
TerminatorInst *BBTerm = BB->getTerminator();
- Value *DbgRegionEndContext = NULL;
+
// Loop through all of our successors and make sure they know that one
// of their predecessors is going away.
for (unsigned i = 0, e = BBTerm->getNumSuccessors(); i != e; ++i)
@@ -41,10 +40,6 @@ void llvm::DeleteDeadBlock(BasicBlock *BB) {
// Zap all the instructions in the block.
while (!BB->empty()) {
Instruction &I = BB->back();
- // It is possible to have multiple llvm.dbg.region.end in a block.
- if (DbgRegionEndInst *DREI = dyn_cast<DbgRegionEndInst>(&I))
- DbgRegionEndContext = DREI->getContext();
-
// If this instruction is used, replace uses with an arbitrary value.
// Because control flow can't get here, we don't care what we replace the
// value with. Note that since this block is unreachable, and all values
@@ -54,22 +49,7 @@ void llvm::DeleteDeadBlock(BasicBlock *BB) {
I.replaceAllUsesWith(UndefValue::get(I.getType()));
BB->getInstList().pop_back();
}
-
- if (DbgRegionEndContext) {
- // Delete corresponding llvm.dbg.func.start from entry block.
- BasicBlock &Entry = BB->getParent()->getEntryBlock();
- DbgFuncStartInst *DbgFuncStart = NULL;
- for (BasicBlock::iterator BI = Entry.begin(), BE = Entry.end();
- BI != BE; ++BI) {
- if (DbgFuncStartInst *DFSI = dyn_cast<DbgFuncStartInst>(BI)) {
- DbgFuncStart = DFSI;
- break;
- }
- }
- if (DbgFuncStart && DbgFuncStart->getSubprogram() == DbgRegionEndContext)
- DbgFuncStart->eraseFromParent();
- }
-
+
// Zap the block!
BB->eraseFromParent();
}
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;
}