From db6e4d662597d57df7a7f00dc342d8cf7fb5465a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 14 Aug 2002 21:35:02 +0000 Subject: [PATCH] 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 --- lib/Transforms/Scalar/ADCE.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 062b52ff50c..618ff23b4fb 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