Reject attempts to define intrinsics. This fixes PR1047 and

Regression/Verifier/2006-12-12-IntrinsicDefine.ll

llvm-svn: 32529
This commit is contained in:
Chris Lattner 2006-12-13 04:30:37 +00:00
parent fc069248f7
commit 50a9951809
1 changed files with 7 additions and 0 deletions

View File

@ -112,6 +112,7 @@ namespace { // Anonymous namespace for class
bool runOnFunction(Function &F) { bool runOnFunction(Function &F) {
// Get dominator information if we are being run by PassManager // Get dominator information if we are being run by PassManager
if (RealPass) EF = &getAnalysis<ETForest>(); if (RealPass) EF = &getAnalysis<ETForest>();
visit(F); visit(F);
InstsInThisBlock.clear(); InstsInThisBlock.clear();
@ -333,6 +334,12 @@ void Verifier::visitFunction(Function &F) {
F.getReturnType() == Type::VoidTy, F.getReturnType() == Type::VoidTy,
"Functions cannot return aggregate values!", &F); "Functions cannot return aggregate values!", &F);
// Verify that this function (which has a body) is not named "llvm.*". It
// is not legal to define intrinsics.
if (F.getName().size() >= 5)
Assert1(F.getName().substr(0, 5) != "llvm.",
"llvm intrinsics cannot be defined!", &F);
// Check that this function meets the restrictions on this calling convention. // Check that this function meets the restrictions on this calling convention.
switch (F.getCallingConv()) { switch (F.getCallingConv()) {
default: default: