[PATCH] D150707: [DebugInfo] Handle undefined values for DBG_PHIs in InstrRef-LiveDebugValues

Stephen Tozer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 12:29:40 PDT 2023

StephenTozer created this revision.
StephenTozer added reviewers: jmorse, aeubanks, debug-info.
StephenTozer added a project: debug-info.
Herald added a subscriber: hiraditya.
Herald added a project: All.
StephenTozer requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fixes https://github.com/llvm/llvm-project/issues/62725

When running `llc` on the IR file in the above issue, after ISel there is a `DBG_INSTR_REF` and a single `DBG_PHI` that it references; at some point in the MIR pipeline, the block containing the `DBG_PHI` becomes unreachable. When we reach LiveDebugValues, this results in a crash due to unreachable blocks not being considered: In the initial tracking of DBG_PHIs, we will set the value of the lone `DBG_PHI` as the live-in value at the phi location, i.e. {4,0,4}. In `ExtendRanges` we perform a machine value dataflow analysis and apply the result to the collected DBG_PHIs. *Generally* this means each `DBG_PHI` will be updated to use the resolved value if one is found, and otherwise is unchanged. When the `DBG_PHI` is in an unreachable block however it will be updated to use the empty value instead, which is inconsistent with other phi values (which use an empty optional instead), resulting in us attempting to use the empty value as an actual value and triggering an assertion.

This patch fixes this error by checking for empty live-in values after the data flow analysis, and continuing to use the existing phi value if no value was found for that phi in the analysis. This prevents crashes from mishandling the empty value internally, and results in the correct value being found for any users of the DBG_PHI.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150707.522739.patch
Type: text/x-patch
Size: 5201 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230516/17de1483/attachment.bin>

More information about the llvm-commits mailing list