2014-12-14 20:16:43 +08:00
|
|
|
// RUN: %clang_cc1 -std=c++11 -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s
|
2011-06-17 12:59:12 +08:00
|
|
|
|
|
|
|
struct X {
|
|
|
|
X();
|
|
|
|
X(const X&);
|
|
|
|
X(const char*);
|
|
|
|
~X();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Y {
|
|
|
|
int i;
|
|
|
|
X x;
|
|
|
|
};
|
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define i32 @_Z1fv()
|
2011-06-17 12:59:12 +08:00
|
|
|
int f() {
|
|
|
|
// CHECK: [[LVALUE:%[a-z0-9.]+]] = alloca
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[I:%[a-z0-9]+]] = getelementptr inbounds {{.*}}, {{.*}}* [[LVALUE]], i32 0, i32 0
|
2011-06-17 12:59:12 +08:00
|
|
|
// CHECK-NEXT: store i32 17, i32* [[I]]
|
|
|
|
// CHECK-NEXT: [[X:%[a-z0-9]+]] = getelementptr inbounds {{.*}} [[LVALUE]], i32 0, i32 1
|
2012-09-20 02:46:03 +08:00
|
|
|
// CHECK-NEXT: call %struct.X* @_ZN1XC1EPKc({{.*}}[[X]]
|
2011-06-17 12:59:12 +08:00
|
|
|
// CHECK-NEXT: [[I:%[a-z0-9]+]] = getelementptr inbounds {{.*}} [[LVALUE]], i32 0, i32 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[RESULT:%[a-z0-9]+]] = load i32, i32*
|
2012-09-20 02:46:03 +08:00
|
|
|
// CHECK-NEXT: call %struct.Y* @_ZN1YD1Ev
|
2011-06-17 12:59:12 +08:00
|
|
|
// CHECK-NEXT: ret i32 [[RESULT]]
|
|
|
|
return ((Y){17, "seventeen"}).i;
|
|
|
|
}
|
2011-11-13 08:51:30 +08:00
|
|
|
|
2013-08-15 14:47:53 +08:00
|
|
|
// CHECK-LABEL: define i32 @_Z1gv()
|
2011-11-13 08:51:30 +08:00
|
|
|
int g() {
|
2015-04-10 06:54:53 +08:00
|
|
|
// CHECK: store [2 x i32]* %{{[a-z0-9.]+}}, [2 x i32]** [[V:%[a-z0-9.]+]]
|
2011-11-13 08:51:30 +08:00
|
|
|
const int (&v)[2] = (int [2]) {1,2};
|
|
|
|
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK: [[A:%[a-z0-9.]+]] = load [2 x i32]*, [2 x i32]** [[V]]
|
2015-02-28 03:18:17 +08:00
|
|
|
// CHECK-NEXT: [[A0ADDR:%[a-z0-9.]+]] = getelementptr inbounds [2 x i32], [2 x i32]* [[A]], i32 0, {{.*}} 0
|
2015-02-28 05:19:58 +08:00
|
|
|
// CHECK-NEXT: [[A0:%[a-z0-9.]+]] = load i32, i32* [[A0ADDR]]
|
2011-11-13 08:51:30 +08:00
|
|
|
// CHECK-NEXT: ret i32 [[A0]]
|
|
|
|
return v[0];
|
|
|
|
}
|
2011-11-23 06:48:32 +08:00
|
|
|
|
|
|
|
struct Z { int i[3]; };
|
|
|
|
int *p = (Z){ {1, 2, 3} }.i;
|
|
|
|
// CHECK: define {{.*}}__cxx_global_var_init()
|
2015-03-14 02:21:46 +08:00
|
|
|
// CHECK: store i32* getelementptr inbounds (%struct.Z, %struct.Z* @.compoundliteral, i32 0, i32 0, i32 0), i32** @p
|
2014-12-14 20:16:43 +08:00
|
|
|
|
|
|
|
|
|
|
|
int *PR21912_1 = (int []){};
|
2015-05-13 00:48:43 +08:00
|
|
|
// CHECK-LABEL: define {{.*}}__cxx_global_var_init.1()
|
|
|
|
// CHECK: store i32* getelementptr inbounds ([0 x i32], [0 x i32]* @.compoundliteral.2, i32 0, i32 0), i32** @PR21912_1
|
2014-12-14 20:16:43 +08:00
|
|
|
|
|
|
|
union PR21912Ty {
|
|
|
|
long long l;
|
|
|
|
double d;
|
|
|
|
};
|
|
|
|
union PR21912Ty *PR21912_2 = (union PR21912Ty[]){{.d = 2.0}, {.l = 3}};
|
2015-05-13 00:48:43 +08:00
|
|
|
// CHECK-LABEL: define {{.*}}__cxx_global_var_init.3()
|
|
|
|
// CHECK: store %union.PR21912Ty* getelementptr inbounds ([2 x %union.PR21912Ty], [2 x %union.PR21912Ty]* bitcast (<{ { double }, %union.PR21912Ty }>* @.compoundliteral.4 to [2 x %union.PR21912Ty]*), i32 0, i32 0), %union.PR21912Ty** @PR21912_2
|