[flang-commits] [flang] [flang] Add debug information for module variables. (PR #91582)

Abid Qadeer via flang-commits flang-commits at lists.llvm.org
Mon May 20 02:56:23 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();
----------------
abidh wrote:

Done.

https://github.com/llvm/llvm-project/pull/91582


More information about the flang-commits mailing list