diff --git a/llvm/include/llvm/Intrinsics.h b/llvm/include/llvm/Intrinsics.h index 81c25b810275..5c1436291861 100644 --- a/llvm/include/llvm/Intrinsics.h +++ b/llvm/include/llvm/Intrinsics.h @@ -17,10 +17,17 @@ namespace LLVMIntrinsic { enum ID { not_intrinsic = 0, // Must be zero + // Varargs handling intrinsics... va_start, // Used to represent a va_start call in C va_end, // Used to represent a va_end call in C va_copy, // Used to represent a va_copy call in C + // Exception handling intrinsics... + exc_throw, // Throw an exception + exc_rethrow, // Rethrow a caught exception + exc_getcurrent, // Get the current pending exception + + // Setjmp/Longjmp intrinsics... setjmp, // Used to represent a setjmp call in C longjmp, // Used to represent a longjmp call in C sigsetjmp, // Used to represent a sigsetjmp call in C diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp index 805070b03049..654cf547e9ab 100644 --- a/llvm/lib/VMCore/Function.cpp +++ b/llvm/lib/VMCore/Function.cpp @@ -189,10 +189,16 @@ unsigned Function::getIntrinsicID() const { switch (getName()[5]) { case 'a': - for (unsigned i = 0; i < num_alpha_intrinsics; ++i) { - if (getName() == alpha_intrinsics[i].name) - return alpha_intrinsics[i].id; - } + if (getName().size() > 11 && + std::string(getName().begin()+4, getName().begin()+11) == ".alpha.") + for (unsigned i = 0; i < num_alpha_intrinsics; ++i) + if (getName() == alpha_intrinsics[i].name) + return alpha_intrinsics[i].id; + break; + case 'e': + if (getName() == "llvm.exc.getcurrent")return LLVMIntrinsic::exc_getcurrent; + if (getName() == "llvm.exc.rethrow") return LLVMIntrinsic::exc_getcurrent; + if (getName() == "llvm.exc.throw") return LLVMIntrinsic::exc_getcurrent; break; case 'l': if (getName() == "llvm.longjmp") return LLVMIntrinsic::longjmp; diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index 644ef10b9d18..eae7d8c1cfe1 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/lib/VMCore/Verifier.cpp @@ -510,6 +510,8 @@ void Verifier::visitIntrinsicFunctionCall(LLVMIntrinsic::ID ID, CallInst &CI) { Assert1(IF->isExternal(), "Intrinsic functions should never be defined!", IF); unsigned NumArgs = 0; + // FIXME: this should check the return type of each intrinsic as well, also + // arguments! switch (ID) { case LLVMIntrinsic::va_start: Assert1(CI.getParent()->getParent()->getFunctionType()->isVarArg(), @@ -519,6 +521,11 @@ void Verifier::visitIntrinsicFunctionCall(LLVMIntrinsic::ID ID, CallInst &CI) { break; case LLVMIntrinsic::va_end: NumArgs = 1; break; case LLVMIntrinsic::va_copy: NumArgs = 2; break; + + case LLVMIntrinsic::exc_throw: NumArgs = 1; break; + case LLVMIntrinsic::exc_rethrow: NumArgs = 0; break; + case LLVMIntrinsic::exc_getcurrent: NumArgs = 0; break; + case LLVMIntrinsic::setjmp: NumArgs = 1; break; case LLVMIntrinsic::longjmp: NumArgs = 2; break; case LLVMIntrinsic::sigsetjmp: NumArgs = 2; break;