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