Cache basic block boundaries for faster RegMaskSlots access.
Provide API to get a list of register mask slots and bits in a basic block. llvm-svn: 150219
This commit is contained in:
parent
aa06de2447
commit
25c4195ecc
|
@ -82,6 +82,13 @@ namespace llvm {
|
||||||
/// Also see the comment in LiveInterval::find().
|
/// Also see the comment in LiveInterval::find().
|
||||||
SmallVector<const uint32_t*, 8> RegMaskBits;
|
SmallVector<const uint32_t*, 8> RegMaskBits;
|
||||||
|
|
||||||
|
/// For each basic block number, keep (begin, size) pairs indexing into the
|
||||||
|
/// RegMaskSlots and RegMaskBits arrays.
|
||||||
|
/// Note that basic block numbers may not be layout contiguous, that's why
|
||||||
|
/// we can't just keep track of the first register mask in each basic
|
||||||
|
/// block.
|
||||||
|
SmallVector<std::pair<unsigned, unsigned>, 8> RegMaskBlocks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char ID; // Pass identification, replacement for typeid
|
static char ID; // Pass identification, replacement for typeid
|
||||||
LiveIntervals() : MachineFunctionPass(ID) {
|
LiveIntervals() : MachineFunctionPass(ID) {
|
||||||
|
@ -280,10 +287,29 @@ namespace llvm {
|
||||||
// LiveIntervalAnalysis maintains a sorted list of instructions with
|
// LiveIntervalAnalysis maintains a sorted list of instructions with
|
||||||
// register mask operands.
|
// register mask operands.
|
||||||
|
|
||||||
/// getRegMaskSlots - Returns asorted array of slot indices of all
|
/// getRegMaskSlots - Returns a sorted array of slot indices of all
|
||||||
/// instructions with register mask operands.
|
/// instructions with register mask operands.
|
||||||
ArrayRef<SlotIndex> getRegMaskSlots() const { return RegMaskSlots; }
|
ArrayRef<SlotIndex> getRegMaskSlots() const { return RegMaskSlots; }
|
||||||
|
|
||||||
|
/// getRegMaskSlotsInBlock - Returns a sorted array of slot indices of all
|
||||||
|
/// instructions with register mask operands in the basic block numbered
|
||||||
|
/// MBBNum.
|
||||||
|
ArrayRef<SlotIndex> getRegMaskSlotsInBlock(unsigned MBBNum) const {
|
||||||
|
std::pair<unsigned, unsigned> P = RegMaskBlocks[MBBNum];
|
||||||
|
return getRegMaskSlots().slice(P.first, P.second);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// getRegMaskBits() - Returns an array of register mask pointers
|
||||||
|
/// corresponding to getRegMaskSlots().
|
||||||
|
ArrayRef<const uint32_t*> getRegMaskBits() const { return RegMaskBits; }
|
||||||
|
|
||||||
|
/// getRegMaskBitsInBlock - Returns an array of mask pointers corresponding
|
||||||
|
/// to getRegMaskSlotsInBlock(MBBNum).
|
||||||
|
ArrayRef<const uint32_t*> getRegMaskBitsInBlock(unsigned MBBNum) const {
|
||||||
|
std::pair<unsigned, unsigned> P = RegMaskBlocks[MBBNum];
|
||||||
|
return getRegMaskBits().slice(P.first, P.second);
|
||||||
|
}
|
||||||
|
|
||||||
/// checkRegMaskInterference - Test if LI is live across any register mask
|
/// checkRegMaskInterference - Test if LI is live across any register mask
|
||||||
/// instructions, and compute a bit mask of physical registers that are not
|
/// instructions, and compute a bit mask of physical registers that are not
|
||||||
/// clobbered by any of them.
|
/// clobbered by any of them.
|
||||||
|
|
|
@ -90,6 +90,7 @@ void LiveIntervals::releaseMemory() {
|
||||||
r2iMap_.clear();
|
r2iMap_.clear();
|
||||||
RegMaskSlots.clear();
|
RegMaskSlots.clear();
|
||||||
RegMaskBits.clear();
|
RegMaskBits.clear();
|
||||||
|
RegMaskBlocks.clear();
|
||||||
|
|
||||||
// Release VNInfo memory regions, VNInfo objects don't need to be dtor'd.
|
// Release VNInfo memory regions, VNInfo objects don't need to be dtor'd.
|
||||||
VNInfoAllocator.Reset();
|
VNInfoAllocator.Reset();
|
||||||
|
@ -533,10 +534,14 @@ void LiveIntervals::computeIntervals() {
|
||||||
<< "********** Function: "
|
<< "********** Function: "
|
||||||
<< ((Value*)mf_->getFunction())->getName() << '\n');
|
<< ((Value*)mf_->getFunction())->getName() << '\n');
|
||||||
|
|
||||||
|
RegMaskBlocks.resize(mf_->getNumBlockIDs());
|
||||||
|
|
||||||
SmallVector<unsigned, 8> UndefUses;
|
SmallVector<unsigned, 8> UndefUses;
|
||||||
for (MachineFunction::iterator MBBI = mf_->begin(), E = mf_->end();
|
for (MachineFunction::iterator MBBI = mf_->begin(), E = mf_->end();
|
||||||
MBBI != E; ++MBBI) {
|
MBBI != E; ++MBBI) {
|
||||||
MachineBasicBlock *MBB = MBBI;
|
MachineBasicBlock *MBB = MBBI;
|
||||||
|
RegMaskBlocks[MBB->getNumber()].first = RegMaskSlots.size();
|
||||||
|
|
||||||
if (MBB->empty())
|
if (MBB->empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -587,6 +592,10 @@ void LiveIntervals::computeIntervals() {
|
||||||
// Move to the next instr slot.
|
// Move to the next instr slot.
|
||||||
MIIndex = indexes_->getNextNonNullIndex(MIIndex);
|
MIIndex = indexes_->getNextNonNullIndex(MIIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compute the number of register mask instructions in this block.
|
||||||
|
std::pair<unsigned, unsigned> &RMB = RegMaskBlocks[MBB->getNumber()];
|
||||||
|
RMB.second = RegMaskSlots.size() - RMB.first;;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create empty intervals for registers defined by implicit_def's (except
|
// Create empty intervals for registers defined by implicit_def's (except
|
||||||
|
|
Loading…
Reference in New Issue