Skip to content

Commit b7c723d

Browse files
abidhAlexisPerry
authored andcommitted
[flang][debug] Cleanup tests. (NFC) (llvm#96189)
@kiranchandramohan mentioned [here](llvm#91582 (comment)) that LLVM IR tests should go in the Integration folder. He also mentioned [here](llvm#91582 (comment)) that tests for `add-debug-info` pass should test that pass only. There were some tests which were added before his comments so I have cleaned them in this PR. The following changes were made. 1. Move LLVM IR tests to `Integration` folder. 2. Change tests from f90 to fir and only test changes done by `add-debug-info` pass.
1 parent 7e8b049 commit b7c723d

File tree

5 files changed

+175
-99
lines changed

5 files changed

+175
-99
lines changed

flang/test/Transforms/debug-fn-info.f90

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// RUN: fir-opt --add-debug-info --mlir-print-debuginfo %s | FileCheck %s
2+
3+
module attributes {dlti.dl_spec = #dlti.dl_spec<>} {
4+
func.func @_QQmain() attributes {fir.bindc_name = "mn"} {
5+
%0 = fir.alloca i32 {bindc_name = "i4", uniq_name = "_QFEi4"}
6+
%1 = fircg.ext_declare %0 {uniq_name = "_QFEi4"} : (!fir.ref<i32>) -> !fir.ref<i32>
7+
%2 = fir.alloca i64 {bindc_name = "i8", uniq_name = "_QFEi8"}
8+
%3 = fircg.ext_declare %2 {uniq_name = "_QFEi8"} : (!fir.ref<i64>) -> !fir.ref<i64>
9+
%4 = fir.alloca !fir.logical<1> {bindc_name = "l1", uniq_name = "_QFEl1"}
10+
%5 = fircg.ext_declare %4 {uniq_name = "_QFEl1"} : (!fir.ref<!fir.logical<1>>) -> !fir.ref<!fir.logical<1>>
11+
%6 = fir.alloca !fir.logical<4> {bindc_name = "l4", uniq_name = "_QFEl4"}
12+
%7 = fircg.ext_declare %6 {uniq_name = "_QFEl4"} : (!fir.ref<!fir.logical<4>>) -> !fir.ref<!fir.logical<4>>
13+
%8 = fir.alloca f32 {bindc_name = "r4", uniq_name = "_QFEr4"}
14+
%9 = fircg.ext_declare %8 {uniq_name = "_QFEr4"} : (!fir.ref<f32>) -> !fir.ref<f32>
15+
%10 = fir.alloca f64 {bindc_name = "r8", uniq_name = "_QFEr8"}
16+
%11 = fircg.ext_declare %10 {uniq_name = "_QFEr8"} : (!fir.ref<f64>) -> !fir.ref<f64>
17+
%12 = fir.call @_QFPfn1(%1, %11, %5) fastmath<contract> : (!fir.ref<i32>, !fir.ref<f64>, !fir.ref<!fir.logical<1>>) -> i64
18+
fir.store %12 to %3 : !fir.ref<i64>
19+
%13 = fir.call @_QFPfn2(%3, %9, %7) fastmath<contract> : (!fir.ref<i64>, !fir.ref<f32>, !fir.ref<!fir.logical<4>>) -> i32
20+
fir.store %13 to %1 : !fir.ref<i32>
21+
return
22+
} loc(#loc1)
23+
func.func private @_QFPfn1(%arg0: !fir.ref<i32> {fir.bindc_name = "a"} , %arg1: !fir.ref<f64> {fir.bindc_name = "b"}, %arg2: !fir.ref<!fir.logical<1>> {fir.bindc_name = "c"}) -> i64 attributes {fir.host_symbol = @_QQmain, llvm.linkage = #llvm.linkage<internal>} {
24+
%0 = fir.undefined !fir.dscope
25+
%1 = fircg.ext_declare %arg0 dummy_scope %0 {uniq_name = "_QFFfn1Ea"} : (!fir.ref<i32>, !fir.dscope) -> !fir.ref<i32>
26+
%2 = fircg.ext_declare %arg1 dummy_scope %0 {uniq_name = "_QFFfn1Eb"} : (!fir.ref<f64>, !fir.dscope) -> !fir.ref<f64>
27+
%3 = fircg.ext_declare %arg2 dummy_scope %0 {uniq_name = "_QFFfn1Ec"} : (!fir.ref<!fir.logical<1>>, !fir.dscope) -> !fir.ref<!fir.logical<1>>
28+
%4 = fir.alloca i64 {bindc_name = "res", uniq_name = "_QFFfn1Eres"}
29+
%5 = fircg.ext_declare %4 {uniq_name = "_QFFfn1Eres"} : (!fir.ref<i64>) -> !fir.ref<i64>
30+
%6 = fir.load %1 : !fir.ref<i32>
31+
%7 = fir.convert %6 : (i32) -> f64
32+
%8 = fir.load %2 : !fir.ref<f64>
33+
%9 = arith.addf %7, %8 fastmath<contract> : f64
34+
%10 = fir.convert %9 : (f64) -> i64
35+
fir.store %10 to %5 : !fir.ref<i64>
36+
%11 = fir.load %5 : !fir.ref<i64>
37+
return %11 : i64
38+
} loc(#loc2)
39+
func.func private @_QFPfn2(%arg0: !fir.ref<i64> {fir.bindc_name = "a"}, %arg1: !fir.ref<f32> {fir.bindc_name = "b"}, %arg2: !fir.ref<!fir.logical<4>> {fir.bindc_name = "c"}) -> i32 attributes {fir.host_symbol = @_QQmain, llvm.linkage = #llvm.linkage<internal>} {
40+
%0 = fir.undefined !fir.dscope
41+
%1 = fircg.ext_declare %arg0 dummy_scope %0 {uniq_name = "_QFFfn2Ea"} : (!fir.ref<i64>, !fir.dscope) -> !fir.ref<i64>
42+
%2 = fircg.ext_declare %arg1 dummy_scope %0 {uniq_name = "_QFFfn2Eb"} : (!fir.ref<f32>, !fir.dscope) -> !fir.ref<f32>
43+
%3 = fircg.ext_declare %arg2 dummy_scope %0 {uniq_name = "_QFFfn2Ec"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> !fir.ref<!fir.logical<4>>
44+
%4 = fir.alloca i32 {bindc_name = "res", uniq_name = "_QFFfn2Eres"}
45+
%5 = fircg.ext_declare %4 {uniq_name = "_QFFfn2Eres"} : (!fir.ref<i32>) -> !fir.ref<i32>
46+
%6 = fir.load %1 : !fir.ref<i64>
47+
%7 = fir.convert %6 : (i64) -> f32
48+
%8 = fir.load %2 : !fir.ref<f32>
49+
%9 = arith.addf %7, %8 fastmath<contract> : f32
50+
%10 = fir.convert %9 : (f32) -> i32
51+
fir.store %10 to %5 : !fir.ref<i32>
52+
%11 = fir.load %5 : !fir.ref<i32>
53+
return %11 : i32
54+
} loc(#loc3)
55+
}
56+
#loc1 = loc("test.f90":15:1)
57+
#loc2 = loc("test.f90":26:22)
58+
#loc3 = loc("test2.f90":43:22)
59+
60+
61+
// CHECK-DAG: #[[INT8:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 64, encoding = DW_ATE_signed>
62+
// CHECK-DAG: #[[INT4:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 32, encoding = DW_ATE_signed>
63+
// CHECK-DAG: #[[REAL8:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "real", sizeInBits = 64, encoding = DW_ATE_float>
64+
// CHECK-DAG: #[[LOG1:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "logical", sizeInBits = 8, encoding = DW_ATE_boolean>
65+
// CHECK-DAG: #[[REAL4:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "real", sizeInBits = 32, encoding = DW_ATE_float>
66+
// CHECK-DAG: #[[LOG4:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "logical", sizeInBits = 32, encoding = DW_ATE_boolean>
67+
// CHECK: #[[TY0:.*]] = #llvm.di_subroutine_type<callingConvention = DW_CC_program>
68+
// CHECK: #[[TY1:.*]] = #llvm.di_subroutine_type<callingConvention = DW_CC_normal, types = #[[INT8]], #[[INT4]], #[[REAL8]], #[[LOG1]]>
69+
// CHECK: #[[TY2:.*]] = #llvm.di_subroutine_type<callingConvention = DW_CC_normal, types = #[[INT4]], #[[INT8]], #[[REAL4]], #[[LOG4]]>
70+
71+
// Line numbers should match the number in corresponding loc entry.
72+
// CHECK: #llvm.di_subprogram<id = {{.*}}, compileUnit = {{.*}}, scope = {{.*}}, name = "_QQmain", linkageName = "_QQmain", file = {{.*}}, line = 15, scopeLine = 15, subprogramFlags = Definition, type = #[[TY0]]>
73+
// CHECK: #llvm.di_subprogram<id = {{.*}}, compileUnit = {{.*}}, scope = {{.*}}, name = "fn1", linkageName = "_QFPfn1", file = {{.*}}, line = 26, scopeLine = 26, subprogramFlags = Definition, type = #[[TY1]]>
74+
// CHECK: #llvm.di_subprogram<id = {{.*}}, compileUnit = {{.*}}, scope = {{.*}}, name = "fn2", linkageName = "_QFPfn2", file = {{.*}}, line = 43, scopeLine = 43, subprogramFlags = Definition, type = #[[TY2]]>
75+

flang/test/Transforms/debug-local-var.f90

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// RUN: fir-opt --add-debug-info --mlir-print-debuginfo %s | FileCheck %s
2+
3+
module attributes {dlti.dl_spec = #dlti.dl_spec<>} {
4+
func.func @_QQmain() attributes {fir.bindc_name = "mn"} {
5+
%0 = fir.alloca i32 {bindc_name = "i4", uniq_name = "_QFEi4"}
6+
%1 = fircg.ext_declare %0 {uniq_name = "_QFEi4"} : (!fir.ref<i32>) -> !fir.ref<i32> loc(#loc1)
7+
%2 = fir.alloca i64 {bindc_name = "i8", uniq_name = "_QFEi8"}
8+
%3 = fircg.ext_declare %2 {uniq_name = "_QFEi8"} : (!fir.ref<i64>) -> !fir.ref<i64> loc(#loc2)
9+
%4 = fir.alloca !fir.logical<1> {bindc_name = "l1", uniq_name = "_QFEl1"}
10+
%5 = fircg.ext_declare %4 {uniq_name = "_QFEl1"} : (!fir.ref<!fir.logical<1>>) -> !fir.ref<!fir.logical<1>> loc(#loc3)
11+
%6 = fir.alloca !fir.logical<4> {bindc_name = "l4", uniq_name = "_QFEl4"}
12+
%7 = fircg.ext_declare %6 {uniq_name = "_QFEl4"} : (!fir.ref<!fir.logical<4>>) -> !fir.ref<!fir.logical<4>> loc(#loc4)
13+
%8 = fir.alloca f32 {bindc_name = "r4", uniq_name = "_QFEr4"}
14+
%9 = fircg.ext_declare %8 {uniq_name = "_QFEr4"} : (!fir.ref<f32>) -> !fir.ref<f32> loc(#loc5)
15+
%10 = fir.alloca f64 {bindc_name = "r8", uniq_name = "_QFEr8"}
16+
%11 = fircg.ext_declare %10 {uniq_name = "_QFEr8"} : (!fir.ref<f64>) -> !fir.ref<f64> loc(#loc6)
17+
%12 = fir.call @_QFPfn1(%1, %11, %5) fastmath<contract> : (!fir.ref<i32>, !fir.ref<f64>, !fir.ref<!fir.logical<1>>) -> i64
18+
fir.store %12 to %3 : !fir.ref<i64>
19+
%13 = fir.call @_QFPfn2(%3, %9, %7) fastmath<contract> : (!fir.ref<i64>, !fir.ref<f32>, !fir.ref<!fir.logical<4>>) -> i32
20+
fir.store %13 to %1 : !fir.ref<i32>
21+
return
22+
} loc(#loc7)
23+
func.func private @_QFPfn1(%arg0: !fir.ref<i32> {fir.bindc_name = "a1"}, %arg1: !fir.ref<f64> {fir.bindc_name = "b1"}, %arg2: !fir.ref<!fir.logical<1>> {fir.bindc_name = "c1"}) -> i64 attributes {fir.host_symbol = @_QQmain, llvm.linkage = #llvm.linkage<internal>} {
24+
%0 = fir.undefined !fir.dscope loc(#loc11)
25+
%1 = fircg.ext_declare %arg0 dummy_scope %0 {uniq_name = "_QFFfn1Ea1"} : (!fir.ref<i32>, !fir.dscope) -> !fir.ref<i32> loc(#loc8)
26+
%2 = fircg.ext_declare %arg1 dummy_scope %0 {uniq_name = "_QFFfn1Eb1"} : (!fir.ref<f64>, !fir.dscope) -> !fir.ref<f64> loc(#loc9)
27+
%3 = fircg.ext_declare %arg2 dummy_scope %0 {uniq_name = "_QFFfn1Ec1"} : (!fir.ref<!fir.logical<1>>, !fir.dscope) -> !fir.ref<!fir.logical<1>> loc(#loc10)
28+
%4 = fir.alloca i64 {bindc_name = "res1", uniq_name = "_QFFfn1Eres1"} loc(#loc15)
29+
%5 = fircg.ext_declare %4 {uniq_name = "_QFFfn1Eres1"} : (!fir.ref<i64>) -> !fir.ref<i64> loc(#loc11)
30+
%6 = fir.load %1 : !fir.ref<i32>
31+
%7 = fir.convert %6 : (i32) -> f64
32+
%8 = fir.load %2 : !fir.ref<f64>
33+
%9 = arith.addf %7, %8 fastmath<contract> : f64
34+
%10 = fir.convert %9 : (f64) -> i64
35+
fir.store %10 to %5 : !fir.ref<i64>
36+
%11 = fir.load %5 : !fir.ref<i64>
37+
return %11 : i64
38+
} loc(#loc12)
39+
func.func private @_QFPfn2(%arg0: !fir.ref<i64> {fir.bindc_name = "a2"}, %arg1: !fir.ref<f32> {fir.bindc_name = "b2"}, %arg2: !fir.ref<!fir.logical<4>> {fir.bindc_name = "c2"}) -> i32 attributes {fir.host_symbol = @_QQmain, llvm.linkage = #llvm.linkage<internal>} {
40+
%0 = fir.undefined !fir.dscope
41+
%1 = fircg.ext_declare %arg0 dummy_scope %0 {uniq_name = "_QFFfn2Ea2"} : (!fir.ref<i64>, !fir.dscope) -> !fir.ref<i64> loc(#loc13)
42+
%2 = fircg.ext_declare %arg1 dummy_scope %0 {uniq_name = "_QFFfn2Eb2"} : (!fir.ref<f32>, !fir.dscope) -> !fir.ref<f32> loc(#loc14)
43+
%3 = fircg.ext_declare %arg2 dummy_scope %0 {uniq_name = "_QFFfn2Ec2"} : (!fir.ref<!fir.logical<4>>, !fir.dscope) -> !fir.ref<!fir.logical<4>> loc(#loc15)
44+
%4 = fir.alloca i32 {bindc_name = "res2", uniq_name = "_QFFfn2Eres2"}
45+
%5 = fircg.ext_declare %4 {uniq_name = "_QFFfn2Eres2"} : (!fir.ref<i32>) -> !fir.ref<i32> loc(#loc16)
46+
%6 = fir.load %1 : !fir.ref<i64>
47+
%7 = fir.convert %6 : (i64) -> f32
48+
%8 = fir.load %2 : !fir.ref<f32>
49+
%9 = arith.addf %7, %8 fastmath<contract> : f32
50+
%10 = fir.convert %9 : (f32) -> i32
51+
fir.store %10 to %5 : !fir.ref<i32>
52+
%11 = fir.load %5 : !fir.ref<i32>
53+
return %11 : i32
54+
} loc(#loc17)
55+
}
56+
#loc7 = loc("test.f90":4:19)
57+
#loc1 = loc("test.f90":5:1)
58+
#loc2 = loc("test.f90":6:22)
59+
#loc3 = loc("test.f90":7:22)
60+
#loc4 = loc("test.f90":8:22)
61+
#loc5 = loc("test.f90":9:22)
62+
#loc6 = loc("test.f90":10:19)
63+
#loc12 = loc("test.f90":12:36)
64+
#loc8 = loc("test.f90":13:3)
65+
#loc9 = loc("test.f90":14:3)
66+
#loc10 = loc("test.f90":15:1)
67+
#loc11 = loc("test.f90":16:1)
68+
#loc17 = loc("test.f90":18:33)
69+
#loc13 = loc("test.f90":19:33)
70+
#loc14 = loc("test.f90":20:36)
71+
#loc15 = loc("test.f90":21:24)
72+
#loc16 = loc("test.f90":22:5)
73+
74+
// CHECK-DAG: #[[INT8:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 64, encoding = DW_ATE_signed>
75+
// CHECK-DAG: #[[INT4:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "integer", sizeInBits = 32, encoding = DW_ATE_signed>
76+
// CHECK-DAG: #[[REAL8:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "real", sizeInBits = 64, encoding = DW_ATE_float>
77+
// CHECK-DAG: #[[LOG1:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "logical", sizeInBits = 8, encoding = DW_ATE_boolean>
78+
// CHECK-DAG: #[[REAL4:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "real", sizeInBits = 32, encoding = DW_ATE_float>
79+
// CHECK-DAG: #[[LOG4:.*]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "logical", sizeInBits = 32, encoding = DW_ATE_boolean>
80+
// CHECK-DAG: #[[MAIN:.*]] = #llvm.di_subprogram<{{.*}}name = "_QQmain"{{.*}}>
81+
// CHECK-DAG: #[[FN1:.*]] = #llvm.di_subprogram<{{.*}}name = "fn1"{{.*}}>
82+
// CHECK-DAG: #[[FN2:.*]] = #llvm.di_subprogram<{{.*}}name = "fn2"{{.*}}>
83+
84+
// Line numbers should match the number in corresponding loc entry.
85+
// CHECK-DAG: #[[I4:.*]] = #llvm.di_local_variable<scope = #[[MAIN]], name = "i4", file = #{{.*}}, line = 5, type = #[[INT4]]>
86+
// CHECK-DAG: #[[I8:.*]] = #llvm.di_local_variable<scope = #[[MAIN]], name = "i8", file = #{{.*}}, line = 6, type = #[[INT8]]>
87+
// CHECK-DAG: #[[R4:.*]] = #llvm.di_local_variable<scope = #[[MAIN]], name = "r4", file = #{{.*}}, line = 9, type = #[[REAL4]]>
88+
// CHECK-DAG: #[[R8:.*]] = #llvm.di_local_variable<scope = #[[MAIN]], name = "r8", file = #{{.*}}, line = 10, type = #[[REAL8]]>
89+
// CHECK-DAG: #[[L1:.*]] = #llvm.di_local_variable<scope = #[[MAIN]], name = "l1", file = #{{.*}}, line = 7, type = #[[LOG1]]>
90+
// CHECK-DAG: #[[L4:.*]] = #llvm.di_local_variable<scope = #[[MAIN]], name = "l4", file = #{{.*}}, line = 8, type = #[[LOG4]]>
91+
92+
// CHECK-DAG: #[[A1:.*]] = #llvm.di_local_variable<scope = #[[FN1]], name = "a1", file = #{{.*}}, line = 13, arg = 1, type = #[[INT4]]>
93+
// CHECK-DAG: #[[B1:.*]] = #llvm.di_local_variable<scope = #[[FN1]], name = "b1", file = #{{.*}}, line = 14, arg = 2, type = #[[REAL8]]>
94+
// CHECK-DAG: #[[C1:.*]] = #llvm.di_local_variable<scope = #[[FN1]], name = "c1", file = #{{.*}}, line = 15, arg = 3, type = #[[LOG1]]>
95+
// CHECK-DAG: #[[RES1:.*]] = #llvm.di_local_variable<scope = #[[FN1]], name = "res1", file = #{{.*}}, line = 16, type = #[[INT8]]>
96+
97+
// CHECK-DAG: #[[A2:.*]] = #llvm.di_local_variable<scope = #[[FN2]], name = "a2", file = #{{.*}}, line = 19, arg = 1, type = #[[INT8]]>
98+
// CHECK-DAG: #[[B2:.*]] = #llvm.di_local_variable<scope = #[[FN2]], name = "b2", file = #{{.*}}, line = 20, arg = 2, type = #[[REAL4]]>
99+
// CHECK-DAG: #[[C2:.*]] = #llvm.di_local_variable<scope = #[[FN2]], name = "c2", file = #{{.*}}, line = 21, arg = 3, type = #[[LOG4]]>
100+
// CHECK-DAG: #[[RES2:.*]] = #llvm.di_local_variable<scope = #[[FN2]], name = "res2", file = #{{.*}}, line = 22, type = #[[INT4]]>

0 commit comments

Comments
 (0)