@@ -216,10 +216,7 @@ TEST(IR2VecTest, CreateSymbolicEmbedder) {
216
216
FunctionType *FTy = FunctionType::get (Type::getVoidTy (Ctx), false );
217
217
Function *F = Function::Create (FTy, Function::ExternalLinkage, " f" , M);
218
218
219
- auto Result = Embedder::create (IR2VecKind::Symbolic, *F, V);
220
- EXPECT_TRUE (static_cast <bool >(Result));
221
-
222
- auto *Emb = Result->get ();
219
+ auto Emb = Embedder::create (IR2VecKind::Symbolic, *F, V);
223
220
EXPECT_NE (Emb, nullptr );
224
221
}
225
222
@@ -231,15 +228,16 @@ TEST(IR2VecTest, CreateInvalidMode) {
231
228
FunctionType *FTy = FunctionType::get (Type::getVoidTy (Ctx), false );
232
229
Function *F = Function::Create (FTy, Function::ExternalLinkage, " f" , M);
233
230
234
- // static_cast an invalid int to IR2VecKind
231
+ // static_cast an invalid int to IR2VecKind
232
+ #ifndef NDEBUG
233
+ #if GTEST_HAS_DEATH_TEST
234
+ EXPECT_DEATH (Embedder::create (static_cast <IR2VecKind>(-1 ), *F, V),
235
+ " Unknown IR2Vec kind" );
236
+ #endif // GTEST_HAS_DEATH_TEST
237
+ #else
235
238
auto Result = Embedder::create (static_cast <IR2VecKind>(-1 ), *F, V);
236
239
EXPECT_FALSE (static_cast <bool >(Result));
237
-
238
- std::string ErrMsg;
239
- llvm::handleAllErrors (
240
- Result.takeError (),
241
- [&](const llvm::ErrorInfoBase &EIB) { ErrMsg = EIB.message (); });
242
- EXPECT_NE (ErrMsg.find (" Unknown IR2VecKind" ), std::string::npos);
240
+ #endif // NDEBUG
243
241
}
244
242
245
243
TEST (IR2VecTest, LookupVocab) {
@@ -298,10 +296,6 @@ class IR2VecTestFixture : public ::testing::Test {
298
296
Instruction *AddInst = nullptr ;
299
297
Instruction *RetInst = nullptr ;
300
298
301
- float OriginalOpcWeight = ::OpcWeight;
302
- float OriginalTypeWeight = ::TypeWeight;
303
- float OriginalArgWeight = ::ArgWeight;
304
-
305
299
void SetUp () override {
306
300
V = {{" add" , {1.0 , 2.0 }},
307
301
{" integerTy" , {0.25 , 0.25 }},
@@ -325,9 +319,8 @@ class IR2VecTestFixture : public ::testing::Test {
325
319
};
326
320
327
321
TEST_F (IR2VecTestFixture, GetInstVecMap) {
328
- auto Result = Embedder::create (IR2VecKind::Symbolic, *F, V);
329
- ASSERT_TRUE (static_cast <bool >(Result));
330
- auto Emb = std::move (*Result);
322
+ auto Emb = Embedder::create (IR2VecKind::Symbolic, *F, V);
323
+ ASSERT_TRUE (static_cast <bool >(Emb));
331
324
332
325
const auto &InstMap = Emb->getInstVecMap ();
333
326
@@ -348,9 +341,8 @@ TEST_F(IR2VecTestFixture, GetInstVecMap) {
348
341
}
349
342
350
343
TEST_F (IR2VecTestFixture, GetBBVecMap) {
351
- auto Result = Embedder::create (IR2VecKind::Symbolic, *F, V);
352
- ASSERT_TRUE (static_cast <bool >(Result));
353
- auto Emb = std::move (*Result);
344
+ auto Emb = Embedder::create (IR2VecKind::Symbolic, *F, V);
345
+ ASSERT_TRUE (static_cast <bool >(Emb));
354
346
355
347
const auto &BBMap = Emb->getBBVecMap ();
356
348
@@ -365,9 +357,8 @@ TEST_F(IR2VecTestFixture, GetBBVecMap) {
365
357
}
366
358
367
359
TEST_F (IR2VecTestFixture, GetBBVector) {
368
- auto Result = Embedder::create (IR2VecKind::Symbolic, *F, V);
369
- ASSERT_TRUE (static_cast <bool >(Result));
370
- auto Emb = std::move (*Result);
360
+ auto Emb = Embedder::create (IR2VecKind::Symbolic, *F, V);
361
+ ASSERT_TRUE (static_cast <bool >(Emb));
371
362
372
363
const auto &BBVec = Emb->getBBVector (*BB);
373
364
@@ -377,9 +368,8 @@ TEST_F(IR2VecTestFixture, GetBBVector) {
377
368
}
378
369
379
370
TEST_F (IR2VecTestFixture, GetFunctionVector) {
380
- auto Result = Embedder::create (IR2VecKind::Symbolic, *F, V);
381
- ASSERT_TRUE (static_cast <bool >(Result));
382
- auto Emb = std::move (*Result);
371
+ auto Emb = Embedder::create (IR2VecKind::Symbolic, *F, V);
372
+ ASSERT_TRUE (static_cast <bool >(Emb));
383
373
384
374
const auto &FuncVec = Emb->getFunctionVector ();
385
375
0 commit comments