From 1d5d31b70666e4b78f4cf4b837c17c9c3bbb53b3 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Tue, 13 Feb 2018 22:27:17 +0000 Subject: [GVN] Salvage debug info from dead insts This preserves an additional 581 unique source variables in a stage2 build of clang (according to `llvm-dwarfdump --statistics`). It increases the size of the .debug_loc section by 0.1% (or 87139 bytes). Differential Revision: https://reviews.llvm.org/D43255 llvm-svn: 325063 --- llvm/lib/Transforms/Scalar/GVN.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index e2c1eaf58e4..a9104408691 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -2105,6 +2105,7 @@ bool GVN::processBlock(BasicBlock *BB) { for (auto *I : InstrsToErase) { assert(I->getParent() == BB && "Removing instruction from wrong block?"); DEBUG(dbgs() << "GVN removed: " << *I << '\n'); + salvageDebugInfo(*I); if (MD) MD->removeInstruction(I); DEBUG(verifyRemoved(I)); if (MaybeFirstICF == I) { @@ -2320,6 +2321,7 @@ bool GVN::performScalarPRE(Instruction *CurInst) { VN.eraseTranslateCacheEntry(ValNo, *CurrentBlock); addToLeaderTable(ValNo, Phi, CurrentBlock); Phi->setDebugLoc(CurInst->getDebugLoc()); + salvageDebugInfo(*CurInst); CurInst->replaceAllUsesWith(Phi); if (MD && Phi->getType()->isPtrOrPtrVectorTy()) MD->invalidateCachedPointerInfo(Phi); -- cgit v1.2.3