1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-18 18:42:46 +02:00

Prune two MachineInstr.h includes, fix up deps

MachineInstr.h included AliasAnalysis.h, which includes a world of IR
constructs mostly unneeded in CodeGen. Prune it. Same for
DebugInfoMetadata.h.

Noticed with -ftime-trace.

llvm-svn: 375311
This commit is contained in:
Reid Kleckner 2019-10-19 00:22:07 +00:00
parent 8e7a1a8142
commit 02a07ff3cc
23 changed files with 52 additions and 36 deletions

View File

@ -144,7 +144,7 @@ class VLIWPacketizerList {
protected: protected:
MachineFunction &MF; MachineFunction &MF;
const TargetInstrInfo *TII; const TargetInstrInfo *TII;
AliasAnalysis *AA; AAResults *AA;
// The VLIW Scheduler. // The VLIW Scheduler.
DefaultVLIWScheduler *VLIWScheduler; DefaultVLIWScheduler *VLIWScheduler;
@ -156,9 +156,9 @@ protected:
std::map<MachineInstr*, SUnit*> MIToSUnit; std::map<MachineInstr*, SUnit*> MIToSUnit;
public: public:
// The AliasAnalysis parameter can be nullptr. // The AAResults parameter can be nullptr.
VLIWPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, VLIWPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI,
AliasAnalysis *AA); AAResults *AA);
virtual ~VLIWPacketizerList(); virtual ~VLIWPacketizerList();

View File

