[llvm] b9ae0b0 - [Assignment Tracking] Initialise maps with minimum required number of entries

via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 22 23:43:50 PST 2023


Author: OCHyams
Date: 2023-02-23T07:43:12Z
New Revision: b9ae0b09810cc24d1a90520e07ba9ea17fdc54b1

URL: https://github.com/llvm/llvm-project/commit/b9ae0b09810cc24d1a90520e07ba9ea17fdc54b1
DIFF: https://github.com/llvm/llvm-project/commit/b9ae0b09810cc24d1a90520e07ba9ea17fdc54b1.diff

LOG: [Assignment Tracking] Initialise maps with minimum required number of entries

The size lower bound is known - the `Join` map in both cases gets an entry for
each variable from both input maps (union).

This reduces the number of times the map grows, improving ReleaseLTO-g compile
time for CTMark projects by an average of around 0.2%.

Reviewed By: scott.linder

Differential Revision: https://reviews.llvm.org/D144486

Added: 
    

Modified: 
    llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
index d3c9d141b5d8..1b9740a5003b 100644
--- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -1612,7 +1612,7 @@ AssignmentTrackingLowering::joinLocMap(const LocMap &A, const LocMap &B) {
   // then adding LocKind::None elements for vars in A xor B. The latter part is
   // equivalent to performing join on elements with variables in A xor B with
   // LocKind::None (⊤) since join(x, ⊤) = ⊤.
-  LocMap Join;
+  LocMap Join(std::max(A.size(), B.size()));
   SmallVector<VariableID, 16> SymmetricDifference;
   // Insert the join of the elements with common vars into Join. Add the
   // remaining elements to into SymmetricDifference.
@@ -1703,7 +1703,7 @@ AssignmentTrackingLowering::joinAssignmentMap(const AssignmentMap &A,
   // then adding LocKind::None elements for vars in A xor B. The latter part is
   // equivalent to performing join on elements with variables in A xor B with
   // Status::NoneOrPhi (⊤) since join(x, ⊤) = ⊤.
-  AssignmentMap Join;
+  AssignmentMap Join(std::max(A.size(), B.size()));
   SmallVector<VariableID, 16> SymmetricDifference;
   // Insert the join of the elements with common vars into Join. Add the
   // remaining elements to into SymmetricDifference.


        


More information about the llvm-commits mailing list