[flang-commits] [flang] [flang] Add debug information for module variables. (PR #91582)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Sun May 19 07:45:53 PDT 2024
================
@@ -99,6 +109,68 @@ void AddDebugInfoPass::handleDeclareOp(fir::cg::XDeclareOp declOp,
declOp->setLoc(builder.getFusedLoc({declOp->getLoc()}, localVarAttr));
}
+// The `module` does not have a first class representation in the `FIR`. We
+// extract information about it from the name of the identifiers and keep a
+// map to avoid duplication.
+mlir::LLVM::DIModuleAttr AddDebugInfoPass::getOrCreateModuleAttr(
+ const std::string &name, mlir::LLVM::DIFileAttr fileAttr,
+ mlir::LLVM::DIScopeAttr scope, unsigned line, bool decl) {
+ mlir::MLIRContext *context = &getContext();
+ mlir::LLVM::DIModuleAttr modAttr;
+ if (auto iter{moduleMap.find(name)}; iter != moduleMap.end())
+ modAttr = iter->getValue();
+ else {
+ modAttr = mlir::LLVM::DIModuleAttr::get(
+ context, fileAttr, scope, mlir::StringAttr::get(context, name),
+ mlir::StringAttr(), mlir::StringAttr(), mlir::StringAttr(), line, decl);
----------------
kiranchandramohan wrote:
Nit: comments here to spell the default attributes.
https://github.com/llvm/llvm-project/pull/91582
More information about the flang-commits
mailing list