[Mlir-commits] [mlir] [mlir][debug] Convert DbgIntrOp to DebugRecords directly. (PR #154926)
Tobias Gysi
llvmlistbot at llvm.org
Sun Aug 24 02:17:20 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();
----------------
gysit wrote:
Since it is not possible anymore to put all the builder code in the debug intrinsic base class there is quite a bit of code duplication. Can you factor out some of this code into a helper function(s) placed in LLVMDialect.cpp? One thing that seems doable is to extract a helper for the scope computation but there may be other options as well. I would place it somewhere to the other intrinsic functionality that has been factored out (e.g. here https://github.com/llvm/llvm-project/blob/3054e06c33ac8977b355bf2cff14617a342dbce9/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp#L4168).
That should reduce code duplication and the amount of C++ embedded in tablegen.
https://github.com/llvm/llvm-project/pull/154926
More information about the Mlir-commits
mailing list