class RegScavenger;
class VirtRegMap;
class LiveIntervals;
+class LiveInterval;
class TargetRegisterClass {
public:
LiveIntervals &LIS) const
{ return true; }
+ /// Region split has a high compile time cost especially for large live range.
+ /// This method is used to decide whether or not \p VirtReg should
+ /// go through this expensive splitting heuristic.
+ virtual bool shouldRegionSplitForVirtReg(const MachineFunction &MF,
+ const LiveInterval &VirtReg) const;
+
//===--------------------------------------------------------------------===//
/// Debug information queries.
"variable because of other evicted variables."),
cl::init(false));
-static cl::opt<unsigned>
- HugeSizeForSplit("huge-size-for-split", cl::Hidden,
- cl::desc("A threshold of live range size which may cause "
- "high compile time cost in global splitting."),
- cl::init(5000));
-
// FIXME: Find a good default for this flag and remove the flag.
static cl::opt<unsigned>
CSRFirstTimeCost("regalloc-csr-first-time-cost",
const SmallVirtRegSet&);
unsigned tryRegionSplit(LiveInterval&, AllocationOrder&,
SmallVectorImpl<unsigned>&);
- unsigned isSplitBenefitWorthCost(LiveInterval &VirtReg);
/// Calculate cost of region splitting.
unsigned calculateRegionSplitCost(LiveInterval &VirtReg,
AllocationOrder &Order,
MF->verify(this, "After splitting live range around region");
}
-// Global split has high compile time cost especially for large live range.
-// Return false for the case here where the potential benefit will never
-// worth the cost.
-unsigned RAGreedy::isSplitBenefitWorthCost(LiveInterval &VirtReg) {
- MachineInstr *MI = MRI->getUniqueVRegDef(VirtReg.reg);
- if (MI && TII->isTriviallyReMaterializable(*MI, AA) &&
- VirtReg.size() > HugeSizeForSplit)
- return false;
- return true;
-}
-
unsigned RAGreedy::tryRegionSplit(LiveInterval &VirtReg, AllocationOrder &Order,
SmallVectorImpl<unsigned> &NewVRegs) {
- if (!isSplitBenefitWorthCost(VirtReg))
+ if (!TRI->shouldRegionSplitForVirtReg(*MF, VirtReg))
return 0;
unsigned NumCands = 0;
BlockFrequency SpillCost = calcSpillCost();
#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
-#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/CodeGen/LiveInterval.h"
#include "llvm/CodeGen/TargetFrameLowering.h"
+#include "llvm/CodeGen/TargetInstrInfo.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/CodeGen/VirtRegMap.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Function.h"
#include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MachineValueType.h"
using namespace llvm;
+static cl::opt<unsigned>
+ HugeSizeForSplit("huge-size-for-split", cl::Hidden,
+ cl::desc("A threshold of live range size which may cause "
+ "high compile time cost in global splitting."),
+ cl::init(5000));
+
TargetRegisterInfo::TargetRegisterInfo(const TargetRegisterInfoDesc *ID,
regclass_iterator RCB, regclass_iterator RCE,
const char *const *SRINames,
TargetRegisterInfo::~TargetRegisterInfo() = default;
+bool TargetRegisterInfo::shouldRegionSplitForVirtReg(
+ const MachineFunction &MF, const LiveInterval &VirtReg) const {
+ const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
+ const MachineRegisterInfo &MRI = MF.getRegInfo();
+ MachineInstr *MI = MRI.getUniqueVRegDef(VirtReg.reg);
+ if (MI && TII->isTriviallyReMaterializable(*MI) &&
+ VirtReg.size() > HugeSizeForSplit)
+ return false;
+ return true;
+}
+
void TargetRegisterInfo::markSuperRegs(BitVector &RegisterSet, unsigned Reg)
const {
for (MCSuperRegIterator AI(Reg, this, true); AI.isValid(); ++AI)