Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,16 @@ mlir::LLVM::DIModuleAttr AddDebugInfoPass::getOrCreateModuleAttr(
if (auto iter{moduleMap.find(name)}; iter != moduleMap.end()) {
modAttr = iter->getValue();
} else {
// When decl is true, it means that module is only being used in this
// compilation unit and it is defined elsewhere. But if the file/line/scope
// fields are valid, the module is not merged with its definition and is
// considered different. So we only set those fields when decl is false.
modAttr = mlir::LLVM::DIModuleAttr::get(
context, fileAttr, scope, mlir::StringAttr::get(context, name),
context, decl ? nullptr : fileAttr, decl ? nullptr : scope,
mlir::StringAttr::get(context, name),
/* configMacros */ mlir::StringAttr(),
/* includePath */ mlir::StringAttr(),
/* apinotes */ mlir::StringAttr(), line, decl);
/* apinotes */ mlir::StringAttr(), decl ? 0 : line, decl);
moduleMap[name] = modAttr;
}
return modAttr;
Expand Down
13 changes: 13 additions & 0 deletions flang/test/Transforms/debug-module-3.fir
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: fir-opt --add-debug-info --mlir-print-debuginfo %s | FileCheck %s

module {
func.func @_QQmain() {
%2 = fir.address_of(@_QMmodEvar1) : !fir.ref<i32> loc(#loc1)
%3 = fircg.ext_declare %2 {uniq_name = "_QMmodEvar1"} : (!fir.ref<i32>) -> !fir.ref<i32> loc(#loc1)
return
} loc(#loc1)
fir.global @_QMmodEvar1 : i32 loc(#loc1)
}
#loc1 = loc("test1.f90":1:0)

// CHECK: #llvm.di_module<name = "mod", isDecl = true>