[llvm] [IR2Vec][NFC] Size the section vector from Section::MaxSections (PR #213643)

Petr Kurapov via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 3 03:50:36 PDT 2026


https://github.com/kurapov-peter created https://github.com/llvm/llvm-project/pull/213643

None

>From 9ac8f90e6d0b881ca6ab3b0633a12987dc204420 Mon Sep 17 00:00:00 2001
From: Petr Kurapov <petr.kurapov at amd.com>
Date: Fri, 31 Jul 2026 09:25:34 -0500
Subject: [PATCH] [IR2Vec][NFC] Size the section vector from
 Section::MaxSections

---
 llvm/lib/Analysis/IR2Vec.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Analysis/IR2Vec.cpp b/llvm/lib/Analysis/IR2Vec.cpp
index 07d0c372cabcc..0b699f5c2d988 100644
--- a/llvm/lib/Analysis/IR2Vec.cpp
+++ b/llvm/lib/Analysis/IR2Vec.cpp
@@ -436,7 +436,7 @@ VocabStorage Vocabulary::createDummyVocabForTest(unsigned Dim) {
   // Create sections for opcodes, types, operands, and predicates
   // Order must match Vocabulary::Section enum
   std::vector<std::vector<Embedding>> Sections;
-  Sections.reserve(4);
+  Sections.reserve(static_cast<unsigned>(Section::MaxSections));
 
   // Opcodes section
   std::vector<Embedding> OpcodeSec;
@@ -589,7 +589,8 @@ VocabStorage Vocabulary::buildVocabStorage(const VocabMap &OpcVocab,
 
   // Create section-based storage instead of flat vocabulary
   // Order must match Vocabulary::Section enum
-  std::vector<std::vector<Embedding>> Sections(4);
+  std::vector<std::vector<Embedding>> Sections(
+      static_cast<unsigned>(Section::MaxSections));
   Sections[static_cast<unsigned>(Section::Opcodes)] =
       std::move(NumericOpcodeEmbeddings); // Section::Opcodes
   Sections[static_cast<unsigned>(Section::CanonicalTypes)] =



More information about the llvm-commits mailing list