[LiveVariables] Replace std::vector with SmallVector.

Replace std::vector with SmallVector to reduce the number of mallocs.
This method is frequently executed, and the number of elements in the
vector is typically small.

https://reviews.llvm.org/D83920
This commit is contained in:
Nadav Rotem 2020-07-15 17:12:48 -07:00
parent ecb2e5bcd7
commit a394aa1b97
2 changed files with 7 additions and 7 deletions

View File

@ -274,9 +274,10 @@ public:
void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock, void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock,
MachineBasicBlock *BB); MachineBasicBlock *BB);
void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock, void MarkVirtRegAliveInBlock(VarInfo &VRInfo, MachineBasicBlock *DefBlock,
MachineBasicBlock *BB, MachineBasicBlock *BB,
std::vector<MachineBasicBlock*> &WorkList); SmallVectorImpl<MachineBasicBlock *> &WorkList);
void HandleVirtRegDef(unsigned reg, MachineInstr &MI); void HandleVirtRegDef(unsigned reg, MachineInstr &MI);
void HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB, MachineInstr &MI); void HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB, MachineInstr &MI);

View File

@ -89,10 +89,9 @@ LiveVariables::VarInfo &LiveVariables::getVarInfo(unsigned RegIdx) {
return VirtRegInfo[RegIdx]; return VirtRegInfo[RegIdx];
} }
void LiveVariables::MarkVirtRegAliveInBlock(VarInfo& VRInfo, void LiveVariables::MarkVirtRegAliveInBlock(
MachineBasicBlock *DefBlock, VarInfo &VRInfo, MachineBasicBlock *DefBlock, MachineBasicBlock *MBB,
MachineBasicBlock *MBB, SmallVectorImpl<MachineBasicBlock *> &WorkList) {
std::vector<MachineBasicBlock*> &WorkList) {
unsigned BBNum = MBB->getNumber(); unsigned BBNum = MBB->getNumber();
// Check to see if this basic block is one of the killing blocks. If so, // Check to see if this basic block is one of the killing blocks. If so,
@ -118,7 +117,7 @@ void LiveVariables::MarkVirtRegAliveInBlock(VarInfo& VRInfo,
void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo, void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo,
MachineBasicBlock *DefBlock, MachineBasicBlock *DefBlock,
MachineBasicBlock *MBB) { MachineBasicBlock *MBB) {
std::vector<MachineBasicBlock*> WorkList; SmallVector<MachineBasicBlock *, 16> WorkList;
MarkVirtRegAliveInBlock(VRInfo, DefBlock, MBB, WorkList); MarkVirtRegAliveInBlock(VRInfo, DefBlock, MBB, WorkList);
while (!WorkList.empty()) { while (!WorkList.empty()) {