Skip to content

Commit 3e742b7

Browse files
[Codegen] Avoid UB-incurring llvm_unreachable in IntrinsicLowering
There is no proof this improves performance and evidence it does not, so choose a consistent and more boring assert-then-break.
1 parent 47e6d18 commit 3e742b7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/CodeGen/IntrinsicLowering.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ static Value *LowerBSWAP(LLVMContext &Context, Value *V, Instruction *IP) {
5858
IRBuilder<> Builder(IP);
5959

6060
switch(BitSize) {
61-
default: llvm_unreachable("Unhandled type size of value to byteswap!");
61+
default:
62+
assert(false && "Unhandled type size of value to byteswap!");
63+
break;
6264
case 16: {
6365
Value *Tmp1 = Builder.CreateShl(V, ConstantInt::get(V->getType(), 8),
6466
"bswap.2");
@@ -203,7 +205,9 @@ static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname,
203205
const char *Dname,
204206
const char *LDname) {
205207
switch (CI->getArgOperand(0)->getType()->getTypeID()) {
206-
default: llvm_unreachable("Invalid type in intrinsic");
208+
default:
209+
assert(false && "Invalid type in intrinsic");
210+
break;
207211
case Type::FloatTyID:
208212
ReplaceCallWith(Fname, CI, CI->arg_begin(), CI->arg_end(),
209213
Type::getFloatTy(CI->getContext()));

0 commit comments

Comments
 (0)