[Mlir-commits] [mlir] [mlir] Add support for DIGlobalVariable and DIGlobalVariableExpression (PR #73367)

Christian Ulmann llvmlistbot at llvm.org
Mon Nov 27 09:03:37 PST 2023


================
@@ -782,6 +782,22 @@ LogicalResult ModuleTranslation::convertGlobals() {
     var->setVisibility(convertVisibilityToLLVM(op.getVisibility_()));
 
     globalsMapping.try_emplace(op, var);
+
+    // Add debug information if present
+    if (op.getDbgExpr()) {
+      auto *const globalExpr = debugTranslation->translate(op.getDbgExpr());
+      const auto *globalVar = globalExpr->getVariable();
+      var->addDebugInfo(globalExpr);
+
+      // Get the compile unit (scope) of the the global variable
+      if (auto *const compileUnit =
+              dyn_cast<llvm::DICompileUnit>(globalVar->getScope());
+          compileUnit) {
----------------
Dinistro wrote:

```suggestion
      if (auto *const compileUnit =
              dyn_cast<llvm::DICompileUnit>(globalVar->getScope())) {
```

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


More information about the Mlir-commits mailing list