llvm.org GIT mirror llvm / 09eef44
Merging r233409: ------------------------------------------------------------------------ r233409 | ahmed.bougacha | 2015-03-27 16:28:30 -0400 (Fri, 27 Mar 2015) | 7 lines [CodeGen] Don't attempt a tail-call with implicit sret. Tailcalls are only OK with forwarded sret pointers. With sret demotion, they're not, as we'd have a pointer into a soon-to-be-dead stack frame. Differential Revison: http://reviews.llvm.org/D8510 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@236066 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 5 years ago
2 changed file(s) with 50 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
73527352 Entry.Alignment = Align;
73537353 CLI.getArgs().insert(CLI.getArgs().begin(), Entry);
73547354 CLI.RetTy = Type::getVoidTy(CLI.RetTy->getContext());
7355
7356 // sret demotion isn't compatible with tail-calls, since the sret argument
7357 // points into the callers stack frame.
7358 CLI.IsTailCall = false;
73557359 } else {
73567360 for (unsigned I = 0, E = RetTys.size(); I != E; ++I) {
73577361 EVT VT = RetTys[I];
0 ; RUN: llc < %s -mtriple arm64-apple-darwin -aarch64-load-store-opt=false -asm-verbose=false | FileCheck %s
1 ; Disable the load/store optimizer to avoid having LDP/STPs and simplify checks.
2
3 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
4
5 ; Check that we don't try to tail-call with an sret-demoted return.
6
7 declare i1024 @test_sret() #0
8
9 ; CHECK-LABEL: _test_call_sret:
10 ; CHECK: mov x[[CALLERX8NUM:[0-9]+]], x8
11 ; CHECK: mov x8, sp
12 ; CHECK-NEXT: bl _test_sret
13 ; CHECK-NEXT: ldr [[CALLERSRET1:x[0-9]+]], [sp]
14 ; CHECK: str [[CALLERSRET1:x[0-9]+]], [x[[CALLERX8NUM]]]
15 ; CHECK: ret
16 define i1024 @test_call_sret() #0 {
17 %a = call i1024 @test_sret()
18 ret i1024 %a
19 }
20
21 ; CHECK-LABEL: _test_tailcall_sret:
22 ; CHECK: mov x[[CALLERX8NUM:[0-9]+]], x8
23 ; CHECK: mov x8, sp
24 ; CHECK-NEXT: bl _test_sret
25 ; CHECK-NEXT: ldr [[CALLERSRET1:x[0-9]+]], [sp]
26 ; CHECK: str [[CALLERSRET1:x[0-9]+]], [x[[CALLERX8NUM]]]
27 ; CHECK: ret
28 define i1024 @test_tailcall_sret() #0 {
29 %a = tail call i1024 @test_sret()
30 ret i1024 %a
31 }
32
33 ; CHECK-LABEL: _test_indirect_tailcall_sret:
34 ; CHECK: mov x[[CALLERX8NUM:[0-9]+]], x8
35 ; CHECK: mov x8, sp
36 ; CHECK-NEXT: blr x0
37 ; CHECK-NEXT: ldr [[CALLERSRET1:x[0-9]+]], [sp]
38 ; CHECK: str [[CALLERSRET1:x[0-9]+]], [x[[CALLERX8NUM]]]
39 ; CHECK: ret
40 define i1024 @test_indirect_tailcall_sret(i1024 ()* %f) #0 {
41 %a = tail call i1024 %f()
42 ret i1024 %a
43 }
44
45 attributes #0 = { nounwind }