Skip to content

Commit 96c1201

Browse files
authored
[nfc][ir2vec] Remove Valid field (#157132)
It is tied to the vocab having had been set. Checking that vector's `emtpy` is sufficient. Less state to track (for a maintainer)
1 parent 96195e7 commit 96c1201

File tree

2 files changed

+7
-15
lines changed

2 files changed

+7
-15
lines changed

llvm/include/llvm/Analysis/IR2Vec.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

169168
public:
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

llvm/lib/Analysis/IR2Vec.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,15 +260,8 @@ void FlowAwareEmbedder::computeEmbeddings(const BasicBlock &BB) const {
260260
// Vocabulary
261261
//===----------------------------------------------------------------------===//
262262

263-
Vocabulary::Vocabulary(VocabVector &&Vocab)
264-
: Vocab(std::move(Vocab)), Valid(true) {}
265-
266-
bool Vocabulary::isValid() const {
267-
return Vocab.size() == NumCanonicalEntries && Valid;
268-
}
269-
270263
unsigned Vocabulary::getDimension() const {
271-
assert(Valid && "IR2Vec Vocabulary is invalid");
264+
assert(isValid() && "IR2Vec Vocabulary is invalid");
272265
return Vocab[0].size();
273266
}
274267

0 commit comments

Comments
 (0)