From 5967649780ccd723cfd7a7303bc63348d27691de Mon Sep 17 00:00:00 2001
From: Evan Cheng
Date: Mon, 8 Mar 2010 21:05:02 +0000
Subject: [PATCH] Add documentation on sibling call optimization. Rename
tailcall2.ll test to sibcall.ll.
llvm-svn: 97980
---
llvm/docs/CodeGenerator.html | 45 +++++++++++++++++++
llvm/docs/LangRef.html | 7 ++-
.../CodeGen/X86/{tailcall2.ll => sibcall.ll} | 0
3 files changed, 50 insertions(+), 2 deletions(-)
rename llvm/test/CodeGen/X86/{tailcall2.ll => sibcall.ll} (100%)
diff --git a/llvm/docs/CodeGenerator.html b/llvm/docs/CodeGenerator.html
index 2be31851e36a..f26d0abfad52 100644
--- a/llvm/docs/CodeGenerator.html
+++ b/llvm/docs/CodeGenerator.html
@@ -86,6 +86,7 @@
Target-specific Implementation Notes
+
+
+
+
+
Sibling call optimization is a restricted form of tail call optimization.
+ Unlike tail call optimization described in the previous section, it can be
+ performed automatically on any tail calls when -tailcallopt option
+ is not specified.
+
+
Sibling call optimization is currently performed on x86/x86-64 when the
+ following constraints are met:
+
+
+ - Caller and callee have the same calling convention. It can be either
+ c or fastcc.
+
+
- The call is a tail call - in tail position (ret immediately follows call
+ and ret uses value of call or is void).
+
+ - Caller and callee have matching return type or the callee result is not
+ used.
+
+
- If any of the callee arguments are being passed in stack, they must be
+ available in caller's own incoming argument stack and the frame offsets
+ must be the same.
+
+
+
Example:
+
+
+declare i32 @bar(i32, i32)
+
+define i32 @foo(i32 %a, i32 %b, i32 %c) {
+entry:
+ %0 = tail call i32 @bar(i32 %a, i32 %b)
+ ret i32 %0
+}
+
+
+
diff --git a/llvm/docs/LangRef.html b/llvm/docs/LangRef.html
index 7cfa05205cea..eec06fcc023f 100644
--- a/llvm/docs/LangRef.html
+++ b/llvm/docs/LangRef.html
@@ -5149,8 +5149,11 @@ Loop: ; Infinite loop that counts from 0 on up...
a
ret instruction. If the "tail" marker is
present, the function call is eligible for tail call optimization,
but
might not in fact be
- optimized into a jump. As of this writing, the extra requirements for
- a call to actually be optimized are:
+ optimized into a jump. The code generator may optimize calls marked
+ "tail" with either 1) automatic
+ sibling call optimization when the caller and callee have
+ matching signatures, or 2) forced tail call optimization when the
+ following extra requirements are met:
- Caller and callee both have the calling
convention fastcc.
diff --git a/llvm/test/CodeGen/X86/tailcall2.ll b/llvm/test/CodeGen/X86/sibcall.ll
similarity index 100%
rename from llvm/test/CodeGen/X86/tailcall2.ll
rename to llvm/test/CodeGen/X86/sibcall.ll
--
GitLab