summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2017-03-13 18:39:33 +0000
committerJessica Paquette <jpaquette@apple.com>2017-03-13 18:39:33 +0000
commitc984e21394b74e63eec7e8b03f14a25882c25ae6 (patch)
tree7bc8c67d83117c458df6ea2a88d6f952707891bc /llvm/test
parent616641632ee5213a4f33b5471c7acea5137d38a2 (diff)
downloadbcm5719-llvm-c984e21394b74e63eec7e8b03f14a25882c25ae6.tar.gz
bcm5719-llvm-c984e21394b74e63eec7e8b03f14a25882c25ae6.zip
[Outliner] Add tail call support
This commit adds tail call support to the MachineOutliner pass. This allows the outliner to insert jumps rather than calls in areas where tail calling is possible. Outlined tail calls include the return or terminator of the basic block being outlined from. Tail call support allows the outliner to take returns and terminators into consideration while finding candidates to outline. It also allows the outliner to save more instructions. For example, in the X86-64 outliner, a tail called outlined function saves one instruction since no return has to be inserted. llvm-svn: 297653
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/CodeGen/X86/machine-outliner-tailcalls.ll35
-rw-r--r--llvm/test/CodeGen/X86/machine-outliner.ll12
2 files changed, 41 insertions, 6 deletions
diff --git a/llvm/test/CodeGen/X86/machine-outliner-tailcalls.ll b/llvm/test/CodeGen/X86/machine-outliner-tailcalls.ll
new file mode 100644
index 00000000000..020f7eeaaff
--- /dev/null
+++ b/llvm/test/CodeGen/X86/machine-outliner-tailcalls.ll
@@ -0,0 +1,35 @@
+; RUN: llc -enable-machine-outliner -mtriple=x86_64-apple-darwin < %s | FileCheck %s
+
+@x = common local_unnamed_addr global i32 0, align 4
+
+define i32 @foo0(i32) local_unnamed_addr #0 {
+; CHECK-LABEL: _foo0:
+; CHECK: jmp l_OUTLINED_FUNCTION_0
+; CHECK-NEXT: .cfi_endproc
+ store i32 0, i32* @x, align 4, !tbaa !2
+ %2 = tail call i32 @ext(i32 1) #2
+ ret i32 undef
+}
+
+declare i32 @ext(i32) local_unnamed_addr #1
+
+define i32 @foo1(i32) local_unnamed_addr #0 {
+; CHECK-LABEL: _foo1:
+; CHECK: jmp l_OUTLINED_FUNCTION_0
+; CHECK-NEXT: .cfi_endproc
+ store i32 0, i32* @x, align 4, !tbaa !2
+ %2 = tail call i32 @ext(i32 1) #2
+ ret i32 undef
+}
+
+attributes #0 = { noredzone nounwind ssp uwtable "no-frame-pointer-elim"="false" }
+
+!2 = !{!3, !3, i64 0}
+!3 = !{!"int", !4, i64 0}
+!4 = !{!"omnipotent char", !5, i64 0}
+!5 = !{!"Simple C/C++ TBAA"}
+
+; CHECK-LABEL: l_OUTLINED_FUNCTION_0:
+; CHECK: movl $0, (%rax)
+; CHECK-NEXT: movl $1, %edi
+; CHECK-NEXT: jmp _ext \ No newline at end of file
diff --git a/llvm/test/CodeGen/X86/machine-outliner.ll b/llvm/test/CodeGen/X86/machine-outliner.ll
index 9246348c563..9f8e6ec298f 100644
--- a/llvm/test/CodeGen/X86/machine-outliner.ll
+++ b/llvm/test/CodeGen/X86/machine-outliner.ll
@@ -15,7 +15,7 @@ define i32 @check_boundaries() #0 {
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
- ; CHECK: callq l_OUTLINED_FUNCTION_1
+ ; CHECK: callq [[OFUNC1:l_OUTLINED_FUNCTION_[0-9]+]]
; CHECK: cmpl $0, -{{[0-9]+}}(%rbp)
store i32 1, i32* %2, align 4
store i32 2, i32* %3, align 4
@@ -30,7 +30,7 @@ define i32 @check_boundaries() #0 {
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
- ; CHECK: callq l_OUTLINED_FUNCTION_1
+ ; CHECK: callq [[OFUNC1]]
store i32 1, i32* %2, align 4
store i32 2, i32* %3, align 4
store i32 3, i32* %4, align 4
@@ -79,13 +79,13 @@ define i32 @main() #0 {
store i32 0, i32* %1, align 4
store i32 0, i32* @x, align 4
- ; CHECK: callq l_OUTLINED_FUNCTION_0
+ ; CHECK: callq [[OFUNC2:l_OUTLINED_FUNCTION_[0-9]+]]
store i32 1, i32* %2, align 4
store i32 2, i32* %3, align 4
store i32 3, i32* %4, align 4
store i32 4, i32* %5, align 4
store i32 1, i32* @x, align 4
- ; CHECK: callq l_OUTLINED_FUNCTION_0
+ ; CHECK: callq [[OFUNC2]]
store i32 1, i32* %2, align 4
store i32 2, i32* %3, align 4
store i32 3, i32* %4, align 4
@@ -95,14 +95,14 @@ define i32 @main() #0 {
attributes #0 = { noredzone nounwind ssp uwtable "no-frame-pointer-elim"="true" }
-; CHECK-LABEL: l_OUTLINED_FUNCTION_0:
+; CHECK-LABEL: l_OUTLINED_FUNCTION_1:
; CHECK: movl $1, -{{[0-9]+}}(%rbp)
; CHECK-NEXT: movl $2, -{{[0-9]+}}(%rbp)
; CHECK-NEXT: movl $3, -{{[0-9]+}}(%rbp)
; CHECK-NEXT: movl $4, -{{[0-9]+}}(%rbp)
; CHECK-NEXT: retq
-; CHECK-LABEL: l_OUTLINED_FUNCTION_1:
+; CHECK-LABEL: l_OUTLINED_FUNCTION_0:
; CHECK: movl $1, -{{[0-9]+}}(%rbp)
; CHECK-NEXT: movl $2, -{{[0-9]+}}(%rbp)
; CHECK-NEXT: movl $3, -{{[0-9]+}}(%rbp)
OpenPOWER on IntegriCloud