This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Upgrade `dbg.addr` to `dbg.value`
ClosedPublic

Authored by jryans on Feb 25 2023, 4:13 PM.

Details

Summary

As part of removing dbg.addr, this upgrades any calls to dbg.value with
DW_OP_deref prepended onto the value expression.

Part of dbg.addr removal
Discussed in https://discourse.llvm.org/t/what-is-the-status-of-dbg-addr/62898

Depends on D144792

Diff Detail

Event Timeline

jryans created this revision.Feb 25 2023, 4:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2023, 4:13 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
jryans requested review of this revision.Feb 25 2023, 4:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2023, 4:13 PM
jryans retitled this revision from [DebugInfo] Upgrade `dbg.addr` to `dbg.value` r=Orlando,StephenTozer,probinson,rnk to [DebugInfo] Upgrade `dbg.addr` to `dbg.value`.Feb 25 2023, 4:16 PM
jryans added a project: debug-info.

I just have a couple of nits/questions (most inline), otherwise SGTM.

Was llvm/test/Bitcode/upgrade-dbg-addr.ll.bc added by accident?

llvm/lib/IR/AutoUpgrade.cpp
4141–4142

nit: missing full stops for the comments.

llvm/test/Bitcode/upgrade-dbg-addr.ll
12

Better to avoid hard-coding metadata in the CHECK directives (I've not used the [[#]] syntax before to match numbers but iiuc it should work here).

19

Did you exclude the metadata definitions on purpose and does the test work like this?

It seems odd to me, but I've not looked at the upgrade tests before.

jryans marked 3 inline comments as done.Feb 27 2023, 3:49 AM

Was llvm/test/Bitcode/upgrade-dbg-addr.ll.bc added by accident?

No, bitcode tests seem to use a pattern of calling llvm-dis on a separate .bc file, so that's what I did here. The .ll file is not the test input like it usually is in most other tests, so that's why e.g. the metadata is not needed. I suppose only the CHECK lines are actually required, but other files seemed to include some amount IR in the .ll part for explanatory reasons I guess.

llvm/test/Bitcode/upgrade-dbg-addr.ll
12

Ah, good tip, done!

19

The .ll content is not that meaningful here because only the .bc is actually used as an input (unlike most other tests). Bitcode tests seem to use this pattern regularly from what I could see.

In any case, yes, the test does pass like this. 🙂

jryans updated this revision to Diff 500731.Feb 27 2023, 3:57 AM
jryans marked 2 inline comments as done.
jryans edited the summary of this revision. (Show Details)

Fixed comments and test syntax.

Apologies for adding an additional round of comments - these should / could have come in the first review.

llvm/lib/IR/AutoUpgrade.cpp
4146

Actually, thinking about it, shouldn't the DW_OP_deref be appended rather than prepended? Before converting the dbg.addr to a dbg.value, the expression modified the address of the variable. In order for that to remain true the deref needs to be added to the end of the expression.

llvm/test/Bitcode/upgrade-dbg-addr.ll
12

It just occurred to me that it might be beneficial to include an existing expression (e.g.DW_OP_plus, DW_OP_constu, 0 or something) to test the pre/appended-ness of it.

19

Oh I see. Ok cool, that makes sense to me.

jryans marked an inline comment as done.Feb 27 2023, 8:12 AM
jryans added inline comments.
llvm/lib/IR/AutoUpgrade.cpp
4146

Ah yes, good catch! Not sure why I convinced myself "prepend" was the thing to do... We want the fully transformed address from the dbg.addr expression, so the deref should go at the end.

I'll update this and improve the test coverage to match.

llvm/test/Bitcode/upgrade-dbg-addr.ll
12

Right, good idea, I will add that.

jryans updated this revision to Diff 501066.Feb 28 2023, 3:03 AM

Switched to appending and extended test to ensure that's indeed what happens.

jryans marked 2 inline comments as done.Feb 28 2023, 3:04 AM
jryans added inline comments.
llvm/test/Bitcode/upgrade-dbg-addr.ll
19

Now that I'm having to modify the test, I think it's better to have the full .ll file in tree for easier tweaking when needed. I'll keep the .bc as the test input though, since that seems to be the pattern here.

Orlando accepted this revision.Feb 28 2023, 3:31 AM

Thanks - LGTM!

This revision is now accepted and ready to land.Feb 28 2023, 3:31 AM
This revision was landed with ongoing or failed builds.Mar 2 2023, 1:31 AM
This revision was automatically updated to reflect the committed changes.