diff options
author | Jessica Paquette <jpaquette@apple.com> | 2018-07-24 20:13:10 +0000 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2018-07-24 20:13:10 +0000 |
commit | f7aac255f9dbd48446c6d83e23c7848fab1c9735 (patch) | |
tree | 59955f8aa387da5c8ce0a69bdc07dae2b2b9f124 /llvm/lib/Target | |
parent | b781a7a2a88401689906fd22883c446a3a88752d (diff) |
[MachineOutliner][NFC] Move target frame info into OutlinedFunction
Just some gardening here.
Similar to how we moved call information into Candidates, this moves outlined
frame information into OutlinedFunction. This allows us to remove
TargetCostInfo entirely.
Anywhere where we returned a TargetCostInfo struct, we now return an
OutlinedFunction. This establishes OutlinedFunctions as more of a general
repeated sequence, and Candidates as occurrences of those repeated sequences.
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 21 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.h | 4 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86InstrInfo.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/Target/X86/X86InstrInfo.h | 4 |
4 files changed, 23 insertions, 21 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index 9d163487c44..dc3fa4f8c1d 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -4927,7 +4927,7 @@ enum MachineOutlinerMBBFlags { HasCalls = 0x4 }; -outliner::TargetCostInfo +outliner::OutlinedFunction AArch64InstrInfo::getOutliningCandidateInfo( std::vector<outliner::Candidate> &RepeatedSequenceLocs) const { unsigned SequenceSize = std::accumulate( @@ -5034,7 +5034,8 @@ AArch64InstrInfo::getOutliningCandidateInfo( RepeatedSequenceLocs[0].back()->isCall()) NumBytesToCreateFrame += 8; - return outliner::TargetCostInfo(SequenceSize, NumBytesToCreateFrame, FrameID); + return outliner::OutlinedFunction(RepeatedSequenceLocs, SequenceSize, + NumBytesToCreateFrame, FrameID); } bool AArch64InstrInfo::isFunctionSafeToOutlineFrom( @@ -5332,10 +5333,10 @@ void AArch64InstrInfo::fixupPostOutline(MachineBasicBlock &MBB) const { void AArch64InstrInfo::buildOutlinedFrame( MachineBasicBlock &MBB, MachineFunction &MF, - const outliner::TargetCostInfo &TCI) const { + const outliner::OutlinedFunction &OF) const { // For thunk outlining, rewrite the last instruction from a call to a // tail-call. - if (TCI.FrameConstructionID == MachineOutlinerThunk) { + if (OF.FrameConstructionID == MachineOutlinerThunk) { MachineInstr *Call = &*--MBB.instr_end(); unsigned TailOpcode; if (Call->getOpcode() == AArch64::BL) { @@ -5358,7 +5359,7 @@ void AArch64InstrInfo::buildOutlinedFrame( if (std::any_of(MBB.instr_begin(), MBB.instr_end(), IsNonTailCall)) { // Fix up the instructions in the range, since we're going to modify the // stack. - assert(TCI.FrameConstructionID != MachineOutlinerDefault && + assert(OF.FrameConstructionID != MachineOutlinerDefault && "Can only fix up stack references once"); fixupPostOutline(MBB); @@ -5368,8 +5369,8 @@ void AArch64InstrInfo::buildOutlinedFrame( MachineBasicBlock::iterator It = MBB.begin(); MachineBasicBlock::iterator Et = MBB.end(); - if (TCI.FrameConstructionID == MachineOutlinerTailCall || - TCI.FrameConstructionID == MachineOutlinerThunk) + if (OF.FrameConstructionID == MachineOutlinerTailCall || + OF.FrameConstructionID == MachineOutlinerThunk) Et = std::prev(MBB.end()); // Insert a save before the outlined region @@ -5409,8 +5410,8 @@ void AArch64InstrInfo::buildOutlinedFrame( } // If this is a tail call outlined function, then there's already a return. - if (TCI.FrameConstructionID == MachineOutlinerTailCall || - TCI.FrameConstructionID == MachineOutlinerThunk) + if (OF.FrameConstructionID == MachineOutlinerTailCall || + OF.FrameConstructionID == MachineOutlinerThunk) return; // It's not a tail call, so we have to insert the return ourselves. @@ -5419,7 +5420,7 @@ void AArch64InstrInfo::buildOutlinedFrame( MBB.insert(MBB.end(), ret); // Did we have to modify the stack by saving the link register? - if (TCI.FrameConstructionID == MachineOutlinerNoLRSave) + if (OF.FrameConstructionID == MachineOutlinerNoLRSave) return; // We modified the stack. diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.h b/llvm/lib/Target/AArch64/AArch64InstrInfo.h index 7249657eca3..0e5953f6216 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.h +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.h @@ -238,13 +238,13 @@ public: bool isFunctionSafeToOutlineFrom(MachineFunction &MF, bool OutlineFromLinkOnceODRs) const override; - outliner::TargetCostInfo getOutliningCandidateInfo( + outliner::OutlinedFunction getOutliningCandidateInfo( std::vector<outliner::Candidate> &RepeatedSequenceLocs) const override; outliner::InstrType getOutliningType(MachineBasicBlock::iterator &MIT, unsigned Flags) const override; unsigned getMachineOutlinerMBBFlags(MachineBasicBlock &MBB) const override; void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, - const outliner::TargetCostInfo &TCI) const override; + const outliner::OutlinedFunction &OF) const override; MachineBasicBlock::iterator insertOutlinedCall(Module &M, MachineBasicBlock &MBB, MachineBasicBlock::iterator &It, MachineFunction &MF, diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp index 5a0a0ecd066..1b61accfb42 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.cpp +++ b/llvm/lib/Target/X86/X86InstrInfo.cpp @@ -7588,7 +7588,7 @@ enum MachineOutlinerClass { MachineOutlinerTailCall }; -outliner::TargetCostInfo X86InstrInfo::getOutliningCandidateInfo( +outliner::OutlinedFunction X86InstrInfo::getOutliningCandidateInfo( std::vector<outliner::Candidate> &RepeatedSequenceLocs) const { unsigned SequenceSize = std::accumulate(RepeatedSequenceLocs[0].front(), @@ -7607,16 +7607,17 @@ outliner::TargetCostInfo X86InstrInfo::getOutliningCandidateInfo( for (outliner::Candidate &C : RepeatedSequenceLocs) C.setCallInfo(MachineOutlinerTailCall, 1); - return outliner::TargetCostInfo(SequenceSize, - 0, // Number of bytes to emit frame. - MachineOutlinerTailCall // Type of frame. + return outliner::OutlinedFunction(RepeatedSequenceLocs, SequenceSize, + 0, // Number of bytes to emit frame. + MachineOutlinerTailCall // Type of frame. ); } for (outliner::Candidate &C : RepeatedSequenceLocs) C.setCallInfo(MachineOutlinerDefault, 1); - return outliner::TargetCostInfo(SequenceSize, 1, MachineOutlinerDefault); + return outliner::OutlinedFunction(RepeatedSequenceLocs, SequenceSize, 1, + MachineOutlinerDefault); } bool X86InstrInfo::isFunctionSafeToOutlineFrom(MachineFunction &MF, @@ -7703,10 +7704,10 @@ X86InstrInfo::getOutliningType(MachineBasicBlock::iterator &MIT, unsigned Flags void X86InstrInfo::buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, - const outliner::TargetCostInfo &TCI) + const outliner::OutlinedFunction &OF) const { // If we're a tail call, we already have a return, so don't do anything. - if (TCI.FrameConstructionID == MachineOutlinerTailCall) + if (OF.FrameConstructionID == MachineOutlinerTailCall) return; // We're a normal call, so our sequence doesn't have a return instruction. diff --git a/llvm/lib/Target/X86/X86InstrInfo.h b/llvm/lib/Target/X86/X86InstrInfo.h index b1e510ae059..b1ceb767cce 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.h +++ b/llvm/lib/Target/X86/X86InstrInfo.h @@ -544,7 +544,7 @@ public: ArrayRef<std::pair<unsigned, const char *>> getSerializableDirectMachineOperandTargetFlags() const override; - virtual outliner::TargetCostInfo getOutliningCandidateInfo( + virtual outliner::OutlinedFunction getOutliningCandidateInfo( std::vector<outliner::Candidate> &RepeatedSequenceLocs) const override; bool isFunctionSafeToOutlineFrom(MachineFunction &MF, @@ -554,7 +554,7 @@ public: getOutliningType(MachineBasicBlock::iterator &MIT, unsigned Flags) const override; void buildOutlinedFrame(MachineBasicBlock &MBB, MachineFunction &MF, - const outliner::TargetCostInfo &TCI) const override; + const outliner::OutlinedFunction &OF) const override; MachineBasicBlock::iterator insertOutlinedCall(Module &M, MachineBasicBlock &MBB, |