[all-commits] [llvm/llvm-project] abe3e5: [mlir] Add support for generating debug locations ...

River Riddle via All-commits all-commits at lists.llvm.org
Sat Feb 8 15:16:19 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: abe3e5babdad001100b285d188e63f76fe21aea4
      https://github.com/llvm/llvm-project/commit/abe3e5babdad001100b285d188e63f76fe21aea4
  Author: River Riddle <riddleriver at gmail.com>
  Date:   2020-02-08 (Sat, 08 Feb 2020)

  Changed paths:
    M mlir/include/mlir/IR/AsmState.h
    A mlir/include/mlir/Transforms/LocationSnapshot.h
    M mlir/lib/IR/AsmPrinter.cpp
    M mlir/lib/Transforms/CMakeLists.txt
    A mlir/lib/Transforms/LocationSnapshot.cpp
    A mlir/test/Transforms/location-snapshot.mlir

  Log Message:
  -----------
  [mlir] Add support for generating debug locations from intermediate levels of the IR.

Summary:
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.

Differential Revision: https://reviews.llvm.org/D74019




More information about the All-commits mailing list