This is an archive of the discontinued LLVM Phabricator instance.

Simplify coro::salvageDebugInfo() (NFC-ish)
ClosedPublic

Authored by aprantl on Aug 3 2021, 11:53 AM.

Details

Summary

This patch removes the hand-rolled implementation of salvageDebugInfo for cast and GEPs and replaces it with a call into llvm::salvageDebugInfoImpl().

A side-effect of this is that additional redundant convert operations are introduced, but those don't have any negative effect on the resulting DWARF expression.

Diff Detail

Event Timeline

aprantl created this revision.Aug 3 2021, 11:53 AM
aprantl requested review of this revision.Aug 3 2021, 11:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2021, 11:53 AM
ChuanqiXu added inline comments.Aug 3 2021, 7:00 PM
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
2534–2537

If Op is null and we break this loop, Storage would still be no-nullptr. It means that it wouldn't trigger the condition in 2547, then there could be a potential bug to me.

aprantl marked an inline comment as done.Aug 4 2021, 4:47 PM
aprantl added inline comments.
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
2534–2537

Previously we filtered out only GEP instructions on line 2530, and so the if (!Storage) meant salvaging a GEP instruction failed. In the new code we try to salvage any instruction and so the if (!Op) mostly takes over the role of the else break. In the new code the else break only catches function arguments, constants, and other non-instructions.
There's a behavior change here in that we no longer can detect if a GEP instruction was unsalvageable. Note that we still filter for function arguments on line 2558. The new code is now rewriting DVI for a failed GEP, which the old code didn't, but that's a perfectly safe change that doesn't pessimize debug info in any way.

ChuanqiXu added inline comments.Aug 4 2021, 6:41 PM
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
2534–2537

Many thanks for the detailed explanation! Now I got it. Another question is that: is the line if (!Storage) and the loop condition while(Storage) redundant now? Since it looks like that Storage wouldn't be converted to null in this loop.

aprantl updated this revision to Diff 364560.Aug 5 2021, 11:23 AM
aprantl marked an inline comment as done.

Simplified the loop even more based on feedback by @ChuanqiXu !

aprantl marked an inline comment as done.Aug 5 2021, 11:23 AM
ChuanqiXu accepted this revision.Aug 5 2021, 6:44 PM

LGTM.

This revision is now accepted and ready to land.Aug 5 2021, 6:44 PM
This revision was landed with ongoing or failed builds.Aug 10 2021, 3:21 PM
This revision was automatically updated to reflect the committed changes.