aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Optimizer/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Optimizer/Transforms')
-rw-r--r--flang/lib/Optimizer/Transforms/AddDebugInfo.cpp9
-rw-r--r--flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp7
2 files changed, 11 insertions, 5 deletions
diff --git a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
index bdf7e4a..e006d2e 100644
--- a/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
+++ b/flang/lib/Optimizer/Transforms/AddDebugInfo.cpp
@@ -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;
diff --git a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
index a7e4723..00fdb5a 100644
--- a/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
+++ b/flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp
@@ -682,10 +682,11 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertPointerLikeType(
static mlir::StringAttr getBasicTypeName(mlir::MLIRContext *context,
llvm::StringRef baseName,
unsigned bitSize) {
- std::string name(baseName.str());
+ std::ostringstream oss;
+ oss << baseName.str();
if (bitSize != 32)
- name += "*" + std::to_string(bitSize / 8);
- return mlir::StringAttr::get(context, name);
+ oss << "(kind=" << (bitSize / 8) << ")";
+ return mlir::StringAttr::get(context, oss.str());
}
mlir::LLVM::DITypeAttr