Dehao Chen | e239e95 | 2016-10-07 15:21:29 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -w -debug-info-kind=line-tables-only -std=c++11 -fexceptions -fcxx-exceptions -S -mllvm -no-discriminators -emit-llvm %s -o - -triple %itanium_abi_triple | FileCheck %s |
| 2 | // RUN: %clang_cc1 -w -debug-info-kind=line-tables-only -std=c++11 -fexceptions -fcxx-exceptions -S -mllvm -no-discriminators -emit-llvm %s -o - -triple i686-linux-gnu | FileCheck %s |
David Blaikie | 66e4197 | 2015-01-14 07:38:27 +0000 | [diff] [blame] | 3 | |
David Blaikie | 538deff | 2014-12-09 20:52:24 +0000 | [diff] [blame] | 4 | int &src(); |
David Blaikie | 8ec8dfe | 2014-12-09 21:10:43 +0000 | [diff] [blame] | 5 | int *sink(); |
Reid Kleckner | 60e54da | 2014-12-10 00:47:33 +0000 | [diff] [blame] | 6 | extern "C" __complex float complex_src(); |
| 7 | extern "C" __complex float *complex_sink(); |
David Blaikie | 0b7fad6 | 2014-12-08 21:48:57 +0000 | [diff] [blame] | 8 | |
David Blaikie | 8ec8dfe | 2014-12-09 21:10:43 +0000 | [diff] [blame] | 9 | // CHECK-LABEL: define |
David Blaikie | 0b7fad6 | 2014-12-08 21:48:57 +0000 | [diff] [blame] | 10 | void f1() { |
David Blaikie | 9b47966 | 2015-01-25 01:19:10 +0000 | [diff] [blame] | 11 | *sink() |
David Blaikie | 73ca569 | 2014-12-09 00:32:22 +0000 | [diff] [blame] | 12 | // CHECK: store {{.*}}, !dbg [[DBG_F1:!.*]] |
David Blaikie | 9b47966 | 2015-01-25 01:19:10 +0000 | [diff] [blame] | 13 | #line 100 |
| 14 | = // |
| 15 | src(); |
David Blaikie | 0b7fad6 | 2014-12-08 21:48:57 +0000 | [diff] [blame] | 16 | } |
| 17 | |
David Blaikie | 73ca569 | 2014-12-09 00:32:22 +0000 | [diff] [blame] | 18 | struct foo { |
| 19 | int i; |
| 20 | int &j; |
David Blaikie | 538deff | 2014-12-09 20:52:24 +0000 | [diff] [blame] | 21 | __complex float k; |
David Blaikie | 73ca569 | 2014-12-09 00:32:22 +0000 | [diff] [blame] | 22 | foo(); |
| 23 | }; |
| 24 | |
David Blaikie | 8ec8dfe | 2014-12-09 21:10:43 +0000 | [diff] [blame] | 25 | // CHECK-LABEL: define |
David Blaikie | 73ca569 | 2014-12-09 00:32:22 +0000 | [diff] [blame] | 26 | foo::foo() |
David Blaikie | 8ec8dfe | 2014-12-09 21:10:43 +0000 | [diff] [blame] | 27 | : |
David Blaikie | 73ca569 | 2014-12-09 00:32:22 +0000 | [diff] [blame] | 28 | #line 200 |
David Blaikie | 8ec8dfe | 2014-12-09 21:10:43 +0000 | [diff] [blame] | 29 | i // CHECK: store i32 {{.*}} !dbg [[DBG_FOO_VALUE:!.*]] |
| 30 | (src()), |
| 31 | j // CHECK: store i32* {{.*}} !dbg [[DBG_FOO_REF:!.*]] |
| 32 | (src()), |
| 33 | k // CHECK: store float {{.*}} !dbg [[DBG_FOO_COMPLEX:!.*]] |
| 34 | (complex_src()) { |
| 35 | } |
| 36 | |
Reid Kleckner | 60e54da | 2014-12-10 00:47:33 +0000 | [diff] [blame] | 37 | // CHECK-LABEL: define {{.*}}f2{{.*}} |
David Blaikie | 8ec8dfe | 2014-12-09 21:10:43 +0000 | [diff] [blame] | 38 | void f2() { |
David Blaikie | 9b47966 | 2015-01-25 01:19:10 +0000 | [diff] [blame] | 39 | // CHECK: store float {{.*}} !dbg [[DBG_F2:!.*]] |
| 40 | *complex_sink() |
David Blaikie | 8ec8dfe | 2014-12-09 21:10:43 +0000 | [diff] [blame] | 41 | #line 300 |
David Blaikie | 9b47966 | 2015-01-25 01:19:10 +0000 | [diff] [blame] | 42 | = // |
| 43 | complex_src(); |
David Blaikie | 73ca569 | 2014-12-09 00:32:22 +0000 | [diff] [blame] | 44 | } |
| 45 | |
David Blaikie | 93e9cf8 | 2014-12-09 21:32:00 +0000 | [diff] [blame] | 46 | // CHECK-LABEL: define |
| 47 | void f3() { |
David Blaikie | 9b47966 | 2015-01-25 01:19:10 +0000 | [diff] [blame] | 48 | // CHECK: store float {{.*}} !dbg [[DBG_F3:!.*]] |
| 49 | *complex_sink() |
David Blaikie | 93e9cf8 | 2014-12-09 21:32:00 +0000 | [diff] [blame] | 50 | #line 400 |
David Blaikie | 9b47966 | 2015-01-25 01:19:10 +0000 | [diff] [blame] | 51 | += // |
| 52 | complex_src(); |
David Blaikie | 93e9cf8 | 2014-12-09 21:32:00 +0000 | [diff] [blame] | 53 | } |
| 54 | |
David Blaikie | 7f13881 | 2014-12-09 22:04:13 +0000 | [diff] [blame] | 55 | // CHECK-LABEL: define |
| 56 | void f4() { |
| 57 | #line 500 |
| 58 | auto x // CHECK: store {{.*}} !dbg [[DBG_F4:!.*]] |
| 59 | = src(); |
| 60 | } |
| 61 | |
David Blaikie | 00de22f | 2014-12-09 22:15:02 +0000 | [diff] [blame] | 62 | // CHECK-LABEL: define |
| 63 | void f5() { |
| 64 | #line 600 |
| 65 | auto x // CHECK: store float {{.*}} !dbg [[DBG_F5:!.*]] |
| 66 | = complex_src(); |
| 67 | } |
| 68 | |
David Blaikie | d73f3c6 | 2014-12-09 23:33:26 +0000 | [diff] [blame] | 69 | struct agg { int i; }; |
| 70 | agg agg_src(); |
| 71 | |
| 72 | // CHECK-LABEL: define |
| 73 | void f6() { |
| 74 | agg x; |
David Blaikie | 9f7ae2c | 2015-01-25 01:25:37 +0000 | [diff] [blame] | 75 | // CHECK: call void @llvm.memcpy{{.*}} !dbg [[DBG_F6:!.*]] |
| 76 | x |
David Blaikie | d73f3c6 | 2014-12-09 23:33:26 +0000 | [diff] [blame] | 77 | #line 700 |
David Blaikie | 9f7ae2c | 2015-01-25 01:25:37 +0000 | [diff] [blame] | 78 | = // |
| 79 | agg_src(); |
David Blaikie | d73f3c6 | 2014-12-09 23:33:26 +0000 | [diff] [blame] | 80 | } |
| 81 | |
David Blaikie | f0aceb2 | 2014-12-10 01:03:48 +0000 | [diff] [blame] | 82 | // CHECK-LABEL: define |
| 83 | void f7() { |
| 84 | int *src1(); |
| 85 | int src2(); |
| 86 | #line 800 |
| 87 | int x = ( // CHECK: load {{.*}} !dbg [[DBG_F7:!.*]] |
| 88 | src1())[src2()]; |
| 89 | } |
| 90 | |
David Blaikie | d85548d | 2014-12-10 01:16:09 +0000 | [diff] [blame] | 91 | // CHECK-LABEL: define |
| 92 | void f8() { |
| 93 | int src1[1]; |
| 94 | int src2(); |
| 95 | #line 900 |
| 96 | int x = ( // CHECK: load {{.*}} !dbg [[DBG_F8:!.*]] |
| 97 | src1)[src2()]; |
| 98 | } |
| 99 | |
David Blaikie | 7c5da41 | 2014-12-10 01:34:25 +0000 | [diff] [blame] | 100 | // CHECK-LABEL: define |
| 101 | void f9(int i) { |
| 102 | int src1[1][i]; |
| 103 | int src2(); |
| 104 | #line 1000 |
| 105 | auto x = ( // CHECK: getelementptr {{.*}} !dbg [[DBG_F9:!.*]] |
| 106 | src1)[src2()]; |
| 107 | } |
| 108 | |
David Blaikie | 09f12fa | 2014-12-14 18:48:18 +0000 | [diff] [blame] | 109 | inline void *operator new(decltype(sizeof(1)), void *p) noexcept { return p; } |
David Blaikie | a2c1124 | 2014-12-10 19:04:09 +0000 | [diff] [blame] | 110 | |
| 111 | // CHECK-LABEL: define |
| 112 | void f10() { |
| 113 | void *void_src(); |
Richard Smith | 902a023 | 2015-02-14 01:52:20 +0000 | [diff] [blame] | 114 | ( |
David Blaikie | 09f12fa | 2014-12-14 18:48:18 +0000 | [diff] [blame] | 115 | // CHECK: store {{.*}} !dbg [[DBG_F10_STORE:!.*]] |
David Blaikie | a2c1124 | 2014-12-10 19:04:09 +0000 | [diff] [blame] | 116 | #line 1100 |
| 117 | new (void_src()) int(src())); |
| 118 | } |
| 119 | |
David Blaikie | 47d28e0 | 2015-01-14 07:10:46 +0000 | [diff] [blame] | 120 | // noexcept just to simplify the codegen a bit |
| 121 | void fn() noexcept(true); |
| 122 | |
| 123 | struct bar { |
| 124 | bar(); |
| 125 | // noexcept(false) to convolute the global dtor |
| 126 | ~bar() noexcept(false); |
| 127 | }; |
| 128 | // global ctor cleanup |
| 129 | // CHECK-LABEL: define |
| 130 | // CHECK: invoke{{ }} |
| 131 | // CHECK: invoke{{ }} |
| 132 | // CHECK: to label {{.*}}, !dbg [[DBG_GLBL_CTOR_B:!.*]] |
David Blaikie | 66e4197 | 2015-01-14 07:38:27 +0000 | [diff] [blame] | 133 | |
| 134 | // terminate caller |
| 135 | // CHECK-LABEL: define |
| 136 | |
David Blaikie | 47d28e0 | 2015-01-14 07:10:46 +0000 | [diff] [blame] | 137 | // global dtor cleanup |
| 138 | // CHECK-LABEL: define |
| 139 | // CHECK: invoke{{ }} |
| 140 | // CHECK: invoke{{ }} |
| 141 | // CHECK: to label {{.*}}, !dbg [[DBG_GLBL_DTOR_B:!.*]] |
David Blaikie | 71fb83e | 2015-01-16 22:55:09 +0000 | [diff] [blame] | 142 | #line 1200 |
David Blaikie | 47d28e0 | 2015-01-14 07:10:46 +0000 | [diff] [blame] | 143 | bar b[1] = { // |
| 144 | (fn(), // |
| 145 | bar())}; |
| 146 | |
David Blaikie | 66e4197 | 2015-01-14 07:38:27 +0000 | [diff] [blame] | 147 | // CHECK-LABEL: define |
| 148 | __complex double f11() { |
| 149 | __complex double f; |
| 150 | // CHECK: store {{.*}} !dbg [[DBG_F11:!.*]] |
David Blaikie | 71fb83e | 2015-01-16 22:55:09 +0000 | [diff] [blame] | 151 | #line 1300 |
David Blaikie | 66e4197 | 2015-01-14 07:38:27 +0000 | [diff] [blame] | 152 | return f; |
| 153 | } |
| 154 | |
| 155 | // CHECK-LABEL: define |
| 156 | void f12() { |
| 157 | int f12_1(); |
| 158 | void f12_2(int = f12_1()); |
David Blaikie | ea3e51d | 2015-06-29 17:29:50 +0000 | [diff] [blame] | 159 | // CHECK: call {{.*}}{{(signext )?}}i32 {{.*}} !dbg [[DBG_F12:!.*]] |
David Blaikie | 71fb83e | 2015-01-16 22:55:09 +0000 | [diff] [blame] | 160 | #line 1400 |
David Blaikie | 66e4197 | 2015-01-14 07:38:27 +0000 | [diff] [blame] | 161 | f12_2(); |
| 162 | } |
| 163 | |
| 164 | // CHECK-LABEL: define |
| 165 | void f13() { |
| 166 | // CHECK: call {{.*}} !dbg [[DBG_F13:!.*]] |
| 167 | #define F13_IMPL 1, src() |
| 168 | 1, |
David Blaikie | 71fb83e | 2015-01-16 22:55:09 +0000 | [diff] [blame] | 169 | #line 1500 |
David Blaikie | 66e4197 | 2015-01-14 07:38:27 +0000 | [diff] [blame] | 170 | F13_IMPL; |
| 171 | } |
| 172 | |
David Blaikie | 01fb5fb | 2015-01-18 01:48:19 +0000 | [diff] [blame] | 173 | struct f14_impl { |
| 174 | f14_impl(int); |
David Blaikie | 71fb83e | 2015-01-16 22:55:09 +0000 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | // CHECK-LABEL: define |
David Blaikie | 1c39bbb | 2015-01-18 00:37:04 +0000 | [diff] [blame] | 178 | struct f14_use { |
David Blaikie | 01fb5fb | 2015-01-18 01:48:19 +0000 | [diff] [blame] | 179 | // CHECK: call {{.*}}f14_impl{{.*}}, !dbg [[DBG_F14_CTOR_CALL:![0-9]*]] |
David Blaikie | a81d410 | 2015-01-18 00:12:58 +0000 | [diff] [blame] | 180 | #line 1600 |
David Blaikie | 01fb5fb | 2015-01-18 01:48:19 +0000 | [diff] [blame] | 181 | f14_impl v{// |
| 182 | 1}; |
David Blaikie | 1c39bbb | 2015-01-18 00:37:04 +0000 | [diff] [blame] | 183 | f14_use(); |
| 184 | }; |
| 185 | |
| 186 | f14_use::f14_use() = default; |
David Blaikie | 71fb83e | 2015-01-16 22:55:09 +0000 | [diff] [blame] | 187 | |
| 188 | // CHECK-LABEL: define |
David Blaikie | c659307 | 2015-01-18 01:57:54 +0000 | [diff] [blame] | 189 | // CHECK-LABEL: define |
David Blaikie | 01fb5fb | 2015-01-18 01:48:19 +0000 | [diff] [blame] | 190 | void func(foo); |
| 191 | void f15(foo *f) { |
| 192 | func( |
| 193 | // CHECK: getelementptr {{.*}}, !dbg [[DBG_F15:![0-9]*]] |
| 194 | #line 1700 |
| 195 | f[3]); |
| 196 | } |
David Blaikie | 71fb83e | 2015-01-16 22:55:09 +0000 | [diff] [blame] | 197 | |
David Blaikie | c659307 | 2015-01-18 01:57:54 +0000 | [diff] [blame] | 198 | // CHECK-LABEL: define |
| 199 | void f16(__complex float f) { |
| 200 | __complex float g = // |
| 201 | // CHECK: add {{.*}}, !dbg [[DBG_F16:![0-9]*]] |
| 202 | #line 1800 |
| 203 | f + 1; |
| 204 | } |
| 205 | |
David Blaikie | 2d321fb | 2015-01-24 23:35:17 +0000 | [diff] [blame] | 206 | // CHECK-LABEL: define |
| 207 | void f17(int *x) { |
| 208 | 1, |
| 209 | // CHECK: getelementptr {{.*}}, !dbg [[DBG_F17:![0-9]*]] |
| 210 | #line 1900 |
| 211 | x[1]; |
| 212 | } |
| 213 | |
David Blaikie | 298720d | 2015-01-28 19:50:09 +0000 | [diff] [blame] | 214 | // CHECK-LABEL: define |
| 215 | void f18(int a, int b) { |
| 216 | // CHECK: icmp {{.*}}, !dbg [[DBG_F18_1:![0-9]*]] |
| 217 | // CHECK: br {{.*}}, !dbg [[DBG_F18_2:![0-9]*]] |
| 218 | #line 2000 |
| 219 | if (a // |
| 220 | && // |
| 221 | b) |
| 222 | ; |
| 223 | } |
| 224 | |
| 225 | // CHECK-LABEL: define |
| 226 | void f19(int a, int b) { |
| 227 | // CHECK: icmp {{.*}}, !dbg [[DBG_F19_1:![0-9]*]] |
| 228 | // CHECK: br {{.*}}, !dbg [[DBG_F19_2:![0-9]*]] |
| 229 | #line 2100 |
| 230 | if (a // |
| 231 | || // |
| 232 | b) |
| 233 | ; |
| 234 | } |
| 235 | |
| 236 | // CHECK-LABEL: define |
| 237 | void f20(int a, int b, int c) { |
| 238 | // CHECK: icmp {{.*}}, !dbg [[DBG_F20_1:![0-9]*]] |
| 239 | // FIXME: Conditional operator's exprloc should be the '?' not the start of the |
| 240 | // expression, then this would go in the right place. (but adding getExprLoc to |
| 241 | // the ConditionalOperator breaks the ARC migration tool - need to investigate |
| 242 | // further). |
| 243 | // CHECK: br {{.*}}, !dbg [[DBG_F20_1]] |
| 244 | #line 2200 |
| 245 | if (a // |
| 246 | ? // |
| 247 | b : c) |
| 248 | ; |
| 249 | } |
| 250 | |
David Blaikie | 14177b7 | 2015-02-03 22:37:17 +0000 | [diff] [blame] | 251 | // CHECK-LABEL: define |
| 252 | int f21_a(int = 0); |
| 253 | void f21_b(int = f21_a()); |
| 254 | void f21() { |
| 255 | // CHECK: call {{.*}}f21_b{{.*}}, !dbg [[DBG_F21:![0-9]*]] |
| 256 | #line 2300 |
| 257 | f21_b(); |
| 258 | } |
| 259 | |
David Blaikie | 4d52443 | 2015-02-04 19:47:54 +0000 | [diff] [blame] | 260 | // CHECK-LABEL: define |
| 261 | struct f22_dtor { |
| 262 | ~f22_dtor(); |
| 263 | }; |
| 264 | void f22() { |
| 265 | { |
| 266 | f22_dtor f; |
| 267 | src(); |
NAKAMURA Takumi | b1980e6 | 2015-02-05 01:02:34 +0000 | [diff] [blame] | 268 | // CHECK: invoke {{.*}}src |
David Blaikie | 4d52443 | 2015-02-04 19:47:54 +0000 | [diff] [blame] | 269 | // CHECK: call {{.*}}, !dbg [[DBG_F22:![0-9]*]] |
| 270 | // CHECK: call {{.*}}, !dbg [[DBG_F22]] |
| 271 | #line 2400 |
| 272 | } |
| 273 | } |
| 274 | |
David Blaikie | 2221aba | 2015-02-09 18:47:14 +0000 | [diff] [blame] | 275 | // CHECK-LABEL: define |
| 276 | struct f23_struct { |
| 277 | }; |
| 278 | f23_struct f23_a(); |
| 279 | void f23_b(f23_struct = f23_a()); |
| 280 | void f23() { |
| 281 | // CHECK: call {{.*}}f23_a{{.*}}, !dbg [[DBG_F23:![0-9]*]] |
| 282 | #line 2500 |
| 283 | f23_b(); |
| 284 | } |
| 285 | |
David Blaikie | 20937be | 2015-02-09 18:55:57 +0000 | [diff] [blame] | 286 | // CHECK-LABEL: define |
| 287 | void f24_a(__complex float = complex_src()); |
| 288 | void f24() { |
| 289 | // CHECK: call {{.*}}complex_src{{.*}}, !dbg [[DBG_F24:![0-9]*]] |
| 290 | #line 2600 |
| 291 | f24_a(); |
| 292 | } |
| 293 | |
Duncan P. N. Exon Smith | 9dd4e4e | 2015-04-29 16:40:08 +0000 | [diff] [blame] | 294 | // CHECK: [[DBG_F1]] = !DILocation(line: 100, |
| 295 | // CHECK: [[DBG_FOO_VALUE]] = !DILocation(line: 200, |
| 296 | // CHECK: [[DBG_FOO_REF]] = !DILocation(line: 202, |
| 297 | // CHECK: [[DBG_FOO_COMPLEX]] = !DILocation(line: 204, |
| 298 | // CHECK: [[DBG_F2]] = !DILocation(line: 300, |
| 299 | // CHECK: [[DBG_F3]] = !DILocation(line: 400, |
| 300 | // CHECK: [[DBG_F4]] = !DILocation(line: 500, |
| 301 | // CHECK: [[DBG_F5]] = !DILocation(line: 600, |
| 302 | // CHECK: [[DBG_F6]] = !DILocation(line: 700, |
| 303 | // CHECK: [[DBG_F7]] = !DILocation(line: 800, |
| 304 | // CHECK: [[DBG_F8]] = !DILocation(line: 900, |
| 305 | // CHECK: [[DBG_F9]] = !DILocation(line: 1000, |
| 306 | // CHECK: [[DBG_F10_STORE]] = !DILocation(line: 1100, |
| 307 | // CHECK: [[DBG_GLBL_CTOR_B]] = !DILocation(line: 1200, |
| 308 | // CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 1200, |
| 309 | // CHECK: [[DBG_F11]] = !DILocation(line: 1300, |
| 310 | // CHECK: [[DBG_F12]] = !DILocation(line: 1400, |
| 311 | // CHECK: [[DBG_F13]] = !DILocation(line: 1500, |
| 312 | // CHECK: [[DBG_F14_CTOR_CALL]] = !DILocation(line: 1600, |
| 313 | // CHECK: [[DBG_F15]] = !DILocation(line: 1700, |
| 314 | // CHECK: [[DBG_F16]] = !DILocation(line: 1800, |
| 315 | // CHECK: [[DBG_F17]] = !DILocation(line: 1900, |
| 316 | // CHECK: [[DBG_F18_1]] = !DILocation(line: 2000, |
| 317 | // CHECK: [[DBG_F18_2]] = !DILocation(line: 2001, |
| 318 | // CHECK: [[DBG_F19_1]] = !DILocation(line: 2100, |
| 319 | // CHECK: [[DBG_F19_2]] = !DILocation(line: 2101, |
| 320 | // CHECK: [[DBG_F20_1]] = !DILocation(line: 2200, |
| 321 | // CHECK: [[DBG_F23]] = !DILocation(line: 2500, |
| 322 | // CHECK: [[DBG_F24]] = !DILocation(line: 2600, |