summaryrefslogtreecommitdiffstats
path: root/lib
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
commitdb6e4d662597d57df7a7f00dc342d8cf7fb5465a (patch)
tree206eaf4c89ccfdd5bf955c1d6e16e27919230b68 /lib
parent7ce83e576a99f5be6b06209ce463abbc1e25a3c7 (diff)
downloadexternal_llvm-db6e4d662597d57df7a7f00dc342d8cf7fb5465a.zip
external_llvm-db6e4d662597d57df7a7f00dc342d8cf7fb5465a.tar.gz
external_llvm-db6e4d662597d57df7a7f00dc342d8cf7fb5465a.tar.bz2
Avoid inserting an entry block unless we need it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3336 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/ADCE.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
index 062b52f..618ff23 100644
--- a/lib/Transforms/Scalar/ADCE.cpp
+++ b/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