[flang-commits] [flang] [flang][debug] Fix issues with local variables. (PR #98661)
via flang-commits
flang-commits at lists.llvm.org
Mon Jul 15 08:16:48 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);
----------------
jeanPerier wrote:
module lookups are linear with the number of symbol inside the module.
So this will introduce a "number of variables" * "number of types + number of global + number of function" pseudo quadratic behavior that is noticeable on real applications.
I advise sharing a const mlir::SymbolTable that would be initialized in in runOnOperation only once (ideally, it would be done in pass initialization, but I am not sure how it can be done with the initialize hook from Pass.h that only provide the mlir::Context).
https://github.com/llvm/llvm-project/pull/98661
More information about the flang-commits
mailing list