[llvm-commits] [llvm-gcc-4.2] r113357 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-internal.h

Duncan Sands baldrick at free.fr
Wed Sep 8 07:06:36 PDT 2010


Author: baldrick
Date: Wed Sep  8 09:06:36 2010
New Revision: 113357

URL: http://llvm.org/viewvc/llvm-project?rev=113357&view=rev
Log:
The _Unwind_Resume_or_Rethrow fixup code in DwarfEHPrepare needs
llvm.eh.catch.all.value in order to do its job, but llvm-gcc was
only outputting it if the original code had a catch-all in it.
The result was that code that uses cleanups and catches some
exceptions (but not all) did not always work correctly.  So just
always output llvm.eh.catch.all.value when doing exception handling,
fixing several failures in the Ada ACATS test suite.

Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
    llvm-gcc-4.2/trunk/gcc/llvm-internal.h

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=113357&r1=113356&r2=113357&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Wed Sep  8 09:06:36 2010
@@ -188,6 +188,7 @@
   GreatestAlignment = TheTarget->getFrameInfo()->getStackAlignment();
   SeenVLA = NULL;
 
+  CatchAll = 0;
   ExceptionValue = 0;
   ExceptionSelectorValue = 0;
   FuncEHException = 0;
@@ -2151,6 +2152,23 @@
                                               Intrinsic::eh_selector);
   FuncEHGetTypeID = Intrinsic::getDeclaration(TheModule,
                                               Intrinsic::eh_typeid_for);
+
+  CatchAll = TheModule->getGlobalVariable("llvm.eh.catch.all.value");
+  if (!CatchAll && lang_eh_catch_all) {
+    Constant *Init = 0;
+    tree catch_all_type = lang_eh_catch_all();
+    if (catch_all_type == NULL_TREE)
+      // Use a C++ style null catch-all object.
+      Init = Constant::getNullValue(Type::getInt8PtrTy(Context));
+    else
+      // This language has a type that catches all others.
+      Init = cast<Constant>(Emit(catch_all_type, 0));
+
+    CatchAll = new GlobalVariable(*TheModule, Init->getType(), true,
+                                  GlobalVariable::LinkOnceAnyLinkage,
+                                  Init, "llvm.eh.catch.all.value");
+    CatchAll->setSection("llvm.metadata");
+  }
 }
 
 /// getPostPad - Return the post landing pad for the given exception handling
@@ -2204,7 +2222,6 @@
 
     bool HasCleanup = false;
     bool HasCatchAll = false;
-    static GlobalVariable *CatchAll = 0;
 
     for (std::vector<struct eh_region *>::iterator I = Handlers.begin(),
          E = Handlers.end(); I != E; ++I) {
@@ -2231,17 +2248,8 @@
         tree TypeList = get_eh_type_list(region);
 
         if (!TypeList) {
-          // Catch-all - push a null pointer.
-          if (!CatchAll) {
-            Constant *Init =
-              Constant::getNullValue(Type::getInt8PtrTy(Context));
-
-            CatchAll = new GlobalVariable(*TheModule, Init->getType(), true,
-                                          GlobalVariable::LinkOnceAnyLinkage,
-                                          Init, "llvm.eh.catch.all.value");
-            CatchAll->setSection("llvm.metadata");
-          }
-
+          // Catch-all - push the catch-all object.
+          assert(CatchAll && "Language did not define lang_eh_catch_all?");
           Args.push_back(CatchAll);
           HasCatchAll = true;
         } else {
@@ -2268,23 +2276,7 @@
           // 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.
-
-          if (!CatchAll) {
-            Constant *Init = 0;
-            tree catch_all_type = lang_eh_catch_all();
-            if (catch_all_type == NULL_TREE)
-              // Use a C++ style null catch-all object.
-              Init = Constant::getNullValue(Type::getInt8PtrTy(Context));
-            else
-              // This language has a type that catches all others.
-              Init = cast<Constant>(Emit(catch_all_type, 0));
-
-            CatchAll = new GlobalVariable(*TheModule, Init->getType(), true,
-                                          GlobalVariable::LinkOnceAnyLinkage,
-                                          Init, "llvm.eh.catch.all.value");
-            CatchAll->setSection("llvm.metadata");
-          }
-
+          assert(CatchAll && "Language did not define lang_eh_catch_all?");
           Args.push_back(CatchAll);
         }
       }

Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=113357&r1=113356&r2=113357&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Wed Sep  8 09:06:36 2010
@@ -320,6 +320,9 @@
   /// PostPads - The post landing pad for a given EH region.
   IndexedMap<BasicBlock *> PostPads;
 
+  /// CatchAll - Language specific catch-all object.
+  GlobalVariable *CatchAll;
+
   /// ExceptionValue - Is the local to receive the current exception.
   Value *ExceptionValue;
 





More information about the llvm-commits mailing list