Skip to content

Commit 670ac23

Browse files
authored
[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.
1 parent b926f75 commit 670ac23

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ void registerFromLLVMIRTranslation() {
5656
if (llvm::verifyModule(*llvmModule, &llvm::errs()))
5757
return nullptr;
5858

59+
// Debug records are not currently supported in the LLVM IR translator.
60+
if (llvmModule->IsNewDbgInfoFormat)
61+
llvmModule->convertFromNewDbgValues();
62+
5963
return translateLLVMIRToModule(std::move(llvmModule), context,
6064
emitExpensiveWarnings,
6165
dropDICompositeTypeElements);

mlir/test/Target/LLVMIR/Import/import-failure.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ define void @unhandled_intrinsic() gc "example" {
6464
declare void @llvm.dbg.value(metadata, metadata, metadata)
6565

6666
; CHECK: import-failure.ll
67-
; 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))
67+
; 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))
6868
; CHECK: import-failure.ll
69-
; CHECK-SAME: warning: dropped intrinsic: call void @llvm.dbg.value(metadata !6, metadata !3, metadata !DIExpression())
69+
; CHECK-SAME: warning: dropped intrinsic: tail call void @llvm.dbg.value(metadata !6, metadata !3, metadata !DIExpression())
7070
define void @unsupported_argument(i64 %arg1) {
71-
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
72-
call void @llvm.dbg.value(metadata !6, metadata !3, metadata !DIExpression()), !dbg !5
71+
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
72+
tail call void @llvm.dbg.value(metadata !6, metadata !3, metadata !DIExpression()), !dbg !5
7373
ret void
7474
}
7575

0 commit comments

Comments
 (0)