]> granicus.if.org Git - llvm/commitdiff
[RegisterBankInfo] Avoid heap allocation in InstructionMapping.
authorQuentin Colombet <qcolombet@apple.com>
Tue, 20 Sep 2016 00:48:44 +0000 (00:48 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Tue, 20 Sep 2016 00:48:44 +0000 (00:48 +0000)
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

include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h

index 77c0a8cb48eb0deb922ded2ffa1fb9a812c825fc..f72fba20ecf1669f570de8e55b78388ec433e9d4 100644 (file)
@@ -109,7 +109,8 @@ public:
     /// Cost of this mapping.
     unsigned Cost;
     /// Mapping of all the operands.
-    std::unique_ptr<ValueMapping[]> OperandsMapping;
+    /// Note: Use a SmallVector to avoid heap allocation in most cases.
+    SmallVector<ValueMapping, 8> 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.