Add a pass that builds a debug info scope for LLVMFuncOp (adding a DISubprogramAttr)
authorMehdi Amini <joker.eph@gmail.com>
Wed, 15 Feb 2023 05:15:30 +0000 (21:15 -0800)
committerMehdi Amini <joker.eph@gmail.com>
Wed, 15 Feb 2023 06:43:26 +0000 (22:43 -0800)
commit72429a42ac33564fa82449d99dc234da32a05498
tree49453f7e009a40d1e4a51ad06a1545b19e46a031
parentd7ca25342ff6341d99f5075fdbcb8a29298befe8
Add a pass that builds a debug info scope for LLVMFuncOp (adding a DISubprogramAttr)

This may be seen as a hack, but it allows for any piece of MLIR to be able
to end up with DWARF debug info through LLVM.
Assuming the operations in the function have location such as FileLineCol,
this provides backtraces with line tables and allows to step in a debugger.
That makes this pass a perfect companion to -snapshot-op-locations

It was also the default behavior of MLIR to LLVM IR translation until MLIR
got support for proper debug info attributes.

Differential Revision: https://reviews.llvm.org/D144069
mlir/examples/toy/Ch6/toyc.cpp
mlir/examples/toy/Ch7/toyc.cpp
mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h
mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
mlir/lib/Dialect/LLVMIR/Transforms/CMakeLists.txt
mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp [new file with mode: 0644]
mlir/test/Dialect/LLVMIR/add-debuginfo-func-scope.mlir [new file with mode: 0644]