[llvm] [CodeLayout] Fixing initialization of empty ranges (PR #68917)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 12 15:14:09 PDT 2023


https://github.com/spupyrev updated https://github.com/llvm/llvm-project/pull/68917

>From 9ee7608e4186d65c62076774410261d463b41905 Mon Sep 17 00:00:00 2001
From: spupyrev <spupyrev at fb.com>
Date: Thu, 12 Oct 2023 10:50:10 -0700
Subject: [PATCH] [CodeLayout] Fixing initialization of empty ranges

---
 llvm/lib/Transforms/Utils/CodeLayout.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/llvm/lib/Transforms/Utils/CodeLayout.cpp b/llvm/lib/Transforms/Utils/CodeLayout.cpp
index dea91dcac21ae14..620b52b69c31d57 100644
--- a/llvm/lib/Transforms/Utils/CodeLayout.cpp
+++ b/llvm/lib/Transforms/Utils/CodeLayout.cpp
@@ -476,13 +476,16 @@ void ChainT::mergeEdges(ChainT *Other) {
 }
 
 using NodeIter = std::vector<NodeT *>::const_iterator;
+static std::vector<NodeT *> EmptyList;
 
 /// A wrapper around three concatenated vectors (chains) of nodes; it is used
 /// to avoid extra instantiation of the vectors.
 struct MergedNodesT {
-  MergedNodesT(NodeIter Begin1, NodeIter End1, NodeIter Begin2 = NodeIter(),
-               NodeIter End2 = NodeIter(), NodeIter Begin3 = NodeIter(),
-               NodeIter End3 = NodeIter())
+  MergedNodesT(NodeIter Begin1, NodeIter End1,
+               NodeIter Begin2 = EmptyList.begin(),
+               NodeIter End2 = EmptyList.end(),
+               NodeIter Begin3 = EmptyList.begin(),
+               NodeIter End3 = EmptyList.end())
       : Begin1(Begin1), End1(End1), Begin2(Begin2), End2(End2), Begin3(Begin3),
         End3(End3) {}
 



More information about the llvm-commits mailing list