2017-06-09 21:40:18 +08:00
|
|
|
// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o %t -debug-info-kind=limited
|
2013-05-10 03:17:11 +08:00
|
|
|
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-GLOBALS
|
|
|
|
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-1
|
|
|
|
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-2
|
|
|
|
// RUN: FileCheck %s -input-file=%t -check-prefix=CHECK-3
|
|
|
|
|
2014-10-29 20:21:55 +08:00
|
|
|
typedef __INTPTR_TYPE__ intptr_t;
|
|
|
|
|
2013-05-10 03:17:11 +08:00
|
|
|
int foo();
|
|
|
|
int global;
|
|
|
|
|
|
|
|
// Single statement
|
|
|
|
void test1() {
|
|
|
|
int i = 0;
|
|
|
|
#pragma clang __debug captured
|
|
|
|
{
|
2015-05-07 14:28:46 +08:00
|
|
|
static float inner = 3.0;
|
|
|
|
(void)inner;
|
2013-05-10 03:17:11 +08:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
// CHECK-1: %struct.anon = type { i32* }
|
2015-05-07 14:28:46 +08:00
|
|
|
// CHECK-1: {{.+}} global float 3.0
|
2013-05-10 03:17:11 +08:00
|
|
|
//
|
2015-11-21 04:47:34 +08:00
|
|
|
// CHECK-1: @test1(
|
2013-05-10 03:17:11 +08:00
|
|
|
// CHECK-1: alloca %struct.anon
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-1: getelementptr inbounds %struct.anon, %struct.anon*
|
2013-05-10 03:17:11 +08:00
|
|
|
// CHECK-1: store i32* %i
|
2015-05-13 00:48:43 +08:00
|
|
|
// CHECK-1: call void @[[HelperName:__captured_stmt[\.0-9]+]]
|
2013-05-10 03:17:11 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 01:29:50 +08:00
|
|
|
// CHECK-1: define internal {{.*}}void @[[HelperName]](%struct.anon
|
2013-05-10 03:17:11 +08:00
|
|
|
// CHECK-1: getelementptr inbounds %struct.anon{{.*}}, i32 0, i32 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-1: load i32*, i32**
|
|
|
|
// CHECK-1: load i32, i32*
|
2013-05-10 03:17:11 +08:00
|
|
|
// CHECK-1: add nsw i32
|
|
|
|
// CHECK-1: store i32
|
|
|
|
|
|
|
|
// Compound statement with local variable
|
|
|
|
void test2(int x) {
|
|
|
|
#pragma clang __debug captured
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < x; i++)
|
|
|
|
foo();
|
|
|
|
}
|
2015-11-21 04:47:34 +08:00
|
|
|
// CHECK-2: @test2(
|
2013-05-10 03:17:11 +08:00
|
|
|
// CHECK-2-NOT: %i
|
2015-05-13 00:48:43 +08:00
|
|
|
// CHECK-2: call void @[[HelperName:__captured_stmt[\.0-9]+]]
|
2013-05-10 03:17:11 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 01:29:50 +08:00
|
|
|
// CHECK-2: define internal {{.*}}void @[[HelperName]]
|
2013-05-10 03:17:11 +08:00
|
|
|
// CHECK-2-NOT: }
|
|
|
|
// CHECK-2: %i = alloca i32
|
|
|
|
|
|
|
|
// Capture array
|
2014-06-30 10:55:54 +08:00
|
|
|
void test3(int size) {
|
2013-05-10 03:17:11 +08:00
|
|
|
int arr[] = {1, 2, 3, 4, 5};
|
2014-06-30 10:55:54 +08:00
|
|
|
int vla_arr[size];
|
2013-05-10 03:17:11 +08:00
|
|
|
#pragma clang __debug captured
|
|
|
|
{
|
2014-06-30 10:55:54 +08:00
|
|
|
arr[2] = vla_arr[size - 1];
|
2013-05-10 03:17:11 +08:00
|
|
|
}
|
2015-11-21 04:47:34 +08:00
|
|
|
// CHECK-3: @test3(
|
2013-05-10 03:17:11 +08:00
|
|
|
// CHECK-3: alloca [5 x i32]
|
|
|
|
// CHECK-3: call void @__captured_stmt
|
|
|
|
}
|
|
|
|
|
2014-07-02 15:05:22 +08:00
|
|
|
// Capture VLA array
|
2014-10-29 20:21:55 +08:00
|
|
|
void test4(intptr_t size, intptr_t vla_arr[size]) {
|
2014-07-02 15:05:22 +08:00
|
|
|
#pragma clang __debug captured
|
|
|
|
{
|
|
|
|
vla_arr[0] = 1;
|
|
|
|
}
|
2014-10-29 20:21:55 +08:00
|
|
|
// CHECK-3: test4([[INTPTR_T:i.+]] {{.*}}[[SIZE_ARG:%.+]], [[INTPTR_T]]*
|
|
|
|
// CHECK-3: store [[INTPTR_T]] {{.*}}[[SIZE_ARG]], [[INTPTR_T]]* [[SIZE_ADDR:%.+]],
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-3: [[SIZE:%.+]] = load [[INTPTR_T]], [[INTPTR_T]]* [[SIZE_ADDR]],
|
2014-07-02 15:05:22 +08:00
|
|
|
// CHECK-3: [[REF:%.+]] = getelementptr inbounds
|
2014-10-29 20:21:55 +08:00
|
|
|
// CHECK-3: store [[INTPTR_T]] [[SIZE]], [[INTPTR_T]]* [[REF]]
|
2014-07-02 15:05:22 +08:00
|
|
|
// CHECK-3: call void @__captured_stmt
|
|
|
|
}
|
|
|
|
|
2013-05-10 03:17:11 +08:00
|
|
|
void dont_capture_global() {
|
|
|
|
static int s;
|
|
|
|
extern int e;
|
|
|
|
#pragma clang __debug captured
|
|
|
|
{
|
|
|
|
global++;
|
|
|
|
s++;
|
|
|
|
e++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-GLOBALS: %[[Capture:struct\.anon[\.0-9]*]] = type {}
|
2015-05-13 00:48:43 +08:00
|
|
|
// CHECK-GLOBALS: call void @__captured_stmt[[HelperName:[\.0-9]+]](%[[Capture]]
|
2013-05-10 03:17:11 +08:00
|
|
|
}
|
|
|
|
|
2015-06-30 01:29:50 +08:00
|
|
|
// CHECK-GLOBALS: define internal {{.*}}void @__captured_stmt[[HelperName]]
|
2013-05-10 03:17:11 +08:00
|
|
|
// CHECK-GLOBALS-NOT: ret
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-GLOBALS: load i32, i32* @global
|
|
|
|
// CHECK-GLOBALS: load i32, i32* @
|
|
|
|
// CHECK-GLOBALS: load i32, i32* @e
|
2017-06-09 21:40:18 +08:00
|
|
|
|
|
|
|
// CHECK-GLOBALS-NOT: DIFlagObjectPointer
|
|
|
|
// CHECK-1-NOT: DIFlagObjectPointer
|
|
|
|
// CHECK-2-NOT: DIFlagObjectPointer
|
|
|
|
// CHECK-3-NOT: DIFlagObjectPointer
|