[Bitcode] Delete instruction on error

As these errors are detected after the instruction has already been
created (but before it has been inserted into the function), we
also need to delete it.
This commit is contained in:
Nikita Popov
2022-03-11 10:38:00 +01:00
parent 5c3861b277
commit d7645f4ef8

View File

@@ -5076,8 +5076,10 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
cast<InvokeInst>(I)->setCallingConv(
static_cast<CallingConv::ID>(CallingConv::MaxID & CCInfo));
cast<InvokeInst>(I)->setAttributes(PAL);
if (Error Err = propagateAttributeTypes(cast<CallBase>(I), ArgTyIDs))
if (Error Err = propagateAttributeTypes(cast<CallBase>(I), ArgTyIDs)) {
I->deleteValue();
return Err;
}
break;
}
@@ -5171,8 +5173,10 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
cast<CallBrInst>(I)->setCallingConv(
static_cast<CallingConv::ID>((0x7ff & CCInfo) >> bitc::CALL_CCONV));
cast<CallBrInst>(I)->setAttributes(PAL);
if (Error Err = propagateAttributeTypes(cast<CallBase>(I), ArgTyIDs))
if (Error Err = propagateAttributeTypes(cast<CallBase>(I), ArgTyIDs)) {
I->deleteValue();
return Err;
}
break;
}
case bitc::FUNC_CODE_INST_UNREACHABLE: // UNREACHABLE
@@ -5784,8 +5788,10 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
TCK = CallInst::TCK_NoTail;
cast<CallInst>(I)->setTailCallKind(TCK);
cast<CallInst>(I)->setAttributes(PAL);
if (Error Err = propagateAttributeTypes(cast<CallBase>(I), ArgTyIDs))
if (Error Err = propagateAttributeTypes(cast<CallBase>(I), ArgTyIDs)) {
I->deleteValue();
return Err;
}
if (FMF.any()) {
if (!isa<FPMathOperator>(I))
return error("Fast-math-flags specified for call without "