David Blaikie | 1deeedb | 2012-09-19 18:46:03 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s |
Douglas Gregor | 751ec9b | 2011-06-17 04:59:12 +0000 | [diff] [blame] | 2 | |
| 3 | struct X { |
| 4 | X(); |
| 5 | X(const X&); |
| 6 | X(const char*); |
| 7 | ~X(); |
| 8 | }; |
| 9 | |
| 10 | struct Y { |
| 11 | int i; |
| 12 | X x; |
| 13 | }; |
| 14 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 15 | // CHECK-LABEL: define i32 @_Z1fv() |
Douglas Gregor | 751ec9b | 2011-06-17 04:59:12 +0000 | [diff] [blame] | 16 | int f() { |
| 17 | // CHECK: [[LVALUE:%[a-z0-9.]+]] = alloca |
| 18 | // CHECK-NEXT: [[I:%[a-z0-9]+]] = getelementptr inbounds {{.*}}* [[LVALUE]], i32 0, i32 0 |
| 19 | // CHECK-NEXT: store i32 17, i32* [[I]] |
| 20 | // CHECK-NEXT: [[X:%[a-z0-9]+]] = getelementptr inbounds {{.*}} [[LVALUE]], i32 0, i32 1 |
David Blaikie | 1deeedb | 2012-09-19 18:46:03 +0000 | [diff] [blame] | 21 | // CHECK-NEXT: call %struct.X* @_ZN1XC1EPKc({{.*}}[[X]] |
Douglas Gregor | 751ec9b | 2011-06-17 04:59:12 +0000 | [diff] [blame] | 22 | // CHECK-NEXT: [[I:%[a-z0-9]+]] = getelementptr inbounds {{.*}} [[LVALUE]], i32 0, i32 0 |
| 23 | // CHECK-NEXT: [[RESULT:%[a-z0-9]+]] = load i32* |
David Blaikie | 1deeedb | 2012-09-19 18:46:03 +0000 | [diff] [blame] | 24 | // CHECK-NEXT: call %struct.Y* @_ZN1YD1Ev |
Douglas Gregor | 751ec9b | 2011-06-17 04:59:12 +0000 | [diff] [blame] | 25 | // CHECK-NEXT: ret i32 [[RESULT]] |
| 26 | return ((Y){17, "seventeen"}).i; |
| 27 | } |
Peter Collingbourne | 65bfd68 | 2011-11-13 00:51:30 +0000 | [diff] [blame] | 28 | |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 29 | // CHECK-LABEL: define i32 @_Z1gv() |
Peter Collingbourne | 65bfd68 | 2011-11-13 00:51:30 +0000 | [diff] [blame] | 30 | int g() { |
| 31 | // CHECK: store [2 x i32]* %{{[a-z0-9.]+}}, [2 x i32]** [[V:%[a-z0-9.]+]] |
| 32 | const int (&v)[2] = (int [2]) {1,2}; |
| 33 | |
| 34 | // CHECK: [[A:%[a-z0-9.]+]] = load [2 x i32]** [[V]] |
| 35 | // CHECK-NEXT: [[A0ADDR:%[a-z0-9.]+]] = getelementptr inbounds [2 x i32]* [[A]], i32 0, {{.*}} 0 |
| 36 | // CHECK-NEXT: [[A0:%[a-z0-9.]+]] = load i32* [[A0ADDR]] |
| 37 | // CHECK-NEXT: ret i32 [[A0]] |
| 38 | return v[0]; |
| 39 | } |
Richard Smith | 7401cf5 | 2011-11-22 22:48:32 +0000 | [diff] [blame] | 40 | |
| 41 | struct Z { int i[3]; }; |
| 42 | int *p = (Z){ {1, 2, 3} }.i; |
| 43 | // CHECK: define {{.*}}__cxx_global_var_init() |
Richard Smith | 1a3246a | 2011-11-23 02:12:00 +0000 | [diff] [blame] | 44 | // CHECK: store i32* getelementptr inbounds (%struct.Z* @.compoundliteral, i32 0, i32 0, i32 0), i32** @p |