aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index e345167..a11690a 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -5248,7 +5248,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
return error(
"Invalid record: operand number exceeded available operands");
- unsigned PredVal = Record[OpNum];
+ CmpInst::Predicate PredVal = CmpInst::Predicate(Record[OpNum]);
bool IsFP = LHS->getType()->isFPOrFPVectorTy();
FastMathFlags FMF;
if (IsFP && Record.size() > OpNum+1)
@@ -5257,10 +5257,15 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
if (OpNum+1 != Record.size())
return error("Invalid record");
- if (LHS->getType()->isFPOrFPVectorTy())
- I = new FCmpInst((FCmpInst::Predicate)PredVal, LHS, RHS);
- else
- I = new ICmpInst((ICmpInst::Predicate)PredVal, LHS, RHS);
+ if (IsFP) {
+ if (!CmpInst::isFPPredicate(PredVal))
+ return error("Invalid fcmp predicate");
+ I = new FCmpInst(PredVal, LHS, RHS);
+ } else {
+ if (!CmpInst::isIntPredicate(PredVal))
+ return error("Invalid icmp predicate");
+ I = new ICmpInst(PredVal, LHS, RHS);
+ }
ResTypeID = getVirtualTypeID(I->getType()->getScalarType());
if (LHS->getType()->isVectorTy())