[Mlir-commits] [mlir] 253f4bf - [mlir][LLVM] drop `llvm.intr.dbg.value` when promoting in `SROA` or `mem2reg`
Markus Böck
llvmlistbot at llvm.org
Tue Jul 4 08:16:45 PDT 2023
Author: Markus Böck
Date: 2023-07-04T17:15:23+02:00
New Revision: 253f4bfa87f30c6c4def3801fc1bce7b130a8795
URL: https://github.com/llvm/llvm-project/commit/253f4bfa87f30c6c4def3801fc1bce7b130a8795
DIFF: https://github.com/llvm/llvm-project/commit/253f4bfa87f30c6c4def3801fc1bce7b130a8795.diff
LOG: [mlir][LLVM] drop `llvm.intr.dbg.value` when promoting in `SROA` or `mem2reg`
This has previously been done for `llvm.intr.dbg.declare`, which is a common occurrence when the debug info points to the variable through the pointer, but may also occur when the `alloca` itself is a local variable in debug info.
Not doing so prevents `SROA` and `mem2reg` from promoting e.g. an `alloca`. We simply drop the value completetly, since there is no meaninful debug info that can be constructed instead as the pointer value is removed.
Differential Revision: https://reviews.llvm.org/D154451
Added:
Modified:
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
mlir/test/Dialect/LLVMIR/mem2reg-dbginfo.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
index e8065daaf5da98..66edaab2ad5d47 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
@@ -571,7 +571,8 @@ def LLVM_DbgDeclareOp : LLVM_DbgIntrOp<"dbg.declare", "addr",
let arguments = (ins LLVM_AnyPointer:$addr, LLVM_DILocalVariableAttr:$varInfo);
}
-def LLVM_DbgValueOp : LLVM_DbgIntrOp<"dbg.value", "value"> {
+def LLVM_DbgValueOp : LLVM_DbgIntrOp<"dbg.value", "value",
+ [DeclareOpInterfaceMethods<PromotableOpInterface>]> {
let summary = "Describes how the value relates to a source language variable.";
let arguments = (ins LLVM_Type:$value, LLVM_DILocalVariableAttr:$varInfo);
}
diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
index 8248a1e08a25ce..241bfdb732dc42 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp
@@ -260,6 +260,17 @@ DeletionKind LLVM::DbgDeclareOp::removeBlockingUses(
return DeletionKind::Delete;
}
+bool LLVM::DbgValueOp::canUsesBeRemoved(
+ const SmallPtrSetImpl<OpOperand *> &blockingUses,
+ SmallVectorImpl<OpOperand *> &newBlockingUses) {
+ return true;
+}
+
+DeletionKind LLVM::DbgValueOp::removeBlockingUses(
+ const SmallPtrSetImpl<OpOperand *> &blockingUses, RewriterBase &rewriter) {
+ return DeletionKind::Delete;
+}
+
//===----------------------------------------------------------------------===//
// Interfaces for GEPOp
//===----------------------------------------------------------------------===//
diff --git a/mlir/test/Dialect/LLVMIR/mem2reg-dbginfo.mlir b/mlir/test/Dialect/LLVMIR/mem2reg-dbginfo.mlir
index 0c1908ec8fdce2..b01fb55653612b 100644
--- a/mlir/test/Dialect/LLVMIR/mem2reg-dbginfo.mlir
+++ b/mlir/test/Dialect/LLVMIR/mem2reg-dbginfo.mlir
@@ -77,11 +77,13 @@ llvm.func @double_block_argument_value(%arg0: i64, %arg1: i1) -> i64 {
// CHECK-LABEL: llvm.func @always_drop_promoted_declare
// CHECK-NOT: = llvm.alloca
-// CHECK-NOT: llvm.intr.dbg.
+// CHECK-NOT: llvm.intr.dbg.declare
+// CHECK-NOT: llvm.intr.dbg.value
llvm.func @always_drop_promoted_declare() {
%0 = llvm.mlir.constant(1 : i32) : i32
%1 = llvm.alloca %0 x i64 {alignment = 8 : i64} : (i32) -> !llvm.ptr
llvm.intr.dbg.declare #di_local_variable = %1 : !llvm.ptr
+ llvm.intr.dbg.value #di_local_variable = %1 : !llvm.ptr
llvm.return
}
More information about the Mlir-commits
mailing list