mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-23 23:06:06 +00:00

As described in #98883, we have to qualify a module variable name in debugger to get its value. This PR tries to remove this limitation. LLVM provides `DIImportedEntity` to handle such cases but the PR is made more complicated due to the following 2 issues. 1. The MLIR attributes are readonly and we have a circular dependency here. This has to be handled using the recursive interface provided by the MLIR. This requires us to first create a place holder `DISubprogramAttr` which is used in creating `DIImportedEntityAttr`. Later another `DISubprogramAttr` is created which replaces the place holder. 2. The flang IR does not provide any information about the 'used' module so this has to be extracted by doing a pass over the `DeclareOp` in the function. This presents certain limitation as 'only' and module variable renaming may not be handled properly. Due to the change in `DISubprogramAttr`, some tests also needed to be adjusted. Fixes #98883.
31 lines
1.3 KiB
Plaintext
31 lines
1.3 KiB
Plaintext
// RUN: fir-opt --add-debug-info --mlir-print-debuginfo %s | FileCheck %s
|
|
|
|
|
|
module attributes {dlti.dl_spec = #dlti.dl_spec<>} {
|
|
fir.global @_QMfooEv1 : i32 {
|
|
%0 = fir.zero_bits i32
|
|
fir.has_value %0 : i32
|
|
}
|
|
fir.global internal @_QFtestExyz : i32 {
|
|
%c12_i32 = arith.constant 12 : i32
|
|
fir.has_value %c12_i32 : i32
|
|
} loc(#loc4)
|
|
func.func @test() attributes {fir.bindc_name = "test"} {
|
|
%0 = fir.address_of(@_QMfooEv1) : !fir.ref<i32>
|
|
%1 = fircg.ext_declare %0 {uniq_name = "_QMfooEv1"} : (!fir.ref<i32>) -> !fir.ref<i32> loc(#loc1)
|
|
%4 = fir.address_of(@_QFtestExyz) : !fir.ref<i32>
|
|
%5 = fircg.ext_declare %4 {uniq_name = "_QFtestExyz"} : (!fir.ref<i32>) -> !fir.ref<i32> loc(#loc4)
|
|
return
|
|
} loc(#loc3)
|
|
}
|
|
#loc1 = loc("test.f90":2:14)
|
|
#loc2 = loc("test.f90":6:1)
|
|
#loc3 = loc("test.f90":10:1)
|
|
#loc4 = loc("test.f90":13:1)
|
|
|
|
// CHECK: #[[MOD:.+]] = #llvm.di_module<{{.*}}name = "foo"{{.*}}>
|
|
// CHECK: #[[SP_REC:.+]] = #llvm.di_subprogram<recId = distinct[[[REC_ID:[0-9]+]]]<>, isRecSelf = true{{.*}}>
|
|
// CHECK: #[[IMP_ENTITY:.+]] = #llvm.di_imported_entity<tag = DW_TAG_imported_module, scope = #[[SP_REC]], entity = #[[MOD]]{{.*}}>
|
|
// CHECK: #[[SP:.+]] = #llvm.di_subprogram<recId = distinct[[[REC_ID]]]<>{{.*}}retainedNodes = #[[IMP_ENTITY]]>
|
|
// CHECK: #llvm.di_global_variable<scope = #[[SP]], name = "xyz"{{.*}}>
|