Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARM, AArch64, X86: Check preserved registers for tail calls.
We can only perform a tail call to a callee that preserves all the registers that the caller needs to preserve. This situation happens with calling conventions like preserver_mostcc or cxx_fast_tls. It was explicitely handled for fast_tls and failing for preserve_most. This patch generalizes the check to any calling convention. Related to rdar://24207743 Differential Revision: http://reviews.llvm.org/D18680 llvm-svn: 265329
- Loading branch information
Showing
7 changed files
with
80 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; RUN: llc -o - %s | FileCheck %s | ||
target triple="aarch64--" | ||
|
||
declare void @somefunc() | ||
define preserve_mostcc void @test_ccmismatch_notail() { | ||
; Ensure that no tail call is used here, as the called function somefunc does | ||
; not preserve enough registers for preserve_mostcc. | ||
; CHECK-LABEL: test_ccmismatch_notail: | ||
; CHECK-NOT: b somefunc | ||
; CHECK: bl somefunc | ||
tail call void @somefunc() | ||
ret void | ||
} | ||
|
||
declare preserve_mostcc void @some_preserve_most_func() | ||
define void @test_ccmismatch_tail() { | ||
; We can perform a tail call here, because some_preserve_most_func preserves | ||
; all registers necessary for test_ccmismatch_tail. | ||
; CHECK-LABEL: test_ccmismatch_tail: | ||
; CHECK-NOT: bl some_preserve_most_func | ||
; CHECK: b some_preserve_most_func | ||
tail call preserve_mostcc void @some_preserve_most_func() | ||
ret void | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters