diff options
author | Devang Patel <dpatel@apple.com> | 2011-07-06 21:09:55 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2011-07-06 21:09:55 +0000 |
commit | 231a5ab746ca12000aa57208869a98f78781aa6b (patch) | |
tree | e7c7e68bfe206dc2c1c16916df4a87d68c61da4e /lib/Transforms/Scalar | |
parent | 17f91d21a764603b9c482338e929390565f3bb72 (diff) | |
download | external_llvm-231a5ab746ca12000aa57208869a98f78781aa6b.zip external_llvm-231a5ab746ca12000aa57208869a98f78781aa6b.tar.gz external_llvm-231a5ab746ca12000aa57208869a98f78781aa6b.tar.bz2 |
Simplify. Consolidate dbg.declare handling in AllocaPromoter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r-- | lib/Transforms/Scalar/LICM.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/Scalar/ScalarReplAggregates.cpp | 31 |
2 files changed, 19 insertions, 14 deletions
diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index fc1ecf7..66add6c 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -613,7 +613,7 @@ namespace { SmallPtrSet<Value*, 4> &PMA, SmallVectorImpl<BasicBlock*> &LEB, AliasSetTracker &ast, DebugLoc dl, int alignment) - : LoadAndStorePromoter(Insts, S, 0, 0), SomePtr(SP), + : LoadAndStorePromoter(Insts, S), SomePtr(SP), PointerMustAliases(PMA), LoopExitBlocks(LEB), AST(ast), DL(dl), Alignment(alignment) {} diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 87e364d..ef520af 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1094,16 +1094,21 @@ bool SROA::runOnFunction(Function &F) { namespace { class AllocaPromoter : public LoadAndStorePromoter { AllocaInst *AI; + DbgDeclareInst *DDI; + DIBuilder *DIB; public: AllocaPromoter(const SmallVectorImpl<Instruction*> &Insts, SSAUpdater &S, - DbgDeclareInst *DD, DIBuilder *&DB) - : LoadAndStorePromoter(Insts, S, DD, DB), AI(0) {} + DIBuilder *DB) + : LoadAndStorePromoter(Insts, S), AI(0), DDI(0), DIB(DB) {} void run(AllocaInst *AI, const SmallVectorImpl<Instruction*> &Insts) { // Remember which alloca we're promoting (for isInstInList). this->AI = AI; + DDI = FindAllocaDbgDeclare(AI); LoadAndStorePromoter::run(Insts); AI->eraseFromParent(); + if (DDI) + DDI->eraseFromParent(); } virtual bool isInstInList(Instruction *I, @@ -1112,6 +1117,15 @@ public: return LI->getOperand(0) == AI; return cast<StoreInst>(I)->getPointerOperand() == AI; } + + virtual void updateDebugInfo(Instruction *I) const { + if (!DDI) + return; + if (StoreInst *SI = dyn_cast<StoreInst>(I)) + ConvertDebugDeclareToDebugValue(DDI, SI, *DIB); + else if (LoadInst *LI = dyn_cast<LoadInst>(I)) + ConvertDebugDeclareToDebugValue(DDI, LI, *DIB); + } }; } // end anon namespace @@ -1381,10 +1395,9 @@ bool SROA::performPromotion(Function &F) { DT = &getAnalysis<DominatorTree>(); BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function - + DIBuilder DIB(*F.getParent()); bool Changed = false; SmallVector<Instruction*, 64> Insts; - DIBuilder *DIB = 0; while (1) { Allocas.clear(); @@ -1408,11 +1421,7 @@ bool SROA::performPromotion(Function &F) { for (Value::use_iterator UI = AI->use_begin(), E = AI->use_end(); UI != E; ++UI) Insts.push_back(cast<Instruction>(*UI)); - - DbgDeclareInst *DDI = FindAllocaDbgDeclare(AI); - if (DDI && !DIB) - DIB = new DIBuilder(*AI->getParent()->getParent()->getParent()); - AllocaPromoter(Insts, SSA, DDI, DIB).run(AI, Insts); + AllocaPromoter(Insts, SSA, &DIB).run(AI, Insts); Insts.clear(); } } @@ -1420,10 +1429,6 @@ bool SROA::performPromotion(Function &F) { Changed = true; } - // FIXME: Is there a better way to handle the lazy initialization of DIB - // so that there doesn't need to be an explicit delete? - delete DIB; - return Changed; } |