[PATCH] D83920: [LiveVariables] Replace std::vector with SmallVector.
Nadav Rotem via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 15 16:57:53 PDT 2020
nadav created this revision.
nadav added a reviewer: modocache.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D83920
Files:
llvm/include/llvm/CodeGen/LiveVariables.h
llvm/lib/CodeGen/LiveVariables.cpp
Index: llvm/lib/CodeGen/LiveVariables.cpp
===================================================================
--- llvm/lib/CodeGen/LiveVariables.cpp
+++ llvm/lib/CodeGen/LiveVariables.cpp
@@ -89,10 +89,9 @@
return VirtRegInfo[RegIdx];
}
-void LiveVariables::MarkVirtRegAliveInBlock(VarInfo& VRInfo,
- MachineBasicBlock *DefBlock,
- MachineBasicBlock *MBB,
- std::vector<MachineBasicBlock*> &WorkList) {
+void LiveVariables::MarkVirtRegAliveInBlock(
+ VarInfo &VRInfo, MachineBasicBlock *DefBlock, MachineBasicBlock *MBB,
+ SmallVectorImpl<MachineBasicBlock *> &WorkList) {
unsigned BBNum = MBB->getNumber();
// Check to see if this basic block is one of the killing blocks. If so,
@@ -118,7 +117,7 @@
void LiveVariables::MarkVirtRegAliveInBlock(VarInfo &VRInfo,
MachineBasicBlock *DefBlock,
MachineBasicBlock *MBB) {
- std::vector<MachineBasicBlock*> WorkList;
+ SmallVector<MachineBasicBlock *, 16> WorkList;
MarkVirtRegAliveInBlock(VRInfo, DefBlock, MBB, WorkList);
while (!WorkList.empty()) {
Index: llvm/include/llvm/CodeGen/LiveVariables.h
===================================================================
--- llvm/include/llvm/CodeGen/LiveVariables.h
+++ llvm/include/llvm/CodeGen/LiveVariables.h
@@ -274,9 +274,10 @@
void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock,
MachineBasicBlock *BB);
- void MarkVirtRegAliveInBlock(VarInfo& VRInfo, MachineBasicBlock* DefBlock,
+ void MarkVirtRegAliveInBlock(VarInfo &VRInfo, MachineBasicBlock *DefBlock,
MachineBasicBlock *BB,
- std::vector<MachineBasicBlock*> &WorkList);
+ SmallVectorImpl<MachineBasicBlock *> &WorkList);
+
void HandleVirtRegDef(unsigned reg, MachineInstr &MI);
void HandleVirtRegUse(unsigned reg, MachineBasicBlock *MBB, MachineInstr &MI);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83920.278337.patch
Type: text/x-patch
Size: 2117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200715/ffe90318/attachment.bin>
More information about the llvm-commits
mailing list