diff options
author | Stephen Tozer <stephen.tozer@sony.com> | 2024-04-23 14:27:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-23 14:27:06 +0100 |
commit | 670ac235b52887b621ab9c75c6be7f5ac4ceb9f8 (patch) | |
tree | 3217d11fcd7d44f72b1b1102a71941c19a1e44c0 | |
parent | b926f75e89c025afeb040cbd245ce2ba9cce9fce (diff) |
[RemoveDIs][MLIR] Don't process debug records in the LLVM-IR translator (#89735)
We are almost ready to enable the use of debug records everywhere in
LLVM by default; part of the prep-work for this means ensuring that
every tool supports them. Every tool in the `llvm/` project supports
them, front-ends that use the `DIBuilder` will support them, and as far
as I can tell, the only other tool in the LLVM repo that needs to
support them but doesn't is `mlir-translate`. This patch trivially
unblocks them by converting from debug records to debug intrinsics
before translating a module.
-rw-r--r-- | mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp | 4 | ||||
-rw-r--r-- | mlir/test/Target/LLVMIR/Import/import-failure.ll | 8 |
2 files changed, 8 insertions, 4 deletions
diff --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp index 101add70c51e..7e2da1e0303c 100644 --- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp @@ -56,6 +56,10 @@ void registerFromLLVMIRTranslation() { if (llvm::verifyModule(*llvmModule, &llvm::errs())) return nullptr; + // Debug records are not currently supported in the LLVM IR translator. + if (llvmModule->IsNewDbgInfoFormat) + llvmModule->convertFromNewDbgValues(); + return translateLLVMIRToModule(std::move(llvmModule), context, emitExpensiveWarnings, dropDICompositeTypeElements); diff --git a/mlir/test/Target/LLVMIR/Import/import-failure.ll b/mlir/test/Target/LLVMIR/Import/import-failure.ll index 3f4efab70e1c..9c24ed2b7574 100644 --- a/mlir/test/Target/LLVMIR/Import/import-failure.ll +++ b/mlir/test/Target/LLVMIR/Import/import-failure.ll @@ -64,12 +64,12 @@ define void @unhandled_intrinsic() gc "example" { declare void @llvm.dbg.value(metadata, metadata, metadata) ; CHECK: import-failure.ll -; CHECK-SAME: warning: dropped intrinsic: call void @llvm.dbg.value(metadata !DIArgList(i64 %{{.*}}, i64 undef), metadata !3, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_constu, 1, DW_OP_mul, DW_OP_plus, DW_OP_stack_value)) +; CHECK-SAME: warning: dropped intrinsic: tail call void @llvm.dbg.value(metadata !DIArgList(i64 %{{.*}}, i64 undef), metadata !3, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_constu, 1, DW_OP_mul, DW_OP_plus, DW_OP_stack_value)) ; CHECK: import-failure.ll -; CHECK-SAME: warning: dropped intrinsic: call void @llvm.dbg.value(metadata !6, metadata !3, metadata !DIExpression()) +; CHECK-SAME: warning: dropped intrinsic: tail call void @llvm.dbg.value(metadata !6, metadata !3, metadata !DIExpression()) define void @unsupported_argument(i64 %arg1) { - call void @llvm.dbg.value(metadata !DIArgList(i64 %arg1, i64 undef), metadata !3, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_constu, 1, DW_OP_mul, DW_OP_plus, DW_OP_stack_value)), !dbg !5 - call void @llvm.dbg.value(metadata !6, metadata !3, metadata !DIExpression()), !dbg !5 + tail call void @llvm.dbg.value(metadata !DIArgList(i64 %arg1, i64 undef), metadata !3, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_constu, 1, DW_OP_mul, DW_OP_plus, DW_OP_stack_value)), !dbg !5 + tail call void @llvm.dbg.value(metadata !6, metadata !3, metadata !DIExpression()), !dbg !5 ret void } |