reject attempts to take the address of an intrinsic, PR4949.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81530 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 5d9d7ad..d31e6cb 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -638,6 +638,18 @@
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...