[llvm-branch-commits] [llvm-branch] r99035 - in /llvm/branches/Apple/Morbo: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/sibcall.ll
Evan Cheng
evan.cheng at apple.com
Fri Mar 19 20:27:44 PDT 2010
Author: evancheng
Date: Fri Mar 19 22:27:44 2010
New Revision: 99035
URL: http://llvm.org/viewvc/llvm-project?rev=99035&view=rev
Log:
Merge 99032, 99033.
Modified:
llvm/branches/Apple/Morbo/lib/Target/X86/X86ISelLowering.cpp
llvm/branches/Apple/Morbo/test/CodeGen/X86/sibcall.ll
Modified: llvm/branches/Apple/Morbo/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/lib/Target/X86/X86ISelLowering.cpp?rev=99035&r1=99034&r2=99035&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/branches/Apple/Morbo/lib/Target/X86/X86ISelLowering.cpp Fri Mar 19 22:27:44 2010
@@ -2310,6 +2310,28 @@
if (isCalleeStructRet || isCallerStructRet)
return false;
+ // If the call result is in ST0 / ST1, it needs to be popped off the x87 stack.
+ // Therefore if it's not used by the call it is not safe to optimize this into
+ // a sibcall.
+ bool Unused = false;
+ for (unsigned i = 0, e = Ins.size(); i != e; ++i) {
+ if (!Ins[i].Used) {
+ Unused = true;
+ break;
+ }
+ }
+ if (Unused) {
+ SmallVector<CCValAssign, 16> RVLocs;
+ CCState CCInfo(CalleeCC, false, getTargetMachine(),
+ RVLocs, *DAG.getContext());
+ CCInfo.AnalyzeCallResult(Ins, RetCC_X86);
+ for (unsigned i = 0; i != RVLocs.size(); ++i) {
+ CCValAssign &VA = RVLocs[i];
+ if (VA.getLocReg() == X86::ST0 || VA.getLocReg() == X86::ST1)
+ return false;
+ }
+ }
+
// If the callee takes no arguments then go on to check the results of the
// call.
if (!Outs.empty()) {
Modified: llvm/branches/Apple/Morbo/test/CodeGen/X86/sibcall.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Morbo/test/CodeGen/X86/sibcall.ll?rev=99035&r1=99034&r2=99035&view=diff
==============================================================================
--- llvm/branches/Apple/Morbo/test/CodeGen/X86/sibcall.ll (original)
+++ llvm/branches/Apple/Morbo/test/CodeGen/X86/sibcall.ll Fri Mar 19 22:27:44 2010
@@ -57,11 +57,11 @@
entry:
; 32: t5:
; 32-NOT: call
-; 32: jmpl *
+; 32: jmpl *4(%esp)
; 64: t5:
; 64-NOT: call
-; 64: jmpq *
+; 64: jmpq *%rdi
tail call void %x() nounwind
ret void
}
@@ -215,4 +215,59 @@
ret %struct.ns* %0
}
+; rdar://6195379
+; llvm can't do sibcall for this in 32-bit mode (yet).
declare fastcc %struct.ns* @foo7(%struct.cp* byval align 4, i8 signext) nounwind ssp
+
+%struct.__block_descriptor = type { i64, i64 }
+%struct.__block_descriptor_withcopydispose = type { i64, i64, i8*, i8* }
+%struct.__block_literal_1 = type { i8*, i32, i32, i8*, %struct.__block_descriptor* }
+%struct.__block_literal_2 = type { i8*, i32, i32, i8*, %struct.__block_descriptor_withcopydispose*, void ()* }
+
+define void @t14(%struct.__block_literal_2* nocapture %.block_descriptor) nounwind ssp {
+entry:
+; 64: t14:
+; 64: movq 32(%rdi)
+; 64-NOT: movq 16(%rdi)
+; 64: jmpq *16(%rdi)
+ %0 = getelementptr inbounds %struct.__block_literal_2* %.block_descriptor, i64 0, i32 5 ; <void ()**> [#uses=1]
+ %1 = load void ()** %0, align 8 ; <void ()*> [#uses=2]
+ %2 = bitcast void ()* %1 to %struct.__block_literal_1* ; <%struct.__block_literal_1*> [#uses=1]
+ %3 = getelementptr inbounds %struct.__block_literal_1* %2, i64 0, i32 3 ; <i8**> [#uses=1]
+ %4 = load i8** %3, align 8 ; <i8*> [#uses=1]
+ %5 = bitcast i8* %4 to void (i8*)* ; <void (i8*)*> [#uses=1]
+ %6 = bitcast void ()* %1 to i8* ; <i8*> [#uses=1]
+ tail call void %5(i8* %6) nounwind
+ ret void
+}
+
+; rdar://7726868
+%struct.foo = type { [4 x i32] }
+
+define void @t15(%struct.foo* noalias sret %agg.result) nounwind {
+; 32: t15:
+; 32: call {{_?}}f
+; 32: ret $4
+
+; 64: t15:
+; 64: callq {{_?}}f
+; 64: ret
+ tail call fastcc void @f(%struct.foo* noalias sret %agg.result) nounwind
+ ret void
+}
+
+declare void @f(%struct.foo* noalias sret) nounwind
+
+define void @t16() nounwind ssp {
+entry:
+; 32: t16:
+; 32: call {{_?}}bar4
+; 32: fstp
+
+; 64: t16:
+; 64: jmp {{_?}}bar4
+ %0 = tail call double @bar4() nounwind
+ ret void
+}
+
+declare double @bar4()
More information about the llvm-branch-commits
mailing list