summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/ADCE.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-08-14 21:35:02 +0000
committerChris Lattner <sabre@nondot.org>2002-08-14 21:35:02 +0000
commit313fd777678b00f663f15a533ab92510dbe96058 (patch)
tree580d50bbb7a2f83189a25c12b74739c7a10fe4fc /llvm/lib/Transforms/Scalar/ADCE.cpp
parent0c5e293a4a168e2c2df855eba3e19ea367b95518 (diff)
downloadbcm5719-llvm-313fd777678b00f663f15a533ab92510dbe96058.tar.gz
bcm5719-llvm-313fd777678b00f663f15a533ab92510dbe96058.zip
Avoid inserting an entry block unless we need it
llvm-svn: 3336
Diffstat (limited to 'llvm/lib/Transforms/Scalar/ADCE.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/ADCE.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp
index 062b52ff50c..618ff23b4fb 100644
--- a/llvm/lib/Transforms/Scalar/ADCE.cpp
+++ b/llvm/lib/Transforms/Scalar/ADCE.cpp
@@ -235,11 +235,15 @@ bool ADCE::doADCE() {
dropReferencesOfDeadInstructionsInLiveBlock(I);
} else { // If there are some blocks dead...
- // Insert a new entry node to eliminate the entry node as a special case.
- BasicBlock *NewEntry = new BasicBlock();
- NewEntry->getInstList().push_back(new BranchInst(&Func->front()));
- Func->getBasicBlockList().push_front(NewEntry);
- AliveBlocks.insert(NewEntry); // This block is always alive!
+ // If the entry node is dead, insert a new entry node to eliminate the entry
+ // node as a special case.
+ //
+ if (!AliveBlocks.count(&Func->front())) {
+ BasicBlock *NewEntry = new BasicBlock();
+ NewEntry->getInstList().push_back(new BranchInst(&Func->front()));
+ Func->getBasicBlockList().push_front(NewEntry);
+ AliveBlocks.insert(NewEntry); // This block is always alive!
+ }
// Loop over all of the alive blocks in the function. If any successor
// blocks are not alive, we adjust the outgoing branches to branch to the
OpenPOWER on IntegriCloud