From 09d34b50b656d8413b6d38b497a62470a9146774 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 17 Apr 2025 14:55:01 -0700 Subject: [PATCH] [Analysis] Restore the call to reserve commit 47d8fec9b8bd5425af17711317a41743a30a8cef Author: Kazu Hirata 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. --- llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h | 1 + 1 file changed, 1 insertion(+) 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::setBlockFreq(const BlockT *BB, template void BlockFrequencyInfoImpl::initializeRPOT() { const BlockT *Entry = &F->front(); + RPOT.reserve(F->size()); llvm::append_range(RPOT, post_order(Entry)); std::reverse(RPOT.begin(), RPOT.end());