Allow llvm.gcroot to work with non-pointer allocas.
authorTalin <viridia@gmail.com>
Thu, 30 Sep 2010 20:23:47 +0000 (20:23 +0000)
committerTalin <viridia@gmail.com>
Thu, 30 Sep 2010 20:23:47 +0000 (20:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115198 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Verifier.cpp

index 7216891c8270a8728715efaa07d5f569ca2f77d5..384acb748b19bc627446c03d34e3cf98c1e05290 100644 (file)
@@ -1645,10 +1645,14 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
     if (ID == Intrinsic::gcroot) {
       AllocaInst *AI =
         dyn_cast<AllocaInst>(CI.getArgOperand(0)->stripPointerCasts());
-      Assert1(AI && AI->getType()->getElementType()->isPointerTy(),
-              "llvm.gcroot parameter #1 must be a pointer alloca.", &CI);
+      Assert1(AI, "llvm.gcroot parameter #1 must be an alloca.", &CI);
       Assert1(isa<Constant>(CI.getArgOperand(1)),
               "llvm.gcroot parameter #2 must be a constant.", &CI);
+      if (!AI->getType()->getElementType()->isPointerTy()) {
+        Assert1(!isa<ConstantPointerNull>(CI.getArgOperand(1)),
+                "llvm.gcroot parameter #1 must either be a pointer alloca, "
+                "or argument #2 must be a non-null constant.", &CI);
+      }
     }
 
     Assert1(CI.getParent()->getParent()->hasGC(),