[flang-commits] [flang] [flang][debug] Fix issues with local variables. (PR #98661)

Abid Qadeer via flang-commits flang-commits at lists.llvm.org
Tue Jul 16 03:10:09 PDT 2024


================
@@ -80,12 +80,19 @@ void AddDebugInfoPass::handleDeclareOp(fir::cg::XDeclareOp declOp,
                                        mlir::LLVM::DIScopeAttr scopeAttr,
                                        fir::DebugTypeGenerator &typeGen) {
   mlir::MLIRContext *context = &getContext();
+  mlir::ModuleOp module = getOperation();
   mlir::OpBuilder builder(context);
   auto result = fir::NameUniquer::deconstruct(declOp.getUniqName());
 
   if (result.first != fir::NameUniquer::NameKind::VARIABLE)
     return;
 
+  // If this DeclareOp actually represents a global then treat it as such.
+  if (auto global = module.lookupSymbol<fir::GlobalOp>(declOp.getUniqName())) {
+    handleGlobalOp(global, fileAttr, scopeAttr);
----------------
abidh wrote:

Thanks. That is very useful thing to know. I have updated the patch.

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


More information about the flang-commits mailing list