[llvm] r233788 - [WinEH] Implement support for catch-all

David Majnemer david.majnemer at gmail.com
Tue Mar 31 22:20:42 PDT 2015


Author: majnemer
Date: Wed Apr  1 00:20:42 2015
New Revision: 233788

URL: http://llvm.org/viewvc/llvm-project?rev=233788&view=rev
Log:
[WinEH] Implement support for catch-all

A catch (...) doesn't have a type descriptor.  Instead, the 'adjectives'
field has bit six set.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=233788&r1=233787&r2=233788&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Wed Apr  1 00:20:42 2015
@@ -335,14 +335,19 @@ void WinEHNumbering::createTryBlockMapEn
   assert(TBME.CatchHigh > TBME.TryHigh);
   for (CatchHandler *CH : Handlers) {
     WinEHHandlerType HT;
-    auto *GV = cast<GlobalVariable>(CH->getSelector()->stripPointerCasts());
-    // Selectors are always pointers to GlobalVariables with 'struct' type.
-    // The struct has two fields, adjectives and a type descriptor.
-    auto *CS = cast<ConstantStruct>(GV->getInitializer());
-    HT.Adjectives =
-        cast<ConstantInt>(CS->getAggregateElement(0U))->getZExtValue();
-    HT.TypeDescriptor = cast<GlobalVariable>(
-        CS->getAggregateElement(1)->stripPointerCasts());
+    if (CH->getSelector()->isNullValue()) {
+      HT.Adjectives = 0x40;
+      HT.TypeDescriptor = nullptr;
+    } else {
+      auto *GV = cast<GlobalVariable>(CH->getSelector()->stripPointerCasts());
+      // Selectors are always pointers to GlobalVariables with 'struct' type.
+      // The struct has two fields, adjectives and a type descriptor.
+      auto *CS = cast<ConstantStruct>(GV->getInitializer());
+      HT.Adjectives =
+          cast<ConstantInt>(CS->getAggregateElement(0U))->getZExtValue();
+      HT.TypeDescriptor =
+          cast<GlobalVariable>(CS->getAggregateElement(1)->stripPointerCasts());
+    }
     HT.Handler = cast<Function>(CH->getHandlerBlockOrFunc());
     // FIXME: We don't support catching objects yet!
     HT.CatchObjIdx = INT_MAX;





More information about the llvm-commits mailing list