[llvm] [RISCV] Implement tail call optimization in machine outliner (PR #115297)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 08:10:13 PST 2024
================
@@ -2937,19 +2938,47 @@ bool RISCVInstrInfo::shouldOutlineFromFunctionByDefault(
return MF.getFunction().hasMinSize();
}
+static bool IsCandidatePatchable(const MachineInstr &MI) {
+ const MachineBasicBlock *MBB = MI.getParent();
+ const MachineFunction *MF = MBB->getParent();
+ const Function &F = MF->getFunction();
+ return F.getFnAttribute("fentry-call").getValueAsBool() ||
+ F.hasFnAttribute("patchable-function-entry");
+}
+
+static bool CannotInsertTailCall(const MachineInstr &MI) {
+ if (MI.isTerminator())
+ return IsCandidatePatchable(MI);
+ return true;
+}
+
+static bool MIUseX5(const MachineInstr &MI, const TargetRegisterInfo *TRI) {
+ return MI.modifiesRegister(RISCV::X5, TRI) ||
+ MI.getDesc().hasImplicitDefOfPhysReg(RISCV::X5);
+}
+
std::optional<std::unique_ptr<outliner::OutlinedFunction>>
RISCVInstrInfo::getOutliningCandidateInfo(
const MachineModuleInfo &MMI,
std::vector<outliner::Candidate> &RepeatedSequenceLocs,
unsigned MinRepeats) const {
- // First we need to filter out candidates where the X5 register (IE t0) can't
- // be used to setup the function call.
- auto CannotInsertCall = [](outliner::Candidate &C) {
+ auto CandidateUseX5 = [](outliner::Candidate &C) {
----------------
topperc wrote:
Use -> Uses
https://github.com/llvm/llvm-project/pull/115297
More information about the llvm-commits
mailing list