xref: /llvm-project/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/odr-member-functions.cpp (revision f1fdfe6888f93b9f6dfb4689e1f3206de584ff5b)
1 /* Compile with:
2    for FILE in `seq 3`; do
3      clang -g -c  odr-member-functions.cpp -DFILE$FILE -o
4    odr-member-functions/$FILE.o done
5  */
6 
7 // RUN: dsymutil --linker=parallel -f \
8 // RUN: -oso-prepend-path=%p/../../Inputs/odr-member-functions \
9 // RUN: -y %p/../dummy-debug-map.map -o %t1.out
10 // RUN: llvm-dwarfdump -debug-info %t1.out | FileCheck %s
11 
12 struct S {
fooS13   __attribute__((always_inline)) void foo() { bar(); }
fooS14   __attribute__((always_inline)) void foo(int i) {
15     if (i)
16       bar();
17   }
18   void bar();
19 
bazS20   template <typename T> void baz(T t) {}
21 };
22 
23 #ifdef FILE1
foo()24 void foo() { S s; }
25 
26 // First chack that types are moved into the type table unit.
27 
28 // CHECK: TAG_compile_unit
29 // CHECK: AT_name{{.*}}"__artificial_type_unit"
30 
31 // CHECK: 0x[[INT_BASE:[0-9a-f]*]]: DW_TAG_base_type
32 // CHECK-NEXT: DW_AT_name{{.*}}"int"
33 
34 // CHECK: 0x[[PTR_S:[0-9a-f]*]]:{{.*}}DW_TAG_pointer_type
35 // CHECK-NEXT: DW_AT_type{{.*}}0x[[STRUCT_S:[0-9a-f]*]] "S")
36 
37 // CHECK: 0x[[STRUCT_S]]:{{.*}}DW_TAG_structure_type
38 // CHECK-NEXT: DW_AT_name{{.*}}"S"
39 
40 // CHECK: DW_TAG_subprogram
41 // CHECK: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3barEv"
42 // CHECK: DW_AT_name{{.*}}"bar"
43 
44 // CHECK: DW_TAG_formal_parameter
45 // CHECK-NEXT: DW_AT_type{{.*}}0x[[PTR_S]] "S *"
46 
47 // CHECK: 0x[[BAZ_SUBPROGRAM:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
48 // CHECK: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3bazIiEEvT_"
49 // CHECK: DW_AT_name{{.*}}"baz<int>"
50 
51 // CHECK: DW_TAG_formal_parameter
52 // CHECK-NEXT: DW_AT_type{{.*}}0x[[PTR_S]] "S *"
53 
54 // CHECK: DW_TAG_formal_parameter
55 // CHECK-NEXT: DW_AT_type{{.*}}0x[[INT_BASE]] "int"
56 
57 // CHECK: DW_TAG_template_type_parameter
58 // CHECK-NEXT: DW_AT_type{{.*}}0x[[INT_BASE]] "int"
59 // CHECK-NEXT: DW_AT_name{{.*}}"T"
60 
61 // CHECK: 0x[[FOO_Ei:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
62 // CHECK: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3fooEi"
63 // CHECK: DW_AT_name{{.*}}"foo"
64 
65 // CHECK: DW_TAG_formal_parameter
66 // CHECK-NEXT: DW_AT_type{{.*}}0x[[PTR_S]] "S *"
67 
68 // CHECK: DW_TAG_formal_parameter
69 // CHECK-NEXT: DW_AT_type{{.*}}0x[[INT_BASE]] "int"
70 
71 // CHECK: 0x[[FOO_Ev:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
72 // CHECK: DW_AT_MIPS_linkage_name{{.*}}"_ZN1S3fooEv"
73 // CHECK: DW_AT_name{{.*}}"foo"
74 
75 // CHECK: DW_TAG_formal_parameter
76 // CHECK-NEXT: DW_AT_type{{.*}}0x[[PTR_S]] "S *"
77 
78 // For the second unit check that it references structure "S"
79 
80 // CHECK: TAG_compile_unit
81 // CHECK-NOT: {{DW_TAG|NULL}}
82 // CHECK: AT_name{{.*}}"odr-member-functions.cpp"
83 
84 // CHECK: DW_TAG_subprogram
85 // CHECK: DW_AT_MIPS_linkage_name{{.*}}"_Z3foov"
86 // CHECK-NEXT: AT_name{{.*}}"foo"
87 
88 // CHECK: DW_TAG_variable
89 // CHECK: DW_AT_name{{.*}}"s"
90 // CHECK: DW_AT_type{{.*}}(0x00000000[[STRUCT_S]] "S"
91 
92 #elif defined(FILE2)
foo()93 void foo() {
94   S s;
95   // Check that the overloaded member functions are resolved correctly
96   s.foo();
97   s.foo(1);
98 }
99 
100 // For the third unit check that it references member functions of structure S.
101 // CHECK: TAG_compile_unit
102 // CHECK-NOT: DW_TAG
103 // CHECK: AT_name{{.*}}"odr-member-functions.cpp"
104 
105 // CHECK: 0x[[ABASE_FOO_Ev:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
106 // CHECK-NEXT: DW_AT_specification {{.*}}(0x00000000[[FOO_Ev]] "_ZN1S3fooEv"
107 // CHECK-NEXT: DW_AT_inline    (DW_INL_inlined)
108 // CHECK-NEXT: DW_AT_object_pointer {{.*}}(0x[[ABASE_FOO_Ev_PARAM1:[0-9a-f]*]]
109 
110 // CHECK: 0x[[ABASE_FOO_Ev_PARAM1]]:{{.*}}DW_TAG_formal_parameter
111 // CHECK-NEXT: DW_AT_name{{.*}}"this"
112 // CHECK-NEXT: DW_AT_type{{.*}}(0x00000000[[PTR_S]] "S *"
113 
114 // CHECK: 0x[[ABASE_FOO_Ei:[0-9a-f]*]]:{{.*}}DW_TAG_subprogram
115 // CHECK-NEXT: DW_AT_specification {{.*}}(0x00000000[[FOO_Ei]] "_ZN1S3fooEi"
116 // CHECK-NEXT: DW_AT_inline    (DW_INL_inlined)
117 // CHECK-NEXT: DW_AT_object_pointer {{.*}}(0x[[ABASE_FOO_Ei_PARAM1:[0-9a-f]*]]
118 
119 // CHECK: 0x[[ABASE_FOO_Ei_PARAM1]]:{{.*}}DW_TAG_formal_parameter
120 // CHECK-NEXT: DW_AT_name{{.*}}"this"
121 // CHECK-NEXT: DW_AT_type{{.*}}(0x00000000[[PTR_S]] "S *"
122 
123 // CHECK: 0x[[ABASE_FOO_Ei_PARAM2:[0-9a-f]*]]:{{.*}}DW_TAG_formal_parameter
124 // CHECK-NEXT: DW_AT_name{{.*}}"i"
125 // CHECK: DW_AT_type    (0x00000000[[INT_BASE]] "int"
126 
127 // CHECK: DW_TAG_subprogram
128 // CHECK: DW_AT_MIPS_linkage_name{{.*}}"_Z3foov"
129 // CHECK: DW_AT_name{{.*}}"foo"
130 
131 // CHECK: DW_TAG_variable
132 // CHECK: DW_AT_name{{.*}}"s"
133 // CHECK: DW_AT_type{{.*}}(0x00000000[[STRUCT_S]] "S"
134 
135 // CHECK: DW_TAG_inlined_subroutine
136 // CHECK: DW_AT_abstract_origin{{.*}}(0x[[ABASE_FOO_Ev]] "_ZN1S3fooEv"
137 // CHECK: DW_AT_low_pc
138 // CHECK: DW_AT_high_pc
139 
140 // CHECK: DW_TAG_formal_parameter
141 // CHECK: DW_AT_abstract_origin{{.*}}(0x[[ABASE_FOO_Ev_PARAM1]] "this"
142 
143 // CHECK: DW_TAG_inlined_subroutine
144 // CHECK: DW_AT_abstract_origin{{.*}}(0x[[ABASE_FOO_Ei]] "_ZN1S3fooEi"
145 // CHECK: DW_AT_low_pc
146 // CHECK: DW_AT_high_pc
147 
148 // CHECK: DW_TAG_formal_parameter
149 // CHECK: DW_AT_abstract_origin{{.*}}(0x[[ABASE_FOO_Ei_PARAM1]] "this"
150 
151 // CHECK: DW_TAG_formal_parameter
152 // CHECK: DW_AT_abstract_origin{{.*}}(0x[[ABASE_FOO_Ei_PARAM2]] "i"
153 
154 #elif defined(FILE3)
foo()155 void foo() {
156   S s;
157   s.baz<int>(42);
158 }
159 
160 // For the fourth unit check that it references member functions of structure S.
161 
162 // CHECK: TAG_compile_unit
163 // CHECK-NOT: DW_TAG
164 // CHECK: AT_name{{.*}}"odr-member-functions.cpp"
165 
166 // CHECK: DW_TAG_subprogram
167 // CHECK: DW_AT_MIPS_linkage_name{{.*}}"_Z3foov"
168 // CHECK: DW_AT_name{{.*}}"foo"
169 
170 // CHECK: DW_TAG_variable
171 // CHECK: DW_AT_name{{.*}}"s"
172 // CHECK: DW_AT_type{{.*}}(0x00000000[[STRUCT_S]] "S"
173 
174 // CHECK: DW_TAG_subprogram
175 // CHECK: DW_AT_object_pointer{{.*}}(0x[[INST_PARAM2:[0-9a-f]*]]
176 // CHECK: DW_AT_specification{{.*}}(0x00000000[[BAZ_SUBPROGRAM]] "_ZN1S3bazIiEEvT_"
177 
178 // CHECK: 0x[[INST_PARAM2]]:{{.*}}DW_TAG_formal_parameter
179 // CHECK: DW_AT_name{{.*}}"this"
180 // CHECK: DW_AT_type{{.*}}(0x00000000[[PTR_S]] "S *"
181 
182 // CHECK: DW_TAG_formal_parameter
183 // CHECK: DW_AT_name{{.*}}"t"
184 // CHECK: DW_AT_type{{.*}}(0x00000000[[INT_BASE]] "int"
185 
186 // CHECK: DW_TAG_template_type_parameter
187 // CHECK: DW_AT_type{{.*}}(0x00000000[[INT_BASE]] "int"
188 // CHECK: DW_AT_name{{.*}}"T"
189 
190 #else
191 #error "You must define which file you generate"
192 #endif
193