diff options
| author | Nikita Popov <npopov@redhat.com> | 2022-03-11 12:10:00 +0100 |
|---|---|---|
| committer | Nikita Popov <npopov@redhat.com> | 2022-03-11 12:12:54 +0100 |
| commit | cda82d39f3f25d8f6d1c1a105a59001339e54bb2 (patch) | |
| tree | cfc76e8de04150c52ede3b56dd2a31a4168575de /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
| parent | fbbc41f8dd233f1f0655852ca3e9634b1bb90cf0 (diff) | |
| download | llvm-cda82d39f3f25d8f6d1c1a105a59001339e54bb2.zip llvm-cda82d39f3f25d8f6d1c1a105a59001339e54bb2.tar.gz llvm-cda82d39f3f25d8f6d1c1a105a59001339e54bb2.tar.bz2 | |
[Bitcode] Check for type mismatch when assigning value
If the value is forward-declared, then the type must match,
otherwise we can't RAUW.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
| -rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 767b5f5..6dd2fdb 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2511,9 +2511,10 @@ Error BitcodeReader::parseConstants() { SmallVector<int, 16> Mask; ShuffleVectorInst::getShuffleMask(Op2, Mask); Value *V = ConstantExpr::getShuffleVector(Op0, Op1, Mask); - ValueList.assignValue( - CstNo, V, - getVirtualTypeID(V->getType(), getContainedTypeID(OpTyID))); + if (Error Err = ValueList.assignValue( + CstNo, V, + getVirtualTypeID(V->getType(), getContainedTypeID(OpTyID)))) + return Err; } for (auto &DelayedSelector : DelayedSelectors) { Type *OpTy = DelayedSelector.OpTy; @@ -2539,7 +2540,8 @@ Error BitcodeReader::parseConstants() { Constant *Op0 = ValueList.getConstantFwdRef(Op0Idx, SelectorTy, SelectorTyID); Value *V = ConstantExpr::getSelect(Op0, Op1, Op2); - ValueList.assignValue(CstNo, V, OpTyID); + if (Error Err = ValueList.assignValue(CstNo, V, OpTyID)) + return Err; } if (NextCstNo != ValueList.size()) @@ -3146,7 +3148,8 @@ Error BitcodeReader::parseConstants() { } assert(V->getType() == getTypeByID(CurTyID) && "Incorrect result type ID"); - ValueList.assignValue(NextCstNo, V, CurTyID); + if (Error Err = ValueList.assignValue(NextCstNo, V, CurTyID)) + return Err; ++NextCstNo; } } @@ -5880,7 +5883,8 @@ Error BitcodeReader::parseFunctionBody(Function *F) { if (!I->getType()->isVoidTy()) { assert(I->getType() == getTypeByID(ResTypeID) && "Incorrect result type ID"); - ValueList.assignValue(NextValueNo++, I, ResTypeID); + if (Error Err = ValueList.assignValue(NextValueNo++, I, ResTypeID)) + return Err; } } |
