[PATCH] D74019: [mlir] Add support for generating debug locations from intermediate levels of the IR.

River Riddle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 4 18:58:44 PST 2020


rriddle created this revision.
rriddle added reviewers: jpienaar, mehdi_amini, benvanik.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako.
Herald added a project: LLVM.

This revision adds a utility to generate debug locations from the IR during compilation, by snapshotting to a output stream and using the locations that operations were dumped in that stream. The new locations may either;

- Replace the original location of the operation.

old:

  loc("original_source.cpp":1:1)

new:

  loc("snapshot_source.mlir":10:10)

- Fuse with the original locations as NamedLocs with a specific tag.

old:

  loc("original_source.cpp":1:1)

new:

  loc(fused["original_source.cpp":1:1, "snapshot"("snapshot_source.mlir":10:10)])

This feature may be used by a debugger to display the code at various different levels of the IR. It would also be able to show the different levels of IR attached to a specific source line in the original source file.

This feature may also be used to generate locations for operations generated during compilation, that don't necessarily have a user source location to attach to.

This requires changes in the printer to track the locations of operations emitted in the stream. Moving forward we need to properly(and efficiently) track the number of newlines emitted to the stream during printing.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74019

Files:
  mlir/include/mlir/IR/AsmState.h
  mlir/include/mlir/Transforms/LocationSnapshot.h
  mlir/lib/IR/AsmPrinter.cpp
  mlir/lib/Transforms/LocationSnapshot.cpp
  mlir/test/Transforms/location-snapshot.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74019.242501.patch
Type: text/x-patch
Size: 19386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200205/9107cb32/attachment.bin>


More information about the llvm-commits mailing list