diff options
author | Devang Patel <dpatel@apple.com> | 2011-07-29 19:00:35 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2011-07-29 19:00:35 +0000 |
commit | 1619560521c46ecee0ef2d0c651ed18feb57df97 (patch) | |
tree | f548245975887fabdf26f986abf735151233987e /lib | |
parent | 2c6363a62df95b74468d9a561bbcb9edddeb3507 (diff) | |
download | external_llvm-1619560521c46ecee0ef2d0c651ed18feb57df97.zip external_llvm-1619560521c46ecee0ef2d0c651ed18feb57df97.tar.gz external_llvm-1619560521c46ecee0ef2d0c651ed18feb57df97.tar.bz2 |
Clean up debug info after reassociation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136480 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/Reassociate.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index e6341ae..578e8e0 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -75,6 +75,7 @@ namespace { class Reassociate : public FunctionPass { DenseMap<BasicBlock*, unsigned> RankMap; DenseMap<AssertingVH<>, unsigned> ValueRankMap; + DenseMap<Value *, DbgValueInst *> DbgValues; SmallVector<WeakVH, 8> RedoInsts; SmallVector<WeakVH, 8> DeadInsts; bool MadeChange; @@ -104,6 +105,9 @@ namespace { void ReassociateInst(BasicBlock::iterator &BBI); void RemoveDeadBinaryOp(Value *V); + + /// collectDbgValues - Collect all llvm.dbg.value intrinsics. + void collectDbgValues(Function &F); }; } @@ -344,6 +348,11 @@ void Reassociate::LinearizeExprTree(BinaryOperator *I, void Reassociate::RewriteExprTree(BinaryOperator *I, SmallVectorImpl<ValueEntry> &Ops, unsigned i) { + // If this operation was representing debug info of a value then it + // is no longer true, so remove the dbg.value instrinsic. + if (DbgValueInst *DVI = DbgValues.lookup(I)) + DeadInsts.push_back(DVI); + if (i+2 == Ops.size()) { if (I->getOperand(0) != Ops[i].Op || I->getOperand(1) != Ops[i+1].Op) { @@ -1094,6 +1103,7 @@ Value *Reassociate::ReassociateExpression(BinaryOperator *I) { bool Reassociate::runOnFunction(Function &F) { + collectDbgValues(F); // Recalculate the rank map for F BuildRankMap(F); @@ -1113,7 +1123,9 @@ bool Reassociate::runOnFunction(Function &F) { // Now that we're done, delete any instructions which are no longer used. while (!DeadInsts.empty()) if (Value *V = DeadInsts.pop_back_val()) - RecursivelyDeleteTriviallyDeadInstructions(V); + if (!RecursivelyDeleteTriviallyDeadInstructions(V)) + if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(V)) + DVI->eraseFromParent(); // We are done with the rank map. RankMap.clear(); @@ -1121,3 +1133,11 @@ bool Reassociate::runOnFunction(Function &F) { return MadeChange; } +/// collectDbgValues - Collect all llvm.dbg.value intrinsics. +void Reassociate::collectDbgValues(Function &F) { + for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) + for (BasicBlock::iterator BI = FI->begin(), BE = FI->end(); + BI != BE; ++BI) + if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(BI)) + DbgValues[DVI->getValue()] = DVI; +} |