Add the AddLandingPadInfo function.
authorBill Wendling <isanbard@gmail.com>
Thu, 28 Jul 2011 23:42:57 +0000 (23:42 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 28 Jul 2011 23:42:57 +0000 (23:42 +0000)
AddLandingPadInfo takes a landingpad instruction and grabs all of the
information from it that it needs for EH table generation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136429 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/FunctionLoweringInfo.h
lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp

index 7eb21b5c669f78c00b7cd46d6ac4327e48bd818f..280481b25a3d48c1a69963547c76ae632f6901b5 100644 (file)
@@ -220,6 +220,11 @@ void AddCatchInfo(const CallInst &I,
 void CopyCatchInfo(const BasicBlock *SuccBB, const BasicBlock *LPad,
                    MachineModuleInfo *MMI, FunctionLoweringInfo &FLI);
 
+/// AddLandingPadInfo - Extract the exception handling information from the
+/// landingpad instruction and add them to the specified machine module info.
+void AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI,
+                       MachineBasicBlock *MBB);
+
 } // end namespace llvm
 
 #endif
index d5bf12055e07bc623a1f84926fe8f687da24355b..1f41f043dba8c16a5bd9ec97d6f7607de7a736e6 100644 (file)
@@ -454,3 +454,37 @@ void llvm::CopyCatchInfo(const BasicBlock *SuccBB, const BasicBlock *LPad,
       break;
   }
 }
+
+//--------- NEW EH - Begin ---------
+
+/// AddLandingPadInfo - Extract the exception handling information from the
+/// landingpad instruction and add them to the specified machine module info.
+void llvm::AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI,
+                             MachineBasicBlock *MBB) {
+  MMI.addPersonality(MBB, I.getPersonalityFn());
+
+  if (I.isCleanup())
+    MMI.addCleanup(MBB);
+
+  for (unsigned i = 0, e = I.getNumClauses(); i != e; ) {
+    switch (I.getClauseType(i)) {
+    case LandingPadInst::Catch:
+      MMI.addCatchTypeInfo(MBB, dyn_cast<GlobalVariable>(I.getClauseValue(i)));
+      ++i;
+      break;
+    case LandingPadInst::Filter: {
+      // Add filters in a list.
+      SmallVector<const GlobalVariable*, 4> FilterList;
+      do {
+        FilterList.push_back(cast<GlobalVariable>(I.getClauseValue(i)));
+        ++i;
+      } while (i != e && I.getClauseType(i) == LandingPadInst::Filter);
+
+      MMI.addFilterTypeInfo(MBB, FilterList);
+      break;
+    }
+    }
+  }
+}
+
+//--------- NEW EH - End   ---------