[llvm-commits] [dragonegg] r141094 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp

Duncan Sands baldrick at free.fr
Tue Oct 4 10:01:06 PDT 2011


Author: baldrick
Date: Tue Oct  4 12:01:05 2011
New Revision: 141094

URL: http://llvm.org/viewvc/llvm-project?rev=141094&view=rev
Log:
Add lowering for builtin_eh_copy_values and (while there)
builtin_eh_filter.  These can occur if GCC optimizations
are enabled.  Fixes PR11049.

Modified:
    dragonegg/trunk/include/dragonegg/Internals.h
    dragonegg/trunk/src/Convert.cpp

Modified: dragonegg/trunk/include/dragonegg/Internals.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=141094&r1=141093&r2=141094&view=diff
==============================================================================
--- dragonegg/trunk/include/dragonegg/Internals.h (original)
+++ dragonegg/trunk/include/dragonegg/Internals.h Tue Oct  4 12:01:05 2011
@@ -646,6 +646,8 @@
   bool EmitBuiltinVAEnd(gimple_statement_d *stmt);
   bool EmitBuiltinVAStart(gimple_statement_d *stmt);
 
+  bool EmitBuiltinEHCopyValues(gimple_statement_d *stmt);
+  bool EmitBuiltinEHFilter(gimple_statement_d *stmt, Value *&Result);
   bool EmitBuiltinEHPointer(gimple_statement_d *stmt, Value *&Result);
   bool EmitBuiltinDwarfCFA(gimple_statement_d *stmt, Value *&Result);
   bool EmitBuiltinDwarfSPColumn(gimple_statement_d *stmt, Value *&Result);

Modified: dragonegg/trunk/src/Convert.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=141094&r1=141093&r2=141094&view=diff
==============================================================================
--- dragonegg/trunk/src/Convert.cpp (original)
+++ dragonegg/trunk/src/Convert.cpp Tue Oct  4 12:01:05 2011
@@ -3748,6 +3748,10 @@
   case BUILT_IN_UNREACHABLE:    return EmitBuiltinUnreachable();
 
   // Exception handling builtins.
+  case BUILT_IN_EH_COPY_VALUES:
+    return EmitBuiltinEHCopyValues(stmt);
+  case BUILT_IN_EH_FILTER:
+    return EmitBuiltinEHFilter(stmt, Result);
   case BUILT_IN_EH_POINTER:
     return EmitBuiltinEHPointer(stmt, Result);
 
@@ -5035,6 +5039,31 @@
 
 // Exception handling builtins.
 
+bool TreeToLLVM::EmitBuiltinEHCopyValues(gimple stmt) {
+  unsigned DstRegionNo = tree_low_cst(gimple_call_arg(stmt, 0), 0);
+  unsigned SrcRegionNo = tree_low_cst(gimple_call_arg(stmt, 1), 0);
+  // Copy the exception pointer.
+  Value *ExcPtr = Builder.CreateLoad(getExceptionPtr(SrcRegionNo));
+  Builder.CreateStore(ExcPtr, getExceptionPtr(DstRegionNo));
+  // Copy the selector value.
+  Value *Filter = Builder.CreateLoad(getExceptionFilter(SrcRegionNo));
+  Builder.CreateStore(Filter, getExceptionFilter(DstRegionNo));
+  return true;
+}
+
+bool TreeToLLVM::EmitBuiltinEHFilter(gimple stmt, Value *&Result) {
+  // Lookup the local that holds the selector value for this region.
+  unsigned RegionNo = tree_low_cst(gimple_call_arg(stmt, 0), 0);
+  AllocaInst *Filter = getExceptionFilter(RegionNo);
+  // Load the selector value out.
+  Result = Builder.CreateLoad(Filter);
+  // Ensure the returned value has the right integer type.
+  tree type = gimple_call_return_type(stmt);
+  Result = CastToAnyType(Result, /*isSigned*/true, getRegType(type),
+                         /*isSigned*/!TYPE_UNSIGNED(type));
+  return true;
+}
+
 bool TreeToLLVM::EmitBuiltinEHPointer(gimple stmt, Value *&Result) {
   // Lookup the local that holds the exception pointer for this region.
   unsigned RegionNo = tree_low_cst(gimple_call_arg(stmt, 0), 0);
@@ -5043,7 +5072,7 @@
   Result = Builder.CreateLoad(ExcPtr);
   // Ensure the returned value has the right pointer type.
   tree type = gimple_call_return_type(stmt);
-  Result = Builder.CreateBitCast(Result, ConvertType(type));
+  Result = Builder.CreateBitCast(Result, getRegType(type));
   return true;
 }
 





More information about the llvm-commits mailing list