[llvm-branch-commits] [llvm] [MC][NFC] Statically allocate storage for decoded pseudo probes and function records (PR #102789)
Lei Wang via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 15 00:16:36 PDT 2024
================
@@ -605,13 +616,20 @@ bool MCPseudoProbeDecoder::buildAddress2ProbeMap(
TopLevelFuncs += !Discard;
}
assert(Data == End && "Have unprocessed data in pseudo_probe section");
+ PseudoProbeVec.reserve(ProbeCount);
+ InlineTreeVec.reserve(InlinedCount);
----------------
wlei-llvm wrote:
Since this assumes the vector's reserved size will be equal to the amount it will be used. How about adding assertions at the end of function. like `assert(InlineTreeVec.size() == InlinedCount && ...)` this is for checking any accidental re-allocation/extension of the vector during the build the map.
https://github.com/llvm/llvm-project/pull/102789
More information about the llvm-branch-commits
mailing list