This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][InstrRef] Avoid crash when values optimised out late in sdag
ClosedPublic

Authored by jmorse on Nov 23 2021, 2:12 PM.

Details

Summary

It appears that we can emit all the instructions for a function, including debug instructions, and then optimise some of the values out late. Specifically, in the attached test case, an argument gets optimised out after DBG_VALUE / DBG_INSTR_REFs are created. This confuses MachineFunction::finalizeDebugInstrRefs, which expects to be able to find a defining instruction, and crashes instead.

Fix this by identifying when there's no defining instruction, and translating that instead into a DBG_VALUE $noreg.

Diff Detail

Event Timeline

jmorse created this revision.Nov 23 2021, 2:12 PM
jmorse requested review of this revision.Nov 23 2021, 2:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2021, 2:12 PM
jmorse updated this revision to Diff 389320.Nov 23 2021, 2:13 PM

Remove un-necessary debug info

djtodoro accepted this revision.Nov 24 2021, 12:42 AM

Sounds reasonable to me (I guess this doesn't depend on the rest of the stack, so it can go even now).

This revision is now accepted and ready to land.Nov 24 2021, 12:42 AM