[llvm] [CodeLayout][NFC] Using MergedVector to avoid extra vector allocations (PR #68724)

Rahman Lavaee via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 22:19:49 PDT 2023


================
@@ -798,17 +822,14 @@ class ExtTSPImpl {
   /// element being the corresponding merging type.
   MergeGainT getBestMergeGain(ChainT *ChainPred, ChainT *ChainSucc,
                               ChainEdge *Edge) const {
-    if (Edge->hasCachedMergeGain(ChainPred, ChainSucc)) {
+    if (Edge->hasCachedMergeGain(ChainPred, ChainSucc))
       return Edge->getCachedMergeGain(ChainPred, ChainSucc);
-    }
 
     // Precompute jumps between ChainPred and ChainSucc.
-    auto Jumps = Edge->jumps();
+    MergedJumpsT Jumps(&Edge->jumps());
----------------
rlavaee wrote:

One last change. It's unusual for structs to have private members. We can make `JumpArray` public and then use default initializers.

`MergedJumpsT Jumps ({&Edge->jumps(), EdgePP ? &EdgePP->jumps() : nullptr});`

Then you don't need to define append anymore.

https://github.com/llvm/llvm-project/pull/68724


More information about the llvm-commits mailing list