diff options
| author | Teresa Johnson <tejohnson@google.com> | 2017-03-19 13:54:57 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2017-03-19 13:54:57 +0000 |
| commit | 9b4b8c8d7b7a2b249e2947a570385a6740c7dade (patch) | |
| tree | 16327e1a76cb36a292850ba2810fabb6695c912e /llvm/lib | |
| parent | 75537b65668c0bc7ca33558fd8d853c79253e73a (diff) | |
| download | bcm5719-llvm-9b4b8c8d7b7a2b249e2947a570385a6740c7dade.tar.gz bcm5719-llvm-9b4b8c8d7b7a2b249e2947a570385a6740c7dade.zip | |
Enable stripping of multiple DILocation on !llvm.loop metadata
Summary:
I found that stripDebugInfo was still leaving significant amounts of
debug info due to !llvm.loop that contained DILocation after stripping.
The support for stripping debug info on !llvm.loop added in r293377 only
removes a single DILocation. Enhance that to remove all DILocation from
!llvm.loop.
Reviewers: hfinkel, aprantl, dsanders
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D31117
llvm-svn: 298213
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 5e14723c3af..918fdc26068 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -241,26 +241,29 @@ bool DebugInfoFinder::addScope(DIScope *Scope) { static llvm::MDNode *stripDebugLocFromLoopID(llvm::MDNode *N) { assert(N->op_begin() != N->op_end() && "Missing self reference?"); - auto DebugLocOp = - std::find_if(N->op_begin() + 1, N->op_end(), [](const MDOperand &Op) { - return isa<DILocation>(Op.get()); - }); - // No debug location, we do not have to rewrite this MDNode. - if (DebugLocOp == N->op_end()) + // if there is no debug location, we do not have to rewrite this MDNode. + if (std::none_of(N->op_begin() + 1, N->op_end(), [](const MDOperand &Op) { + return isa<DILocation>(Op.get()); + })) return N; - // There is only the debug location without any actual loop metadata, hence we + // If there is only the debug location without any actual loop metadata, we // can remove the metadata. - if (N->getNumOperands() == 2) + if (std::none_of(N->op_begin() + 1, N->op_end(), [](const MDOperand &Op) { + return !isa<DILocation>(Op.get()); + })) return nullptr; SmallVector<Metadata *, 4> Args; // Reserve operand 0 for loop id self reference. auto TempNode = MDNode::getTemporary(N->getContext(), None); Args.push_back(TempNode.get()); - Args.append(N->op_begin() + 1, DebugLocOp); - Args.append(DebugLocOp + 1, N->op_end()); + // Add all non-debug location operands back. + for (auto Op = N->op_begin() + 1; Op != N->op_end(); Op++) { + if (!isa<DILocation>(*Op)) + Args.push_back(*Op); + } // Set the first operand to itself. MDNode *LoopID = MDNode::get(N->getContext(), Args); |

