Teach VMCore to constant fold shufflevectors with constant operands.
[oota-llvm.git] / lib / VMCore / Verifier.cpp
index a547721d68d7ec03786b1d204d9b2317ec7bb2ed..c3633ff97a11635c9fa916346c13d8ed5c6dda6f 100644 (file)
@@ -390,12 +390,16 @@ void Verifier::visitFunction(Function &F) {
           F.getReturnType() == Type::VoidTy,
           "Functions cannot return aggregate values!", &F);
 
-  Assert1(!FT->isStructReturn() || FT->getReturnType() == Type::VoidTy,
+  Assert1(!F.isStructReturn() || FT->getReturnType() == Type::VoidTy,
           "Invalid struct-return function!", &F);
 
   bool SawSRet = false;
 
-  if (const ParamAttrsList *Attrs = FT->getParamAttrs()) {
+  if (const ParamAttrsList *Attrs = F.getParamAttrs()) {
+    Assert1(Attrs->size() &&
+            Attrs->getParamIndex(Attrs->size()-1) <= FT->getNumParams(),
+            "Function has excess attributes!", &F);
+
     bool SawNest = false;
 
     for (unsigned Idx = 0; Idx <= FT->getNumParams(); ++Idx) {
@@ -448,7 +452,7 @@ void Verifier::visitFunction(Function &F) {
     }
   }
 
-  Assert1(SawSRet == FT->isStructReturn(),
+  Assert1(SawSRet == F.isStructReturn(),
           "StructReturn function with no sret attribute!", &F);
 
   // Check that this function meets the restrictions on this calling convention.