From ade025c65c12503aba161a4fa399fd97414abaff Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 29 Jul 2009 00:31:35 +0000 Subject: [PATCH] - Temporarily unbreak the build by forcing the TType "absptr", which isn't correct. But what are you going to do? I'll fix this in the future. - Move another large loop into its own method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77408 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfException.cpp | 111 ++++++++++++---------- lib/CodeGen/AsmPrinter/DwarfException.h | 14 ++- 2 files changed, 75 insertions(+), 50 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfException.cpp b/lib/CodeGen/AsmPrinter/DwarfException.cpp index 8f20b506b30..f6f3906626b 100644 --- a/lib/CodeGen/AsmPrinter/DwarfException.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfException.cpp @@ -286,11 +286,10 @@ bool DwarfException::PadLT(const LandingPadInfo *L, const LandingPadInfo *R) { /// ComputeActionsTable - Compute the actions table and gather the first action /// index for each landing pad site. -unsigned -DwarfException::ComputeActionsTable(const SmallVectorImpl - &LandingPads, - SmallVectorImpl &Actions, - SmallVectorImpl &FirstActions) { +unsigned DwarfException:: +ComputeActionsTable(const SmallVectorImpl &LandingPads, + SmallVectorImpl &Actions, + SmallVectorImpl &FirstActions) { const std::vector &FilterIds = MMI->getFilterIds(); // Negative type IDs index into FilterIds. Positive type IDs index into @@ -374,50 +373,18 @@ DwarfException::ComputeActionsTable(const SmallVectorImpl return SizeActions; } -void DwarfException::EmitExceptionTable() { - const std::vector &TypeInfos = MMI->getTypeInfos(); - const std::vector &FilterIds = MMI->getFilterIds(); - const std::vector &PadInfos = MMI->getLandingPads(); - if (PadInfos.empty()) return; - - // Sort the landing pads in order of their type ids. This is used to fold - // duplicate actions. - SmallVector LandingPads; - LandingPads.reserve(PadInfos.size()); - - for (unsigned i = 0, N = PadInfos.size(); i != N; ++i) - LandingPads.push_back(&PadInfos[i]); - - std::sort(LandingPads.begin(), LandingPads.end(), PadLT); - - // Compute the actions table and gather the first action index for each - // landing pad site. - SmallVector Actions; - SmallVector FirstActions; - unsigned SizeActions = ComputeActionsTable(LandingPads, Actions, FirstActions); - - // Invokes and nounwind calls have entries in PadMap (due to being bracketed - // by try-range labels when lowered). Ordinary calls do not, so appropriate - // try-ranges for them need be deduced. - RangeMapType PadMap; - for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) { - const LandingPadInfo *LandingPad = LandingPads[i]; - for (unsigned j = 0, E = LandingPad->BeginLabels.size(); j != E; ++j) { - unsigned BeginLabel = LandingPad->BeginLabels[j]; - assert(!PadMap.count(BeginLabel) && "Duplicate landing pad labels!"); - PadRange P = { i, j }; - PadMap[BeginLabel] = P; - } - } - - // Compute the call-site table. The entry for an invoke has a try-range - // containing the call, a non-zero landing pad and an appropriate action. The - // entry for an ordinary call has a try-range containing the call and zero for - // the landing pad and the action. Calls marked 'nounwind' have no entry and - // must not be contained in the try-range of any entry - they form gaps in the - // table. Entries must be ordered by try-range address. - SmallVector CallSites; - +/// ComputeCallSiteTable - Compute the call-site table. The entry for an invoke +/// has a try-range containing the call, a non-zero landing pad and an +/// appropriate action. The entry for an ordinary call has a try-range +/// containing the call and zero for the landing pad and the action. Calls +/// marked 'nounwind' have no entry and must not be contained in the try-range +/// of any entry - they form gaps in the table. Entries must be ordered by +/// try-range address. +void DwarfException:: +ComputeCallSiteTable(SmallVectorImpl &CallSites, + const RangeMapType &PadMap, + const SmallVectorImpl &LandingPads, + const SmallVectorImpl &FirstActions) { // The end label of the previous invoke or nounwind try-range. unsigned LastLabel = 0; @@ -501,6 +468,47 @@ void DwarfException::EmitExceptionTable() { CallSiteEntry Site = {LastLabel, 0, 0, 0}; CallSites.push_back(Site); } +} + +void DwarfException::EmitExceptionTable() { + const std::vector &TypeInfos = MMI->getTypeInfos(); + const std::vector &FilterIds = MMI->getFilterIds(); + const std::vector &PadInfos = MMI->getLandingPads(); + if (PadInfos.empty()) return; + + // Sort the landing pads in order of their type ids. This is used to fold + // duplicate actions. + SmallVector LandingPads; + LandingPads.reserve(PadInfos.size()); + + for (unsigned i = 0, N = PadInfos.size(); i != N; ++i) + LandingPads.push_back(&PadInfos[i]); + + std::sort(LandingPads.begin(), LandingPads.end(), PadLT); + + // Compute the actions table and gather the first action index for each + // landing pad site. + SmallVector Actions; + SmallVector FirstActions; + unsigned SizeActions = ComputeActionsTable(LandingPads, Actions, FirstActions); + + // Invokes and nounwind calls have entries in PadMap (due to being bracketed + // by try-range labels when lowered). Ordinary calls do not, so appropriate + // try-ranges for them need be deduced. + RangeMapType PadMap; + for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) { + const LandingPadInfo *LandingPad = LandingPads[i]; + for (unsigned j = 0, E = LandingPad->BeginLabels.size(); j != E; ++j) { + unsigned BeginLabel = LandingPad->BeginLabels[j]; + assert(!PadMap.count(BeginLabel) && "Duplicate landing pad labels!"); + PadRange P = { i, j }; + PadMap[BeginLabel] = P; + } + } + + // Compute the call-site table. + SmallVector CallSites; + ComputeCallSiteTable(CallSites, PadMap, LandingPads, FirstActions); // Final tallies. @@ -545,6 +553,7 @@ void DwarfException::EmitExceptionTable() { Asm->EmitInt8(dwarf::DW_EH_PE_omit); Asm->EOL("LPStart format (DW_EH_PE_omit)"); +#if 0 if (!TypeInfos.empty() || !FilterIds.empty()) { Asm->EmitInt8(TAI->PreferredEHDataFormat(DwarfEncoding::Data, true)); // FIXME: The comment here should correspond with what PreferredEHDataFormat @@ -556,6 +565,10 @@ void DwarfException::EmitExceptionTable() { Asm->EmitInt8(dwarf::DW_EH_PE_omit); Asm->EOL("TType format (DW_EH_PE_omit)"); } +#else + Asm->EmitInt8(dwarf::DW_EH_PE_absptr); + Asm->EOL("TType format (DW_EH_PE_absptr)"); +#endif Asm->EmitInt8(dwarf::DW_EH_PE_udata4); Asm->EOL("Call site format (DW_EH_PE_udata4)"); diff --git a/lib/CodeGen/AsmPrinter/DwarfException.h b/lib/CodeGen/AsmPrinter/DwarfException.h index 4b3753893ef..e165df4693d 100644 --- a/lib/CodeGen/AsmPrinter/DwarfException.h +++ b/lib/CodeGen/AsmPrinter/DwarfException.h @@ -143,9 +143,21 @@ class VISIBILITY_HIDDEN DwarfException : public Dwarf { /// ComputeActionsTable - Compute the actions table and gather the first /// action index for each landing pad site. - unsigned ComputeActionsTable(const SmallVectorImpl &LP, + unsigned ComputeActionsTable(const SmallVectorImpl&LPs, SmallVectorImpl &Actions, SmallVectorImpl &FirstActions); + + /// ComputeCallSiteTable - Compute the call-site table. The entry for an + /// invoke has a try-range containing the call, a non-zero landing pad and an + /// appropriate action. The entry for an ordinary call has a try-range + /// containing the call and zero for the landing pad and the action. Calls + /// marked 'nounwind' have no entry and must not be contained in the try-range + /// of any entry - they form gaps in the table. Entries must be ordered by + /// try-range address. + void ComputeCallSiteTable(SmallVectorImpl &CallSites, + const RangeMapType &PadMap, + const SmallVectorImpl &LPs, + const SmallVectorImpl &FirstActions); void EmitExceptionTable(); public: