diff options
author | Adrian Prantl <aprantl@apple.com> | 2017-03-30 20:10:56 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2017-03-30 20:10:56 +0000 |
commit | 346dcaf1fa0f7823fda655b55d22f628367784f9 (patch) | |
tree | 4f5c8a6a0b688315667265e243af42c2b9f0d5e9 /llvm/lib/IR | |
parent | 9a3e73383b7d5ae2600af00c381b16cb312e1f18 (diff) | |
download | bcm5719-llvm-346dcaf1fa0f7823fda655b55d22f628367784f9.tar.gz bcm5719-llvm-346dcaf1fa0f7823fda655b55d22f628367784f9.zip |
Teach stripNonLineTableDebugInfo() to remap DILocations in !llvm.loop nodes.
llvm-svn: 299107
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 918fdc26068..4fe2553687c 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -601,17 +601,26 @@ bool llvm::stripNonLineTableDebugInfo(Module &M) { } for (auto &BB : F) { for (auto &I : BB) { - if (I.getDebugLoc() == DebugLoc()) - continue; - - // Make a replacement. - auto &DL = I.getDebugLoc(); - auto *Scope = DL.getScope(); - MDNode *InlinedAt = DL.getInlinedAt(); - Scope = remap(Scope); - InlinedAt = remap(InlinedAt); - I.setDebugLoc( - DebugLoc::get(DL.getLine(), DL.getCol(), Scope, InlinedAt)); + auto remapDebugLoc = [&](DebugLoc DL) -> DebugLoc { + auto *Scope = DL.getScope(); + MDNode *InlinedAt = DL.getInlinedAt(); + Scope = remap(Scope); + InlinedAt = remap(InlinedAt); + return DebugLoc::get(DL.getLine(), DL.getCol(), Scope, InlinedAt); + }; + + if (I.getDebugLoc() != DebugLoc()) + I.setDebugLoc(remapDebugLoc(I.getDebugLoc())); + + // Remap DILocations in untyped MDNodes (e.g., llvm.loop). + SmallVector<std::pair<unsigned, MDNode *>, 2> MDs; + I.getAllMetadata(MDs); + for (auto Attachment : MDs) + if (auto *T = dyn_cast_or_null<MDTuple>(Attachment.second)) + for (unsigned N = 0; N < T->getNumOperands(); ++N) + if (auto *Loc = dyn_cast_or_null<DILocation>(T->getOperand(N))) + if (Loc != DebugLoc()) + T->replaceOperandWith(N, remapDebugLoc(Loc)); } } } |