blob: 3f850e6e94b7c062dd62fd67aebcaedf6304a75e [file] [log] [blame]
Tim Shen95e84c52016-05-20 22:42:01 +00001; RUN: llc -O2 < %s | FileCheck %s
2
Tim Shenfa573672016-05-25 17:01:09 +00003; The call to function TestBar should be a tail call, when in C++ the string
4; `ret` is RVO returned.
5; string TestFoo() {
6; string ret = undef;
7; TestBar(&ret); // tail call optimized
8; return ret;
9; }
10
Tim Shen95e84c52016-05-20 22:42:01 +000011target triple = "powerpc64le-linux-gnu"
12
13%class.basic_string.11.42.73 = type { %"class.__gnu_cxx::__versa_string.10.41.72" }
14%"class.__gnu_cxx::__versa_string.10.41.72" = type { %"class.__gnu_cxx::__sso_string_base.9.40.71" }
15%"class.__gnu_cxx::__sso_string_base.9.40.71" = type { %"struct.__gnu_cxx::__vstring_utility<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider.7.38.69", i64, %union.anon.8.39.70 }
16%"struct.__gnu_cxx::__vstring_utility<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider.7.38.69" = type { i8* }
17%union.anon.8.39.70 = type { i64, [8 x i8] }
18
19declare void @TestBaz(%class.basic_string.11.42.73* noalias sret %arg)
20
21define void @TestBar(%class.basic_string.11.42.73* noalias sret %arg) {
22bb:
23 call void @TestBaz(%class.basic_string.11.42.73* noalias sret %arg)
24 ret void
25}
26
Tim Shen95e84c52016-05-20 22:42:01 +000027define void @TestFoo(%class.basic_string.11.42.73* noalias sret %arg) {
28; CHECK-LABEL: TestFoo:
29; CHECK: #TC_RETURNd8 TestBar 0
30bb:
31 %tmp = getelementptr inbounds %class.basic_string.11.42.73, %class.basic_string.11.42.73* %arg, i64 0, i32 0, i32 0, i32 2
32 %tmp1 = bitcast %class.basic_string.11.42.73* %arg to %union.anon.8.39.70**
33 store %union.anon.8.39.70* %tmp, %union.anon.8.39.70** %tmp1, align 8
34 %tmp2 = bitcast %union.anon.8.39.70* %tmp to i8*
35 tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp2, i8* nonnull undef, i64 13, i32 1, i1 false)
36 %tmp3 = getelementptr inbounds %class.basic_string.11.42.73, %class.basic_string.11.42.73* %arg, i64 0, i32 0, i32 0, i32 1
37 store i64 13, i64* %tmp3, align 8
38 %tmp4 = getelementptr inbounds %class.basic_string.11.42.73, %class.basic_string.11.42.73* %arg, i64 0, i32 0, i32 0, i32 2, i32 1, i64 5
39 store i8 0, i8* %tmp4, align 1
40 tail call void @TestBar(%class.basic_string.11.42.73* noalias sret %arg)
41 ret void
42}
43
44; Function Attrs: argmemonly nounwind
45declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #0
46
47attributes #0 = { argmemonly nounwind }