This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Produce undef DBG_VALUE instructions for variadic dbg.values when using FastISel or GlobalIsel
ClosedPublic

Authored by StephenTozer on May 14 2021, 7:46 AM.

Details

Summary

Currently, variadic dbg.values (i.e. those using a DIArgList as part of their location) are not handled properly by FastIsel or GlobalIsel. A full implementation may take some time to complete, but these pipelines must not produce invalid debug info in the absence of a full implementation. Maintaining current behaviour in this case means producing undef DBG_VALUE instructions for each variadic dbg.value; currently these passes instead produce DBG_VALUE instructions as normal, but only using the first value in the DIArgList - this is not only incorrect, but also invalid as the set of valid DIExpressions for variadic and non-variadic dbg.values are disjoint. This may result in errors further along the pipeline.

Diff Detail

Event Timeline

StephenTozer created this revision.May 14 2021, 7:46 AM
StephenTozer requested review of this revision.May 14 2021, 7:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 14 2021, 7:46 AM

Added test that was missing from the previous diff.

Do we expect cases where this feature is useful when doing -O0? I guess no, right? So the FastISel is OK, since it is being used at -O0 case only.

Do we expect cases where this feature is useful when doing -O0? I guess no, right? So the FastISel is OK, since it is being used at -O0 case only.

You're right for the most part, but there are some edge cases: a function which is "always inline" called from a function marked "optnone" can result in FastIsel being run on a variadic dbg.value.

jmorse accepted this revision.May 20 2021, 6:02 AM

LGTM given that I've seen a reproducer where this causes an assertion failure -- it's clearly best to avoid the assertion failure. We should re-visit this in the future as there are quite legitimate scenarios where this would be important, for example using optimised LLVM-IR with llc -O0.

This revision is now accepted and ready to land.May 20 2021, 6:02 AM