llvm-project
dab36b28 - [mlir][debug] Allow global with local scope. (#98358)

Commit
1 year ago
[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.
Author
Parents
Loading