Initial support for recognizing LLVM exception handling intrinsics
authorChris Lattner <sabre@nondot.org>
Sun, 24 Aug 2003 05:30:29 +0000 (05:30 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 24 Aug 2003 05:30:29 +0000 (05:30 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8102 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Intrinsics.h
lib/VMCore/Function.cpp
lib/VMCore/Verifier.cpp

index 81c25b810275814df5e8727593a1c3cd8b3022a4..5c143629186127084f8b33bf6091e9e530e964e7 100644 (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
index 805070b030496795de389c2df77cd0b40e705bf9..654cf547e9abd65f05d3be40c92bcc1884539270 100644 (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;
index 644ef10b9d187ad5677ab30b37a1a7dd1ee9acb5..eae7d8c1cfe17f0a3e94033e99132186c16b6ec0 100644 (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;