1 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
2 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS
3 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
4 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
5 // RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3
7 typedef __INTPTR_TYPE__
intptr_t;
15 #pragma clang __debug captured
17 static float inner
= 3.0;
21 // CHECK-1: %struct.anon = type { ptr }
22 // CHECK-1: {{.+}} global float 3.0
25 // CHECK-1: alloca %struct.anon
26 // CHECK-1: getelementptr inbounds %struct.anon, ptr
27 // CHECK-1: store ptr %i
28 // CHECK-1: call void @[[HelperName:__captured_stmt[\.0-9]+]]
31 // CHECK-1: define internal {{.*}}void @[[HelperName]](ptr
32 // CHECK-1: getelementptr inbounds %struct.anon{{.*}}, i32 0, i32 0
33 // CHECK-1: load ptr, ptr
34 // CHECK-1: load i32, ptr
35 // CHECK-1: add nsw i32
38 // Compound statement with local variable
40 #pragma clang __debug captured
43 for (i
= 0; i
< x
; i
++)
48 // CHECK-2: call void @[[HelperName:__captured_stmt[\.0-9]+]]
51 // CHECK-2: define internal {{.*}}void @[[HelperName]]
53 // CHECK-2: %i = alloca i32
56 void test3(int size
) {
57 int arr
[] = {1, 2, 3, 4, 5};
59 #pragma clang __debug captured
61 arr
[2] = vla_arr
[size
- 1];
64 // CHECK-3: alloca [5 x i32]
65 // CHECK-3: call void @__captured_stmt
69 void test4(intptr_t size
, intptr_t vla_arr
[size
]) {
70 #pragma clang __debug captured
74 // CHECK-3: test4([[INTPTR_T:i.+]] noundef {{.*}}[[SIZE_ARG:%.+]], ptr
75 // CHECK-3: store [[INTPTR_T]] {{.*}}[[SIZE_ARG]], ptr [[SIZE_ADDR:%.+]],
76 // CHECK-3: [[SIZE:%.+]] = load [[INTPTR_T]], ptr [[SIZE_ADDR]],
77 // CHECK-3: [[REF:%.+]] = getelementptr inbounds
78 // CHECK-3: store [[INTPTR_T]] [[SIZE]], ptr [[REF]]
79 // CHECK-3: call void @__captured_stmt
82 void dont_capture_global(void) {
85 #pragma clang __debug captured
92 // CHECK-GLOBALS: %[[Capture:struct\.anon[\.0-9]*]] = type {}
93 // CHECK-GLOBALS: call void @__captured_stmt[[HelperName:\.4]](
96 // CHECK-GLOBALS: define internal {{.*}}void @__captured_stmt[[HelperName]]
97 // CHECK-GLOBALS-NOT: ret
98 // CHECK-GLOBALS: load i32, ptr @global
99 // CHECK-GLOBALS: load i32, ptr @
100 // CHECK-GLOBALS: load i32, ptr @e
102 // CHECK-GLOBALS-NOT: DIFlagObjectPointer
103 // CHECK-1-NOT: DIFlagObjectPointer
104 // CHECK-2-NOT: DIFlagObjectPointer
105 // CHECK-3-NOT: DIFlagObjectPointer