- Add a "getOrInsertGlobal" method to the Module class. This acts similarly to
[oota-llvm.git] / lib / VMCore / Verifier.cpp
index affbc9a6ba4a4ad29077bde94dad48ec8c293c38..f8dd24c3af62f0f7eea74b92fc96742eff954ed5 100644 (file)
@@ -1347,8 +1347,10 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
   case Intrinsic::gcwrite:
   case Intrinsic::gcread:
     if (ID == Intrinsic::gcroot) {
-      Assert1(isa<AllocaInst>(CI.getOperand(1)->stripPointerCasts()),
-              "llvm.gcroot parameter #1 must be an alloca.", &CI);
+      AllocaInst *AI =
+        dyn_cast<AllocaInst>(CI.getOperand(1)->stripPointerCasts());
+      Assert1(AI && isa<PointerType>(AI->getType()->getElementType()),
+              "llvm.gcroot parameter #1 must be a pointer alloca.", &CI);
       Assert1(isa<Constant>(CI.getOperand(2)),
               "llvm.gcroot parameter #2 must be a constant.", &CI);
     }
@@ -1361,6 +1363,14 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
             "llvm.init_trampoline parameter #2 must resolve to a function.",
             &CI);
     break;
+  case Intrinsic::prefetch:
+    Assert1(isa<ConstantInt>(CI.getOperand(2)) &&
+            isa<ConstantInt>(CI.getOperand(3)) &&
+            cast<ConstantInt>(CI.getOperand(2))->getZExtValue() < 2 &&
+            cast<ConstantInt>(CI.getOperand(3))->getZExtValue() < 4,
+            "invalid arguments to llvm.prefetch",
+            &CI);
+    break;
   }
 }