[llvm] Update ModuleSummaryIndexBitcodeReader::makeCallList reserve amount (PR #95461)

Jan Voung via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 20 06:33:00 PDT 2024


================
@@ -7332,7 +7332,15 @@ ModuleSummaryIndexBitcodeReader::makeCallList(ArrayRef<uint64_t> Record,
                                               bool IsOldProfileFormat,
                                               bool HasProfile, bool HasRelBF) {
   std::vector<FunctionSummary::EdgeTy> Ret;
-  Ret.reserve(Record.size());
+  // In the case of new profile formats, there are two Record entries per
+  // Edge. Otherwise, conservatively reserve up to Record.size and later
+  // shrink_to_fit when we are done (and shrink_to_fit for the exact
+  // case should be a no-op).
+  if (!IsOldProfileFormat && (HasProfile || HasRelBF)) {
+    Ret.reserve(Record.size() / 2);
+  } else
----------------
jvoung wrote:

Done

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


More information about the llvm-commits mailing list