diff options
author | Chris Lattner <sabre@nondot.org> | 2008-04-23 20:33:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-04-23 20:33:41 +0000 |
commit | 1e31bf5b1988def2a360b6570b673e162891fb3d (patch) | |
tree | 79ee2466848ae5d9fce0d2932fbc80617035ea92 | |
parent | e9e3891c094b2fb39395492865ac5658370acaeb (diff) | |
download | bcm5719-llvm-1e31bf5b1988def2a360b6570b673e162891fb3d.tar.gz bcm5719-llvm-1e31bf5b1988def2a360b6570b673e162891fb3d.zip |
tighten up verifier checks which missed cases where
return instrs operands didn't match up with function results.
llvm-svn: 50182
-rw-r--r-- | llvm/lib/VMCore/Verifier.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index 8a1b86f763a..a0d7d0fe65e 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/lib/VMCore/Verifier.cpp @@ -592,22 +592,23 @@ void Verifier::visitTerminatorInst(TerminatorInst &I) { void Verifier::visitReturnInst(ReturnInst &RI) { Function *F = RI.getParent()->getParent(); unsigned N = RI.getNumOperands(); - if (N == 0) - Assert2(F->getReturnType() == Type::VoidTy, + if (F->getReturnType() == Type::VoidTy) + Assert2(N == 0, "Found return instr that returns void in Function of non-void " "return type!", &RI, F->getReturnType()); else if (const StructType *STy = dyn_cast<StructType>(F->getReturnType())) { - for (unsigned i = 0; i < N; i++) + Assert2(STy->getNumElements() == N, + "Incorrect number of return values in ret instruction!", + &RI, F->getReturnType()); + for (unsigned i = 0; i != N; ++i) Assert2(STy->getElementType(i) == RI.getOperand(i)->getType(), "Function return type does not match operand " "type of return inst!", &RI, F->getReturnType()); - } - else if (N == 1) - Assert2(F->getReturnType() == RI.getOperand(0)->getType(), + } else { + Assert2(N == 1 && F->getReturnType() == RI.getOperand(0)->getType(), "Function return type does not match operand " "type of return inst!", &RI, F->getReturnType()); - else - Assert1(0, "Invalid return type!", &RI); + } // Check to make sure that the return value has necessary properties for // terminators... |