@@ -164,7 +164,6 @@ class Vocabulary {
164164 friend class llvm ::IR2VecVocabAnalysis;
165165 using VocabVector = std::vector<ir2vec::Embedding>;
166166 VocabVector Vocab;
167- bool Valid = false ;
168167
169168public:
170169 // Slot layout:
@@ -210,9 +209,9 @@ class Vocabulary {
210209 static_cast <unsigned >(OperandKind::MaxOperandKind);
211210
212211 Vocabulary () = default ;
213- LLVM_ABI Vocabulary (VocabVector &&Vocab);
212+ LLVM_ABI Vocabulary (VocabVector &&Vocab) : Vocab(std::move(Vocab)) {}
214213
215- LLVM_ABI bool isValid () const ;
214+ LLVM_ABI bool isValid () const { return Vocab. size () == NumCanonicalEntries; } ;
216215 LLVM_ABI unsigned getDimension () const ;
217216 // / Total number of entries (opcodes + canonicalized types + operand kinds)
218217 static constexpr size_t getCanonicalSize () { return NumCanonicalEntries; }
@@ -243,22 +242,22 @@ class Vocabulary {
243242 // / Const Iterator type aliases
244243 using const_iterator = VocabVector::const_iterator;
245244 const_iterator begin () const {
246- assert (Valid && " IR2Vec Vocabulary is invalid" );
245+ assert (isValid () && " IR2Vec Vocabulary is invalid" );
247246 return Vocab.begin ();
248247 }
249248
250249 const_iterator cbegin () const {
251- assert (Valid && " IR2Vec Vocabulary is invalid" );
250+ assert (isValid () && " IR2Vec Vocabulary is invalid" );
252251 return Vocab.cbegin ();
253252 }
254253
255254 const_iterator end () const {
256- assert (Valid && " IR2Vec Vocabulary is invalid" );
255+ assert (isValid () && " IR2Vec Vocabulary is invalid" );
257256 return Vocab.end ();
258257 }
259258
260259 const_iterator cend () const {
261- assert (Valid && " IR2Vec Vocabulary is invalid" );
260+ assert (isValid () && " IR2Vec Vocabulary is invalid" );
262261 return Vocab.cend ();
263262 }
264263
0 commit comments