[Mlir-commits] [mlir] [mlir][debug] Convert DbgIntrOp to DebugRecords directly. (PR #154926)
Abid Qadeer
llvmlistbot at llvm.org
Tue Aug 26 04:01:16 PDT 2025
================
@@ -721,6 +727,29 @@ def LLVM_DbgValueOp : LLVM_DbgIntrOp<"dbg.value", "value",
LLVM_DILocalVariableAttr:$varInfo,
DefaultValuedAttr<LLVM_DIExpressionAttr, "{}">:$locationExpr
);
+ let llvmBuilder = [{
+ // Debug intrinsics without debug locations are invalid.
+ if(!builder.getCurrentDebugLocation())
+ return success();
+ llvm::Function *parentFn = builder.GetInsertBlock()->getParent();
+ llvm::DILocalScope *scope;
+ if (auto scopeLoc =
+ opInst.getLoc()->findInstanceOf<FusedLocWith<LLVM::DIScopeAttr>>())
+ scope = llvm::cast<llvm::DILocalScope>(
+ moduleTranslation.translateDebugInfo(scopeLoc.getMetadata()));
+ else
+ scope = parentFn->getSubprogram();
----------------
abidh wrote:
Thanks for your suggestion. I have moved the code in a separate function. I initially used the location that you suggested for the new function but it would have required to add its declaration in `LLVMDialect.h` and then at least a forward declaration of `ModuleTranslation` there. It seemed like too much churn for a local helper. I have instead added in `LLVMToLLVMIRTranslation.cpp`.
I also changed the code to use dyn_cast.
https://github.com/llvm/llvm-project/pull/154926
More information about the Mlir-commits
mailing list