[llvm] [Analysis] Restore the call to reserve (PR #136215)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 17 15:03:47 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/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.
>From 09d34b50b656d8413b6d38b497a62470a9146774 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 17 Apr 2025 14:55:01 -0700
Subject: [PATCH] [Analysis] Restore the call to reserve
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.
---
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<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