[PATCH] D123033: [DebugInfo][InstrRef] Avoid a crash from mixed variable location modes

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 07:53:50 PDT 2022


jmorse created this revision.
jmorse added reviewers: Orlando, StephenTozer.
Herald added subscribers: hiraditya, MatzeB.
Herald added a project: All.
jmorse requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Variable locations now come in two modes, instruction referencing and DBG_VALUE -- I initially assumed that we could use information like the current optimisation level to detect which mode we should use (-O0 uses DBG_VALUE). Unfortunately, it turns out that SelectionDAG fiddles with the optimisation level in the presence of opt-bisect-limit (see the lines in `SelectionDAGISel::runOnMachineFunction` immediately below my additions), making this not a robust technique. Over in [0] there's a crash observed from this, SelectionDAG produces DBG_VALUEs but the debug-info passes expect to see DBG_INSTR_REFs.

Changing the target options in the middle of a pass is accepted as a horrible hack in the comments in SelectionDAG -- there's not much to do about this, except:

- Store a flag in MachineFunction indicating what flavour of debug-info it contains,
- Plumb the original debug-info flavour through SelectionDAG so that the correct one is picked.

This patch implements the latter: the "use instr-ref?" boolean is stored before the target options are edited, then passed down to the instruction emitting functions. This is mildly ugly, but there aren't any good options.

[0] https://github.com/llvm/llvm-project/issues/53937


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123033

Files:
  llvm/include/llvm/CodeGen/FastISel.h
  llvm/include/llvm/CodeGen/SelectionDAG.h
  llvm/include/llvm/CodeGen/SelectionDAGISel.h
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp
  llvm/lib/CodeGen/SelectionDAG/InstrEmitter.h
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
  llvm/test/DebugInfo/X86/instr-ref-opt-bisect.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123033.420181.patch
Type: text/x-patch
Size: 14859 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220404/daf7e770/attachment.bin>


More information about the llvm-commits mailing list