This is an archive of the discontinued LLVM Phabricator instance.

[MachineFunction][DebugInfo][nfc] Introduce EntryValue variable kind
ClosedPublic

Authored by fdeazeve on May 4 2023, 11:33 AM.

Details

Summary

MachineFunction keeps a table of variables whose addresses never change
throughout the function. Today, the only kinds of locations it can
handle are stack slots.

However, we could expand this for variables whose address is derived
from the value a register had upon function entry. One case where this
happens is with variables alive across coroutine funclets: these can
be placed in a coroutine frame object whose pointer is placed in a
register that is an argument to coroutine funclets.

define @foo(ptr %frame_ptr) {
  dbg.declare(%frame_ptr, !some_var,
              !DIExpression(EntryValue, <ptr_arithmetic>))

This is a patch in a series that aims to improve the debug information
generated by the CoroSplit pass in the context of swiftasync
arguments. Variables stored in the coroutine frame _must_ be described
the entry_value of the ABI-defined register containing a pointer to the
coroutine frame. Since these variables have a single location throughout
their lifetime, they are candidates for being stored in the
MachineFunction table.

Diff Detail

Event Timeline

fdeazeve created this revision.May 4 2023, 11:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2023, 11:33 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
fdeazeve requested review of this revision.May 4 2023, 11:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2023, 11:33 AM
aprantl accepted this revision.May 4 2023, 12:21 PM

That looks nice and clean.

llvm/include/llvm/CodeGen/MachineFunction.h
414

///

1295

this lambda is different from the one above in that it uses const auto

This revision is now accepted and ready to land.May 4 2023, 12:21 PM
fdeazeve added inline comments.May 5 2023, 5:02 AM
llvm/include/llvm/CodeGen/MachineFunction.h
1295

Unfortunately there isn't much we can do about that prior C++23's "deducing this" feature :/
This is the const version of the function above

fdeazeve updated this revision to Diff 519809.May 5 2023, 5:03 AM

Address review comments

aprantl added inline comments.May 5 2023, 8:17 AM
llvm/include/llvm/CodeGen/MachineFunction.h
1295

Oh I didn't realize that this was actually necessary because it affects the return type.