Move callseq_start above the call address load to allow load to be folded into the call node.

llvm-svn: 55292
This commit is contained in:
Evan Cheng 2008-08-24 19:19:55 +00:00
parent 72e7d91591
commit 8fa17424f7
2 changed files with 17 additions and 2 deletions

View File

@ -1499,6 +1499,11 @@ SDValue X86TargetLowering::LowerCALL(SDValue Op, SelectionDAG &DAG) {
MF.getInfo<X86MachineFunctionInfo>()->setTCReturnAddrDelta(FPDiff); MF.getInfo<X86MachineFunctionInfo>()->setTCReturnAddrDelta(FPDiff);
} }
// If the address is a load, i.e. indirect function call, move callseq_start
// above the load. This makes it possible for the load to fold into the call.
if (Callee.Val == Chain.Val && ISD::isNormalLoad(Callee.Val) &&
Chain.hasOneUse() && Callee.hasOneUse())
Chain = Chain.getOperand(0);
Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumBytes)); Chain = DAG.getCALLSEQ_START(Chain, DAG.getIntPtrConstant(NumBytes));
SDValue RetAddrFrIdx; SDValue RetAddrFrIdx;

View File

@ -0,0 +1,10 @@
; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin | grep mov | count 1
@f = external global void ()* ; <void ()**> [#uses=1]
define i32 @main() nounwind {
entry:
load void ()** @f, align 8 ; <void ()*>:0 [#uses=1]
tail call void %0( ) nounwind
ret i32 0
}