[PATCH] D144486: [Assignment Tracking] Initialise maps with exact required number of entries

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 07:09:16 PST 2023


Orlando created this revision.
Orlando added reviewers: jmorse, StephenTozer, scott.linder.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Orlando requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The required size is known - the `Join` map in both cases gets an entry for each variable from both input maps (union). This avoids the unnecessary cost of repeatedly growing the map.

This improves ReleaseLTO-g compile time for CTMark projects by an average of around 0.2%.


https://reviews.llvm.org/D144486

Files:
  llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp


Index: llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
===================================================================
--- llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -1612,7 +1612,7 @@
   // 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 @@
   // 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144486.499159.patch
Type: text/x-patch
Size: 1197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230221/d0ff007a/attachment.bin>


More information about the llvm-commits mailing list