Skip to content

Commit fc2850f

Browse files
authored
[IR2VecTest] Avoid magic constants
Instead make the members of Vocabulary public. This was causing test failures with #139357. Reviewed By: svkeerthy, boomanaiden154 Pull Request: #150878
1 parent 4f58c82 commit fc2850f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

llvm/include/llvm/Analysis/IR2Vec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ class Vocabulary {
153153
static_cast<unsigned>(OperandKind::MaxOperandKind),
154154
"OperandKindNames array size must match MaxOperandKind");
155155

156+
public:
156157
/// Vocabulary layout constants
157158
#define LAST_OTHER_INST(NUM) static constexpr unsigned MaxOpcodes = NUM;
158159
#include "llvm/IR/Instruction.def"
@@ -162,7 +163,6 @@ class Vocabulary {
162163
static constexpr unsigned MaxOperandKinds =
163164
static_cast<unsigned>(OperandKind::MaxOperandKind);
164165

165-
public:
166166
Vocabulary() = default;
167167
Vocabulary(VocabVector &&Vocab);
168168

llvm/unittests/Analysis/IR2VecTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ TEST_F(IR2VecTestFixture, GetFunctionVector) {
364364
EXPECT_TRUE(FuncVec.approximatelyEquals(Embedding(2, 44.4)));
365365
}
366366

367-
static constexpr unsigned MaxOpcodes = 67;
368-
static constexpr unsigned MaxTypeIDs = 21;
369-
static constexpr unsigned MaxOperands = 4;
367+
static constexpr unsigned MaxOpcodes = Vocabulary::MaxOpcodes;
368+
static constexpr unsigned MaxTypeIDs = Vocabulary::MaxTypeIDs;
369+
static constexpr unsigned MaxOperands = Vocabulary::MaxOperandKinds;
370370

371371
TEST(IR2VecVocabularyTest, DummyVocabTest) {
372372
for (unsigned Dim = 1; Dim <= 10; ++Dim) {

0 commit comments

Comments
 (0)