@ -20,11 +20,9 @@
#include "llvm/ADT/ilist.h" #include "llvm/ADT/ilist.h"
#include "llvm/ADT/ilist_node.h" #include "llvm/ADT/ilist_node.h"
#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/iterator_range.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/CodeGen/MachineMemOperand.h" #include "llvm/CodeGen/MachineMemOperand.h"
#include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/TargetOpcodes.h" #include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h" #include "llvm/IR/DebugLoc.h"
#include "llvm/IR/InlineAsm.h" #include "llvm/IR/InlineAsm.h"
#include "llvm/MC/MCInstrDesc.h" #include "llvm/MC/MCInstrDesc.h"
@ -38,6 +36,7 @@
namespace llvm { namespace llvm {
class AAResults;
template <typename T> class ArrayRef; template <typename T> class ArrayRef;
class DIExpression; class DIExpression;
class DILocalVariable; class DILocalVariable;
@ -1043,9 +1042,7 @@ public:
/// A DBG_VALUE is an entry value iff its debug expression contains the /// A DBG_VALUE is an entry value iff its debug expression contains the
/// DW_OP_LLVM_entry_value operation. /// DW_OP_LLVM_entry_value operation.
bool isDebugEntryValue() const { bool isDebugEntryValue() const;
return isDebugValue() && getDebugExpression()->isEntryValue();
}
/// Return true if the instruction is a debug value which describes a part of /// Return true if the instruction is a debug value which describes a part of
/// a variable as unavailable. /// a variable as unavailable.
@ -1414,7 +1411,7 @@ public:
/// Return true if it is safe to move this instruction. If /// Return true if it is safe to move this instruction. If
/// SawStore is set to true, it means that there is a store (or call) between /// SawStore is set to true, it means that there is a store (or call) between
/// the instruction's location and its intended destination. /// the instruction's location and its intended destination.
bool isSafeToMove(AliasAnalysis *AA, bool &SawStore) const; bool isSafeToMove(AAResults *AA, bool &SawStore) const;
/// Returns true if this instruction's memory access aliases the memory /// Returns true if this instruction's memory access aliases the memory
/// access of Other. /// access of Other.
@ -1426,7 +1423,7 @@ public:
/// @param AA Optional alias analysis, used to compare memory operands. /// @param AA Optional alias analysis, used to compare memory operands.
/// @param Other MachineInstr to check aliasing against. /// @param Other MachineInstr to check aliasing against.
/// @param UseTBAA Whether to pass TBAA information to alias analysis. /// @param UseTBAA Whether to pass TBAA information to alias analysis.
bool mayAlias(AliasAnalysis *AA, const MachineInstr &Other, bool UseTBAA) const; bool mayAlias(AAResults *AA, const MachineInstr &Other, bool UseTBAA) const;
/// Return true if this instruction may have an ordered /// Return true if this instruction may have an ordered
/// or volatile memory reference, or if the information describing the memory /// or volatile memory reference, or if the information describing the memory
@ -1441,7 +1438,7 @@ public:
/// argument area of a function (if it does not change). If the instruction /// argument area of a function (if it does not change). If the instruction
/// does multiple loads, this returns true only if all of the loads are /// does multiple loads, this returns true only if all of the loads are
/// dereferenceable and invariant. /// dereferenceable and invariant.
bool isDereferenceableInvariantLoad(AliasAnalysis *AA) const; bool isDereferenceableInvariantLoad(AAResults *AA) const;
/// If the specified instruction is a PHI that always merges together the /// If the specified instruction is a PHI that always merges together the
/// same virtual register, return the register, otherwise return 0. /// same virtual register, return the register, otherwise return 0.

View File

@ -367,17 +367,7 @@ public:
/// Check if given function is safe for not having callee saved registers. /// Check if given function is safe for not having callee saved registers.
/// This is used when interprocedural register allocation is enabled. /// This is used when interprocedural register allocation is enabled.
static bool isSafeForNoCSROpt(const Function &F) { static bool isSafeForNoCSROpt(const Function &F);
if (!F.hasLocalLinkage() || F.hasAddressTaken() ||
!F.hasFnAttribute(Attribute::NoRecurse))
return false;
// Function should not be optimized as tail call.
for (const User *U : F.users())
if (auto CS = ImmutableCallSite(U))
if (CS.isTailCall())
return false;
return true;
}
/// Check if the no-CSR optimisation is profitable for the given function. /// Check if the no-CSR optimisation is profitable for the given function.
virtual bool isProfitableForNoCSROpt(const Function &F) const { virtual bool isProfitableForNoCSROpt(const Function &F) const {

View File

@ -39,6 +39,7 @@
namespace llvm { namespace llvm {
class AAResults;
class DFAPacketizer; class DFAPacketizer;
class InstrItineraryData; class InstrItineraryData;
class LiveIntervals; class LiveIntervals;
@ -95,7 +96,7 @@ public:
/// registers so that the instructions result is independent of the place /// registers so that the instructions result is independent of the place
/// in the function. /// in the function.
bool isTriviallyReMaterializable(const MachineInstr &MI, bool isTriviallyReMaterializable(const MachineInstr &MI,
AliasAnalysis *AA = nullptr) const { AAResults *AA = nullptr) const {
return MI.getOpcode() == TargetOpcode::IMPLICIT_DEF || return MI.getOpcode() == TargetOpcode::IMPLICIT_DEF ||
(MI.getDesc().isRematerializable() && (MI.getDesc().isRematerializable() &&
(isReallyTriviallyReMaterializable(MI, AA) || (isReallyTriviallyReMaterializable(MI, AA) ||
@ -111,7 +112,7 @@ protected:
/// not always available. /// not always available.
/// Requirements must be check as stated in isTriviallyReMaterializable() . /// Requirements must be check as stated in isTriviallyReMaterializable() .
virtual bool isReallyTriviallyReMaterializable(const MachineInstr &MI, virtual bool isReallyTriviallyReMaterializable(const MachineInstr &MI,
AliasAnalysis *AA) const { AAResults *AA) const {
return false; return false;
} }
@ -154,7 +155,7 @@ private:
/// this function does target-independent tests to determine if the /// this function does target-independent tests to determine if the
/// instruction is really trivially rematerializable. /// instruction is really trivially rematerializable.
bool isReallyTriviallyReMaterializableGeneric(const MachineInstr &MI, bool isReallyTriviallyReMaterializableGeneric(const MachineInstr &MI,
AliasAnalysis *AA) const; AAResults *AA) const;
public: public:
/// These methods return the opcode of the frame setup/destroy instructions /// These methods return the opcode of the frame setup/destroy instructions

View File

@ -12,6 +12,7 @@
#include "llvm/CodeGen/GlobalISel/RegisterBank.h" #include "llvm/CodeGen/GlobalISel/RegisterBank.h"
#include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/Config/llvm-config.h" #include "llvm/Config/llvm-config.h"
#include "llvm/Support/Debug.h"
#define DEBUG_TYPE "registerbank" #define DEBUG_TYPE "registerbank"

View File

@ -21,6 +21,7 @@
#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Config/llvm-config.h" #include "llvm/Config/llvm-config.h"
#include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Metadata.h" #include "llvm/IR/Metadata.h"
#include "llvm/Support/Casting.h" #include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"

View File

@ -26,6 +26,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/CodeGen/LiveVariables.h" #include "llvm/CodeGen/LiveVariables.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/DepthFirstIterator.h" #include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallPtrSet.h"

View File

@ -30,6 +30,7 @@
#include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/Passes.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include <queue> #include <queue>

View File

@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "MIRVRegNamerUtils.h" #include "MIRVRegNamerUtils.h"
#include "llvm/Support/Debug.h"
using namespace llvm; using namespace llvm;

View File

@ -832,6 +832,10 @@ const DIExpression *MachineInstr::getDebugExpression() const {
return cast<DIExpression>(getOperand(3).getMetadata()); return cast<DIExpression>(getOperand(3).getMetadata());
} }
bool MachineInstr::isDebugEntryValue() const {
return isDebugValue() && getDebugExpression()->isEntryValue();
}
const TargetRegisterClass* const TargetRegisterClass*
MachineInstr::getRegClassConstraint(unsigned OpIdx, MachineInstr::getRegClassConstraint(unsigned OpIdx,
const TargetInstrInfo *TII, const TargetInstrInfo *TII,
@ -1164,7 +1168,7 @@ void MachineInstr::substituteRegister(Register FromReg, Register ToReg,
/// isSafeToMove - Return true if it is safe to move this instruction. If /// isSafeToMove - Return true if it is safe to move this instruction. If
/// SawStore is set to true, it means that there is a store (or call) between /// SawStore is set to true, it means that there is a store (or call) between
/// the instruction's location and its intended destination. /// the instruction's location and its intended destination.
bool MachineInstr::isSafeToMove(AliasAnalysis *AA, bool &SawStore) const { bool MachineInstr::isSafeToMove(AAResults *AA, bool &SawStore) const {
// Ignore stuff that we obviously can't move. // Ignore stuff that we obviously can't move.
// //
// Treat volatile loads as stores. This is not strictly necessary for // Treat volatile loads as stores. This is not strictly necessary for
@ -1193,7 +1197,7 @@ bool MachineInstr::isSafeToMove(AliasAnalysis *AA, bool &SawStore) const {
return true; return true;
} }
bool MachineInstr::mayAlias(AliasAnalysis *AA, const MachineInstr &Other, bool MachineInstr::mayAlias(AAResults *AA, const MachineInstr &Other,
bool UseTBAA) const { bool UseTBAA) const {
const MachineFunction *MF = getMF(); const MachineFunction *MF = getMF();
const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo(); const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
@ -1311,7 +1315,7 @@ bool MachineInstr::hasOrderedMemoryRef() const {
/// isDereferenceableInvariantLoad - Return true if this instruction will never /// isDereferenceableInvariantLoad - Return true if this instruction will never
/// trap and is loading from a location whose value is invariant across a run of /// trap and is loading from a location whose value is invariant across a run of
/// this function. /// this function.
bool MachineInstr::isDereferenceableInvariantLoad(AliasAnalysis *AA) const { bool MachineInstr::isDereferenceableInvariantLoad(AAResults *AA) const {
// If the instruction doesn't load at all, it isn't an invariant load. // If the instruction doesn't load at all, it isn't an invariant load.
if (!mayLoad()) if (!mayLoad())
return false; return false;

View File

@ -9,6 +9,7 @@
#include "llvm/CodeGen/ReachingDefAnalysis.h" #include "llvm/CodeGen/ReachingDefAnalysis.h"
#include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/Support/Debug.h"
using namespace llvm; using namespace llvm;

View File

@ -18,6 +18,7 @@
#include "llvm/CodeGen/TargetRegisterInfo.h" #include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h" #include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/IR/Attributes.h" #include "llvm/IR/Attributes.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/CallingConv.h" #include "llvm/IR/CallingConv.h"
#include "llvm/IR/Function.h" #include "llvm/IR/Function.h"
#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCRegisterInfo.h"
@ -120,6 +121,18 @@ unsigned TargetFrameLowering::getStackAlignmentSkew(
return 0; return 0;
} }
bool TargetFrameLowering::isSafeForNoCSROpt(const Function &F) {
if (!F.hasLocalLinkage() || F.hasAddressTaken() ||
!F.hasFnAttribute(Attribute::NoRecurse))
return false;
// Function should not be optimized as tail call.
for (const User *U : F.users())
if (auto CS = ImmutableCallSite(U))
if (CS.isTailCall())
return false;
return true;
}
int TargetFrameLowering::getInitialCFAOffset(const MachineFunction &MF) const { int TargetFrameLowering::getInitialCFAOffset(const MachineFunction &MF) const {
llvm_unreachable("getInitialCFAOffset() not implemented!"); llvm_unreachable("getInitialCFAOffset() not implemented!");
} }
@ -127,4 +140,4 @@ int TargetFrameLowering::getInitialCFAOffset(const MachineFunction &MF) const {
unsigned TargetFrameLowering::getInitialCFARegister(const MachineFunction &MF) unsigned TargetFrameLowering::getInitialCFARegister(const MachineFunction &MF)
const { const {
llvm_unreachable("getInitialCFARegister() not implemented!"); llvm_unreachable("getInitialCFARegister() not implemented!");
} }

View File

@ -19,6 +19,7 @@
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/CallingConvLower.h" #include "llvm/CodeGen/CallingConvLower.h"
#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunction.h"
#include "llvm/IR/Function.h"
#include "llvm/MC/MCLinkerOptimizationHint.h" #include "llvm/MC/MCLinkerOptimizationHint.h"
#include <cassert> #include <cassert>

View File

@ -173,7 +173,7 @@ public:
} }
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, bool isReallyTriviallyReMaterializable(const MachineInstr &MI,
AliasAnalysis *AA) const override; AAResults *AA) const override;
bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2, bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2,
int64_t &Offset1, int64_t &Offset1,

View File

@ -21,6 +21,8 @@
#include "SIDefines.h" #include "SIDefines.h"
#include "llvm/BinaryFormat/ELF.h" #include "llvm/BinaryFormat/ELF.h"
#include "llvm/IR/CallingConv.h" #include "llvm/IR/CallingConv.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/AMDGPUMetadata.h" #include "llvm/Support/AMDGPUMetadata.h"
#include "llvm/Support/EndianStream.h" #include "llvm/Support/EndianStream.h"

View File

@ -17,6 +17,7 @@
#include "llvm/IR/Constant.h" #include "llvm/IR/Constant.h"
#include "llvm/IR/Constants.h" #include "llvm/IR/Constants.h"
#include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Type.h" #include "llvm/IR/Type.h"
#include "llvm/Support/Casting.h" #include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h" #include "llvm/Support/Compiler.h"

View File

@ -130,7 +130,7 @@ INITIALIZE_PASS_END(HexagonPacketizer, "hexagon-packetizer",
"Hexagon Packetizer", false, false) "Hexagon Packetizer", false, false)
HexagonPacketizerList::HexagonPacketizerList(MachineFunction &MF, HexagonPacketizerList::HexagonPacketizerList(MachineFunction &MF,
MachineLoopInfo &MLI, AliasAnalysis *AA, MachineLoopInfo &MLI, AAResults *AA,
const MachineBranchProbabilityInfo *MBPI, bool Minimal) const MachineBranchProbabilityInfo *MBPI, bool Minimal)
: VLIWPacketizerList(MF, MLI, AA), MBPI(MBPI), MLI(&MLI), : VLIWPacketizerList(MF, MLI, AA), MBPI(MBPI), MLI(&MLI),
Minimal(Minimal) { Minimal(Minimal) {

View File

@ -69,8 +69,7 @@ private:
public: public:
HexagonPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, HexagonPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI,
AliasAnalysis *AA, AAResults *AA, const MachineBranchProbabilityInfo *MBPI,
const MachineBranchProbabilityInfo *MBPI,
bool Minimal); bool Minimal);
// initPacketizerState - initialize some internal flags. // initPacketizerState - initialize some internal flags.

View File

@ -16,6 +16,7 @@
#include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Support/Debug.h"
#include <queue> #include <queue>

View File

@ -248,7 +248,7 @@ public:
unsigned isLoadFromStackSlot(const MachineInstr &MI, unsigned isLoadFromStackSlot(const MachineInstr &MI,
int &FrameIndex) const override; int &FrameIndex) const override;
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, bool isReallyTriviallyReMaterializable(const MachineInstr &MI,
AliasAnalysis *AA) const override; AAResults *AA) const override;
unsigned isStoreToStackSlot(const MachineInstr &MI, unsigned isStoreToStackSlot(const MachineInstr &MI,
int &FrameIndex) const override; int &FrameIndex) const override;

View File

@ -43,7 +43,7 @@ public:
const WebAssemblyRegisterInfo &getRegisterInfo() const { return RI; } const WebAssemblyRegisterInfo &getRegisterInfo() const { return RI; }
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, bool isReallyTriviallyReMaterializable(const MachineInstr &MI,
AliasAnalysis *AA) const override; AAResults *AA) const override;
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg,

View File

@ -206,7 +206,7 @@ public:
int &FrameIndex) const override; int &FrameIndex) const override;
bool isReallyTriviallyReMaterializable(const MachineInstr &MI, bool isReallyTriviallyReMaterializable(const MachineInstr &MI,
AliasAnalysis *AA) const override; AAResults *AA) const override;
void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, void reMaterialize(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI,
unsigned DestReg, unsigned SubIdx, unsigned DestReg, unsigned SubIdx,
const MachineInstr &Orig, const MachineInstr &Orig,

View File

@ -10,6 +10,7 @@
#include "SnippetRepetitor.h" #include "SnippetRepetitor.h"
#include "Target.h" #include "Target.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/CodeGen/GlobalISel/CallLowering.h" #include "llvm/CodeGen/GlobalISel/CallLowering.h"
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h" #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineInstrBuilder.h"