[Mlir-commits] [mlir] [MLIR][LLVM] Improve inlining debug information (PR #123520)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Jan 19 09:17:51 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Tobias Gysi (gysit)
<details>
<summary>Changes</summary>
This commit improves the debug information for `alloca` and `memcpy` operations generated by the LLVM dialect inlining interface.
When inlining by value parameters, the inliner creates `alloca` and `memcpy` operations. This revision sets the location of these created operations to the respective argument locations instead of the function location. This change enables users to better identify the source code location of the copied variables.
---
Full diff: https://github.com/llvm/llvm-project/pull/123520.diff
2 Files Affected:
- (modified) mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp (+3-3)
- (added) mlir/test/Dialect/LLVMIR/inlining-debuginfo.mlir (+21)
``````````diff
diff --git a/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp b/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
index 79dd3e30696482..aab8d037cd8d21 100644
--- a/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/LLVMIR/Transforms/InlinerInterfaceImpl.cpp
@@ -643,9 +643,9 @@ static Value handleByValArgument(OpBuilder &builder, Operation *callable,
return argument;
}
uint64_t targetAlignment = std::max(requestedAlignment, minimumAlignment);
- return handleByValArgumentInit(builder, func.getLoc(), argument, elementType,
- dataLayout.getTypeSize(elementType),
- targetAlignment);
+ return handleByValArgumentInit(
+ builder, argument.getLoc(), argument, elementType,
+ dataLayout.getTypeSize(elementType), targetAlignment);
}
namespace {
diff --git a/mlir/test/Dialect/LLVMIR/inlining-debuginfo.mlir b/mlir/test/Dialect/LLVMIR/inlining-debuginfo.mlir
new file mode 100644
index 00000000000000..10b06d987e4498
--- /dev/null
+++ b/mlir/test/Dialect/LLVMIR/inlining-debuginfo.mlir
@@ -0,0 +1,21 @@
+// RUN: mlir-opt %s -inline -mlir-print-debuginfo | FileCheck %s
+
+llvm.func @foo() -> !llvm.ptr
+
+llvm.func @with_byval_arg(%ptr : !llvm.ptr { llvm.byval = f64 }) {
+ llvm.return
+}
+
+// CHECK-LABEL: llvm.func @test_byval
+llvm.func @test_byval() {
+ // CHECK: %[[COPY:.+]] = llvm.alloca %{{.+}} x f64
+ // CHECK-SAME: loc(#[[LOC:.+]])
+ // CHECK: %[[ORIG:.+]] = llvm.call @foo() : () -> !llvm.ptr loc(#[[LOC]])
+ %0 = llvm.call @foo() : () -> !llvm.ptr loc("inlining-debuginfo.mlir":14:2)
+ // CHECK: "llvm.intr.memcpy"(%[[COPY]], %[[ORIG]]
+ // CHECK-SAME: loc(#[[LOC]])
+ llvm.call @with_byval_arg(%0) : (!llvm.ptr) -> ()
+ llvm.return
+}
+
+// CHECK: #[[LOC]] = loc("inlining-debuginfo.mlir":14:2)
\ No newline at end of file
``````````
</details>
https://github.com/llvm/llvm-project/pull/123520
More information about the Mlir-commits
mailing list