From d7645f4ef866059da66442308c4c015c55b84e02 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 11 Mar 2022 10:38:00 +0100 Subject: [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. --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 6a3012d..63b084c 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -5076,8 +5076,10 @@ Error BitcodeReader::parseFunctionBody(Function *F) { cast(I)->setCallingConv( static_cast(CallingConv::MaxID & CCInfo)); cast(I)->setAttributes(PAL); - if (Error Err = propagateAttributeTypes(cast(I), ArgTyIDs)) + if (Error Err = propagateAttributeTypes(cast(I), ArgTyIDs)) { + I->deleteValue(); return Err; + } break; } @@ -5171,8 +5173,10 @@ Error BitcodeReader::parseFunctionBody(Function *F) { cast(I)->setCallingConv( static_cast((0x7ff & CCInfo) >> bitc::CALL_CCONV)); cast(I)->setAttributes(PAL); - if (Error Err = propagateAttributeTypes(cast(I), ArgTyIDs)) + if (Error Err = propagateAttributeTypes(cast(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(I)->setTailCallKind(TCK); cast(I)->setAttributes(PAL); - if (Error Err = propagateAttributeTypes(cast(I), ArgTyIDs)) + if (Error Err = propagateAttributeTypes(cast(I), ArgTyIDs)) { + I->deleteValue(); return Err; + } if (FMF.any()) { if (!isa(I)) return error("Fast-math-flags specified for call without " -- cgit v1.1