| 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 |
// FIXME: We could defer starting the lifetime of the return object of concat |
| 30 |
// until the call. |
| 31 |
// CHECK: call void @llvm.lifetime.start.p0(ptr [[T1]]) |
| 32 |
// |
| 33 |
// CHECK: call void @llvm.lifetime.start.p0(ptr [[T2]]) |
| 34 |
// CHECK: [[T4:%.*]] = call noundef ptr @_ZN1TC1EPKc(ptr {{[^,]*}} [[T2]], ptr noundef @.str) |
| 35 |
// |
| 36 |
// CHECK: call void @llvm.lifetime.start.p0(ptr [[T3]]) |
| 37 |
// CHECK: [[T5:%.*]] = call noundef ptr @_ZN1TC1E1S(ptr {{[^,]*}} [[T3]], [2 x i32] %{{.*}}) |
| 38 |
// |
| 39 |
// CHECK: call void @_ZNK1T6concatERKS_(ptr dead_on_unwind writable sret(%class.T) align 4 [[T1]], ptr {{[^,]*}} [[T2]], ptr noundef nonnull align 4 dereferenceable(16) [[T3]]) |
| 40 |
// CHECK: [[T6:%.*]] = call noundef ptr @_ZNK1T3strEv(ptr {{[^,]*}} [[T1]]) |
| 41 |
// |
| 42 |
// CHECK: call void @llvm.lifetime.end.p0( |
| 43 |
// CHECK: call void @llvm.lifetime.end.p0( |
| 44 |
// CHECK: call void @llvm.lifetime.end.p0( |
| 45 |
// CHECK: ret ptr [[T6]] |
| 46 |
|
| 47 |
return T("[").concat(T(s)).str(); |
| 48 |
} |
| 49 |
|
| 50 |
// CHECK: declare {{.*}}llvm.lifetime.start |
| 51 |
// CHECK: declare {{.*}}llvm.lifetime.end |