OSDN Git Service

reject attempts to take the address of an intrinsic, PR4949.
authorChris Lattner <sabre@nondot.org>
Fri, 11 Sep 2009 17:05:29 +0000 (17:05 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 11 Sep 2009 17:05:29 +0000 (17:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81530 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Verifier.cpp

index 5d9d7ad..d31e6cb 100644 (file)
@@ -638,6 +638,18 @@ void Verifier::visitFunction(Function &F) {
     Assert1(pred_begin(Entry) == pred_end(Entry),
             "Entry block to function must not have predecessors!", Entry);
   }
+  
+  // If this function is actually an intrinsic, verify that it is only used in
+  // direct call/invokes, never having its "address taken".
+  if (F.getIntrinsicID()) {
+    for (Value::use_iterator UI = F.use_begin(), E = F.use_end(); UI != E;++UI){
+      User *U = cast<User>(UI);
+      if ((isa<CallInst>(U) || isa<InvokeInst>(U)) && UI.getOperandNo() == 0)
+        continue;  // Direct calls/invokes are ok.
+      
+      Assert1(0, "Invalid user of intrinsic instruction!", U); 
+    }
+  }
 }
 
 // verifyBasicBlock - Verify that a basic block is well formed...