@@ -216,10 +216,7 @@ TEST(IR2VecTest, CreateSymbolicEmbedder) {
216216 FunctionType *FTy = FunctionType::get (Type::getVoidTy (Ctx), false );
217217 Function *F = Function::Create (FTy, Function::ExternalLinkage, " f" , M);
218218
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);
223220 EXPECT_NE (Emb, nullptr );
224221}
225222
@@ -231,15 +228,16 @@ TEST(IR2VecTest, CreateInvalidMode) {
231228 FunctionType *FTy = FunctionType::get (Type::getVoidTy (Ctx), false );
232229 Function *F = Function::Create (FTy, Function::ExternalLinkage, " f" , M);
233230
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
235238 auto Result = Embedder::create (static_cast <IR2VecKind>(-1 ), *F, V);
236239 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
243241}
244242
245243TEST (IR2VecTest, LookupVocab) {
@@ -298,10 +296,6 @@ class IR2VecTestFixture : public ::testing::Test {
298296 Instruction *AddInst = nullptr ;
299297 Instruction *RetInst = nullptr ;
300298
301- float OriginalOpcWeight = ::OpcWeight;
302- float OriginalTypeWeight = ::TypeWeight;
303- float OriginalArgWeight = ::ArgWeight;
304-
305299 void SetUp () override {
306300 V = {{" add" , {1.0 , 2.0 }},
307301 {" integerTy" , {0.25 , 0.25 }},
@@ -325,9 +319,8 @@ class IR2VecTestFixture : public ::testing::Test {
325319};
326320
327321TEST_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));
331324
332325 const auto &InstMap = Emb->getInstVecMap ();
333326
@@ -348,9 +341,8 @@ TEST_F(IR2VecTestFixture, GetInstVecMap) {
348341}
349342
350343TEST_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));
354346
355347 const auto &BBMap = Emb->getBBVecMap ();
356348
@@ -365,9 +357,8 @@ TEST_F(IR2VecTestFixture, GetBBVecMap) {
365357}
366358
367359TEST_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));
371362
372363 const auto &BBVec = Emb->getBBVector (*BB);
373364
@@ -377,9 +368,8 @@ TEST_F(IR2VecTestFixture, GetBBVector) {
377368}
378369
379370TEST_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));
383373
384374 const auto &FuncVec = Emb->getFunctionVector ();
385375
0 commit comments