Page MenuHomePhabricator

[DebugInfo] Add new metadata, DIArgList, for referencing a list of SSA values inside a debug variable intrinsic
Needs ReviewPublic

Authored by StephenTozer on Sep 23 2020, 11:40 AM.

Details

Summary

Continuing further with the work from the initial RFC[0], this patch is the first step to supporting variadic debug values within the IR. This patch adds a new metadata node, DIArgList, which contains a list of SSA values.

This node is in many ways similar in function to the existing ValueAsMetadata node, with the difference being that it tracks a list instead of a single value. Internally, it uses ValueAsMetadata to track the individual values, but there is also a reasonable amount of DIArgList-specific value-tracking logic on top of that. Similar to ValueAsMetadata, it is a special case in parsing and printing due to the fact that it requires a function state (as it may reference function-local values).

This patch does not add any useful functionality; it allows for DIArgLists to be parsed and printed, but debug variable intrinsics do not yet recognize them as a valid argument (outside of parsing). This functionality will come in later patches, which should be up tomorrow.

Although this approach differs from the MIR approach (which was to use a variadic set of arguments to the DBG_VALUE itself), the "variadic" approach is not suitable for an IR intrinsic: I've not been able to find any documentation or examples that make it look less complicated than adding a new metadata node; if anyone has anything to offer on that front I'm happy to take a look at it. The tracking behaviour in the DIArgList is also useful to have as it allows us to potentially respond to RAUWs that would cause a dbg.value to become undef, and cease tracking all of the listed SSA values at once, preventing us from needlessly processing and updating dbg.values that can only ever become empty DWARF locations.

[0] http://lists.llvm.org/pipermail/llvm-dev/2020-February/139376.html

Diff Detail

Event Timeline

StephenTozer created this revision.Sep 23 2020, 11:40 AM
StephenTozer requested review of this revision.Sep 23 2020, 11:40 AM
StephenTozer edited the summary of this revision. (Show Details)
aprantl added inline comments.Mon, Sep 28, 8:59 AM
llvm/include/llvm/IR/DebugInfoMetadata.h
3440

Why doesn't this inherit from, e.g., MDTuple or have multiple MDOperands?

StephenTozer added inline comments.Mon, Sep 28, 9:19 AM
llvm/include/llvm/IR/DebugInfoMetadata.h
3440

The short explanation is that this doesn't use the built-in MD operands at all - you'll notice that we pass None to the Ops argument in the MDNode constructor below. The baisc reason for that is that the way the MDOperands are handled has some incompatibilities with the intended use of the DIArgList arguments. I'll have to go back over my work to collect a more specific set of reasons as to why using MDOperands doesn't work for this.