Add support for the llvm.memmove intrinsic
[oota-llvm.git] / lib / VMCore / Verifier.cpp
index 1d441d1dd5eccf0b9dbff4742a4096477dd76177..e2ccb5b12b99fed706ca20babc9e407821f6ffff 100644 (file)
@@ -241,6 +241,9 @@ void Verifier::visitFunction(Function &F) {
   Assert2(FT->getNumParams() == NumArgs,
           "# formal arguments must match # of arguments for function type!",
           &F, FT);
+  Assert1(F.getReturnType()->isFirstClassType() ||
+          F.getReturnType() == Type::VoidTy,
+          "Functions cannot return aggregate values!", &F);
 
   // Check that the argument values match the function type for this function...
   unsigned i = 0;
@@ -503,18 +506,25 @@ void Verifier::visitInstruction(Instruction &I) {
               "Cannot take the address of an intrinsic!", &I);
 
     else if (Instruction *Op = dyn_cast<Instruction>(I.getOperand(i))) {
+      BasicBlock *OpBlock = Op->getParent();
+
       // Check that a definition dominates all of its uses.
       //
       if (!isa<PHINode>(I)) {
+        // Invoke results are only usable in the normal destination, not in the
+        // exceptional destination.
+        if (InvokeInst *II = dyn_cast<InvokeInst>(Op))
+          OpBlock = II->getNormalDest();
+
         // Definition must dominate use unless use is unreachable!
-        Assert2(DS->dominates(Op->getParent(), BB) ||
+        Assert2(DS->dominates(OpBlock, BB) ||
                 !DS->dominates(&BB->getParent()->getEntryBlock(), BB),
                 "Instruction does not dominate all uses!", Op, &I);
       } else {
         // PHI nodes are more difficult than other nodes because they actually
         // "use" the value in the predecessor basic blocks they correspond to.
         BasicBlock *PredBB = cast<BasicBlock>(I.getOperand(i+1));
-        Assert2(DS->dominates(Op->getParent(), PredBB) ||
+        Assert2(DS->dominates(OpBlock, PredBB) ||
                 !DS->dominates(&BB->getParent()->getEntryBlock(), PredBB),
                 "Instruction does not dominate all uses!", Op, &I);
       }
@@ -545,6 +555,15 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
   case Intrinsic::longjmp:         NumArgs = 2; break;
   case Intrinsic::sigsetjmp:       NumArgs = 2; break;
   case Intrinsic::siglongjmp:      NumArgs = 2; break;
+
+  case Intrinsic::dbg_stoppoint:   NumArgs = 4; break;
+  case Intrinsic::dbg_region_start:NumArgs = 1; break;
+  case Intrinsic::dbg_region_end:  NumArgs = 1; break;
+  case Intrinsic::dbg_func_start:  NumArgs = 1; break;
+  case Intrinsic::dbg_declare:     NumArgs = 1; break;
+
+  case Intrinsic::memcpy:          NumArgs = 4; break;
+  case Intrinsic::memmove:         NumArgs = 4; break;
  
   case Intrinsic::alpha_ctlz:      NumArgs = 1; break;
   case Intrinsic::alpha_cttz:      NumArgs = 1; break;