This is an archive of the discontinued LLVM Phabricator instance.

Support stripping indirectly referenced DILocations from !llvm.loop metadata in stripDebugInfo()
ClosedPublic

Authored by aprantl on May 26 2021, 7:10 PM.

Details

Summary

This patch fixes an oversight in https://reviews.llvm.org/D96181 and also takes into account loop metadata pointing to other MDNodes that point into the debug info.

rdar://78487175

Diff Detail

Event Timeline

aprantl created this revision.May 26 2021, 7:10 PM
aprantl requested review of this revision.May 26 2021, 7:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 26 2021, 7:10 PM
JDevlieghere added inline comments.
llvm/lib/IR/DebugInfo.cpp
389–390

Do we need to remember that the MDNode was visited when it's a DILocation?

411–412
shafik added a subscriber: shafik.May 27 2021, 9:31 AM
shafik added inline comments.
llvm/lib/IR/DebugInfo.cpp
391

This is why I dislike std::pair what does second mean? A comment like if it was already inserted exit now would be helpful.

411–412

I see in the other files the lambda explicitly list their captures instead of just using & to capture all by reference, I think that is a better style to be explicit.

llvm/lib/Transforms/Utils/InlineFunction.cpp
1523

I see that previously Loc was const can MD also be const?

aprantl added inline comments.May 27 2021, 9:37 AM
llvm/lib/Transforms/Utils/InlineFunction.cpp
1523

I don't think so because we need to return it as a Metadata * and the input may be nullptr.

aprantl added inline comments.May 27 2021, 9:44 AM
llvm/lib/IR/DebugInfo.cpp
389–390

In that case it will be in Reachable so there's no need to.

411–412

For a one-line lambda like this, I feel like it just adds visual noise and makes it harder to read:

if (!std::count_if(N->op_begin() + 1, N->op_end(),
 [&Visited, &DILocationReachable](const MDOperand &Op) {
   return isa<DILocation>(Op.get()) ||
             isDILocationReachable(Visited, DILocationReachable, Op.get());
    }))
aprantl updated this revision to Diff 348316.May 27 2021, 9:44 AM

Address review feedback.

aprantl marked 4 inline comments as done.May 27 2021, 9:45 AM
aprantl updated this revision to Diff 348333.May 27 2021, 11:06 AM

Add another comment and explicitly mark lambda captures.

aprantl updated this revision to Diff 348339.May 27 2021, 11:20 AM

Add more comments

shafik accepted this revision.May 27 2021, 1:19 PM

LGTM

This revision is now accepted and ready to land.May 27 2021, 1:19 PM
This revision was landed with ongoing or failed builds.May 27 2021, 1:24 PM
This revision was automatically updated to reflect the committed changes.
vsk added a comment.Jun 2 2021, 7:53 AM

Thanks Adrian. + 1 from me as well, FTR.

llvm/lib/IR/DebugInfo.cpp
418

Is the isa<DILocation>(Op.get()) part redundant here, since it should be checked within isDILocationReachable?

aprantl added inline comments.Jun 2 2021, 9:53 AM
llvm/lib/IR/DebugInfo.cpp
418

Yes. I removed them in fcfaed4ae6d7. Thanks!