Skip to content

Commit 0a69c83

Browse files
authored
[NFC][IR2Vec] Remove unreachable code and simplify invalid mode test (#146459)
The code following `llvm_unreachable` is optimized out in Release builds. In this case, `Embedder::create` do not seem to return `nullptr` causing `CreateInvalidMode` test to break. Hence removing `llvm_unreachable`.
1 parent 66cc167 commit 0a69c83

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

llvm/lib/Analysis/IR2Vec.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,6 @@ std::unique_ptr<Embedder> Embedder::create(IR2VecKind Mode, const Function &F,
129129
case IR2VecKind::Symbolic:
130130
return std::make_unique<SymbolicEmbedder>(F, Vocabulary);
131131
}
132-
llvm_unreachable("Unknown IR2Vec kind");
133132
return nullptr;
134133
}
135134

llvm/unittests/Analysis/IR2VecTest.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,9 @@ TEST(IR2VecTest, CreateInvalidMode) {
228228
FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), false);
229229
Function *F = Function::Create(FTy, Function::ExternalLinkage, "f", M);
230230

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
231+
// static_cast an invalid int to IR2VecKind
238232
auto Result = Embedder::create(static_cast<IR2VecKind>(-1), *F, V);
239233
EXPECT_FALSE(static_cast<bool>(Result));
240-
#endif // NDEBUG
241234
}
242235

243236
TEST(IR2VecTest, LookupVocab) {

0 commit comments

Comments
 (0)