[PATCH] D105657: [InstrRef][X86] Drop debug instruction numbers from x87 instructions

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 8 14:21:32 PDT 2021


jmorse created this revision.
jmorse added a reviewer: debug-info.
Herald added subscribers: pengfei, hiraditya.
jmorse requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Avoid a crash when using instruction referencing if x87 floating point instructions are used. These instructions are significantly mutated when they're rewritten from referring to registers, to referring to floating-point-stack positions. As a result, their operands are re-ordered, and (InstrRef) LiveDebugValues asserts when it sees a DBG_INSTR_REF referring to a non-reg non-def register operand.

To fix this, I'm just dropping the instruction numbers, and thus variable locations. This avoids the crash -- we could try and record the substitution from fp-register operand to floating-point-stack-position but then... what would we do with the floating point stack position? They shift position throughout the program, and an additional dataflow analysis would be needed to work out how to refer to them correctly.

Instead, take the pragmatic approach that VarLoc LiveDebugvalues / variable locations does, and drop the lot of them. This isn't a coverage regression at all, because all DBG_VALUEs of, for example, $fp0, don't make it to the output file because they're pseudo-registers with no DWARF register number. I'll open a PR for poor x87 variable location support, however I suspect interest is limited.

This patch adds a "dropDebugNumber" helper to MachineInstr, the idea being that it's (sort-of) self documenting what's going on. The attached test case covers all six call sites that I add in the x86-codegen pass.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105657

Files:
  llvm/include/llvm/CodeGen/MachineInstr.h
  llvm/lib/Target/X86/X86FloatingPoint.cpp
  llvm/lib/Target/X86/X86InstrInfo.cpp
  llvm/test/DebugInfo/MIR/InstrRef/x86-fp-stackifier-drop-locations.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105657.357357.patch
Type: text/x-patch
Size: 15490 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210708/0f2164ab/attachment.bin>


More information about the llvm-commits mailing list