diff --git a/include/llvm/CodeGen/FunctionLoweringInfo.h b/include/llvm/CodeGen/FunctionLoweringInfo.h index 7eb21b5c669..280481b25a3 100644 --- a/include/llvm/CodeGen/FunctionLoweringInfo.h +++ b/include/llvm/CodeGen/FunctionLoweringInfo.h @@ -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 diff --git a/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index d5bf12055e0..1f41f043dba 100644 --- a/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -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(I.getClauseValue(i))); + ++i; + break; + case LandingPadInst::Filter: { + // Add filters in a list. + SmallVector FilterList; + do { + FilterList.push_back(cast(I.getClauseValue(i))); + ++i; + } while (i != e && I.getClauseType(i) == LandingPadInst::Filter); + + MMI.addFilterTypeInfo(MBB, FilterList); + break; + } + } + } +} + +//--------- NEW EH - End ---------