[llvm-branch-commits] [llvm-gcc-tag] r97294 - in /llvm-gcc-4.2/tags/Apple/llvmgcc42-2325: ./ gcc/llvm-convert.cpp

Bill Wendling isanbard at gmail.com
Fri Feb 26 16:50:15 PST 2010


Author: void
Date: Fri Feb 26 18:50:15 2010
New Revision: 97294

URL: http://llvm.org/viewvc/llvm-project?rev=97294&view=rev
Log:
Copy of Hermes to test EH patch.

Added:
    llvm-gcc-4.2/tags/Apple/llvmgcc42-2325/
      - copied from r97287, llvm-gcc-4.2/branches/Apple/Hermes/
Modified:
    llvm-gcc-4.2/tags/Apple/llvmgcc42-2325/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/tags/Apple/llvmgcc42-2325/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/tags/Apple/llvmgcc42-2325/gcc/llvm-convert.cpp?rev=97294&r1=97287&r2=97294&view=diff
==============================================================================
--- llvm-gcc-4.2/tags/Apple/llvmgcc42-2325/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/tags/Apple/llvmgcc42-2325/gcc/llvm-convert.cpp Fri Feb 26 18:50:15 2010
@@ -2089,6 +2089,8 @@
     // Add selections for each handler.
     foreach_reachable_handler(i, false, AddHandler, &Handlers);
 
+    bool HasCleanup = false;
+
     for (std::vector<struct eh_region *>::iterator I = Handlers.begin(),
          E = Handlers.end(); I != E; ++I) {
       struct eh_region *region = *I;
@@ -2125,30 +2127,36 @@
             Args.push_back(Emit(TType, 0));
           }
         }
+      } else {
+        // Cleanup.
+        HasCleanup = true;
       }
     }
 
     if (can_throw_external_1(i, false)) {
-      // Some exceptions from this region may not be caught by any handler.
-      // Since invokes are required to branch to the unwind label no matter
-      // what exception is being unwound, append a catch-all.
-
-      // The representation of a catch-all is language specific.
-      Value *CatchAll;
-      if (USING_SJLJ_EXCEPTIONS || !lang_eh_catch_all) {
-        // Use a "cleanup" - this should be good enough for most languages.
-        CatchAll = ConstantInt::get(Type::getInt32Ty(Context), 0);
+      if (HasCleanup && Args.size() == 2) {
+        Args.push_back(ConstantInt::get(Type::getInt32Ty(Context), 0));
       } else {
-        tree catch_all_type = lang_eh_catch_all();
-        if (catch_all_type == NULL_TREE)
-          // Use a C++ style null catch-all object.
-          CatchAll = Constant::getNullValue(
-                                    Type::getInt8PtrTy(Context));
-        else
-          // This language has a type that catches all others.
-          CatchAll = Emit(catch_all_type, 0);
+        // Some exceptions from this region may not be caught by any handler.
+        // Since invokes are required to branch to the unwind label no matter
+        // what exception is being unwound, append a catch-all.
+
+        // The representation of a catch-all is language specific.
+        Value *CatchAll;
+        if (USING_SJLJ_EXCEPTIONS || !lang_eh_catch_all) {
+          // Use a "cleanup" - this should be good enough for most languages.
+          CatchAll = ConstantInt::get(Type::getInt32Ty(Context), 0);
+        } else {
+          tree catch_all_type = lang_eh_catch_all();
+          if (catch_all_type == NULL_TREE)
+            // Use a C++ style null catch-all object.
+            CatchAll = Constant::getNullValue(Type::getInt8PtrTy(Context));
+          else
+            // This language has a type that catches all others.
+            CatchAll = Emit(catch_all_type, 0);
+        }
+        Args.push_back(CatchAll);
       }
-      Args.push_back(CatchAll);
     }
 
     // Emit the selector call.





More information about the llvm-branch-commits mailing list