|
@@ -396,7 +396,7 @@ bool ARMConstantIslands::runOnMachineFunction(MachineFunction &mf) {
|
|
// Functions with jump tables need an alignment of 4 because they use the ADR
|
|
// Functions with jump tables need an alignment of 4 because they use the ADR
|
|
// instruction, which aligns the PC to 4 bytes before adding an offset.
|
|
// instruction, which aligns the PC to 4 bytes before adding an offset.
|
|
if (!T2JumpTables.empty())
|
|
if (!T2JumpTables.empty())
|
|
- MF->ensureAlignment(2);
|
|
|
|
|
|
+ MF->ensureLogAlignment(2);
|
|
|
|
|
|
/// Remove dead constant pool entries.
|
|
/// Remove dead constant pool entries.
|
|
MadeChange |= removeUnusedCPEntries();
|
|
MadeChange |= removeUnusedCPEntries();
|
|
@@ -486,20 +486,21 @@ ARMConstantIslands::doInitialConstPlacement(std::vector<MachineInstr*> &CPEMIs)
|
|
MF->push_back(BB);
|
|
MF->push_back(BB);
|
|
|
|
|
|
// MachineConstantPool measures alignment in bytes. We measure in log2(bytes).
|
|
// MachineConstantPool measures alignment in bytes. We measure in log2(bytes).
|
|
- unsigned MaxAlign = Log2_32(MCP->getConstantPoolAlignment());
|
|
|
|
|
|
+ unsigned MaxLogAlign = Log2_32(MCP->getConstantPoolAlignment());
|
|
|
|
|
|
// Mark the basic block as required by the const-pool.
|
|
// Mark the basic block as required by the const-pool.
|
|
- BB->setAlignment(MaxAlign);
|
|
|
|
|
|
+ BB->setLogAlignment(MaxLogAlign);
|
|
|
|
|
|
// The function needs to be as aligned as the basic blocks. The linker may
|
|
// The function needs to be as aligned as the basic blocks. The linker may
|
|
// move functions around based on their alignment.
|
|
// move functions around based on their alignment.
|
|
- MF->ensureAlignment(BB->getAlignment());
|
|
|
|
|
|
+ MF->ensureLogAlignment(BB->getLogAlignment());
|
|
|
|
|
|
// Order the entries in BB by descending alignment. That ensures correct
|
|
// Order the entries in BB by descending alignment. That ensures correct
|
|
// alignment of all entries as long as BB is sufficiently aligned. Keep
|
|
// alignment of all entries as long as BB is sufficiently aligned. Keep
|
|
// track of the insertion point for each alignment. We are going to bucket
|
|
// track of the insertion point for each alignment. We are going to bucket
|
|
// sort the entries as they are created.
|
|
// sort the entries as they are created.
|
|
- SmallVector<MachineBasicBlock::iterator, 8> InsPoint(MaxAlign + 1, BB->end());
|
|
|
|
|
|
+ SmallVector<MachineBasicBlock::iterator, 8> InsPoint(MaxLogAlign + 1,
|
|
|
|
+ BB->end());
|
|
|
|
|
|
// Add all of the constants from the constant pool to the end block, use an
|
|
// Add all of the constants from the constant pool to the end block, use an
|
|
// identity mapping of CPI's to CPE's.
|
|
// identity mapping of CPI's to CPE's.
|
|
@@ -524,7 +525,7 @@ ARMConstantIslands::doInitialConstPlacement(std::vector<MachineInstr*> &CPEMIs)
|
|
|
|
|
|
// Ensure that future entries with higher alignment get inserted before
|
|
// Ensure that future entries with higher alignment get inserted before
|
|
// CPEMI. This is bucket sort with iterators.
|
|
// CPEMI. This is bucket sort with iterators.
|
|
- for (unsigned a = LogAlign + 1; a <= MaxAlign; ++a)
|
|
|
|
|
|
+ for (unsigned a = LogAlign + 1; a <= MaxLogAlign; ++a)
|
|
if (InsPoint[a] == InsAt)
|
|
if (InsPoint[a] == InsAt)
|
|
InsPoint[a] = CPEMI;
|
|
InsPoint[a] = CPEMI;
|
|
|
|
|
|
@@ -685,7 +686,7 @@ initializeFunctionInfo(const std::vector<MachineInstr*> &CPEMIs) {
|
|
BBInfoVector &BBInfo = BBUtils->getBBInfo();
|
|
BBInfoVector &BBInfo = BBUtils->getBBInfo();
|
|
// The known bits of the entry block offset are determined by the function
|
|
// The known bits of the entry block offset are determined by the function
|
|
// alignment.
|
|
// alignment.
|
|
- BBInfo.front().KnownBits = MF->getAlignment();
|
|
|
|
|
|
+ BBInfo.front().KnownBits = MF->getLogAlignment();
|
|
|
|
|
|
// Compute block offsets and known bits.
|
|
// Compute block offsets and known bits.
|
|
BBUtils->adjustBBOffsetsAfter(&MF->front());
|
|
BBUtils->adjustBBOffsetsAfter(&MF->front());
|
|
@@ -1015,14 +1016,14 @@ bool ARMConstantIslands::isWaterInRange(unsigned UserOffset,
|
|
BBInfoVector &BBInfo = BBUtils->getBBInfo();
|
|
BBInfoVector &BBInfo = BBUtils->getBBInfo();
|
|
unsigned CPELogAlign = getCPELogAlign(U.CPEMI);
|
|
unsigned CPELogAlign = getCPELogAlign(U.CPEMI);
|
|
unsigned CPEOffset = BBInfo[Water->getNumber()].postOffset(CPELogAlign);
|
|
unsigned CPEOffset = BBInfo[Water->getNumber()].postOffset(CPELogAlign);
|
|
- unsigned NextBlockOffset, NextBlockAlignment;
|
|
|
|
|
|
+ unsigned NextBlockOffset, NextBlockLogAlignment;
|
|
MachineFunction::const_iterator NextBlock = Water->getIterator();
|
|
MachineFunction::const_iterator NextBlock = Water->getIterator();
|
|
if (++NextBlock == MF->end()) {
|
|
if (++NextBlock == MF->end()) {
|
|
NextBlockOffset = BBInfo[Water->getNumber()].postOffset();
|
|
NextBlockOffset = BBInfo[Water->getNumber()].postOffset();
|
|
- NextBlockAlignment = 0;
|
|
|
|
|
|
+ NextBlockLogAlignment = 0;
|
|
} else {
|
|
} else {
|
|
NextBlockOffset = BBInfo[NextBlock->getNumber()].Offset;
|
|
NextBlockOffset = BBInfo[NextBlock->getNumber()].Offset;
|
|
- NextBlockAlignment = NextBlock->getAlignment();
|
|
|
|
|
|
+ NextBlockLogAlignment = NextBlock->getLogAlignment();
|
|
}
|
|
}
|
|
unsigned Size = U.CPEMI->getOperand(2).getImm();
|
|
unsigned Size = U.CPEMI->getOperand(2).getImm();
|
|
unsigned CPEEnd = CPEOffset + Size;
|
|
unsigned CPEEnd = CPEOffset + Size;
|
|
@@ -1034,13 +1035,13 @@ bool ARMConstantIslands::isWaterInRange(unsigned UserOffset,
|
|
Growth = CPEEnd - NextBlockOffset;
|
|
Growth = CPEEnd - NextBlockOffset;
|
|
// Compute the padding that would go at the end of the CPE to align the next
|
|
// Compute the padding that would go at the end of the CPE to align the next
|
|
// block.
|
|
// block.
|
|
- Growth += OffsetToAlignment(CPEEnd, 1ULL << NextBlockAlignment);
|
|
|
|
|
|
+ Growth += OffsetToAlignment(CPEEnd, 1ULL << NextBlockLogAlignment);
|
|
|
|
|
|
// If the CPE is to be inserted before the instruction, that will raise
|
|
// If the CPE is to be inserted before the instruction, that will raise
|
|
// the offset of the instruction. Also account for unknown alignment padding
|
|
// the offset of the instruction. Also account for unknown alignment padding
|
|
// in blocks between CPE and the user.
|
|
// in blocks between CPE and the user.
|
|
if (CPEOffset < UserOffset)
|
|
if (CPEOffset < UserOffset)
|
|
- UserOffset += Growth + UnknownPadding(MF->getAlignment(), CPELogAlign);
|
|
|
|
|
|
+ UserOffset += Growth + UnknownPadding(MF->getLogAlignment(), CPELogAlign);
|
|
} else
|
|
} else
|
|
// CPE fits in existing padding.
|
|
// CPE fits in existing padding.
|
|
Growth = 0;
|
|
Growth = 0;
|
|
@@ -1315,7 +1316,7 @@ void ARMConstantIslands::createNewWater(unsigned CPUserIndex,
|
|
// Try to split the block so it's fully aligned. Compute the latest split
|
|
// Try to split the block so it's fully aligned. Compute the latest split
|
|
// point where we can add a 4-byte branch instruction, and then align to
|
|
// point where we can add a 4-byte branch instruction, and then align to
|
|
// LogAlign which is the largest possible alignment in the function.
|
|
// LogAlign which is the largest possible alignment in the function.
|
|
- unsigned LogAlign = MF->getAlignment();
|
|
|
|
|
|
+ unsigned LogAlign = MF->getLogAlignment();
|
|
assert(LogAlign >= CPELogAlign && "Over-aligned constant pool entry");
|
|
assert(LogAlign >= CPELogAlign && "Over-aligned constant pool entry");
|
|
unsigned KnownBits = UserBBI.internalKnownBits();
|
|
unsigned KnownBits = UserBBI.internalKnownBits();
|
|
unsigned UPad = UnknownPadding(LogAlign, KnownBits);
|
|
unsigned UPad = UnknownPadding(LogAlign, KnownBits);
|
|
@@ -1493,9 +1494,9 @@ bool ARMConstantIslands::handleConstantPoolUser(unsigned CPUserIndex,
|
|
// Always align the new block because CP entries can be smaller than 4
|
|
// Always align the new block because CP entries can be smaller than 4
|
|
// bytes. Be careful not to decrease the existing alignment, e.g. NewMBB may
|
|
// bytes. Be careful not to decrease the existing alignment, e.g. NewMBB may
|
|
// be an already aligned constant pool block.
|
|
// be an already aligned constant pool block.
|
|
- const unsigned Align = isThumb ? 1 : 2;
|
|
|
|
- if (NewMBB->getAlignment() < Align)
|
|
|
|
- NewMBB->setAlignment(Align);
|
|
|
|
|
|
+ const unsigned LogAlign = isThumb ? 1 : 2;
|
|
|
|
+ if (NewMBB->getLogAlignment() < LogAlign)
|
|
|
|
+ NewMBB->setLogAlignment(LogAlign);
|
|
|
|
|
|
// Remove the original WaterList entry; we want subsequent insertions in
|
|
// Remove the original WaterList entry; we want subsequent insertions in
|
|
// this vicinity to go after the one we're about to insert. This
|
|
// this vicinity to go after the one we're about to insert. This
|
|
@@ -1524,7 +1525,7 @@ bool ARMConstantIslands::handleConstantPoolUser(unsigned CPUserIndex,
|
|
decrementCPEReferenceCount(CPI, CPEMI);
|
|
decrementCPEReferenceCount(CPI, CPEMI);
|
|
|
|
|
|
// Mark the basic block as aligned as required by the const-pool entry.
|
|
// Mark the basic block as aligned as required by the const-pool entry.
|
|
- NewIsland->setAlignment(getCPELogAlign(U.CPEMI));
|
|
|
|
|
|
+ NewIsland->setLogAlignment(getCPELogAlign(U.CPEMI));
|
|
|
|
|
|
// Increase the size of the island block to account for the new entry.
|
|
// Increase the size of the island block to account for the new entry.
|
|
BBUtils->adjustBBSize(NewIsland, Size);
|
|
BBUtils->adjustBBSize(NewIsland, Size);
|
|
@@ -1558,10 +1559,10 @@ void ARMConstantIslands::removeDeadCPEMI(MachineInstr *CPEMI) {
|
|
BBInfo[CPEBB->getNumber()].Size = 0;
|
|
BBInfo[CPEBB->getNumber()].Size = 0;
|
|
|
|
|
|
// This block no longer needs to be aligned.
|
|
// This block no longer needs to be aligned.
|
|
- CPEBB->setAlignment(0);
|
|
|
|
|
|
+ CPEBB->setLogAlignment(0);
|
|
} else
|
|
} else
|
|
// Entries are sorted by descending alignment, so realign from the front.
|
|
// Entries are sorted by descending alignment, so realign from the front.
|
|
- CPEBB->setAlignment(getCPELogAlign(&*CPEBB->begin()));
|
|
|
|
|
|
+ CPEBB->setLogAlignment(getCPELogAlign(&*CPEBB->begin()));
|
|
|
|
|
|
BBUtils->adjustBBOffsetsAfter(CPEBB);
|
|
BBUtils->adjustBBOffsetsAfter(CPEBB);
|
|
// An island has only one predecessor BB and one successor BB. Check if
|
|
// An island has only one predecessor BB and one successor BB. Check if
|