1 // RUN: %clang_cc1 -triple armv7l-unknown-linux-gnueabihf -emit-llvm -O1 -disable-llvm-passes -std=c++03 %s -o - | FileCheck %s --implicit-check-not=llvm.lifetime 2 3 class S { 4 char *ptr; 5 unsigned int len; 6 }; 7 8 class T { 9 S left; 10 S right; 11 12 public: 13 T(const char s[]); 14 T(S); 15 16 T concat(const T &Suffix) const; 17 const char * str() const; 18 }; 19 20 const char * f(S s) 21 { 22 // It's essential that the lifetimes of all three T temporaries here are 23 // overlapping. They must all remain alive through the call to str(). 24 // 25 // CHECK: [[T1:%.*]] = alloca %class.T, align 4 26 // CHECK: [[T2:%.*]] = alloca %class.T, align 4 27 // CHECK: [[T3:%.*]] = alloca %class.T, align 4 28 // 29 // CHECK: [[AGG:%.*]] = alloca %class.S, align 4 30 // 31 // FIXME: We could defer starting the lifetime of the return object of concat 32 // until the call. 33 // CHECK: [[T1i8:%.*]] = bitcast %class.T* [[T1]] to i8* 34 // CHECK: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[T1i8]]) 35 // 36 // CHECK: [[T2i8:%.*]] = bitcast %class.T* [[T2]] to i8* 37 // CHECK: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[T2i8]]) 38 // CHECK: [[T4:%.*]] = call %class.T* @_ZN1TC1EPKc(%class.T* [[T2]], i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0)) 39 // 40 // CHECK: [[T3i8:%.*]] = bitcast %class.T* [[T3]] to i8* 41 // CHECK: call void @llvm.lifetime.start.p0i8(i64 16, i8* [[T3i8]]) 42 // 43 // CHECK: [[AGGi8:%.*]] = bitcast %class.S* [[AGG]] to i8* 44 // CHECK: call void @llvm.lifetime.start.p0i8(i64 8, i8* [[AGGi8]]) 45 // 46 // CHECK: [[T5:%.*]] = call %class.T* @_ZN1TC1E1S(%class.T* [[T3]], [2 x i32] %{{.*}}) 47 // 48 // CHECK: [[AGGi8:%.*]] = bitcast %class.S* {{.*}} to i8* 49 // CHECK: call void @llvm.lifetime.end.p0i8(i64 8, i8* [[AGGi8]]) 50 // 51 // CHECK: call void @_ZNK1T6concatERKS_(%class.T* sret [[T1]], %class.T* [[T2]], %class.T* dereferenceable(16) [[T3]]) 52 // CHECK: [[T6:%.*]] = call i8* @_ZNK1T3strEv(%class.T* [[T1]]) 53 // 54 // CHECK: call void @llvm.lifetime.end.p0i8( 55 // CHECK: call void @llvm.lifetime.end.p0i8( 56 // CHECK: call void @llvm.lifetime.end.p0i8( 57 // CHECK: ret i8* [[T6]] 58 59 return T("[").concat(T(s)).str(); 60 } 61 62 // CHECK: declare {{.*}}llvm.lifetime.start 63 // CHECK: declare {{.*}}llvm.lifetime.end 64