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

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 3 04:33:35 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlgo

Author: Petr Kurapov (kurapov-peter)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/213643.diff


1 Files Affected:

- (modified) llvm/lib/Analysis/IR2Vec.cpp (+3-2) 


``````````diff
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)] =

``````````

</details>


https://github.com/llvm/llvm-project/pull/213643


More information about the llvm-commits mailing list