X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=lib%2FVMCore%2FVerifier.cpp;h=e86c89bfa82766e6a794d75ec8c98e5ab9a3064f;hb=e6be34a53ecbe8c2ff9f0793b13d847e94c0de91;hp=427b95b36dae37252645adbb007531117ae95b23;hpb=22c3979fcaa7ff19c44253eb9b0b0160dfef0aa4;p=oota-llvm.git diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 427b95b36da..e86c89bfa82 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -576,14 +576,22 @@ void Verifier::visitTerminatorInst(TerminatorInst &I) { void Verifier::visitReturnInst(ReturnInst &RI) { Function *F = RI.getParent()->getParent(); - if (RI.getNumOperands() == 0) + unsigned N = RI.getNumOperands(); + if (N == 0) Assert2(F->getReturnType() == Type::VoidTy, "Found return instr that returns void in Function of non-void " "return type!", &RI, F->getReturnType()); - else + else if (N == 1) Assert2(F->getReturnType() == RI.getOperand(0)->getType(), "Function return type does not match operand " "type of return inst!", &RI, F->getReturnType()); + else if (const StructType *STy = dyn_cast(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 + Assert1(0, "Invalid return type!", &RI); // Check to make sure that the return value has necessary properties for // terminators...