[all-commits] [llvm/llvm-project] dab36b: [mlir][debug] Allow global with local scope. (#98358)

Abid Qadeer via All-commits all-commits at lists.llvm.org
Thu Jul 11 08:31:32 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dab36b288a1566d7b41154751e547c555ad43358
      https://github.com/llvm/llvm-project/commit/dab36b288a1566d7b41154751e547c555ad43358
  Author: Abid Qadeer <haqadeer at amd.com>
  Date:   2024-07-11 (Thu, 11 Jul 2024)

  Changed paths:
    M mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
    M mlir/test/Target/LLVMIR/llvmir-debug.mlir

  Log Message:
  -----------
  [mlir][debug] Allow global with local scope. (#98358)

Currently, only those global variables in debug info are allowed which
have a compile unit or module scope. But global variable with function
scope are used in debug info to represent certain type of variables. One
example will be static local variables in C. Here the variable is
represented as global variable with parent function as its scope. See
the code and debug metadata as generated by clang below. You can see
that scope of `DIGlobalVariable` is `DISubprogram`.

```
int test() {
    static int a = 0;
    return a++;
}

!0 = !DIGlobalVariableExpression(var: !1...)
!1 = !DIGlobalVariable(name: "a", scope: !2 ...)
!2 = !DISubprogram(name: "test" ...)
!7 = !DICompileUnit(... globals: !8...)
!8 = !{!0}
```

Similar issue exist in fortran where global variable with function scope
are used to represent local variable with save attribute.

This PR will allows such variables during module translation.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list