summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-09-19 17:33:55 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-09-19 17:33:55 +0000
commita7330ba5ac04eb0163ac6d5bcd5c59a71bcc107e (patch)
tree5c73515bccc647ed9d6b93413afc4b29e3f8b8a2
parent042acb2cf7384a011464551ed489a1a539509d66 (diff)
downloadbcm5719-llvm-a7330ba5ac04eb0163ac6d5bcd5c59a71bcc107e.tar.gz
bcm5719-llvm-a7330ba5ac04eb0163ac6d5bcd5c59a71bcc107e.zip
[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
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h3
-rw-r--r--llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp2
2 files changed, 3 insertions, 2 deletions
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
index d075d7ab10a..77c0a8cb48e 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
@@ -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.
diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
index 91681fb7a40..ca9e8e61552 100644
--- a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
@@ -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");
OpenPOWER on IntegriCloud