diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-24 05:30:29 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-24 05:30:29 +0000 |
commit | 9dd7d1c8eb9ade8426545129eb2e3e41b824eb8e (patch) | |
tree | 3674bf59823b463b0cf6de56019f7aae7e55bb12 | |
parent | 6a67393e19632a9829c7ba0d3e7446db322612d9 (diff) |
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
-rw-r--r-- | include/llvm/Intrinsics.h | 7 | ||||
-rw-r--r-- | lib/VMCore/Function.cpp | 14 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 7 |
3 files changed, 24 insertions, 4 deletions
diff --git a/include/llvm/Intrinsics.h b/include/llvm/Intrinsics.h index 81c25b8102..5c14362918 100644 --- a/include/llvm/Intrinsics.h +++ b/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/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 805070b030..654cf547e9 100644 --- a/lib/VMCore/Function.cpp +++ b/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/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 644ef10b9d..eae7d8c1cf 100644 --- a/lib/VMCore/Verifier.cpp +++ b/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; |