[Flang] Add/Restore basic debug support (1/n)
authorKiran Chandramohan <kiran.chandramohan@arm.com>
Thu, 12 Jan 2023 10:34:34 +0000 (10:34 +0000)
committerKiran Chandramohan <kiran.chandramohan@arm.com>
Thu, 12 Jan 2023 10:40:59 +0000 (10:40 +0000)
commit87e547d8f035c8de321e246629dd2b1ccec31662
treed8d7e4121a97a2125aa8af0373704a6179fb8f58
parentf460c6658107ba214edadcdac9aa0656c4c51505
[Flang] Add/Restore basic debug support (1/n)

Recent changes to MLIR meant that Flang does not generate any debug line
table information.

This patch adds a pass that provides some foundation work with which
basic line table debug info can be generated. A walk is performed on
all the `func` ops in the module and they are decorated with a fusedLoc
op that contains the debug metadata for the subroutine along with
location information.

Alternatives include populating this info during lowering or during FIR
to LLVM Dialect conversion.

Note: Patches in future will add
    -> more realistic debug info for types and other fields.
    -> driver flags to control generation of debug.

Fixes #58634.

Reviewed By: awarzynski, vzakhari

Differential Revision: https://reviews.llvm.org/D137956
flang/include/flang/Lower/Bridge.h
flang/include/flang/Optimizer/Transforms/Passes.h
flang/include/flang/Optimizer/Transforms/Passes.td
flang/include/flang/Tools/CLOptions.inc
flang/lib/Frontend/FrontendActions.cpp
flang/lib/Lower/Bridge.cpp
flang/lib/Optimizer/Transforms/AddDebugFoundation.cpp [new file with mode: 0644]
flang/lib/Optimizer/Transforms/CMakeLists.txt
flang/test/Lower/module-debug-file-loc.f90 [new file with mode: 0644]
flang/test/Transforms/debug-line-table.fir [new file with mode: 0644]
flang/tools/bbc/bbc.cpp