Alex Lorenz | 6cc8317 | 2017-08-25 10:07:00 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -std=c++11 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s |
| 2 | |
| 3 | struct Agg { const char * x; const char * y; constexpr Agg() : x(0), y(0) {} }; |
| 4 | |
| 5 | struct Struct { |
| 6 | constexpr static const char *name = "foo"; |
| 7 | |
| 8 | constexpr static __complex float complexValue = 42.0; |
| 9 | |
| 10 | static constexpr const Agg &agg = Agg(); |
| 11 | |
| 12 | Struct(); |
| 13 | Struct(int x); |
| 14 | }; |
| 15 | |
| 16 | void use(int n, const char *c); |
| 17 | |
| 18 | Struct *getPtr(); |
| 19 | |
| 20 | // CHECK: @[[STR:.*]] = private unnamed_addr constant [4 x i8] c"foo\00", align 1 |
| 21 | |
| 22 | void scalarStaticVariableInMemberExpr(Struct *ptr, Struct &ref) { |
| 23 | use(1, Struct::name); |
| 24 | // CHECK: call void @_Z3useiPKc(i32 1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) |
| 25 | Struct s; |
| 26 | use(2, s.name); |
| 27 | // CHECK: call void @_Z3useiPKc(i32 2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) |
| 28 | use(3, ptr->name); |
| 29 | // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8 |
| 30 | // CHECK: call void @_Z3useiPKc(i32 3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) |
| 31 | use(4, ref.name); |
| 32 | // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8 |
| 33 | // CHECK: call void @_Z3useiPKc(i32 4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) |
| 34 | use(5, Struct(2).name); |
| 35 | // CHECK: call void @_ZN6StructC1Ei(%struct.Struct* %{{.*}}, i32 2) |
| 36 | // CHECK: call void @_Z3useiPKc(i32 5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) |
| 37 | use(6, getPtr()->name); |
| 38 | // CHECK: call %struct.Struct* @_Z6getPtrv() |
| 39 | // CHECK: call void @_Z3useiPKc(i32 6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @[[STR]], i32 0, i32 0)) |
| 40 | } |
| 41 | |
| 42 | void use(int n, __complex float v); |
| 43 | |
| 44 | void complexStaticVariableInMemberExpr(Struct *ptr, Struct &ref) { |
| 45 | use(1, Struct::complexValue); |
| 46 | // CHECK: store float 4.200000e+01, float* %[[coerce0:.*]].{{.*}}, align 4 |
| 47 | // CHECK: store float 0.000000e+00, float* %[[coerce0]].{{.*}}, align 4 |
| 48 | // CHECK: %[[cast0:.*]] = bitcast { float, float }* %[[coerce0]] to <2 x float>* |
| 49 | // CHECK: %[[vector0:.*]] = load <2 x float>, <2 x float>* %[[cast0]], align 4 |
| 50 | // CHECK: call void @_Z3useiCf(i32 1, <2 x float> %[[vector0]]) |
| 51 | Struct s; |
| 52 | use(2, s.complexValue); |
| 53 | // CHECK: store float 4.200000e+01, float* %[[coerce1:.*]].{{.*}}, align 4 |
| 54 | // CHECK: store float 0.000000e+00, float* %[[coerce1]].{{.*}}, align 4 |
| 55 | // CHECK: %[[cast1:.*]] = bitcast { float, float }* %[[coerce1]] to <2 x float>* |
| 56 | // CHECK: %[[vector1:.*]] = load <2 x float>, <2 x float>* %[[cast1]], align 4 |
| 57 | // CHECK: call void @_Z3useiCf(i32 2, <2 x float> %[[vector1]]) |
| 58 | use(3, ptr->complexValue); |
| 59 | // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8 |
| 60 | // CHECK: store float 4.200000e+01, float* %[[coerce2:.*]].{{.*}}, align 4 |
| 61 | // CHECK: store float 0.000000e+00, float* %[[coerce2]].{{.*}}, align 4 |
| 62 | // CHECK: %[[cast2:.*]] = bitcast { float, float }* %[[coerce2]] to <2 x float>* |
| 63 | // CHECK: %[[vector2:.*]] = load <2 x float>, <2 x float>* %[[cast2]], align 4 |
| 64 | // CHECK: call void @_Z3useiCf(i32 3, <2 x float> %[[vector2]]) |
| 65 | use(4, ref.complexValue); |
| 66 | // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8 |
| 67 | // CHECK: store float 4.200000e+01, float* %[[coerce3:.*]].{{.*}}, align 4 |
| 68 | // CHECK: store float 0.000000e+00, float* %[[coerce3]].{{.*}}, align 4 |
| 69 | // CHECK: %[[cast3:.*]] = bitcast { float, float }* %[[coerce3]] to <2 x float>* |
| 70 | // CHECK: %[[vector3:.*]] = load <2 x float>, <2 x float>* %[[cast3]], align 4 |
| 71 | // CHECK: call void @_Z3useiCf(i32 4, <2 x float> %[[vector3]]) |
| 72 | use(5, Struct(2).complexValue); |
| 73 | // CHECK: call void @_ZN6StructC1Ei(%struct.Struct* %{{.*}}, i32 2) |
| 74 | // CHECK: store float 4.200000e+01, float* %[[coerce4:.*]].{{.*}}, align 4 |
| 75 | // CHECK: store float 0.000000e+00, float* %[[coerce4]].{{.*}}, align 4 |
| 76 | // CHECK: %[[cast4:.*]] = bitcast { float, float }* %[[coerce4]] to <2 x float>* |
| 77 | // CHECK: %[[vector4:.*]] = load <2 x float>, <2 x float>* %[[cast4]], align 4 |
| 78 | // CHECK: call void @_Z3useiCf(i32 5, <2 x float> %[[vector4]]) |
| 79 | use(6, getPtr()->complexValue); |
| 80 | // CHECK: call %struct.Struct* @_Z6getPtrv() |
| 81 | // CHECK: store float 4.200000e+01, float* %[[coerce5:.*]].{{.*}}, align 4 |
| 82 | // CHECK: store float 0.000000e+00, float* %[[coerce5]].{{.*}}, align 4 |
| 83 | // CHECK: %[[cast5:.*]] = bitcast { float, float }* %[[coerce5]] to <2 x float>* |
| 84 | // CHECK: %[[vector5:.*]] = load <2 x float>, <2 x float>* %[[cast5]], align 4 |
| 85 | // CHECK: call void @_Z3useiCf(i32 6, <2 x float> %[[vector5]]) |
| 86 | } |
| 87 | |
| 88 | void aggregateRefInMemberExpr(Struct *ptr, Struct &ref) { |
| 89 | use(1, Struct::agg.x); |
| 90 | // CHECK: %[[value0:.*]] = load i8*, i8** getelementptr inbounds (%struct.Agg, %struct.Agg* @_ZGRN6Struct3aggE_, i32 0, i32 0), align 8 |
| 91 | // CHECK: call void @_Z3useiPKc(i32 1, i8* %[[value0]]) |
| 92 | Struct s; |
| 93 | use(2, s.agg.x); |
| 94 | // CHECK: %[[value1:.*]] = load i8*, i8** getelementptr inbounds (%struct.Agg, %struct.Agg* @_ZGRN6Struct3aggE_, i32 0, i32 0), align 8 |
| 95 | // CHECK: call void @_Z3useiPKc(i32 2, i8* %[[value1]]) |
| 96 | use(3, ptr->agg.x); |
| 97 | // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8 |
| 98 | // CHECK: %[[value2:.*]] = load i8*, i8** getelementptr inbounds (%struct.Agg, %struct.Agg* @_ZGRN6Struct3aggE_, i32 0, i32 0), align 8 |
| 99 | // CHECK: call void @_Z3useiPKc(i32 3, i8* %[[value2]]) |
| 100 | use(4, ref.agg.x); |
| 101 | // CHECK: load %struct.Struct*, %struct.Struct** %{{.*}}, align 8 |
| 102 | // CHECK: %[[value3:.*]] = load i8*, i8** getelementptr inbounds (%struct.Agg, %struct.Agg* @_ZGRN6Struct3aggE_, i32 0, i32 0), align 8 |
| 103 | // CHECK: call void @_Z3useiPKc(i32 4, i8* %[[value3]]) |
| 104 | } |