brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.0 KiB · ffeb871 Raw
163 lines · plain
1// RUN: mlir-opt %s --pass-pipeline="builtin.module(ensure-debug-info-scope-on-llvm-func)" --split-input-file --mlir-print-debuginfo | FileCheck %s2// RUN: mlir-opt %s --pass-pipeline="builtin.module(ensure-debug-info-scope-on-llvm-func{emission-kind=DebugDirectivesOnly})" --split-input-file --mlir-print-debuginfo | FileCheck --check-prefix=CHECK_OTHER_KIND %s 3 4// CHECK-LABEL: llvm.func @func_no_debug()5// CHECK: llvm.return loc(#loc6// CHECK: loc(#loc[[LOC:[0-9]+]])7// CHECK: #di_file = #llvm.di_file<"<unknown>" in "">8// CHECK: #di_subprogram = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #di_compile_unit, scope = #di_file, name = "func_no_debug", linkageName = "func_no_debug", file = #di_file, line = 1, scopeLine = 1, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type>9// CHECK: #loc[[LOC]] = loc(fused<#di_subprogram>10module {11  llvm.func @func_no_debug() {12    llvm.return loc(unknown)13  } loc(unknown)14} loc(unknown)15 16// -----17 18// Test that the declarations subprogram is not made distinct.19// CHECK-LABEL: llvm.func @func_decl_no_debug()20// CHECK: #di_subprogram = #llvm.di_subprogram<21// CHECK-NOT: id = distinct22module {23  llvm.func @func_decl_no_debug() loc(unknown)24} loc(unknown)25 26// -----27 28// Test that existing debug info is not overwritten.29// CHECK-LABEL: llvm.func @func_with_debug()30// CHECK: llvm.return loc(#loc31// CHECK: loc(#loc[[LOC:[0-9]+]])32// CHECK: #di_file = #llvm.di_file<"<unknown>" in "">33// CHECK: #di_subprogram = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #di_compile_unit, scope = #di_file, name = "func_with_debug", linkageName = "func_with_debug", file = #di_file, line = 42, scopeLine = 42, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type>34// CHECK: #loc[[LOC]] = loc(fused<#di_subprogram>35// CHECK_OTHER_KIND: emissionKind = DebugDirectivesOnly36module {37  llvm.func @func_with_debug() {38    llvm.return loc(#loc1)39  } loc(#loc2)40} loc(#loc)41#di_file = #llvm.di_file<"<unknown>" in "">42#di_subroutine_type = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>43#loc = loc("foo":0:0)44#loc1 = loc(unknown)45#di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file, producer = "MLIR", isOptimized = true, emissionKind = LineTablesOnly>46#di_subprogram = #llvm.di_subprogram<id = distinct[1]<>, compileUnit = #di_compile_unit, scope = #di_file, name = "func_with_debug", linkageName = "func_with_debug", file = #di_file, line = 42, scopeLine = 42, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type>47#loc2 = loc(fused<#di_subprogram>[#loc1])48 49// -----50 51// Test that a compile unit present on a module op is used for the function.52// CHECK-LABEL: llvm.func @propagate_compile_unit()53// CHECK: llvm.return loc(#loc54// CHECK: loc(#loc[[FUNCLOC:[0-9]+]])55// CHECK: loc(#loc[[MODULELOC:[0-9]+]])56// CHECK-DAG: #[[DI_FILE_MODULE:.+]] = #llvm.di_file<"bar.mlir" in "baz">57// CHECK-DAG: #[[DI_FILE_FUNC:.+]] = #llvm.di_file<"file.mlir" in ""> 58// CHECK-DAG: #loc[[FUNCFILELOC:[0-9]+]] = loc("file.mlir":9:8)59// CHECK-DAG: #di_compile_unit = #llvm.di_compile_unit<id = distinct[{{.*}}]<>, sourceLanguage = DW_LANG_C, file = #[[DI_FILE_MODULE]], producer = "MLIR", isOptimized = true, emissionKind = LineTablesOnly>60// CHECK-DAG: #di_subprogram = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #di_compile_unit, scope = #[[DI_FILE_FUNC]], name = "propagate_compile_unit", linkageName = "propagate_compile_unit", file = #[[DI_FILE_FUNC]], line = 9, scopeLine = 9, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type>61// CHECK-DAG: #loc[[MODULELOC]] = loc(fused<#di_compile_unit>[#loc])62// CHECK-DAG: #loc[[FUNCLOC]] = loc(fused<#di_subprogram>[#loc[[FUNCFILELOC]]63module {64  llvm.func @propagate_compile_unit() {65    llvm.return loc(unknown)66  } loc("file.mlir":9:8)67} loc(#loc)68#di_file = #llvm.di_file<"bar.mlir" in "baz">69#di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file, producer = "MLIR", isOptimized = true, emissionKind = LineTablesOnly>70#loc = loc(fused<#di_compile_unit>["foo.mlir":2:1])71 72// -----73 74// Test that only one compile unit is created.75// CHECK-LABEL: module @multiple_funcs76// CHECK: llvm.di_compile_unit77// CHECK-NOT: llvm.di_compile_unit78module @multiple_funcs {79  llvm.func @func0() {80    llvm.return loc(unknown)81  } loc(unknown)82  llvm.func @func1() {83    llvm.return loc(unknown)84  } loc(unknown)85} loc(unknown)86 87// -----88 89// CHECK-LABEL: llvm.func @func_inlined()90// CHECK: #di_file = #llvm.di_file<"base.py" in "testing">91// CHECK: #di_file1 = #llvm.di_file<"gpu_test.py" in "">92// CHECK: #di_subroutine_type = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>93// CHECK: #di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file, producer = "MLIR", isOptimized = true, emissionKind = LineTablesOnly>94// CHECK: #loc3 = loc(callsite(#loc1 at #loc2))95// CHECK: #di_subprogram = #llvm.di_subprogram<id = distinct[1]<>, compileUnit = #di_compile_unit, scope = #di_file1, name = "func_inlined", linkageName = "func_inlined", file = #di_file1, line = 1150, scopeLine = 1150, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type>96// CHECK: #di_lexical_block_file = #llvm.di_lexical_block_file<scope = #di_subprogram, file = #di_file, discriminator = 0>97 98 99#loc = loc("gpu_test.py":1150:34 to :43)100#loc1 = loc("testing/parameterized.py":321:17 to :53)101#loc2 = loc("testing/base.py":2904:19 to :56)102#loc_1 = loc(callsite(#loc at #loc1))103#loc21 = loc(callsite(#loc2 at #loc_1))104 105module {106  llvm.func @func_inlined() {107    llvm.return loc(#loc21)108  } loc(#loc)109} loc(#loc2)110 111// -----112 113// CHECK-LABEL: llvm.func @func_name_with_child()114// CHECK: #di_file = #llvm.di_file<"file" in "/tmp">115// CHECK: #di_subroutine_type = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>116// CHECK: #di_subprogram = #llvm.di_subprogram<scope = #di_file, name = "func_name_with_child", linkageName = "func_name_with_child", file = #di_file, line = 100, scopeLine = 100, subprogramFlags = Optimized, type = #di_subroutine_type>117 118module {119  llvm.func @func_name_with_child() loc("foo"("/tmp/file":100))120} loc(unknown)121 122// -----123 124// CHECK-LABEL: llvm.func @func_fusion()125// CHECK: #di_file = #llvm.di_file<"file" in "/tmp">126// CHECK: #di_subroutine_type = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>127// CHECK: #di_subprogram = #llvm.di_subprogram<scope = #di_file, name = "func_fusion", linkageName = "func_fusion", file = #di_file, line = 20, scopeLine = 20, subprogramFlags = Optimized, type = #di_subroutine_type>128 129module {130  llvm.func @func_fusion() loc(fused<"myPass">["foo", "/tmp/file":20])131} loc(unknown)132 133// -----134 135// CHECK-LABEL: llvm.func @func_callsiteloc()136// CHECK: #di_file = #llvm.di_file<"mysource.cc" in "">137// CHECK: #di_subroutine_type = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>138// CHECK: #di_subprogram = #llvm.di_subprogram<scope = #di_file, name = "func_callsiteloc", linkageName = "func_callsiteloc", file = #di_file, line = 10, scopeLine = 10, subprogramFlags = Optimized, type = #di_subroutine_type>139 140module {141  llvm.func @func_callsiteloc() loc(callsite("foo" at "mysource.cc":10:8))142} loc(unknown)143 144// -----145 146// CHECK-LABEL: llvm.func @func_cross_file_op()147// CHECK: #di_file = #llvm.di_file<"<unknown>" in "">148// CHECK: #di_file1 = #llvm.di_file<"caller.py" in "">149// CHECK: #di_file2 = #llvm.di_file<"callee.py" in "">150// CHECK: #di_subroutine_type = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>151// CHECK: #di_subprogram = #llvm.di_subprogram<id = distinct[1]<>, compileUnit = #di_compile_unit, scope = #di_file1, name = "func_cross_file_op", linkageName = "func_cross_file_op", file = #di_file1, line = 5, scopeLine = 5, subprogramFlags = "Definition|Optimized", type = #di_subroutine_type>152// CHECK: #di_lexical_block_file = #llvm.di_lexical_block_file<scope = #di_subprogram, file = #di_file2, discriminator = 0>153 154#loc = loc("caller.py":5:1)155#loc1 = loc("callee.py":10:5)156 157module {158  llvm.func @func_cross_file_op() {159    llvm.return loc(#loc1)160  } loc(#loc)161} loc(unknown)162 163