[Mlir-commits] [mlir] [mlir] Add support for DIGlobalVariable and DIGlobalVariableExpression (PR #73367)
Justin Wilson
llvmlistbot at llvm.org
Tue Nov 28 07:41:52 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()) {
+ llvm::DIGlobalVariableExpression *globalExpr =
+ debugTranslation->translateGlobalVariableExpression(op.getDbgExpr());
+ const llvm::DIGlobalVariable *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())) {
+ // Update the compile unit with this incoming global variable
+ compileUnit->replaceGlobalVariables(
----------------
waj334 wrote:
yep I need to revise that and make sure I'm collecting them all up for the specific compile unit and then replaceGlobalVariables should be called as a finalizer step. This is what DIBuilder does.
https://github.com/llvm/llvm-project/pull/73367
More information about the Mlir-commits
mailing list