mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
[RegisterBankInfo] Avoid heap allocation in most cases.
The OperandsMapper class is used heavy in RegBankSelect and each instantiation triggered a heap allocation for the array of operands. Instead, use a SmallVector with a big enough size such that most of the cases do not have to use dynamically allocated memory. This improves the compile time of the RegBankSelect pass. llvm-svn: 281916
This commit is contained in:
parent
c02cdc0d60
commit
b578cb62bb
@ -193,7 +193,8 @@ public:
|
||||
class OperandsMapper {
|
||||
/// The OpIdx-th cell contains the index in NewVRegs where the VRegs of the
|
||||
/// OpIdx-th operand starts. -1 means we do not have such mapping yet.
|
||||
std::unique_ptr<int[]> OpToNewVRegIdx;
|
||||
/// Note: We use a SmallVector to avoid heap allocation for most cases.
|
||||
SmallVector<int, 8> OpToNewVRegIdx;
|
||||
/// Hold the registers that will be used to map MI with InstrMapping.
|
||||
SmallVector<unsigned, 8> NewVRegs;
|
||||
/// Current MachineRegisterInfo, used to create new virtual registers.
|
||||
|
@ -513,7 +513,7 @@ RegisterBankInfo::OperandsMapper::OperandsMapper(
|
||||
MachineRegisterInfo &MRI)
|
||||
: MRI(MRI), MI(MI), InstrMapping(InstrMapping) {
|
||||
unsigned NumOpds = MI.getNumOperands();
|
||||
OpToNewVRegIdx.reset(new int[NumOpds]);
|
||||
OpToNewVRegIdx.resize(NumOpds);
|
||||
std::fill(&OpToNewVRegIdx[0], &OpToNewVRegIdx[NumOpds],
|
||||
OperandsMapper::DontKnowIdx);
|
||||
assert(InstrMapping.verify(MI) && "Invalid mapping for MI");
|
||||
|
Loading…
Reference in New Issue
Block a user