[PATCH] D77446: Add MIR-level debugify with only locations support for now

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 3 17:53:49 PDT 2020


dsanders created this revision.
dsanders added reviewers: aprantl, bogner, vsk.
Herald added subscribers: hiraditya, mgorny.
Herald added a project: LLVM.

Re-used the IR-level debugify for the most part. The MIR-level code then
adds locations to the MachineInstrs afterwards based on the LLVM-IR debug
info.

It's worth mentioning that the resulting locations make little sense as
the range of line numbers used in a Function at the MIR level exceeds that
of the equivelent IR level function. As such, MachineInstrs can appear to
originate from outside the subprogram scope (and from other subprogram
scopes). However, it doesn't seem worth worrying about as the source is
imaginary anyway.

There's a few high level goals this pass works towards:

- We should be able to debugify our .ll/.mir in the lit tests without changing the checks and still pass them. I.e. Debug info should not change codegen. Combining this with a strip-debug pass should enable this. The main issue I ran into without the strip-debug pass was instructions with MMO's and checks on both the instruction and the MMO as the debug-location is between them. I currently have a simple hack in the MIRPrinter to resolve that but the more general solution is a proper strip-debug pass.
- We should be able to test that GlobalISel does not lose debug info. I recently found that the legalizer can be unexpectedly lossy in seemingly simple cases (e.g. expanding one instr into many). I have a verifier (will be posted separately) that can be integrated with passes that use the observer interface and will catch location loss (it does not verify correctness, just that there's zero lossage). It is a little conservative as the line-0 locations that arise from conflicts do not track the conflicting locations but it can still catch a fair bit.

Depends on D77439 <https://reviews.llvm.org/D77439>, D77438 <https://reviews.llvm.org/D77438>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77446

Files:
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Utils/Debugify.h
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CodeGen.cpp
  llvm/lib/CodeGen/MachineDebugify.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77446.254967.patch
Type: text/x-patch
Size: 8135 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200404/81e6bfe3/attachment.bin>


More information about the llvm-commits mailing list