summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-02-13 03:34:23 +0000
committerVedant Kumar <vsk@apple.com>2018-02-13 03:34:23 +0000
commit388fac5de6c4ce1b93058f9963a66569ebf3e131 (patch)
treed8aa2cdace771dc65b7490002014a540964b3bb1 /llvm/lib/Transforms/Utils
parent3b6de6fe1c43ea0396903089122c9fd670cd894d (diff)
downloadbcm5719-llvm-388fac5de6c4ce1b93058f9963a66569ebf3e131.tar.gz
bcm5719-llvm-388fac5de6c4ce1b93058f9963a66569ebf3e131.zip
[Utils] Salvage debug info from all no-op casts
We already try to salvage debug values from no-op bitcasts and inttoptr instructions: we should handle ptrtoint instructions as well. This saves an additional 24,444 debug values in a stage2 build of clang, and (according to llvm-dwarfdump --statistics) provides an additional 289 unique source variables. llvm-svn: 324982
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 45962ca9615..e170b22b740 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1518,11 +1518,14 @@ void llvm::salvageDebugInfo(Instruction &I) {
doSalvage(DII, Ops);
};
- if (isa<BitCastInst>(&I) || isa<IntToPtrInst>(&I)) {
- // Bitcasts are entirely irrelevant for debug info. Rewrite dbg.value,
- // dbg.addr, and dbg.declare to use the cast's source.
+ if (auto *CI = dyn_cast<CastInst>(&I)) {
+ if (!CI->isNoopCast(M.getDataLayout()))
+ return;
+
+ // No-op casts are irrelevant for debug info.
+ MetadataAsValue *CastSrc = wrapMD(I.getOperand(0));
for (auto *DII : DbgUsers) {
- DII->setOperand(0, wrapMD(I.getOperand(0)));
+ DII->setOperand(0, CastSrc);
DEBUG(dbgs() << "SALVAGE: " << *DII << '\n');
}
} else if (auto *GEP = dyn_cast<GetElementPtrInst>(&I)) {
OpenPOWER on IntegriCloud