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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 18 14:43:09 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
----------------
MaskRay wrote:

In this case the braces for the "then" branch can be removed per https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements

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


More information about the llvm-commits mailing list