From 290ae0398e3673ff742c8e0e2fddfae388950c5b Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Mon, 22 Sep 2008 14:50:07 +0000 Subject: [PATCH] Change the calling convention used when tail call optimization is enabled from CC_X86_32_TailCall to CC_X86_32_FastCC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56436 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86CallingConv.td | 16 ---------------- lib/Target/X86/X86FastISel.cpp | 2 -- lib/Target/X86/X86ISelLowering.cpp | 6 ++---- test/CodeGen/X86/tailcall-stackalign.ll | 2 +- test/CodeGen/X86/tailcallbyval.ll | 2 +- test/CodeGen/X86/tailcallfp2.ll | 2 +- 6 files changed, 5 insertions(+), 25 deletions(-) diff --git a/lib/Target/X86/X86CallingConv.td b/lib/Target/X86/X86CallingConv.td index e720b0b3b22..b98b5d9b495 100644 --- a/lib/Target/X86/X86CallingConv.td +++ b/lib/Target/X86/X86CallingConv.td @@ -312,22 +312,6 @@ def CC_X86_32_C : CallingConv<[ CCDelegateTo ]>; -/// Same as C calling convention except for non-free ECX which is used for storing -/// a potential pointer to the tail called function. -def CC_X86_32_TailCall : CallingConv<[ - // Promote i8/i16 arguments to i32. - CCIfType<[i8, i16], CCPromoteToType>, - - // Nested function trampolines are currently not supported by fastcc. - - // The first 3 integer arguments, if marked 'inreg' and if the call is not - // a vararg call, are passed in integer registers. - CCIfNotVarArg>>>, - - // Otherwise, same as everything else. - CCDelegateTo -]>; - def CC_X86_32_FastCall : CallingConv<[ // Promote i8/i16 arguments to i32. CCIfType<[i8, i16], CCPromoteToType>, diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp index 3d27ff32324..7747788e813 100644 --- a/lib/Target/X86/X86FastISel.cpp +++ b/lib/Target/X86/X86FastISel.cpp @@ -142,8 +142,6 @@ CCAssignFn *X86FastISel::CCAssignFnForCall(unsigned CC, bool isTaillCall) { if (CC == CallingConv::X86_FastCall) return CC_X86_32_FastCall; - else if (CC == CallingConv::Fast && isTaillCall) - return CC_X86_32_TailCall; else if (CC == CallingConv::Fast) return CC_X86_32_FastCC; else diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 3401a2c4d35..78121bd7352 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -890,7 +890,7 @@ SDValue X86TargetLowering::LowerRET(SDValue Op, SelectionDAG &DAG) { SDValue TargetAddress = TailCall.getOperand(1); SDValue StackAdjustment = TailCall.getOperand(2); assert(((TargetAddress.getOpcode() == ISD::Register && - (cast(TargetAddress)->getReg() == X86::ECX || + (cast(TargetAddress)->getReg() == X86::EAX || cast(TargetAddress)->getReg() == X86::R9)) || TargetAddress.getOpcode() == ISD::TargetExternalSymbol || TargetAddress.getOpcode() == ISD::TargetGlobalAddress) && @@ -1098,8 +1098,6 @@ CCAssignFn *X86TargetLowering::CCAssignFnForNode(unsigned CC) const { if (CC == CallingConv::X86_FastCall) return CC_X86_32_FastCall; - else if (CC == CallingConv::Fast && PerformTailCallOpt) - return CC_X86_32_TailCall; else if (CC == CallingConv::Fast) return CC_X86_32_FastCC; else @@ -1700,7 +1698,7 @@ SDValue X86TargetLowering::LowerCALL(SDValue Op, SelectionDAG &DAG) { } else if (ExternalSymbolSDNode *S = dyn_cast(Callee)) { Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy()); } else if (IsTailCall) { - unsigned Opc = Is64Bit ? X86::R9 : X86::ECX; + unsigned Opc = Is64Bit ? X86::R9 : X86::EAX; Chain = DAG.getCopyToReg(Chain, DAG.getRegister(Opc, getPointerTy()), diff --git a/test/CodeGen/X86/tailcall-stackalign.ll b/test/CodeGen/X86/tailcall-stackalign.ll index 80111925eec..ff960b8ce1f 100644 --- a/test/CodeGen/X86/tailcall-stackalign.ll +++ b/test/CodeGen/X86/tailcall-stackalign.ll @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -mtriple=i686-unknown-linux -tailcallopt | grep -A 1 call | grep -A 1 tailcaller | grep subl | grep 20 +; RUN: llvm-as < %s | llc -mtriple=i686-unknown-linux -tailcallopt | grep -A 1 call | grep -A 1 tailcaller | grep subl | grep 12 ; Linux has 8 byte alignment so the params cause stack size 20 when tailcallopt ; is enabled, ensure that a normal fastcc call has matching stack size diff --git a/test/CodeGen/X86/tailcallbyval.ll b/test/CodeGen/X86/tailcallbyval.ll index 9085b050ec5..112a497f75e 100644 --- a/test/CodeGen/X86/tailcallbyval.ll +++ b/test/CodeGen/X86/tailcallbyval.ll @@ -1,6 +1,6 @@ ; RUN: llvm-as < %s | llc -march=x86 -tailcallopt | grep TAILCALL ; check for the 2 byval moves -; RUN: llvm-as < %s | llc -march=x86 -tailcallopt | grep rep | wc -l | grep 2 +; RUN: llvm-as < %s | llc -march=x86 -tailcallopt | grep movl | grep ecx | grep eax | wc -l | grep 1 %struct.s = type {i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32, i32 } diff --git a/test/CodeGen/X86/tailcallfp2.ll b/test/CodeGen/X86/tailcallfp2.ll index 4fa01f6fb11..151701ed439 100644 --- a/test/CodeGen/X86/tailcallfp2.ll +++ b/test/CodeGen/X86/tailcallfp2.ll @@ -1,4 +1,4 @@ -; RUN: llvm-as < %s | llc -march=x86 -tailcallopt | grep {jmp} | grep {\\*%ecx} +; RUN: llvm-as < %s | llc -march=x86 -tailcallopt | grep {jmp} | grep {\\*%eax} declare i32 @putchar(i32) -- 2.34.1