[Mlir-commits] [mlir] [mlir][debug] Allow global with local scope. (PR #98358)
Tobias Gysi
llvmlistbot at llvm.org
Wed Jul 10 23:02:39 PDT 2024
================
@@ -1073,9 +1073,16 @@ LogicalResult ModuleTranslation::convertGlobals() {
// variable -> module -> compile unit
// If a variable scope points to the module then we use the scope of the
// module to get the compile unit.
+ // Global variables are also used for things like static local variables
+ // in C and local variables with the save attribute in Fortran. The scope
+ // of the variable is the parent function. We use the compile unit of the
+ // parent function in this case.
llvm::DIScope *scope = diGlobalVar->getScope();
if (llvm::DIModule *mod = dyn_cast_if_present<llvm::DIModule>(scope))
scope = mod->getScope();
+ else if (llvm::DISubprogram *sp =
+ dyn_cast_or_null<llvm::DISubprogram>(scope))
----------------
gysit wrote:
```suggestion
else if (auto *sp =
dyn_cast_if_present<llvm::DISubprogram>(scope))
```
nit: auto makes sense here and I believe dyn_cast_if_present is the more modern version.
PS feel free to change llvm::DIModule to auto in the if above as well.
https://github.com/llvm/llvm-project/pull/98358
More information about the Mlir-commits
mailing list