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

Stephen Tozer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 16 11:08:50 PDT 2021


StephenTozer added a comment.

Quick question: Do call instructions need to be handled here? I tried modifying the C source to have a variable directly assigned from a call instruction:

  d = ext();
  a *= d;

Then with the following command line (I don't know if there's a way to pass `experimental-debug-variable-locations` directly to clang), the call+instruction reference appear as in the below block: `clang -m32 -g -O2 test.c -S -emit-llvm -o - | llc -experimental-debug-variable-locations -stop-before=x86-codegen -o test.mir`

  CALLpcrel32 @ext, csr_32, implicit $esp, implicit $ssp, implicit-def $esp, implicit-def $ssp, implicit-def $fp0, debug-instr-number 6, debug-location !23
  ADJCALLSTACKUP32 0, 0, implicit-def dead $esp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $esp, implicit $ssp, debug-location !23
  DBG_INSTR_REF 6, 6, !19, !DIExpression(), debug-location !21

If I understand the syntax correctly, this means that the `DBG_INSTR_REF` is referring to `$fp0` in the call instruction. Finally, running `llc test.mir -experimental-debug-variable-locations -run-pass=x86-codegen -o -` translates this to the following:

  CALLpcrel32 @ext, csr_32, implicit $esp, implicit $ssp, implicit-def $esp, implicit-def $ssp, debug-instr-number 6, debug-location !23
  ADJCALLSTACKUP32 0, 0, implicit-def dead $esp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $esp, implicit $ssp, debug-location !23
  DBG_INSTR_REF 6, 6, !19, !DIExpression(), debug-location !21

If I've understood correctly, the `DBG_INSTR_REF` now refers to a non-existent operand, while the call instruction still has a `debug-instr-number` attached. I'd assume that this is an issue given the other areas handled by this patch, does this need handling here?



================
Comment at: llvm/include/llvm/CodeGen/MachineInstr.h:475
+  /// will be dropped.
+  void dropDebugNumber() { DebugInstrNum = 0; }
+
----------------
:+1:


================
Comment at: llvm/test/DebugInfo/MIR/InstrRef/x86-fp-stackifier-drop-locations.mir:84
+  !11 = !{i32 1, !"wchar_size", i32 4}
+  !12 = !{!"clang version 10.0 (git at github.com:llvm/llvm-project 7c502acec2e9618931cb0c1209889b7b98c5fc2e)"}
+  !13 = distinct !DISubprogram(name: "foo", scope: !6, file: !6, line: 5, type: !14, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !16)
----------------
Nit, remove git+commit reference.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105657/new/

https://reviews.llvm.org/D105657



More information about the llvm-commits mailing list