This is an archive of the discontinued LLVM Phabricator instance.

[AsmPrinter][DebugInfo] Create EntryValue mode for DbgVariable
ClosedPublic

Authored by fdeazeve on Aug 21 2023, 2:43 PM.

Details

Summary

With D149881, we converted EntryValue MachineFunction table entries into
DbgVariables initialized by a "DbgValue" intrinsic, which can only handle a
single, non-fragment DIExpression. However, it is desirable to handle variables
with multiple fragments and DIExpressions.

To do this, we expand the DbgVariable class to handle the EntryValue case.
This class can already operate under three different "modes" (stack slot,
unchanging location described by a dbg value, changing location described by a
loc list). A fourth case is added as a separate class entirely, but a subsequent
patch should redesign DbgVariable with four subclasses in order to make the
code more readable.

This patch also exposed a bug in the beginEntryValueExpression function, which
was not initializing the LocationFlags properly. Note how the
finalizeEntryValue function resets that flag. We fix this bug here, as testing
this changing in isolation would be tricky.

Diff Detail

Event Timeline

fdeazeve created this revision.Aug 21 2023, 2:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2023, 2:43 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
fdeazeve requested review of this revision.Aug 21 2023, 2:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2023, 2:43 PM
fdeazeve added inline comments.Aug 21 2023, 2:44 PM
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
877

FYI I recommend looking at DwarfDebug.h and DwarfDebug.cpp before looking at the other files.

aprantl accepted this revision.Aug 21 2023, 3:59 PM

LGTM, some minor nitpicks inside.

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
113

///

119

getFragmentOffsetInBits?

126

Why not a DenseSet<std::pair<MCRegister, DIExpression&>> or something that inherits from std::pair, then you don't need to define any sorting/hashing methods.

This revision is now accepted and ready to land.Aug 21 2023, 3:59 PM
fdeazeve added inline comments.Aug 23 2023, 9:29 AM
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
126

Just to register an offline discussion: this wouldn't quite work as we want to sort based on the fragment offset, not directly on the value of any particular pair member.

This revision was landed with ongoing or failed builds.Aug 23 2023, 9:29 AM
This revision was automatically updated to reflect the committed changes.