1 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t
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
19 // CHECK-1: %struct.anon = type { i32* }
22 // CHECK-1: alloca %struct.anon
23 // CHECK-1: getelementptr inbounds %struct.anon*
24 // CHECK-1: store i32* %i
25 // CHECK-1: call void @[[HelperName:__captured_stmt[0-9]+]]
28 // CHECK-1: define internal void @[[HelperName]](%struct.anon
29 // CHECK-1: getelementptr inbounds %struct.anon{{.*}}, i32 0, i32 0
30 // CHECK-1: load i32**
32 // CHECK-1: add nsw i32
35 // Compound statement with local variable
37 #pragma clang __debug captured
40 for (i = 0; i < x; i++)
45 // CHECK-2: call void @[[HelperName:__captured_stmt[0-9]+]]
48 // CHECK-2: define internal void @[[HelperName]]
50 // CHECK-2: %i = alloca i32
53 void test3(int size) {
54 int arr[] = {1, 2, 3, 4, 5};
56 #pragma clang __debug captured
58 arr[2] = vla_arr[size - 1];
61 // CHECK-3: alloca [5 x i32]
62 // CHECK-3: call void @__captured_stmt
66 void test4(intptr_t size, intptr_t vla_arr[size]) {
67 #pragma clang __debug captured
71 // CHECK-3: test4([[INTPTR_T:i.+]] {{.*}}[[SIZE_ARG:%.+]], [[INTPTR_T]]*
72 // CHECK-3: store [[INTPTR_T]] {{.*}}[[SIZE_ARG]], [[INTPTR_T]]* [[SIZE_ADDR:%.+]],
73 // CHECK-3: [[SIZE:%.+]] = load [[INTPTR_T]]* [[SIZE_ADDR]],
74 // CHECK-3: [[REF:%.+]] = getelementptr inbounds
75 // CHECK-3: store [[INTPTR_T]] [[SIZE]], [[INTPTR_T]]* [[REF]]
76 // CHECK-3: call void @__captured_stmt
79 void dont_capture_global() {
82 #pragma clang __debug captured
89 // CHECK-GLOBALS: %[[Capture:struct\.anon[\.0-9]*]] = type {}
90 // CHECK-GLOBALS: call void @__captured_stmt[[HelperName:[0-9]+]](%[[Capture]]
93 // CHECK-GLOBALS: define internal void @__captured_stmt[[HelperName]]
94 // CHECK-GLOBALS-NOT: ret
95 // CHECK-GLOBALS: load i32* @global
96 // CHECK-GLOBALS: load i32* @
97 // CHECK-GLOBALS: load i32* @e