aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachinePassManager.cpp
diff options
context:
space:
mode:
authorAbid Qadeer <haqadeer@amd.com>2024-05-15 15:20:27 +0100
committerGitHub <noreply@github.com>2024-05-15 15:20:27 +0100
commit61da6366d043792d7db280ce9edd2db62516e0e8 (patch)
treee258d2b01c43c1387b907f3dd17cc60f49329717 /llvm/lib/CodeGen/MachinePassManager.cpp
parent466d266945196ebbdefd8d72f654551d54d68600 (diff)
downloadllvm-61da6366d043792d7db280ce9edd2db62516e0e8.zip
llvm-61da6366d043792d7db280ce9edd2db62516e0e8.tar.gz
llvm-61da6366d043792d7db280ce9edd2db62516e0e8.tar.bz2
[flang] Initial debug info support for local variables. (#90905)
We need the information in the `DeclareOp` to generate debug information for variables. Currently, cg-rewrite removes the `DeclareOp`. As `AddDebugInfo` runs after that, it cannot process the `DeclareOp`. My initial plan was to make the `AddDebugInfo` pass run before the cg-rewrite but that has few issues. 1. Initially I was thinking to use the memref op to carry the variable attr. But as @tblah suggested in the #86939, it makes more sense to carry that information on `DeclareOp`. It also makes it easy to handle it in codegen and there is no special handling needed for arguments. For this reason, we need to preserve the `DeclareOp` till the codegen. 2. Running earlier, we will miss the changes in passes that run between cg-rewrite and codegen. But not removing the DeclareOp in cg-rewrite has the issue that ShapeOp remains and it causes errors during codegen. To solve this problem, I convert DeclareOp to XDeclareOp in cg-rewrite instead of removing it. This was mentioned as possible solution by @jeanPerier in https://reviews.llvm.org/D136254 The conversion follows similar logic as used for other operators in that file. The FortranAttr and CudaAttr are currently not converted but left as TODO when the need arise. Now `AddDebugInfo` pass can extracts information about local variables from `XDeclareOp` and creates `DILocalVariableAttr`. These are attached to `XDeclareOp` using `FusedLoc` approach. Codegen can use them to create `DbgDeclareOp`. I have added tests that checks the debug information in mlir from and also in llvm ir. Currently we only handle very limited types. Rest are given a place holder type. The previous placeholder type was basic type with `DW_ATE_address` encoding. When variables are added, it started causing assertions in the llvm debug info generation logic for some types. It has been changed to an interger type to prevent these issues until we handle those types properly.
Diffstat (limited to 'llvm/lib/CodeGen/MachinePassManager.cpp')
0 files changed, 0 insertions, 0 deletions