From: Quentin Colombet Date: Tue, 20 Sep 2016 00:48:44 +0000 (+0000) Subject: [RegisterBankInfo] Avoid heap allocation in InstructionMapping. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=879da284b56503c16c671031adc9c1b805854094;p=llvm [RegisterBankInfo] Avoid heap allocation in InstructionMapping. Use SmallVector instead of dynamically allocated arrays for the mapping of the operands in the InstructionMapping. That way we avoid heap allocation for most of the cases. Ultimately, we should not have to rely on such tricky, the instances of InstructionMapping would be TableGen'ed. This improves the compilation time of the RegBankSelect pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281955 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h index 77c0a8cb48e..f72fba20ecf 100644 --- a/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h +++ b/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h @@ -109,7 +109,8 @@ public: /// Cost of this mapping. unsigned Cost; /// Mapping of all the operands. - std::unique_ptr OperandsMapping; + /// Note: Use a SmallVector to avoid heap allocation in most cases. + SmallVector OperandsMapping; /// Number of operands. unsigned NumOperands; @@ -131,7 +132,7 @@ public: : ID(ID), Cost(Cost), NumOperands(NumOperands) { assert(getID() != InvalidMappingID && "Use the default constructor for invalid mapping"); - OperandsMapping.reset(new ValueMapping[getNumOperands()]); + OperandsMapping.resize(getNumOperands()); } /// Default constructor.