+
+
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 7cfa05205cead0d9264a0acfdabdf00c95d263c7..eec06fcc023f886e6f10b762758ab5ec11a2b9ba 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