aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2010-08-22 23:45:14 +0000
committerNick Lewycky <nicholas@mxc.ca>2010-08-22 23:45:14 +0000
commit55e97d47c4c801aaf599854706f9210f90d8980d (patch)
tree8a78fb690635a07af34b8cd4f367e4d9951a2ff1 /lib/VMCore
parent24a1182184336c088f70e86191ebda47df629beb (diff)
downloadexternal_llvm-55e97d47c4c801aaf599854706f9210f90d8980d.zip
external_llvm-55e97d47c4c801aaf599854706f9210f90d8980d.tar.gz
external_llvm-55e97d47c4c801aaf599854706f9210f90d8980d.tar.bz2
Verify the predicates on icmp/fcmp. Suggested by Jeff Yasskin!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111787 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Verifier.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index a3f1510..b2eba79 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -1282,28 +1282,37 @@ void Verifier::visitBinaryOperator(BinaryOperator &B) {
visitInstruction(B);
}
-void Verifier::visitICmpInst(ICmpInst& IC) {
+void Verifier::visitICmpInst(ICmpInst &IC) {
// Check that the operands are the same type
- const Type* Op0Ty = IC.getOperand(0)->getType();
- const Type* Op1Ty = IC.getOperand(1)->getType();
+ const Type *Op0Ty = IC.getOperand(0)->getType();
+ const Type *Op1Ty = IC.getOperand(1)->getType();
Assert1(Op0Ty == Op1Ty,
"Both operands to ICmp instruction are not of the same type!", &IC);
// Check that the operands are the right type
Assert1(Op0Ty->isIntOrIntVectorTy() || Op0Ty->isPointerTy(),
"Invalid operand types for ICmp instruction", &IC);
+ // Check that the predicate is valid.
+ Assert1(IC.getPredicate() >= CmpInst::FIRST_ICMP_PREDICATE &&
+ IC.getPredicate() <= CmpInst::LAST_ICMP_PREDICATE,
+ "Invalid predicate in ICmp instruction!", &IC);
visitInstruction(IC);
}
-void Verifier::visitFCmpInst(FCmpInst& FC) {
+void Verifier::visitFCmpInst(FCmpInst &FC) {
// Check that the operands are the same type
- const Type* Op0Ty = FC.getOperand(0)->getType();
- const Type* Op1Ty = FC.getOperand(1)->getType();
+ const Type *Op0Ty = FC.getOperand(0)->getType();
+ const Type *Op1Ty = FC.getOperand(1)->getType();
Assert1(Op0Ty == Op1Ty,
"Both operands to FCmp instruction are not of the same type!", &FC);
// Check that the operands are the right type
Assert1(Op0Ty->isFPOrFPVectorTy(),
"Invalid operand types for FCmp instruction", &FC);
+ // Check that the predicate is valid.
+ Assert1(FC.getPredicate() >= CmpInst::FIRST_FCMP_PREDICATE &&
+ FC.getPredicate() <= CmpInst::LAST_FCMP_PREDICATE,
+ "Invalid predicate in FCmp instruction!", &FC);
+
visitInstruction(FC);
}