From 0a78d09ccbfb71ff609ae28c4d2c7829fdb3c018 Mon Sep 17 00:00:00 2001 From: Jessica Paquette Date: Tue, 19 Jun 2018 21:14:48 +0000 Subject: [PATCH] [MachineOutliner] NFC: Remove insertOutlinerPrologue, rename insertOutlinerEpilogue insertOutlinerPrologue was not used by any target, and prologue-esque code was beginning to appear in insertOutlinerEpilogue. Refactor that into one function, buildOutlinedFrame. This just removes insertOutlinerPrologue and renames insertOutlinerEpilogue. llvm-svn: 335076 --- include/llvm/CodeGen/TargetInstrInfo.h | 17 +++-------------- lib/CodeGen/MachineOutliner.cpp | 7 ++----- lib/Target/AArch64/AArch64InstrInfo.cpp | 6 +----- lib/Target/AArch64/AArch64InstrInfo.h | 4 +--- lib/Target/X86/X86InstrInfo.cpp | 7 +------ lib/Target/X86/X86InstrInfo.h | 5 +---- 6 files changed, 9 insertions(+), 37 deletions(-) diff --git a/include/llvm/CodeGen/TargetInstrInfo.h b/include/llvm/CodeGen/TargetInstrInfo.h index f6dbe31ca50..2619488c525 100644 --- a/include/llvm/CodeGen/TargetInstrInfo.h +++ b/include/llvm/CodeGen/TargetInstrInfo.h @@ -1626,14 +1626,12 @@ public: return 0x0; } - /// Insert a custom epilogue for outlined functions. - /// This may be empty, in which case no epilogue or return statement will be - /// emitted. - virtual void insertOutlinerEpilogue(MachineBasicBlock &MBB, + /// Insert a custom frame for outlined functions. + virtual void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, const outliner::TargetCostInfo &TCI) const { llvm_unreachable( - "Target didn't implement TargetInstrInfo::insertOutlinerEpilogue!"); + "Target didn't implement TargetInstrInfo::buildOutlinedFrame!"); } /// Insert a call to an outlined function into the program. @@ -1647,15 +1645,6 @@ public: "Target didn't implement TargetInstrInfo::insertOutlinedCall!"); } - /// Insert a custom prologue for outlined functions. - /// This may be empty, in which case no prologue will be emitted. - virtual void insertOutlinerPrologue(MachineBasicBlock &MBB, - MachineFunction &MF, - const outliner::TargetCostInfo &TCI) const { - llvm_unreachable( - "Target didn't implement TargetInstrInfo::insertOutlinerPrologue!"); - } - /// Return true if the function can safely be outlined from. /// A function \p MF is considered safe for outlining if an outlined function /// produced from instructions in F will produce a program which produces the diff --git a/lib/CodeGen/MachineOutliner.cpp b/lib/CodeGen/MachineOutliner.cpp index eb9480ada47..fde35202a34 100644 --- a/lib/CodeGen/MachineOutliner.cpp +++ b/lib/CodeGen/MachineOutliner.cpp @@ -25,9 +25,8 @@ /// /// Targets must implement /// * getOutliningCandidateInfo -/// * insertOutlinerEpilogue +/// * buildOutlinedFrame /// * insertOutlinedCall -/// * insertOutlinerPrologue /// * isFunctionSafeToOutlineFrom /// /// in order to make use of the MachineOutliner. @@ -1150,8 +1149,6 @@ MachineOutliner::createOutlinedFunction(Module &M, const OutlinedFunction &OF, // Insert the new function into the module. MF.insert(MF.begin(), &MBB); - TII.insertOutlinerPrologue(MBB, MF, OF.TCI); - // Copy over the instructions for the function using the integer mappings in // its sequence. for (unsigned Str : OF.Sequence) { @@ -1164,7 +1161,7 @@ MachineOutliner::createOutlinedFunction(Module &M, const OutlinedFunction &OF, MBB.insert(MBB.end(), NewMI); } - TII.insertOutlinerEpilogue(MBB, MF, OF.TCI); + TII.buildOutlinedFrame(MBB, MF, OF.TCI); // If there's a DISubprogram associated with this outlined function, then // emit debug info for the outlined function. diff --git a/lib/Target/AArch64/AArch64InstrInfo.cpp b/lib/Target/AArch64/AArch64InstrInfo.cpp index 384c8ab45f3..1ad51d5a449 100644 --- a/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -5302,7 +5302,7 @@ void AArch64InstrInfo::fixupPostOutline(MachineBasicBlock &MBB) const { } } -void AArch64InstrInfo::insertOutlinerEpilogue( +void AArch64InstrInfo::buildOutlinedFrame( MachineBasicBlock &MBB, MachineFunction &MF, const outliner::TargetCostInfo &TCI) const { // For thunk outlining, rewrite the last instruction from a call to a @@ -5399,10 +5399,6 @@ void AArch64InstrInfo::insertOutlinerEpilogue( fixupPostOutline(MBB); } -void AArch64InstrInfo::insertOutlinerPrologue( - MachineBasicBlock &MBB, MachineFunction &MF, - const outliner::TargetCostInfo &TCI) const {} - MachineBasicBlock::iterator AArch64InstrInfo::insertOutlinedCall( Module &M, MachineBasicBlock &MBB, MachineBasicBlock::iterator &It, MachineFunction &MF, const outliner::TargetCostInfo &TCI) const { diff --git a/lib/Target/AArch64/AArch64InstrInfo.h b/lib/Target/AArch64/AArch64InstrInfo.h index 4165316d124..634aaa21d1b 100644 --- a/lib/Target/AArch64/AArch64InstrInfo.h +++ b/lib/Target/AArch64/AArch64InstrInfo.h @@ -248,9 +248,7 @@ public: outliner::InstrType getOutliningType(MachineBasicBlock::iterator &MIT, unsigned Flags) const override; unsigned getMachineOutlinerMBBFlags(MachineBasicBlock &MBB) const override; - void insertOutlinerEpilogue(MachineBasicBlock &MBB, MachineFunction &MF, - const outliner::TargetCostInfo &TCI) const override; - void insertOutlinerPrologue(MachineBasicBlock &MBB, MachineFunction &MF, + void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, const outliner::TargetCostInfo &TCI) const override; MachineBasicBlock::iterator insertOutlinedCall(Module &M, MachineBasicBlock &MBB, diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index fed66fb9b9d..e618f7cbd48 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -13017,7 +13017,7 @@ X86InstrInfo::getOutliningType(MachineBasicBlock::iterator &MIT, unsigned Flags return outliner::InstrType::Legal; } -void X86InstrInfo::insertOutlinerEpilogue(MachineBasicBlock &MBB, +void X86InstrInfo::buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, const outliner::TargetCostInfo &TCI) const { @@ -13031,11 +13031,6 @@ void X86InstrInfo::insertOutlinerEpilogue(MachineBasicBlock &MBB, MBB.insert(MBB.end(), retq); } -void X86InstrInfo::insertOutlinerPrologue(MachineBasicBlock &MBB, - MachineFunction &MF, - const outliner::TargetCostInfo &TCI) - const {} - MachineBasicBlock::iterator X86InstrInfo::insertOutlinedCall(Module &M, MachineBasicBlock &MBB, MachineBasicBlock::iterator &It, diff --git a/lib/Target/X86/X86InstrInfo.h b/lib/Target/X86/X86InstrInfo.h index 8e502470c66..79f74108694 100644 --- a/lib/Target/X86/X86InstrInfo.h +++ b/lib/Target/X86/X86InstrInfo.h @@ -602,10 +602,7 @@ public: outliner::InstrType getOutliningType(MachineBasicBlock::iterator &MIT, unsigned Flags) const override; - void insertOutlinerEpilogue(MachineBasicBlock &MBB, MachineFunction &MF, - const outliner::TargetCostInfo &TCI) const override; - - void insertOutlinerPrologue(MachineBasicBlock &MBB, MachineFunction &MF, + void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, const outliner::TargetCostInfo &TCI) const override; MachineBasicBlock::iterator