[llvm-commits] [llvm] r120622 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/sibcall-5.ll
Evan Cheng
evan.cheng at apple.com
Wed Dec 1 14:59:46 PST 2010
Author: evancheng
Date: Wed Dec 1 16:59:46 2010
New Revision: 120622
URL: http://llvm.org/viewvc/llvm-project?rev=120622&view=rev
Log:
Fix and re-enable tail call optimization of expanded libcalls.
Modified:
llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/CodeGen/X86/sibcall-5.ll
Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=120622&r1=120621&r2=120622&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Dec 1 16:59:46 2010
@@ -1737,6 +1737,8 @@
if (NumCopies != 1 && NumCopies != 2)
return false;
+
+ bool HasRet = false;
for (unsigned i = 0; i < NumCopies; ++i) {
SDNode *Copy = Copies[i];
for (SDNode::use_iterator UI = Copy->use_begin(), UE = Copy->use_end();
@@ -1749,10 +1751,11 @@
}
if (UI->getOpcode() != ARMISD::RET_FLAG)
return false;
+ HasRet = true;
}
}
- return true;
+ return HasRet;
}
// ConstantPool, JumpTable, GlobalAddress, and ExternalSymbol are lowered as
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=120622&r1=120621&r2=120622&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Dec 1 16:59:46 2010
@@ -1339,22 +1339,25 @@
}
bool X86TargetLowering::isUsedByReturnOnly(SDNode *N) const {
- // Temporarily disabled.
- return false;
if (N->getNumValues() != 1)
return false;
if (!N->hasNUsesOfValue(1, 0))
return false;
SDNode *Copy = *N->use_begin();
- if (Copy->getOpcode() != ISD::CopyToReg)
+ if (Copy->getOpcode() != ISD::CopyToReg &&
+ Copy->getOpcode() != ISD::FP_EXTEND)
return false;
+
+ bool HasRet = false;
for (SDNode::use_iterator UI = Copy->use_begin(), UE = Copy->use_end();
- UI != UE; ++UI)
+ UI != UE; ++UI) {
if (UI->getOpcode() != X86ISD::RET_FLAG)
return false;
+ HasRet = true;
+ }
- return true;
+ return HasRet;
}
/// LowerCallResult - Lower the result values of a call into the
@@ -2161,19 +2164,17 @@
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) {
unsigned char OpFlags = 0;
- if (!isTailCall) {
- // On ELF targets, in either X86-64 or X86-32 mode, direct calls to
- // external symbols should go through the PLT.
- if (Subtarget->isTargetELF() &&
- getTargetMachine().getRelocationModel() == Reloc::PIC_) {
- OpFlags = X86II::MO_PLT;
- } else if (Subtarget->isPICStyleStubAny() &&
- Subtarget->getDarwinVers() < 9) {
- // PC-relative references to external symbols should go through $stub,
- // unless we're building with the leopard linker or later, which
- // automatically synthesizes these stubs.
- OpFlags = X86II::MO_DARWIN_STUB;
- }
+ // On ELF targets, in either X86-64 or X86-32 mode, direct calls to
+ // external symbols should go through the PLT.
+ if (Subtarget->isTargetELF() &&
+ getTargetMachine().getRelocationModel() == Reloc::PIC_) {
+ OpFlags = X86II::MO_PLT;
+ } else if (Subtarget->isPICStyleStubAny() &&
+ Subtarget->getDarwinVers() < 9) {
+ // PC-relative references to external symbols should go through $stub,
+ // unless we're building with the leopard linker or later, which
+ // automatically synthesizes these stubs.
+ OpFlags = X86II::MO_DARWIN_STUB;
}
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy(),
Modified: llvm/trunk/test/CodeGen/X86/sibcall-5.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sibcall-5.ll?rev=120622&r1=120621&r2=120622&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/sibcall-5.ll (original)
+++ llvm/trunk/test/CodeGen/X86/sibcall-5.ll Wed Dec 1 16:59:46 2010
@@ -1,20 +1,26 @@
-; RUN: llc < %s -march=x86-64 | FileCheck %s
-; XFAIL: *
+; RUN: llc < %s -mtriple=i386-apple-darwin8 | FileCheck %s --check-prefix=X32
+; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s --check-prefix=X64
; Sibcall optimization of expanded libcalls.
; rdar://8707777
define double @foo(double %a) nounwind readonly ssp {
entry:
-; CHECK: foo:
-; CHECK: jmp {{_?}}sin
+; X32: foo:
+; X32: jmp _sin$stub
+
+; X64: foo:
+; X64: jmp _sin
%0 = tail call double @sin(double %a) nounwind readonly
ret double %0
}
define float @bar(float %a) nounwind readonly ssp {
-; CHECK: bar:
-; CHECK: jmp {{_?}}sinf
+; X32: bar:
+; X32: jmp _sinf$stub
+
+; X64: bar:
+; X64: jmp _sinf
entry:
%0 = tail call float @sinf(float %a) nounwind readonly
ret float %0
More information about the llvm-commits
mailing list