From: Devang Patel Date: Mon, 17 Nov 2008 18:37:53 +0000 (+0000) Subject: Let AnalyzeAlloca() remove debug intrinsics. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=b8c564f72ef75c775ce473e7b450d5c4da933e89;p=oota-llvm.git Let AnalyzeAlloca() remove debug intrinsics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59454 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 6a4cdc62a99..cc626ae71f5 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -277,21 +277,6 @@ namespace { AllocaPointerVal = 0; } - /// RemoveDebugUses - Remove uses of the alloca in DbgInfoInstrinsics. - void RemoveDebugUses(AllocaInst *AI) { - for (Value::use_iterator U = AI->use_begin(), E = AI->use_end(); - U != E;) { - Instruction *User = cast(*U); - ++U; - if (BitCastInst *BC = dyn_cast(User)) { - assert(BC->hasOneUse() && "Unexpected alloca uses!"); - DbgInfoIntrinsic *DI = cast(*BC->use_begin()); - DI->eraseFromParent(); - BC->eraseFromParent(); - } - } - } - /// AnalyzeAlloca - Scan the uses of the specified alloca, filling in our /// ivars. void AnalyzeAlloca(AllocaInst *AI) { @@ -301,9 +286,18 @@ namespace { // and decide whether all of the loads and stores to the alloca are within // the same basic block. for (Value::use_iterator U = AI->use_begin(), E = AI->use_end(); - U != E; ++U) { + U != E;) { Instruction *User = cast(*U); - if (StoreInst *SI = dyn_cast(User)) { + ++U; + if (BitCastInst *BC = dyn_cast(User)) { + // Remove any uses of this alloca in DbgInfoInstrinsics. + assert(BC->hasOneUse() && "Unexpected alloca uses!"); + DbgInfoIntrinsic *DI = cast(*BC->use_begin()); + DI->eraseFromParent(); + BC->eraseFromParent(); + continue; + } + else if (StoreInst *SI = dyn_cast(User)) { // Remember the basic blocks which define new values for the alloca DefiningBlocks.push_back(SI->getParent()); AllocaPointerVal = SI->getOperand(0); @@ -344,9 +338,6 @@ void PromoteMem2Reg::run() { assert(AI->getParent()->getParent() == &F && "All allocas should be in the same function, which is same as DF!"); - // Remove any uses of this alloca in DbgInfoInstrinsics. - Info.RemoveDebugUses(AI); - if (AI->use_empty()) { // If there are no uses of the alloca, just delete it now. if (AST) AST->deleteValue(AI);