https://gcc.gnu.org/g:b2f4914534979a5f714877f32c5ad01f40745b5e
commit r17-4107-gb2f4914534979a5f714877f32c5ad01f40745b5e Author: Lishin <[email protected]> Date: Thu Aug 13 07:05:21 2026 +0000 gccrs: Address review feedback for straight-line BIR drop analysis gcc/rust/ChangeLog: * checks/errors/borrowck/rust-bir-drop-analysis.cc (BasicBlockIdHash): New helper. (DropAnalysis::analyze): Use unordered_set for visited block tracking. * checks/errors/borrowck/rust-bir-drop-analysis.h: Include rust-bir.h directly and remove Function forward declaration. * checks/errors/borrowck/rust-bir-place.h (IndexVec::IndexVec): Add comment for sized constructor. Signed-off-by: Lishin <[email protected]> Diff: --- .../checks/errors/borrowck/rust-bir-drop-analysis.cc | 16 +++++++++++++++- gcc/rust/checks/errors/borrowck/rust-bir-drop-analysis.h | 3 +-- gcc/rust/checks/errors/borrowck/rust-bir-place.h | 1 + 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-drop-analysis.cc b/gcc/rust/checks/errors/borrowck/rust-bir-drop-analysis.cc index c0de04fac2d3..006b07f22a19 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-drop-analysis.cc +++ b/gcc/rust/checks/errors/borrowck/rust-bir-drop-analysis.cc @@ -19,14 +19,28 @@ #include "rust-bir-drop-analysis.h" #include "rust-bir.h" +#include <unordered_set> + namespace Rust { namespace BIR { +namespace { + +struct BasicBlockIdHash +{ + size_t operator() (BasicBlockId id) const + { + return std::hash<uint32_t> () (id.value); + } +}; + +} // namespace + void DropAnalysis::analyze (Function &function) { std::vector<BasicBlockId> block_order; - std::set<BasicBlockId> visited; + std::unordered_set<BasicBlockId, BasicBlockIdHash> visited; BasicBlockId current = ENTRY_BASIC_BLOCK; diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-drop-analysis.h b/gcc/rust/checks/errors/borrowck/rust-bir-drop-analysis.h index eb63f1e1eda2..c6298985a54e 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-drop-analysis.h +++ b/gcc/rust/checks/errors/borrowck/rust-bir-drop-analysis.h @@ -19,11 +19,10 @@ #ifndef RUST_BIR_DROP_ANALYSIS_H #define RUST_BIR_DROP_ANALYSIS_H +#include "rust-bir.h" namespace Rust { namespace BIR { -struct Function; - /* Classifies scheduled whole-local BIR Drop statements according to whether their place is initialized at the drop point. diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-place.h b/gcc/rust/checks/errors/borrowck/rust-bir-place.h index d11ded9c9daa..46b1f5dc8965 100644 --- a/gcc/rust/checks/errors/borrowck/rust-bir-place.h +++ b/gcc/rust/checks/errors/borrowck/rust-bir-place.h @@ -209,6 +209,7 @@ template <typename I, typename T> class IndexVec public: IndexVec () = default; + // Creates `size` elements, instead of only reserving space. IndexVec (size_t size) : internal_vector (size) {} T &at (I pid) { return internal_vector[pid.value]; }
