From: Quentin Colombet Date: Mon, 19 Sep 2016 17:33:55 +0000 (+0000) Subject: [RegisterBankInfo] Avoid heap allocation in most cases. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a7330ba5ac04eb0163ac6d5bcd5c59a71bcc107e;p=platform%2Fupstream%2Fllvm.git [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 --- 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");