Skip to content

Commit fd870c6

Browse files
authored
[MLIR][LLVM] Translate Debug EmissionKind (#74376)
Translate debug emission kind into LLVM (the importer already supports this).
1 parent 6b8d659 commit fd870c6

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

mlir/lib/Target/LLVMIR/DebugTranslation.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,9 @@ llvm::DICompileUnit *DebugTranslation::translateImpl(DICompileUnitAttr attr) {
102102
attr.getSourceLanguage(), translate(attr.getFile()),
103103
attr.getProducer() ? attr.getProducer().getValue() : "",
104104
attr.getIsOptimized(),
105-
/*Flags=*/"", /*RV=*/0);
105+
/*Flags=*/"", /*RV=*/0, /*SplitName=*/{},
106+
static_cast<llvm::DICompileUnit::DebugEmissionKind>(
107+
attr.getEmissionKind()));
106108
}
107109

108110
/// Returns a new `DINodeT` that is either distinct or not, depending on

mlir/test/Target/LLVMIR/llvmir-debug.mlir

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,24 @@ llvm.func @dbg_intrinsics_with_no_location(%arg0: i32) -> (i32) {
286286
#di_basic_type_2 = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "uint64_t", sizeInBits = 64, encoding = DW_ATE_unsigned>
287287
llvm.mlir.global external @global_with_expr_1() {addr_space = 0 : i32, dbg_expr = #llvm.di_global_variable_expression<var = <scope = #di_compile_unit_2, name = "global_with_expr_1", linkageName = "global_with_expr_1", file = #di_file_2, line = 370, type = #di_basic_type_2>, expr = <>>} : i64
288288
llvm.mlir.global external @global_with_expr_2() {addr_space = 0 : i32, dbg_expr = #llvm.di_global_variable_expression<var = <scope = #di_compile_unit_2, name = "global_with_expr_2", linkageName = "global_with_expr_2", file = #di_file_2, line = 371, type = #di_basic_type_2, isLocalToUnit = true, isDefined = true, alignInBits = 8>, expr = <>>} : i64
289+
290+
// -----
291+
292+
// CHECK-DAG: ![[FILE1:.*]] = !DIFile(filename: "foo1.mlir", directory: "/test/")
293+
#di_file_1 = #llvm.di_file<"foo1.mlir" in "/test/">
294+
// CHECK-DAG: ![[FILE2:.*]] = !DIFile(filename: "foo2.mlir", directory: "/test/")
295+
#di_file_2 = #llvm.di_file<"foo2.mlir" in "/test/">
296+
// CHECK-DAG: ![[SCOPE2:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[FILE2]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: DebugDirectivesOnly)
297+
#di_compile_unit_1 = #llvm.di_compile_unit<sourceLanguage = DW_LANG_C, file = #di_file_1, producer = "MLIR", isOptimized = true, emissionKind = LineTablesOnly>
298+
// CHECK-DAG: ![[SCOPE1:.*]] = distinct !DICompileUnit(language: DW_LANG_C, file: ![[FILE1]], producer: "MLIR", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly)
299+
#di_compile_unit_2 = #llvm.di_compile_unit<sourceLanguage = DW_LANG_C, file = #di_file_2, producer = "MLIR", isOptimized = true, emissionKind = DebugDirectivesOnly>
300+
#di_subprogram_1 = #llvm.di_subprogram<compileUnit = #di_compile_unit_1, scope = #di_file_1, name = "func1", file = #di_file_1, subprogramFlags = "Definition|Optimized">
301+
#di_subprogram_2 = #llvm.di_subprogram<compileUnit = #di_compile_unit_2, scope = #di_file_2, name = "func2", file = #di_file_2, subprogramFlags = "Definition|Optimized">
302+
303+
llvm.func @func_line_tables() {
304+
llvm.return
305+
} loc(fused<#di_subprogram_1>["foo1.mlir":0:0])
306+
307+
llvm.func @func_debug_directives() {
308+
llvm.return
309+
} loc(fused<#di_subprogram_2>["foo2.mlir":0:0])

0 commit comments

Comments
 (0)