mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
hoist check for IsTailCall to callers. Eliminate redundant check for
x86-64: GOT-style PIC is never used on x86-64. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75090 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
951bf7d74f
commit
e3ee6f1e1f
@ -1321,22 +1321,18 @@ X86TargetLowering::NameDecorationForFORMAL_ARGUMENTS(SDValue Op) {
|
|||||||
|
|
||||||
/// CallRequiresGOTInRegister - Check whether the call requires the GOT pointer
|
/// CallRequiresGOTInRegister - Check whether the call requires the GOT pointer
|
||||||
/// in a register before calling.
|
/// in a register before calling.
|
||||||
static bool CallRequiresGOTPtrInReg(const TargetMachine &TM,
|
static bool CallRequiresGOTPtrInReg(const TargetMachine &TM) {
|
||||||
bool IsTailCall) {
|
|
||||||
const X86Subtarget &Subtarget = TM.getSubtarget<X86Subtarget>();
|
const X86Subtarget &Subtarget = TM.getSubtarget<X86Subtarget>();
|
||||||
|
|
||||||
return !IsTailCall && !Subtarget.is64Bit() &&
|
return TM.getRelocationModel() == Reloc::PIC_ &&
|
||||||
TM.getRelocationModel() == Reloc::PIC_ &&
|
|
||||||
Subtarget.isPICStyleGOT();
|
Subtarget.isPICStyleGOT();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CallRequiresFnAddressInReg - Check whether the call requires the function
|
/// CallRequiresFnAddressInReg - Check whether the call requires the function
|
||||||
/// address to be loaded in a register.
|
/// address to be loaded in a register.
|
||||||
static bool CallRequiresFnAddressInReg(const TargetMachine &TM,
|
static bool CallRequiresFnAddressInReg(const TargetMachine &TM) {
|
||||||
bool IsTailCall) {
|
|
||||||
const X86Subtarget &Subtarget = TM.getSubtarget<X86Subtarget>();
|
const X86Subtarget &Subtarget = TM.getSubtarget<X86Subtarget>();
|
||||||
return !Subtarget.is64Bit() && IsTailCall &&
|
return TM.getRelocationModel() == Reloc::PIC_ &&
|
||||||
TM.getRelocationModel() == Reloc::PIC_ &&
|
|
||||||
Subtarget.isPICStyleGOT();
|
Subtarget.isPICStyleGOT();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1808,7 +1804,7 @@ SDValue X86TargetLowering::LowerCALL(SDValue Op, SelectionDAG &DAG) {
|
|||||||
|
|
||||||
// ELF / PIC requires GOT in the EBX register before function calls via PLT
|
// ELF / PIC requires GOT in the EBX register before function calls via PLT
|
||||||
// GOT pointer.
|
// GOT pointer.
|
||||||
if (CallRequiresGOTPtrInReg(getTargetMachine(), IsTailCall)) {
|
if (!IsTailCall && CallRequiresGOTPtrInReg(getTargetMachine())) {
|
||||||
Chain = DAG.getCopyToReg(Chain, dl, X86::EBX,
|
Chain = DAG.getCopyToReg(Chain, dl, X86::EBX,
|
||||||
DAG.getNode(X86ISD::GlobalBaseReg,
|
DAG.getNode(X86ISD::GlobalBaseReg,
|
||||||
DebugLoc::getUnknownLoc(),
|
DebugLoc::getUnknownLoc(),
|
||||||
@ -1823,7 +1819,7 @@ SDValue X86TargetLowering::LowerCALL(SDValue Op, SelectionDAG &DAG) {
|
|||||||
// calls on PIC/GOT architectures. Normally we would just put the address of
|
// calls on PIC/GOT architectures. Normally we would just put the address of
|
||||||
// GOT into ebx and then call target@PLT. But for tail calls ebx would be
|
// GOT into ebx and then call target@PLT. But for tail calls ebx would be
|
||||||
// restored (since ebx is callee saved) before jumping to the target@PLT.
|
// restored (since ebx is callee saved) before jumping to the target@PLT.
|
||||||
if (CallRequiresFnAddressInReg(getTargetMachine(), IsTailCall)) {
|
if (IsTailCall && CallRequiresFnAddressInReg(getTargetMachine())) {
|
||||||
// Note: The actual moving to ecx is done further down.
|
// Note: The actual moving to ecx is done further down.
|
||||||
GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee);
|
GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee);
|
||||||
if (G && !G->getGlobal()->hasHiddenVisibility() &&
|
if (G && !G->getGlobal()->hasHiddenVisibility() &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user