[llvm-commits] [129262] A function that only has cleanups (destructors) to run when an exception is raised

clattner at apple.com clattner at apple.com
Wed Jul 11 10:27:27 PDT 2007


Revision: 129262
Author:   clattner
Date:     2007-07-11 10:27:26 -0700 (Wed, 11 Jul 2007)

Log Message:
-----------
A function that only has cleanups (destructors) to run when an exception is raised
currently is not assigned a personality function because we don't bother creating
a call to eh.selector if there are no catches.  But the personality function is
still needed, since it is the personality function that analyses the exception table
and decides where to jump to (to the cleanups in this case).  This patch causes a
call to eh.selector to be generated in every landing pad, even if it has no type infos,
because that specifies the personality function.

Patch from Duncan Sands.

Modified Paths:
--------------
    apple-local/branches/llvm/gcc/llvm-convert.cpp

Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp
===================================================================
--- apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-07-10 17:46:46 UTC (rev 129261)
+++ apple-local/branches/llvm/gcc/llvm-convert.cpp	2007-07-11 17:27:26 UTC (rev 129262)
@@ -2009,6 +2009,11 @@
   // Fetch and store the exception selector.
   std::vector<Value*> Args;
 
+  // The exception and the personality function.
+  Args.push_back(Builder.CreateLoad(ExceptionValue, "eh_ptr"));
+  Args.push_back(CastToType(Instruction::BitCast, FuncCPPPersonality,
+                            PointerType::get(Type::Int8Ty)));
+
   for (std::vector<EHScope>::reverse_iterator I = CurrentEHScopes.rbegin(),
        E = CurrentEHScopes.rend(); I != E; ++I) {
     if (TREE_CODE(I->TryExpr) == TRY_CATCH_EXPR) {
@@ -2022,16 +2027,6 @@
                          EH_FILTER_EXPR) ? FilterExpr : CatchList;
       }
 
-      if (I->InfosType == CatchList && !I->TypeInfos.size())
-        continue;
-
-      // Lazily add the exception and the personality function.
-      if (!Args.size()) {
-        Args.push_back(Builder.CreateLoad(ExceptionValue, "eh_ptr"));
-        Args.push_back(CastToType(Instruction::BitCast, FuncCPPPersonality,
-                                  PointerType::get(Type::Int8Ty)));
-      }
-
       if (I->InfosType == FilterExpr)
         // Filter - note the size.
         Args.push_back(ConstantInt::get(Type::Int32Ty, I->TypeInfos.size()));
@@ -2042,11 +2037,9 @@
     }
   }
 
-  if (Args.size()) {
-    Value *Select = Builder.CreateCall(FuncEHSelector, &Args[0], Args.size(),
-                                       "eh_select");
-    Builder.CreateStore(Select, ExceptionSelectorValue);
-  }
+  Value *Select = Builder.CreateCall(FuncEHSelector, &Args[0], Args.size(),
+                                     "eh_select");
+  Builder.CreateStore(Select, ExceptionSelectorValue);
 }
 
 





More information about the llvm-commits mailing list