diff options
author | Tim Shen <timshen91@gmail.com> | 2016-05-20 22:42:01 +0000 |
---|---|---|
committer | Tim Shen <timshen91@gmail.com> | 2016-05-20 22:42:01 +0000 |
commit | 258d886f6186e1327c6aa9ffb8c79462c19fdea2 (patch) | |
tree | b9cda2a03dfe9eb6907a801aa9cb9e17bc223939 | |
parent | d60c9c7025234a503d251b92d2f1ce8d7a37e791 (diff) |
[PowerPC] Add a testcase for TCO on string rvo function
Differential Revision: http://reviews.llvm.org/D20311
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270287 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | test/CodeGen/PowerPC/tailcall-string-rvo.ll | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/CodeGen/PowerPC/tailcall-string-rvo.ll b/test/CodeGen/PowerPC/tailcall-string-rvo.ll new file mode 100644 index 00000000000..b6b5fb9dbf7 --- /dev/null +++ b/test/CodeGen/PowerPC/tailcall-string-rvo.ll @@ -0,0 +1,44 @@ +; RUN: llc -O2 < %s | FileCheck %s + +target triple = "powerpc64le-linux-gnu" + +%class.basic_string.11.42.73 = type { %"class.__gnu_cxx::__versa_string.10.41.72" } +%"class.__gnu_cxx::__versa_string.10.41.72" = type { %"class.__gnu_cxx::__sso_string_base.9.40.71" } +%"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 } +%"struct.__gnu_cxx::__vstring_utility<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider.7.38.69" = type { i8* } +%union.anon.8.39.70 = type { i64, [8 x i8] } + +declare void @TestBaz(%class.basic_string.11.42.73* noalias sret %arg) + +define void @TestBar(%class.basic_string.11.42.73* noalias sret %arg) { +bb: + call void @TestBaz(%class.basic_string.11.42.73* noalias sret %arg) + ret void +} + +; string TestFoo() { +; string ret = undef; +; TestBar(&ret); // tail call optimized +; return ret; +; } +define void @TestFoo(%class.basic_string.11.42.73* noalias sret %arg) { +; CHECK-LABEL: TestFoo: +; CHECK: #TC_RETURNd8 TestBar 0 +bb: + %tmp = getelementptr inbounds %class.basic_string.11.42.73, %class.basic_string.11.42.73* %arg, i64 0, i32 0, i32 0, i32 2 + %tmp1 = bitcast %class.basic_string.11.42.73* %arg to %union.anon.8.39.70** + store %union.anon.8.39.70* %tmp, %union.anon.8.39.70** %tmp1, align 8 + %tmp2 = bitcast %union.anon.8.39.70* %tmp to i8* + tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp2, i8* nonnull undef, i64 13, i32 1, i1 false) + %tmp3 = getelementptr inbounds %class.basic_string.11.42.73, %class.basic_string.11.42.73* %arg, i64 0, i32 0, i32 0, i32 1 + store i64 13, i64* %tmp3, align 8 + %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 + store i8 0, i8* %tmp4, align 1 + tail call void @TestBar(%class.basic_string.11.42.73* noalias sret %arg) + ret void +} + +; Function Attrs: argmemonly nounwind +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #0 + +attributes #0 = { argmemonly nounwind } |