1 // RUN: %clang_cc1 -std=c++11 -S -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck %s 2 3 namespace reference { 4 struct A { 5 int i1, i2; 6 }; 7 8 void single_init() { 9 // No superfluous instructions allowed here, they could be 10 // hiding extra temporaries. 11 12 // CHECK: store i32 1, i32* 13 // CHECK-NEXT: store i32* %{{.*}}, i32** 14 const int &cri2a = 1; 15 16 // CHECK-NEXT: store i32 1, i32* 17 // CHECK-NEXT: store i32* %{{.*}}, i32** 18 const int &cri1a = {1}; 19 20 // CHECK-NEXT: store i32 1, i32* 21 int i = 1; 22 // CHECK-NEXT: store i32* %{{.*}}, i32** 23 int &ri1a = {i}; 24 25 // CHECK-NEXT: bitcast 26 // CHECK-NEXT: memcpy 27 A a{1, 2}; 28 // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** % 29 A &ra1a = {a}; 30 31 using T = A&; 32 // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** % 33 A &ra1b = T{a}; 34 35 // CHECK-NEXT: ret 36 } 37 38 void reference_to_aggregate() { 39 // CHECK: getelementptr {{.*}}, i32 0, i32 0 40 // CHECK-NEXT: store i32 1 41 // CHECK-NEXT: getelementptr {{.*}}, i32 0, i32 1 42 // CHECK-NEXT: store i32 2 43 // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** %{{.*}}, align 44 const A &ra1{1, 2}; 45 46 // CHECK-NEXT: getelementptr inbounds [3 x i32]* %{{.*}}, i{{32|64}} 0, i{{32|64}} 0 47 // CHECK-NEXT: store i32 1 48 // CHECK-NEXT: getelementptr inbounds i32* %{{.*}}, i{{32|64}} 1 49 // CHECK-NEXT: store i32 2 50 // CHECK-NEXT: getelementptr inbounds i32* %{{.*}}, i{{32|64}} 1 51 // CHECK-NEXT: store i32 3 52 // CHECK-NEXT: store [3 x i32]* %{{.*}}, [3 x i32]** %{{.*}}, align 53 const int (&arrayRef)[] = {1, 2, 3}; 54 55 // CHECK-NEXT: ret 56 } 57 58 struct B { 59 B(); 60 ~B(); 61 }; 62 63 void single_init_temp_cleanup() 64 { 65 // Ensure lifetime extension. 66 67 // CHECK: call %"struct.reference::B"* @_ZN9reference1BC1Ev 68 // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** % 69 const B &rb{ B() }; 70 // CHECK: call %"struct.reference::B"* @_ZN9reference1BD1Ev 71 } 72 73 } 74