From a7330ba5ac04eb0163ac6d5bcd5c59a71bcc107e Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Mon, 19 Sep 2016 17:33:55 +0000 Subject: [PATCH] [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 --- llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h | 3 ++- llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp | 2 +- 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 d075d7ab..77c0a8c 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 OpToNewVRegIdx; + /// Note: We use a SmallVector to avoid heap allocation for most cases. + SmallVector OpToNewVRegIdx; /// Hold the registers that will be used to map MI with InstrMapping. SmallVector 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 91681fb..ca9e8e6 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"); -- 2.7.4