Initial support for recognizing LLVM exception handling intrinsics

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8102 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-08-24 05:30:29 +00:00
parent 6a67393e19
commit 9dd7d1c8eb
3 changed files with 24 additions and 4 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;