[llvm-commits] [llvm-gcc-4.2] r50269 - in /llvm-gcc-4.2/trunk/gcc: ada/misc.c llvm-convert.cpp

Duncan Sands baldrick at free.fr
Fri Apr 25 10:39:27 PDT 2008


Author: baldrick
Date: Fri Apr 25 12:39:27 2008
New Revision: 50269

URL: http://llvm.org/viewvc/llvm-project?rev=50269&view=rev
Log:
Fix Ada exception handling in the presence of LLVM
inlining.  Due to inlining we can get the following:
   invoke .. unwind label %lpad
 lpad:
   %eh_select = call ... @llvm.eh.selector.i32(... , <catch-all>)
   ...
   invoke ... @_Unwind_Resume (...) unwind label %rpad
 rpad:
   <do stuff>
The Ada catch-all used to be a cleanup, but in this
case the personality function is not expecting the
@_Unwind_Resume call to be caught in the same function.
So I've changed the catch-all to a real catch-all type
info, which seems to work fine.  C++ had a very similar
problem, with different details but the same conclusion:
a cleanup doesn't cut the mustard, a real catch-all (NULL
in the C++ case) is needed.
If we used a special intrinsic or instruction for
rewinding rather than a library call then the inliner
could simplify invoke-of-rewind to a branch and this
problem would not arise.  On the happy day when this
is implemented probably both Ada and C++ could go back
to using a cleanup.   

Modified:
    llvm-gcc-4.2/trunk/gcc/ada/misc.c
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/ada/misc.c
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ada/misc.c?rev=50269&r1=50268&r2=50269&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/ada/misc.c (original)
+++ llvm-gcc-4.2/trunk/gcc/ada/misc.c Fri Apr 25 12:39:27 2008
@@ -492,6 +492,17 @@
 #endif
 }
 
+/* LLVM local begin */
+/* Return a type info that catches all exceptions.  */
+static tree gnat_eh_catch_all (void);
+
+tree
+gnat_eh_catch_all (void)
+{
+    return build_unary_op (ADDR_EXPR, NULL_TREE, all_others_decl);
+}
+/* LLVM local end */
+
 /* If we are using the GCC mechanism to process exception handling, we
    have to register the personality routine for Ada and to initialize
    various language dependent hooks.  */
@@ -515,6 +526,7 @@
   /* LLVM LOCAL begin */
   llvm_eh_personality_libfunc = llvm_init_one_libfunc ("__gnat_eh_personality");
   default_init_unwind_resume_libfunc ();
+  lang_eh_catch_all = gnat_eh_catch_all;
   /* LLVM LOCAL end */
   lang_eh_type_covers = gnat_eh_type_covers;
   lang_eh_runtime_type = gnat_eh_runtime_type;

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=50269&r1=50268&r2=50269&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri Apr 25 12:39:27 2008
@@ -1975,7 +1975,7 @@
           Catch_All = Constant::getNullValue(PointerType::getUnqual(Type::Int8Ty));
         else
           // This language has a type that catches all others.
-          Catch_All = Emit(lookup_type_for_runtime(catch_all_type), 0);
+          Catch_All = Emit(catch_all_type, 0);
       }
       Args.push_back(Catch_All);
     }





More information about the llvm-commits mailing list