[llvm] 69b9ddc - [Analysis] Restore the call to reserve (#136215)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 17 15:09:28 PDT 2025
Author: Kazu Hirata
Date: 2025-04-17T15:09:24-07:00
New Revision: 69b9ddc76418c6f60ce7751efb5beb1f3b3be3ff
URL: https://github.com/llvm/llvm-project/commit/69b9ddc76418c6f60ce7751efb5beb1f3b3be3ff
DIFF: https://github.com/llvm/llvm-project/commit/69b9ddc76418c6f60ce7751efb5beb1f3b3be3ff.diff
LOG: [Analysis] Restore the call to reserve (#136215)
commit 47d8fec9b8bd5425af17711317a41743a30a8cef
Author: Kazu Hirata <kazu at google.com>
Date: Wed Apr 16 19:30:01 2025 -0700
has removed the call to reserve here. This patch restores it as
std::vector::insert, called by llvm::append_range, may not be able to
deduce the size of the range. For example, std::vector in libc++
distinguishes has two versions of std::vector::insert depending on
whether the iterator is an input iterator or a foward iterator.
Added:
Modified:
llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
index 57c408968b19a..2237f105e328b 100644
--- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
+++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h
@@ -1159,6 +1159,7 @@ void BlockFrequencyInfoImpl<BT>::setBlockFreq(const BlockT *BB,
template <class BT> void BlockFrequencyInfoImpl<BT>::initializeRPOT() {
const BlockT *Entry = &F->front();
+ RPOT.reserve(F->size());
llvm::append_range(RPOT, post_order(Entry));
std::reverse(RPOT.begin(), RPOT.end());
More information about the llvm-commits
mailing list