Index: include/llvm/Target/TargetInstrInfo.h =================================================================== --- include/llvm/Target/TargetInstrInfo.h +++ include/llvm/Target/TargetInstrInfo.h @@ -1496,9 +1496,11 @@ return None; } - /// Determines whether |Inst| is a tail call instruction. + /// Determines whether \p Inst is a tail call instruction. There is no need to + /// override this method, unless the target doesn't model the isCall/isReturn + /// flags correctly! virtual bool isTailCall(const MachineInstr &Inst) const { - return false; + return Inst.isReturn() && Inst.isCall(); } /// True if the instruction is bound to the top of its basic block and no Index: lib/Target/AArch64/AArch64InstrInfo.h =================================================================== --- lib/Target/AArch64/AArch64InstrInfo.h +++ lib/Target/AArch64/AArch64InstrInfo.h @@ -87,8 +87,6 @@ /// Return true if this is an unscaled load/store. bool isUnscaledLdSt(MachineInstr &MI) const; - bool isTailCall(const MachineInstr &Inst) const override; - static bool isPairableLdStInst(const MachineInstr &MI) { switch (MI.getOpcode()) { default: Index: lib/Target/AArch64/AArch64InstrInfo.cpp =================================================================== --- lib/Target/AArch64/AArch64InstrInfo.cpp +++ lib/Target/AArch64/AArch64InstrInfo.cpp @@ -1627,17 +1627,6 @@ return isUnscaledLdSt(MI.getOpcode()); } -bool AArch64InstrInfo::isTailCall(const MachineInstr &Inst) const -{ - switch (Inst.getOpcode()) { - case AArch64::TCRETURNdi: - case AArch64::TCRETURNri: - return true; - default: - return false; - } -} - // Is this a candidate for ld/st merging or pairing? For example, we don't // touch volatiles or load/stores that have a hint to avoid pair formation. bool AArch64InstrInfo::isCandidateToMergeOrPair(MachineInstr &MI) const { Index: lib/Target/ARM/ARMBaseInstrInfo.h =================================================================== --- lib/Target/ARM/ARMBaseInstrInfo.h +++ lib/Target/ARM/ARMBaseInstrInfo.h @@ -109,8 +109,6 @@ getNoopForMachoTarget(NopInst); } - bool isTailCall(const MachineInstr &Inst) const override; - // Return the non-pre/post incrementing version of 'Opc'. Return 0 // if there is not such an opcode. virtual unsigned getUnindexedOpcode(unsigned Opc) const = 0; Index: lib/Target/ARM/ARMBaseInstrInfo.cpp =================================================================== --- lib/Target/ARM/ARMBaseInstrInfo.cpp +++ lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -4709,19 +4709,6 @@ return Subtarget.getFeatureBits()[ARM::HasV6KOps]; } -bool ARMBaseInstrInfo::isTailCall(const MachineInstr &Inst) const -{ - switch (Inst.getOpcode()) { - case ARM::TAILJMPd: - case ARM::TAILJMPr: - case ARM::TCRETURNdi: - case ARM::TCRETURNri: - return true; - default: - return false; - } -} - bool ARMBaseInstrInfo::isSwiftFastImmShift(const MachineInstr *MI) const { if (MI->getNumOperands() < 4) return true; Index: lib/Target/X86/X86InstrInfo.h =================================================================== --- lib/Target/X86/X86InstrInfo.h +++ lib/Target/X86/X86InstrInfo.h @@ -543,8 +543,6 @@ ArrayRef> getSerializableDirectMachineOperandTargetFlags() const override; - bool isTailCall(const MachineInstr &Inst) const override; - unsigned getOutliningBenefit(size_t SequenceSize, size_t Occurrences) const override; Index: lib/Target/X86/X86InstrInfo.cpp =================================================================== --- lib/Target/X86/X86InstrInfo.cpp +++ lib/Target/X86/X86InstrInfo.cpp @@ -10175,28 +10175,6 @@ return makeArrayRef(TargetFlags); } -bool X86InstrInfo::isTailCall(const MachineInstr &Inst) const { - switch (Inst.getOpcode()) { - case X86::TCRETURNdi: - case X86::TCRETURNmi: - case X86::TCRETURNri: - case X86::TCRETURNdi64: - case X86::TCRETURNmi64: - case X86::TCRETURNri64: - case X86::TAILJMPd: - case X86::TAILJMPm: - case X86::TAILJMPr: - case X86::TAILJMPd64: - case X86::TAILJMPm64: - case X86::TAILJMPr64: - case X86::TAILJMPm64_REX: - case X86::TAILJMPr64_REX: - return true; - default: - return false; - } -} - namespace { /// Create Global Base Reg pass. This initializes the PIC /// global base register for x86-32.