blob: 0ff1036e89e2d81725bec80958b934c3aa4dd77c [file] [log] [blame]
Bill Wendlingeb907212009-05-15 01:12:28 +00001//===-- CodeGen/AsmPrinter/DwarfException.cpp - Dwarf Exception Impl ------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Bill Wendling28275fd2009-09-10 06:50:01 +000010// This file contains support for writing DWARF exception info into asm files.
Bill Wendlingeb907212009-05-15 01:12:28 +000011//
12//===----------------------------------------------------------------------===//
13
14#include "DwarfException.h"
15#include "llvm/Module.h"
Chris Lattner6d733782010-04-05 05:28:23 +000016#include "llvm/CodeGen/AsmPrinter.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000017#include "llvm/CodeGen/MachineModuleInfo.h"
18#include "llvm/CodeGen/MachineFrameInfo.h"
David Greenefc4da0c2009-08-19 21:55:33 +000019#include "llvm/CodeGen/MachineFunction.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000020#include "llvm/CodeGen/MachineLocation.h"
Chris Lattner8c6ed052009-09-16 01:46:41 +000021#include "llvm/MC/MCAsmInfo.h"
22#include "llvm/MC/MCContext.h"
23#include "llvm/MC/MCExpr.h"
Bill Wendling43e484f2009-09-10 01:12:47 +000024#include "llvm/MC/MCSection.h"
Chris Lattner6c2f9e12009-08-19 05:49:37 +000025#include "llvm/MC/MCStreamer.h"
Chris Lattner7a2ba942010-01-16 18:37:32 +000026#include "llvm/MC/MCSymbol.h"
Chris Lattner45111d12010-01-16 21:57:06 +000027#include "llvm/Target/Mangler.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000028#include "llvm/Target/TargetData.h"
29#include "llvm/Target/TargetFrameInfo.h"
Chris Lattnerd5bbb072009-08-02 01:34:32 +000030#include "llvm/Target/TargetLoweringObjectFile.h"
Chris Lattner9d1c1ad2010-04-04 18:06:11 +000031#include "llvm/Target/TargetMachine.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000032#include "llvm/Target/TargetOptions.h"
Chris Lattnerd5bbb072009-08-02 01:34:32 +000033#include "llvm/Target/TargetRegisterInfo.h"
Chris Lattner6c2f9e12009-08-19 05:49:37 +000034#include "llvm/Support/Dwarf.h"
Chris Lattner0ad9c912010-01-22 22:09:00 +000035#include "llvm/Support/FormattedStream.h"
Jim Grosbachc40d9f92009-09-01 18:49:12 +000036#include "llvm/ADT/SmallString.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000037#include "llvm/ADT/StringExtras.h"
Bill Wendling1f8075d2010-02-09 22:49:16 +000038#include "llvm/ADT/Twine.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000039using namespace llvm;
40
Chris Lattner75f50722010-04-04 07:48:20 +000041DwarfException::DwarfException(AsmPrinter *A)
Chris Lattner84ac8b72010-04-05 00:26:50 +000042 : Asm(A), MMI(Asm->MMI), shouldEmitTable(false), shouldEmitMoves(false),
Bill Wendling5f017e82010-04-07 09:28:04 +000043 shouldEmitTableModule(false), shouldEmitMovesModule(false) {}
Bill Wendlingbc0d23a2009-05-15 01:18:50 +000044
Bill Wendling5f017e82010-04-07 09:28:04 +000045DwarfException::~DwarfException() {}
Bill Wendlingbc0d23a2009-05-15 01:18:50 +000046
Bill Wendling7ccda0f2009-08-25 08:08:33 +000047/// EmitCIE - Emit a Common Information Entry (CIE). This holds information that
48/// is shared among many Frame Description Entries. There is at least one CIE
49/// in every non-empty .debug_frame section.
Chris Lattner8c6ed052009-09-16 01:46:41 +000050void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
Bill Wendlingeb907212009-05-15 01:12:28 +000051 // Size and sign of stack growth.
Chris Lattner84ac8b72010-04-05 00:26:50 +000052 int stackGrowth = Asm->getTargetData().getPointerSize();
53 if (Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
54 TargetFrameInfo::StackGrowsDown)
55 stackGrowth *= -1;
Bill Wendlingeb907212009-05-15 01:12:28 +000056
Chris Lattner8c6ed052009-09-16 01:46:41 +000057 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
Anton Korobeynikov9184b252010-02-15 22:35:59 +000058
Bill Wendlingeb907212009-05-15 01:12:28 +000059 // Begin eh frame section.
Chris Lattner8c6ed052009-09-16 01:46:41 +000060 Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection());
Bill Wendlingeb907212009-05-15 01:12:28 +000061
Chris Lattner974c0fb2010-03-10 02:48:06 +000062 MCSymbol *EHFrameSym;
Chris Lattner09d53fe2010-03-10 07:20:42 +000063 if (TLOF.isFunctionEHFrameSymbolPrivate())
Chris Lattnerc0215722010-04-04 19:25:43 +000064 EHFrameSym = Asm->GetTempSymbol("EH_frame", Index);
Chris Lattner974c0fb2010-03-10 02:48:06 +000065 else
66 EHFrameSym = Asm->OutContext.GetOrCreateSymbol(Twine("EH_frame") +
67 Twine(Index));
68 Asm->OutStreamer.EmitLabel(EHFrameSym);
Chris Lattner8c6ed052009-09-16 01:46:41 +000069
Chris Lattnerc0215722010-04-04 19:25:43 +000070 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_eh_frame", Index));
Bill Wendlingeb907212009-05-15 01:12:28 +000071
72 // Define base labels.
Chris Lattnerc0215722010-04-04 19:25:43 +000073 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common", Index));
Bill Wendlingeb907212009-05-15 01:12:28 +000074
75 // Define the eh frame length.
Chris Lattner233f52b2010-03-09 23:52:58 +000076 Asm->OutStreamer.AddComment("Length of Common Information Entry");
Chris Lattnera6437182010-04-04 19:58:12 +000077 Asm->EmitLabelDifference(Asm->GetTempSymbol("eh_frame_common_end", Index),
78 Asm->GetTempSymbol("eh_frame_common_begin", Index),
79 4);
Bill Wendlingeb907212009-05-15 01:12:28 +000080
81 // EH frame header.
Chris Lattnerc0215722010-04-04 19:25:43 +000082 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_begin",Index));
Chris Lattner233f52b2010-03-09 23:52:58 +000083 Asm->OutStreamer.AddComment("CIE Identifier Tag");
Chris Lattnerbcb83e52010-01-20 07:41:15 +000084 Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
Chris Lattner233f52b2010-03-09 23:52:58 +000085 Asm->OutStreamer.AddComment("DW_CIE_VERSION");
Chris Lattner066c9ac2010-01-22 22:23:57 +000086 Asm->OutStreamer.EmitIntValue(dwarf::DW_CIE_VERSION, 1/*size*/, 0/*addr*/);
Bill Wendlingeb907212009-05-15 01:12:28 +000087
88 // The personality presence indicates that language specific information will
Chris Lattner8c6ed052009-09-16 01:46:41 +000089 // show up in the eh frame. Find out how we are supposed to lower the
90 // personality function reference:
Anton Korobeynikov9184b252010-02-15 22:35:59 +000091
92 unsigned LSDAEncoding = TLOF.getLSDAEncoding();
93 unsigned FDEEncoding = TLOF.getFDEEncoding();
94 unsigned PerEncoding = TLOF.getPersonalityEncoding();
Bill Wendling52783c62009-09-09 23:56:55 +000095
Chris Lattner4cf202b2010-01-23 03:11:46 +000096 char Augmentation[6] = { 0 };
Bill Wendling52783c62009-09-09 23:56:55 +000097 unsigned AugmentationSize = 0;
98 char *APtr = Augmentation + 1;
99
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000100 if (PersonalityFn) {
Bill Wendling52783c62009-09-09 23:56:55 +0000101 // There is a personality function.
102 *APtr++ = 'P';
Chris Lattnerd2af7852010-04-04 20:20:50 +0000103 AugmentationSize += 1 + Asm->GetSizeOfEncodedValue(PerEncoding);
Bill Wendling52783c62009-09-09 23:56:55 +0000104 }
105
106 if (UsesLSDA[Index]) {
107 // An LSDA pointer is in the FDE augmentation.
108 *APtr++ = 'L';
109 ++AugmentationSize;
110 }
111
112 if (FDEEncoding != dwarf::DW_EH_PE_absptr) {
113 // A non-default pointer encoding for the FDE.
114 *APtr++ = 'R';
115 ++AugmentationSize;
116 }
117
118 if (APtr != Augmentation + 1)
119 Augmentation[0] = 'z';
120
Chris Lattner233f52b2010-03-09 23:52:58 +0000121 Asm->OutStreamer.AddComment("CIE Augmentation");
Chris Lattner4cf202b2010-01-23 03:11:46 +0000122 Asm->OutStreamer.EmitBytes(StringRef(Augmentation, strlen(Augmentation)+1),0);
Bill Wendlingeb907212009-05-15 01:12:28 +0000123
124 // Round out reader.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000125 Asm->EmitULEB128(1, "CIE Code Alignment Factor");
126 Asm->EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
Chris Lattner233f52b2010-03-09 23:52:58 +0000127 Asm->OutStreamer.AddComment("CIE Return Address Column");
Chris Lattner84ac8b72010-04-05 00:26:50 +0000128
129 const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
Bill Wendlingeb907212009-05-15 01:12:28 +0000130 Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true));
Bill Wendlingeb907212009-05-15 01:12:28 +0000131
Anton Korobeynikovac8a3d02010-02-15 22:36:41 +0000132 if (Augmentation[0]) {
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000133 Asm->EmitULEB128(AugmentationSize, "Augmentation Size");
Bill Wendling52783c62009-09-09 23:56:55 +0000134
Anton Korobeynikovac8a3d02010-02-15 22:36:41 +0000135 // If there is a personality, we need to indicate the function's location.
136 if (PersonalityFn) {
Chris Lattnerca6190b2010-04-04 20:04:21 +0000137 Asm->EmitEncodingByte(PerEncoding, "Personality");
Chris Lattner233f52b2010-03-09 23:52:58 +0000138 Asm->OutStreamer.AddComment("Personality");
Chris Lattnerd2af7852010-04-04 20:20:50 +0000139 Asm->EmitReference(PersonalityFn, PerEncoding);
Anton Korobeynikovac8a3d02010-02-15 22:36:41 +0000140 }
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000141 if (UsesLSDA[Index])
Chris Lattnerca6190b2010-04-04 20:04:21 +0000142 Asm->EmitEncodingByte(LSDAEncoding, "LSDA");
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000143 if (FDEEncoding != dwarf::DW_EH_PE_absptr)
Chris Lattnerca6190b2010-04-04 20:04:21 +0000144 Asm->EmitEncodingByte(FDEEncoding, "FDE");
Bill Wendlingeb907212009-05-15 01:12:28 +0000145 }
146
147 // Indicate locations of general callee saved registers in frame.
148 std::vector<MachineMove> Moves;
149 RI->getInitialFrameState(Moves);
Chris Lattner02b86b92010-04-04 23:41:46 +0000150 Asm->EmitFrameMoves(Moves, 0, true);
Bill Wendlingeb907212009-05-15 01:12:28 +0000151
152 // On Darwin the linker honors the alignment of eh_frame, which means it must
153 // be 8-byte on 64-bit targets to match what gcc does. Otherwise you get
154 // holes which confuse readers of eh_frame.
Chris Lattner059ea132010-04-28 01:05:45 +0000155 Asm->EmitAlignment(Asm->getTargetData().getPointerSize() == 4 ? 2 : 3);
Chris Lattnerc0215722010-04-04 19:25:43 +0000156 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_end", Index));
Bill Wendlingeb907212009-05-15 01:12:28 +0000157}
158
Bill Wendling7ccda0f2009-08-25 08:08:33 +0000159/// EmitFDE - Emit the Frame Description Entry (FDE) for the function.
160void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000161 assert(!EHFrameInfo.function->hasAvailableExternallyLinkage() &&
Bill Wendlingeb907212009-05-15 01:12:28 +0000162 "Should not emit 'available externally' functions at all");
163
Chris Lattner3e0f60b2009-07-17 21:00:50 +0000164 const Function *TheFunc = EHFrameInfo.function;
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000165 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000166
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000167 unsigned LSDAEncoding = TLOF.getLSDAEncoding();
168 unsigned FDEEncoding = TLOF.getFDEEncoding();
169
170 Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection());
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000171
Bill Wendlingeb907212009-05-15 01:12:28 +0000172 // Externally visible entry into the functions eh frame info. If the
173 // corresponding function is static, this should not be externally visible.
Chris Lattner09d53fe2010-03-10 07:20:42 +0000174 if (!TheFunc->hasLocalLinkage() && TLOF.isFunctionEHSymbolGlobal())
175 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,MCSA_Global);
Bill Wendlingeb907212009-05-15 01:12:28 +0000176
177 // If corresponding function is weak definition, this should be too.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000178 if (TheFunc->isWeakForLinker() && Asm->MAI->getWeakDefDirective())
Chris Lattner974c0fb2010-03-10 02:48:06 +0000179 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
180 MCSA_WeakDefinition);
Bill Wendlingee161a62009-11-11 01:24:59 +0000181
182 // If corresponding function is hidden, this should be too.
183 if (TheFunc->hasHiddenVisibility())
Chris Lattner84ac8b72010-04-05 00:26:50 +0000184 if (MCSymbolAttr HiddenAttr = Asm->MAI->getHiddenVisibilityAttr())
Chris Lattner152a29b2010-01-23 06:53:23 +0000185 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
186 HiddenAttr);
Bill Wendlingeb907212009-05-15 01:12:28 +0000187
188 // If there are no calls then you can't unwind. This may mean we can omit the
189 // EH Frame, but some environments do not handle weak absolute symbols. If
190 // UnwindTablesMandatory is set we cannot do this optimization; the unwind
191 // info is to be available for non-EH uses.
Chris Lattner3e0f60b2009-07-17 21:00:50 +0000192 if (!EHFrameInfo.hasCalls && !UnwindTablesMandatory &&
193 (!TheFunc->isWeakForLinker() ||
Chris Lattner84ac8b72010-04-05 00:26:50 +0000194 !Asm->MAI->getWeakDefDirective() ||
Chris Lattner09d53fe2010-03-10 07:20:42 +0000195 TLOF.getSupportsWeakOmittedEHFrame())) {
Chris Lattner974c0fb2010-03-10 02:48:06 +0000196 Asm->OutStreamer.EmitAssignment(EHFrameInfo.FunctionEHSym,
197 MCConstantExpr::Create(0, Asm->OutContext));
Bill Wendlingeb907212009-05-15 01:12:28 +0000198 // This name has no connection to the function, so it might get
199 // dead-stripped when the function is not, erroneously. Prohibit
200 // dead-stripping unconditionally.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000201 if (Asm->MAI->hasNoDeadStrip())
Chris Lattner3a9be0e2010-01-23 05:51:36 +0000202 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
Chris Lattnera5ad93a2010-01-23 06:39:22 +0000203 MCSA_NoDeadStrip);
Bill Wendlingeb907212009-05-15 01:12:28 +0000204 } else {
Chris Lattner974c0fb2010-03-10 02:48:06 +0000205 Asm->OutStreamer.EmitLabel(EHFrameInfo.FunctionEHSym);
Bill Wendlingeb907212009-05-15 01:12:28 +0000206
207 // EH frame header.
Chris Lattner233f52b2010-03-09 23:52:58 +0000208 Asm->OutStreamer.AddComment("Length of Frame Information Entry");
Chris Lattnera6437182010-04-04 19:58:12 +0000209 Asm->EmitLabelDifference(
210 Asm->GetTempSymbol("eh_frame_end", EHFrameInfo.Number),
211 Asm->GetTempSymbol("eh_frame_begin", EHFrameInfo.Number), 4);
Bill Wendlingeb907212009-05-15 01:12:28 +0000212
Chris Lattnerc0215722010-04-04 19:25:43 +0000213 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_begin",
214 EHFrameInfo.Number));
Bill Wendlingeb907212009-05-15 01:12:28 +0000215
Chris Lattner233f52b2010-03-09 23:52:58 +0000216 Asm->OutStreamer.AddComment("FDE CIE offset");
Chris Lattnerf88dce12010-04-04 21:31:54 +0000217 Asm->EmitLabelDifference(
218 Asm->GetTempSymbol("eh_frame_begin", EHFrameInfo.Number),
219 Asm->GetTempSymbol("eh_frame_common",
220 EHFrameInfo.PersonalityIndex), 4);
Bill Wendlingeb907212009-05-15 01:12:28 +0000221
Chris Lattnerc0215722010-04-04 19:25:43 +0000222 MCSymbol *EHFuncBeginSym =
223 Asm->GetTempSymbol("eh_func_begin", EHFrameInfo.Number);
Bill Wendlingeb907212009-05-15 01:12:28 +0000224
Chris Lattner233f52b2010-03-09 23:52:58 +0000225 Asm->OutStreamer.AddComment("FDE initial location");
Chris Lattnerd2af7852010-04-04 20:20:50 +0000226 Asm->EmitReference(EHFuncBeginSym, FDEEncoding);
Chris Lattnerfb658072010-03-13 07:40:56 +0000227
Chris Lattner233f52b2010-03-09 23:52:58 +0000228 Asm->OutStreamer.AddComment("FDE address range");
Chris Lattnera6437182010-04-04 19:58:12 +0000229 Asm->EmitLabelDifference(Asm->GetTempSymbol("eh_func_end",
230 EHFrameInfo.Number),
Chris Lattnerd2af7852010-04-04 20:20:50 +0000231 EHFuncBeginSym,
232 Asm->GetSizeOfEncodedValue(FDEEncoding));
Bill Wendlingeb907212009-05-15 01:12:28 +0000233
234 // If there is a personality and landing pads then point to the language
235 // specific data area in the exception table.
Eric Christopherd44fff72009-08-26 21:30:49 +0000236 if (MMI->getPersonalities()[0] != NULL) {
Chris Lattnerd2af7852010-04-04 20:20:50 +0000237 unsigned Size = Asm->GetSizeOfEncodedValue(LSDAEncoding);
Duncan Sandsc69d74a2009-08-31 16:45:16 +0000238
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000239 Asm->EmitULEB128(Size, "Augmentation size");
Chris Lattner233f52b2010-03-09 23:52:58 +0000240 Asm->OutStreamer.AddComment("Language Specific Data Area");
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000241 if (EHFrameInfo.hasLandingPads)
Chris Lattnerd2af7852010-04-04 20:20:50 +0000242 Asm->EmitReference(Asm->GetTempSymbol("exception", EHFrameInfo.Number),
243 LSDAEncoding);
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000244 else
245 Asm->OutStreamer.EmitIntValue(0, Size/*size*/, 0/*addrspace*/);
Bill Wendlingd58e9cb2010-01-16 01:40:55 +0000246
Bill Wendlingeb907212009-05-15 01:12:28 +0000247 } else {
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000248 Asm->EmitULEB128(0, "Augmentation size");
Bill Wendlingeb907212009-05-15 01:12:28 +0000249 }
250
251 // Indicate locations of function specific callee saved registers in frame.
Chris Lattner02b86b92010-04-04 23:41:46 +0000252 Asm->EmitFrameMoves(EHFrameInfo.Moves, EHFuncBeginSym, true);
Bill Wendlingeb907212009-05-15 01:12:28 +0000253
254 // On Darwin the linker honors the alignment of eh_frame, which means it
255 // must be 8-byte on 64-bit targets to match what gcc does. Otherwise you
256 // get holes which confuse readers of eh_frame.
Chris Lattner059ea132010-04-28 01:05:45 +0000257 Asm->EmitAlignment(Asm->getTargetData().getPointerSize() == 4 ? 2 : 3);
Chris Lattnerc0215722010-04-04 19:25:43 +0000258 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_end",
259 EHFrameInfo.Number));
Bill Wendlingeb907212009-05-15 01:12:28 +0000260
261 // If the function is marked used, this table should be also. We cannot
262 // make the mark unconditional in this case, since retaining the table also
263 // retains the function in this case, and there is code around that depends
264 // on unused functions (calling undefined externals) being dead-stripped to
265 // link correctly. Yes, there really is.
Chris Lattner401e10c2009-07-20 06:14:25 +0000266 if (MMI->isUsedFunction(EHFrameInfo.function))
Chris Lattner84ac8b72010-04-05 00:26:50 +0000267 if (Asm->MAI->hasNoDeadStrip())
Chris Lattner3a9be0e2010-01-23 05:51:36 +0000268 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
Chris Lattnera5ad93a2010-01-23 06:39:22 +0000269 MCSA_NoDeadStrip);
Bill Wendlingeb907212009-05-15 01:12:28 +0000270 }
Chris Lattner188a87d2010-03-10 01:04:13 +0000271 Asm->OutStreamer.AddBlankLine();
Bill Wendlingeb907212009-05-15 01:12:28 +0000272}
273
Bill Wendlingeb907212009-05-15 01:12:28 +0000274/// SharedTypeIds - How many leading type ids two landing pads have in common.
275unsigned DwarfException::SharedTypeIds(const LandingPadInfo *L,
276 const LandingPadInfo *R) {
277 const std::vector<int> &LIds = L->TypeIds, &RIds = R->TypeIds;
278 unsigned LSize = LIds.size(), RSize = RIds.size();
279 unsigned MinSize = LSize < RSize ? LSize : RSize;
280 unsigned Count = 0;
281
282 for (; Count != MinSize; ++Count)
283 if (LIds[Count] != RIds[Count])
284 return Count;
285
286 return Count;
287}
288
289/// PadLT - Order landing pads lexicographically by type id.
290bool DwarfException::PadLT(const LandingPadInfo *L, const LandingPadInfo *R) {
291 const std::vector<int> &LIds = L->TypeIds, &RIds = R->TypeIds;
292 unsigned LSize = LIds.size(), RSize = RIds.size();
293 unsigned MinSize = LSize < RSize ? LSize : RSize;
294
295 for (unsigned i = 0; i != MinSize; ++i)
296 if (LIds[i] != RIds[i])
297 return LIds[i] < RIds[i];
298
299 return LSize < RSize;
300}
301
Bill Wendlingd4609622009-07-28 23:23:00 +0000302/// ComputeActionsTable - Compute the actions table and gather the first action
303/// index for each landing pad site.
Bill Wendlingade025c2009-07-29 00:31:35 +0000304unsigned DwarfException::
305ComputeActionsTable(const SmallVectorImpl<const LandingPadInfo*> &LandingPads,
306 SmallVectorImpl<ActionEntry> &Actions,
307 SmallVectorImpl<unsigned> &FirstActions) {
Bill Wendlinga583c552009-08-20 22:02:24 +0000308
309 // The action table follows the call-site table in the LSDA. The individual
310 // records are of two types:
311 //
312 // * Catch clause
313 // * Exception specification
314 //
315 // The two record kinds have the same format, with only small differences.
316 // They are distinguished by the "switch value" field: Catch clauses
317 // (TypeInfos) have strictly positive switch values, and exception
318 // specifications (FilterIds) have strictly negative switch values. Value 0
319 // indicates a catch-all clause.
320 //
Bill Wendling5e953dd2009-07-28 23:22:13 +0000321 // Negative type IDs index into FilterIds. Positive type IDs index into
322 // TypeInfos. The value written for a positive type ID is just the type ID
323 // itself. For a negative type ID, however, the value written is the
Bill Wendlingeb907212009-05-15 01:12:28 +0000324 // (negative) byte offset of the corresponding FilterIds entry. The byte
Bill Wendling5e953dd2009-07-28 23:22:13 +0000325 // offset is usually equal to the type ID (because the FilterIds entries are
326 // written using a variable width encoding, which outputs one byte per entry
327 // as long as the value written is not too large) but can differ. This kind
328 // of complication does not occur for positive type IDs because type infos are
Bill Wendlingeb907212009-05-15 01:12:28 +0000329 // output using a fixed width encoding. FilterOffsets[i] holds the byte
330 // offset corresponding to FilterIds[i].
Bill Wendling409914b2009-07-29 21:19:44 +0000331
332 const std::vector<unsigned> &FilterIds = MMI->getFilterIds();
Bill Wendlingeb907212009-05-15 01:12:28 +0000333 SmallVector<int, 16> FilterOffsets;
334 FilterOffsets.reserve(FilterIds.size());
335 int Offset = -1;
Bill Wendling409914b2009-07-29 21:19:44 +0000336
337 for (std::vector<unsigned>::const_iterator
338 I = FilterIds.begin(), E = FilterIds.end(); I != E; ++I) {
Bill Wendlingeb907212009-05-15 01:12:28 +0000339 FilterOffsets.push_back(Offset);
Chris Lattneraf76e592009-08-22 20:48:53 +0000340 Offset -= MCAsmInfo::getULEB128Size(*I);
Bill Wendlingeb907212009-05-15 01:12:28 +0000341 }
342
Bill Wendlingeb907212009-05-15 01:12:28 +0000343 FirstActions.reserve(LandingPads.size());
344
345 int FirstAction = 0;
346 unsigned SizeActions = 0;
Bill Wendling5e953dd2009-07-28 23:22:13 +0000347 const LandingPadInfo *PrevLPI = 0;
Bill Wendling409914b2009-07-29 21:19:44 +0000348
Bill Wendling5cff4872009-07-28 23:44:43 +0000349 for (SmallVectorImpl<const LandingPadInfo *>::const_iterator
Bill Wendling5e953dd2009-07-28 23:22:13 +0000350 I = LandingPads.begin(), E = LandingPads.end(); I != E; ++I) {
351 const LandingPadInfo *LPI = *I;
352 const std::vector<int> &TypeIds = LPI->TypeIds;
Chris Lattner9be49132010-04-04 20:10:41 +0000353 unsigned NumShared = PrevLPI ? SharedTypeIds(LPI, PrevLPI) : 0;
Bill Wendlingeb907212009-05-15 01:12:28 +0000354 unsigned SizeSiteActions = 0;
355
356 if (NumShared < TypeIds.size()) {
357 unsigned SizeAction = 0;
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000358 unsigned PrevAction = (unsigned)-1;
Bill Wendlingeb907212009-05-15 01:12:28 +0000359
360 if (NumShared) {
Chris Lattner9be49132010-04-04 20:10:41 +0000361 unsigned SizePrevIds = PrevLPI->TypeIds.size();
Bill Wendlingeb907212009-05-15 01:12:28 +0000362 assert(Actions.size());
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000363 PrevAction = Actions.size() - 1;
364 SizeAction =
365 MCAsmInfo::getSLEB128Size(Actions[PrevAction].NextAction) +
366 MCAsmInfo::getSLEB128Size(Actions[PrevAction].ValueForTypeID);
Bill Wendlingeb907212009-05-15 01:12:28 +0000367
368 for (unsigned j = NumShared; j != SizePrevIds; ++j) {
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000369 assert(PrevAction != (unsigned)-1 && "PrevAction is invalid!");
Bill Wendlingeb907212009-05-15 01:12:28 +0000370 SizeAction -=
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000371 MCAsmInfo::getSLEB128Size(Actions[PrevAction].ValueForTypeID);
372 SizeAction += -Actions[PrevAction].NextAction;
373 PrevAction = Actions[PrevAction].Previous;
Bill Wendlingeb907212009-05-15 01:12:28 +0000374 }
375 }
376
377 // Compute the actions.
Bill Wendling5e953dd2009-07-28 23:22:13 +0000378 for (unsigned J = NumShared, M = TypeIds.size(); J != M; ++J) {
379 int TypeID = TypeIds[J];
380 assert(-1 - TypeID < (int)FilterOffsets.size() && "Unknown filter id!");
Bill Wendlingeb907212009-05-15 01:12:28 +0000381 int ValueForTypeID = TypeID < 0 ? FilterOffsets[-1 - TypeID] : TypeID;
Chris Lattneraf76e592009-08-22 20:48:53 +0000382 unsigned SizeTypeID = MCAsmInfo::getSLEB128Size(ValueForTypeID);
Bill Wendlingeb907212009-05-15 01:12:28 +0000383
384 int NextAction = SizeAction ? -(SizeAction + SizeTypeID) : 0;
Chris Lattneraf76e592009-08-22 20:48:53 +0000385 SizeAction = SizeTypeID + MCAsmInfo::getSLEB128Size(NextAction);
Bill Wendlingeb907212009-05-15 01:12:28 +0000386 SizeSiteActions += SizeAction;
387
Bill Wendlinga583c552009-08-20 22:02:24 +0000388 ActionEntry Action = { ValueForTypeID, NextAction, PrevAction };
Bill Wendlingeb907212009-05-15 01:12:28 +0000389 Actions.push_back(Action);
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000390 PrevAction = Actions.size() - 1;
Bill Wendlingeb907212009-05-15 01:12:28 +0000391 }
392
393 // Record the first action of the landing pad site.
394 FirstAction = SizeActions + SizeSiteActions - SizeAction + 1;
395 } // else identical - re-use previous FirstAction
396
Bill Wendlinga583c552009-08-20 22:02:24 +0000397 // Information used when created the call-site table. The action record
398 // field of the call site record is the offset of the first associated
399 // action record, relative to the start of the actions table. This value is
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000400 // biased by 1 (1 indicating the start of the actions table), and 0
Bill Wendlinga583c552009-08-20 22:02:24 +0000401 // indicates that there are no actions.
Bill Wendlingeb907212009-05-15 01:12:28 +0000402 FirstActions.push_back(FirstAction);
403
404 // Compute this sites contribution to size.
405 SizeActions += SizeSiteActions;
Bill Wendling5e953dd2009-07-28 23:22:13 +0000406
407 PrevLPI = LPI;
Bill Wendlingeb907212009-05-15 01:12:28 +0000408 }
409
Bill Wendling5e953dd2009-07-28 23:22:13 +0000410 return SizeActions;
411}
412
Bill Wendlinged060dc2009-11-12 21:59:20 +0000413/// CallToNoUnwindFunction - Return `true' if this is a call to a function
414/// marked `nounwind'. Return `false' otherwise.
415bool DwarfException::CallToNoUnwindFunction(const MachineInstr *MI) {
416 assert(MI->getDesc().isCall() && "This should be a call instruction!");
417
418 bool MarkedNoUnwind = false;
419 bool SawFunc = false;
420
421 for (unsigned I = 0, E = MI->getNumOperands(); I != E; ++I) {
422 const MachineOperand &MO = MI->getOperand(I);
423
Chris Lattnercfd31882010-03-31 06:09:04 +0000424 if (!MO.isGlobal()) continue;
425
Dan Gohman46510a72010-04-15 01:51:59 +0000426 const Function *F = dyn_cast<Function>(MO.getGlobal());
Chris Lattnercfd31882010-03-31 06:09:04 +0000427 if (F == 0) continue;
Bill Wendlingecc260e2009-11-12 23:13:08 +0000428
Chris Lattnercfd31882010-03-31 06:09:04 +0000429 if (SawFunc) {
430 // Be conservative. If we have more than one function operand for this
431 // call, then we can't make the assumption that it's the callee and
432 // not a parameter to the call.
433 //
434 // FIXME: Determine if there's a way to say that `F' is the callee or
435 // parameter.
436 MarkedNoUnwind = false;
437 break;
Bill Wendlinged060dc2009-11-12 21:59:20 +0000438 }
Chris Lattnercfd31882010-03-31 06:09:04 +0000439
440 MarkedNoUnwind = F->doesNotThrow();
441 SawFunc = true;
Bill Wendlinged060dc2009-11-12 21:59:20 +0000442 }
443
444 return MarkedNoUnwind;
445}
446
Bill Wendlingade025c2009-07-29 00:31:35 +0000447/// ComputeCallSiteTable - Compute the call-site table. The entry for an invoke
Bill Wendlinga583c552009-08-20 22:02:24 +0000448/// has a try-range containing the call, a non-zero landing pad, and an
Bill Wendlingade025c2009-07-29 00:31:35 +0000449/// appropriate action. The entry for an ordinary call has a try-range
450/// containing the call and zero for the landing pad and the action. Calls
451/// marked 'nounwind' have no entry and must not be contained in the try-range
452/// of any entry - they form gaps in the table. Entries must be ordered by
453/// try-range address.
454void DwarfException::
455ComputeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
456 const RangeMapType &PadMap,
457 const SmallVectorImpl<const LandingPadInfo *> &LandingPads,
458 const SmallVectorImpl<unsigned> &FirstActions) {
Bill Wendlingeb907212009-05-15 01:12:28 +0000459 // The end label of the previous invoke or nounwind try-range.
Chris Lattner16112732010-03-14 01:41:15 +0000460 MCSymbol *LastLabel = 0;
Bill Wendlingeb907212009-05-15 01:12:28 +0000461
462 // Whether there is a potentially throwing instruction (currently this means
463 // an ordinary call) between the end of the previous try-range and now.
464 bool SawPotentiallyThrowing = false;
465
Bill Wendling5cff4872009-07-28 23:44:43 +0000466 // Whether the last CallSite entry was for an invoke.
Bill Wendlingeb907212009-05-15 01:12:28 +0000467 bool PreviousIsInvoke = false;
468
469 // Visit all instructions in order of address.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000470 for (MachineFunction::const_iterator I = Asm->MF->begin(), E = Asm->MF->end();
Bill Wendlingeb907212009-05-15 01:12:28 +0000471 I != E; ++I) {
472 for (MachineBasicBlock::const_iterator MI = I->begin(), E = I->end();
473 MI != E; ++MI) {
474 if (!MI->isLabel()) {
Bill Wendlinged060dc2009-11-12 21:59:20 +0000475 if (MI->getDesc().isCall())
476 SawPotentiallyThrowing |= !CallToNoUnwindFunction(MI);
Bill Wendlingeb907212009-05-15 01:12:28 +0000477 continue;
478 }
479
Bill Wendlingeb907212009-05-15 01:12:28 +0000480 // End of the previous try-range?
Chris Lattner0397ada2010-03-14 08:17:53 +0000481 MCSymbol *BeginLabel = MI->getOperand(0).getMCSymbol();
Bill Wendlingeb907212009-05-15 01:12:28 +0000482 if (BeginLabel == LastLabel)
483 SawPotentiallyThrowing = false;
484
485 // Beginning of a new try-range?
Jeffrey Yasskin81cf4322009-11-10 01:02:17 +0000486 RangeMapType::const_iterator L = PadMap.find(BeginLabel);
Bill Wendlingeb907212009-05-15 01:12:28 +0000487 if (L == PadMap.end())
488 // Nope, it was just some random label.
489 continue;
490
Bill Wendlinga583c552009-08-20 22:02:24 +0000491 const PadRange &P = L->second;
Bill Wendlingeb907212009-05-15 01:12:28 +0000492 const LandingPadInfo *LandingPad = LandingPads[P.PadIndex];
Bill Wendlingeb907212009-05-15 01:12:28 +0000493 assert(BeginLabel == LandingPad->BeginLabels[P.RangeIndex] &&
494 "Inconsistent landing pad map!");
495
Bill Wendlinga583c552009-08-20 22:02:24 +0000496 // For Dwarf exception handling (SjLj handling doesn't use this). If some
497 // instruction between the previous try-range and this one may throw,
498 // create a call-site entry with no landing pad for the region between the
499 // try-ranges.
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000500 if (SawPotentiallyThrowing &&
Chris Lattner84ac8b72010-04-05 00:26:50 +0000501 Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
Bill Wendlinga583c552009-08-20 22:02:24 +0000502 CallSiteEntry Site = { LastLabel, BeginLabel, 0, 0 };
Bill Wendlingeb907212009-05-15 01:12:28 +0000503 CallSites.push_back(Site);
504 PreviousIsInvoke = false;
505 }
506
507 LastLabel = LandingPad->EndLabels[P.RangeIndex];
508 assert(BeginLabel && LastLabel && "Invalid landing pad!");
509
Chris Lattnercfd31882010-03-31 06:09:04 +0000510 if (!LandingPad->LandingPadLabel) {
511 // Create a gap.
512 PreviousIsInvoke = false;
513 } else {
Bill Wendlingeb907212009-05-15 01:12:28 +0000514 // This try-range is for an invoke.
Bill Wendlinga583c552009-08-20 22:02:24 +0000515 CallSiteEntry Site = {
516 BeginLabel,
517 LastLabel,
518 LandingPad->LandingPadLabel,
519 FirstActions[P.PadIndex]
520 };
Bill Wendlingeb907212009-05-15 01:12:28 +0000521
Jim Grosbach33668c02009-09-01 17:19:13 +0000522 // Try to merge with the previous call-site. SJLJ doesn't do this
523 if (PreviousIsInvoke &&
Chris Lattner84ac8b72010-04-05 00:26:50 +0000524 Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
Bill Wendlingeb907212009-05-15 01:12:28 +0000525 CallSiteEntry &Prev = CallSites.back();
526 if (Site.PadLabel == Prev.PadLabel && Site.Action == Prev.Action) {
527 // Extend the range of the previous entry.
528 Prev.EndLabel = Site.EndLabel;
529 continue;
530 }
531 }
532
533 // Otherwise, create a new call-site.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000534 if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf)
Jim Grosbachca752c92010-01-28 01:45:32 +0000535 CallSites.push_back(Site);
536 else {
537 // SjLj EH must maintain the call sites in the order assigned
538 // to them by the SjLjPrepare pass.
539 unsigned SiteNo = MMI->getCallSiteBeginLabel(BeginLabel);
540 if (CallSites.size() < SiteNo)
541 CallSites.resize(SiteNo);
542 CallSites[SiteNo - 1] = Site;
543 }
Bill Wendlingeb907212009-05-15 01:12:28 +0000544 PreviousIsInvoke = true;
Bill Wendlingeb907212009-05-15 01:12:28 +0000545 }
546 }
547 }
548
549 // If some instruction between the previous try-range and the end of the
550 // function may throw, create a call-site entry with no landing pad for the
551 // region following the try-range.
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000552 if (SawPotentiallyThrowing &&
Chris Lattner84ac8b72010-04-05 00:26:50 +0000553 Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
Bill Wendlinga583c552009-08-20 22:02:24 +0000554 CallSiteEntry Site = { LastLabel, 0, 0, 0 };
Bill Wendlingeb907212009-05-15 01:12:28 +0000555 CallSites.push_back(Site);
556 }
Bill Wendlingade025c2009-07-29 00:31:35 +0000557}
558
Bill Wendling0dafca92009-07-29 00:50:05 +0000559/// EmitExceptionTable - Emit landing pads and actions.
560///
561/// The general organization of the table is complex, but the basic concepts are
562/// easy. First there is a header which describes the location and organization
563/// of the three components that follow.
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000564///
Bill Wendling0dafca92009-07-29 00:50:05 +0000565/// 1. The landing pad site information describes the range of code covered by
566/// the try. In our case it's an accumulation of the ranges covered by the
567/// invokes in the try. There is also a reference to the landing pad that
568/// handles the exception once processed. Finally an index into the actions
569/// table.
Bill Wendlinga583c552009-08-20 22:02:24 +0000570/// 2. The action table, in our case, is composed of pairs of type IDs and next
Bill Wendling0dafca92009-07-29 00:50:05 +0000571/// action offset. Starting with the action index from the landing pad
Bill Wendlinga583c552009-08-20 22:02:24 +0000572/// site, each type ID is checked for a match to the current exception. If
Bill Wendling0dafca92009-07-29 00:50:05 +0000573/// it matches then the exception and type id are passed on to the landing
574/// pad. Otherwise the next action is looked up. This chain is terminated
Bill Wendling28275fd2009-09-10 06:50:01 +0000575/// with a next action of zero. If no type id is found then the frame is
Bill Wendling0dafca92009-07-29 00:50:05 +0000576/// unwound and handling continues.
Bill Wendlinga583c552009-08-20 22:02:24 +0000577/// 3. Type ID table contains references to all the C++ typeinfo for all
Bill Wendling28275fd2009-09-10 06:50:01 +0000578/// catches in the function. This tables is reverse indexed base 1.
Bill Wendlingade025c2009-07-29 00:31:35 +0000579void DwarfException::EmitExceptionTable() {
Dan Gohman46510a72010-04-15 01:51:59 +0000580 const std::vector<const GlobalVariable *> &TypeInfos = MMI->getTypeInfos();
Bill Wendlingade025c2009-07-29 00:31:35 +0000581 const std::vector<unsigned> &FilterIds = MMI->getFilterIds();
582 const std::vector<LandingPadInfo> &PadInfos = MMI->getLandingPads();
Bill Wendlingade025c2009-07-29 00:31:35 +0000583
584 // Sort the landing pads in order of their type ids. This is used to fold
585 // duplicate actions.
586 SmallVector<const LandingPadInfo *, 64> LandingPads;
587 LandingPads.reserve(PadInfos.size());
588
589 for (unsigned i = 0, N = PadInfos.size(); i != N; ++i)
590 LandingPads.push_back(&PadInfos[i]);
591
592 std::sort(LandingPads.begin(), LandingPads.end(), PadLT);
593
594 // Compute the actions table and gather the first action index for each
595 // landing pad site.
596 SmallVector<ActionEntry, 32> Actions;
597 SmallVector<unsigned, 64> FirstActions;
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000598 unsigned SizeActions=ComputeActionsTable(LandingPads, Actions, FirstActions);
Bill Wendlingade025c2009-07-29 00:31:35 +0000599
600 // Invokes and nounwind calls have entries in PadMap (due to being bracketed
601 // by try-range labels when lowered). Ordinary calls do not, so appropriate
Bill Wendling28275fd2009-09-10 06:50:01 +0000602 // try-ranges for them need be deduced when using DWARF exception handling.
Bill Wendlingade025c2009-07-29 00:31:35 +0000603 RangeMapType PadMap;
604 for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) {
605 const LandingPadInfo *LandingPad = LandingPads[i];
606 for (unsigned j = 0, E = LandingPad->BeginLabels.size(); j != E; ++j) {
Chris Lattner16112732010-03-14 01:41:15 +0000607 MCSymbol *BeginLabel = LandingPad->BeginLabels[j];
Bill Wendlingade025c2009-07-29 00:31:35 +0000608 assert(!PadMap.count(BeginLabel) && "Duplicate landing pad labels!");
609 PadRange P = { i, j };
610 PadMap[BeginLabel] = P;
611 }
612 }
613
614 // Compute the call-site table.
615 SmallVector<CallSiteEntry, 64> CallSites;
Jim Grosbach8b818d72009-08-17 16:41:22 +0000616 ComputeCallSiteTable(CallSites, PadMap, LandingPads, FirstActions);
Bill Wendlingeb907212009-05-15 01:12:28 +0000617
618 // Final tallies.
619
620 // Call sites.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000621 bool IsSJLJ = Asm->MAI->getExceptionHandlingType() == ExceptionHandling::SjLj;
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000622 bool HaveTTData = IsSJLJ ? (!TypeInfos.empty() || !FilterIds.empty()) : true;
Chris Lattner9be49132010-04-04 20:10:41 +0000623
Bill Wendling3dc9b482010-02-24 23:34:35 +0000624 unsigned CallSiteTableLength;
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000625 if (IsSJLJ)
Bill Wendling3dc9b482010-02-24 23:34:35 +0000626 CallSiteTableLength = 0;
Chris Lattner9be49132010-04-04 20:10:41 +0000627 else {
628 unsigned SiteStartSize = 4; // dwarf::DW_EH_PE_udata4
629 unsigned SiteLengthSize = 4; // dwarf::DW_EH_PE_udata4
630 unsigned LandingPadSize = 4; // dwarf::DW_EH_PE_udata4
631 CallSiteTableLength =
632 CallSites.size() * (SiteStartSize + SiteLengthSize + LandingPadSize);
633 }
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000634
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000635 for (unsigned i = 0, e = CallSites.size(); i < e; ++i) {
Bill Wendling3dc9b482010-02-24 23:34:35 +0000636 CallSiteTableLength += MCAsmInfo::getULEB128Size(CallSites[i].Action);
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000637 if (IsSJLJ)
Bill Wendling3dc9b482010-02-24 23:34:35 +0000638 CallSiteTableLength += MCAsmInfo::getULEB128Size(i);
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000639 }
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000640
Bill Wendlingeb907212009-05-15 01:12:28 +0000641 // Type infos.
Chris Lattnerd5bbb072009-08-02 01:34:32 +0000642 const MCSection *LSDASection = Asm->getObjFileLowering().getLSDASection();
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000643 unsigned TTypeEncoding;
Bill Wendlinga2f64492009-09-10 06:27:16 +0000644 unsigned TypeFormatSize;
Bill Wendlingeb907212009-05-15 01:12:28 +0000645
Bill Wendling43e484f2009-09-10 01:12:47 +0000646 if (!HaveTTData) {
Bill Wendling28275fd2009-09-10 06:50:01 +0000647 // For SjLj exceptions, if there is no TypeInfo, then we just explicitly say
648 // that we're omitting that bit.
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000649 TTypeEncoding = dwarf::DW_EH_PE_omit;
Chris Lattner84ac8b72010-04-05 00:26:50 +0000650 // dwarf::DW_EH_PE_absptr
651 TypeFormatSize = Asm->getTargetData().getPointerSize();
Chris Lattner81c9a062009-07-31 22:03:47 +0000652 } else {
Chris Lattnerad88bc42009-08-02 03:59:56 +0000653 // Okay, we have actual filters or typeinfos to emit. As such, we need to
654 // pick a type encoding for them. We're about to emit a list of pointers to
655 // typeinfo objects at the end of the LSDA. However, unless we're in static
656 // mode, this reference will require a relocation by the dynamic linker.
Chris Lattner46b754c2009-07-31 22:18:14 +0000657 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000658 // Because of this, we have a couple of options:
Bill Wendling28275fd2009-09-10 06:50:01 +0000659 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000660 // 1) If we are in -static mode, we can always use an absolute reference
661 // from the LSDA, because the static linker will resolve it.
Bill Wendling28275fd2009-09-10 06:50:01 +0000662 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000663 // 2) Otherwise, if the LSDA section is writable, we can output the direct
664 // reference to the typeinfo and allow the dynamic linker to relocate
665 // it. Since it is in a writable section, the dynamic linker won't
666 // have a problem.
Bill Wendling28275fd2009-09-10 06:50:01 +0000667 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000668 // 3) Finally, if we're in PIC mode and the LDSA section isn't writable,
669 // we need to use some form of indirection. For example, on Darwin,
670 // we can output a statically-relocatable reference to a dyld stub. The
671 // offset to the stub is constant, but the contents are in a section
672 // that is updated by the dynamic linker. This is easy enough, but we
673 // need to tell the personality function of the unwinder to indirect
674 // through the dyld stub.
675 //
Bill Wendling43e484f2009-09-10 01:12:47 +0000676 // FIXME: When (3) is actually implemented, we'll have to emit the stubs
Chris Lattnerad88bc42009-08-02 03:59:56 +0000677 // somewhere. This predicate should be moved to a shared location that is
678 // in target-independent code.
679 //
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000680 TTypeEncoding = Asm->getObjFileLowering().getTTypeEncoding();
Chris Lattnerd2af7852010-04-04 20:20:50 +0000681 TypeFormatSize = Asm->GetSizeOfEncodedValue(TTypeEncoding);
Bill Wendlingfe220282009-09-10 02:07:37 +0000682 }
Bill Wendling43e484f2009-09-10 01:12:47 +0000683
Bill Wendlingfe220282009-09-10 02:07:37 +0000684 // Begin the exception table.
685 Asm->OutStreamer.SwitchSection(LSDASection);
Chris Lattner059ea132010-04-28 01:05:45 +0000686 Asm->EmitAlignment(2);
Bill Wendling43e484f2009-09-10 01:12:47 +0000687
Bill Wendling3dc9b482010-02-24 23:34:35 +0000688 // Emit the LSDA.
Chris Lattner974c0fb2010-03-10 02:48:06 +0000689 MCSymbol *GCCETSym =
690 Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+
Chris Lattner84ac8b72010-04-05 00:26:50 +0000691 Twine(Asm->getFunctionNumber()));
Chris Lattner974c0fb2010-03-10 02:48:06 +0000692 Asm->OutStreamer.EmitLabel(GCCETSym);
Chris Lattner84ac8b72010-04-05 00:26:50 +0000693 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("exception",
694 Asm->getFunctionNumber()));
Bill Wendlingfe220282009-09-10 02:07:37 +0000695
Chris Lattner974c0fb2010-03-10 02:48:06 +0000696 if (IsSJLJ)
Chris Lattnerc0215722010-04-04 19:25:43 +0000697 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("_LSDA_",
698 Asm->getFunctionNumber()));
Bill Wendlingfe220282009-09-10 02:07:37 +0000699
Bill Wendling3dc9b482010-02-24 23:34:35 +0000700 // Emit the LSDA header.
Chris Lattnerca6190b2010-04-04 20:04:21 +0000701 Asm->EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
702 Asm->EmitEncodingByte(TTypeEncoding, "@TType");
Bill Wendlingfe220282009-09-10 02:07:37 +0000703
Bill Wendling3dc9b482010-02-24 23:34:35 +0000704 // The type infos need to be aligned. GCC does this by inserting padding just
705 // before the type infos. However, this changes the size of the exception
706 // table, so you need to take this into account when you output the exception
707 // table size. However, the size is output using a variable length encoding.
708 // So by increasing the size by inserting padding, you may increase the number
709 // of bytes used for writing the size. If it increases, say by one byte, then
710 // you now need to output one less byte of padding to get the type infos
711 // aligned. However this decreases the size of the exception table. This
712 // changes the value you have to output for the exception table size. Due to
713 // the variable length encoding, the number of bytes used for writing the
714 // length may decrease. If so, you then have to increase the amount of
715 // padding. And so on. If you look carefully at the GCC code you will see that
716 // it indeed does this in a loop, going on and on until the values stabilize.
717 // We chose another solution: don't output padding inside the table like GCC
718 // does, instead output it before the table.
719 unsigned SizeTypes = TypeInfos.size() * TypeFormatSize;
720 unsigned CallSiteTableLengthSize =
721 MCAsmInfo::getULEB128Size(CallSiteTableLength);
722 unsigned TTypeBaseOffset =
723 sizeof(int8_t) + // Call site format
724 CallSiteTableLengthSize + // Call site table length size
725 CallSiteTableLength + // Call site table length
726 SizeActions + // Actions size
727 SizeTypes;
728 unsigned TTypeBaseOffsetSize = MCAsmInfo::getULEB128Size(TTypeBaseOffset);
729 unsigned TotalSize =
730 sizeof(int8_t) + // LPStart format
731 sizeof(int8_t) + // TType format
732 (HaveTTData ? TTypeBaseOffsetSize : 0) + // TType base offset size
733 TTypeBaseOffset; // TType base offset
734 unsigned SizeAlign = (4 - TotalSize) & 3;
735
Bill Wendling86f0d332010-02-25 23:52:44 +0000736 if (HaveTTData) {
Bill Wendling6507eca2010-02-26 21:31:01 +0000737 // Account for any extra padding that will be added to the call site table
Bill Wendlingf7e90ae2010-02-25 21:19:47 +0000738 // length.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000739 Asm->EmitULEB128(TTypeBaseOffset, "@TType base offset", SizeAlign);
Bill Wendling1869ac82010-02-26 22:17:52 +0000740 SizeAlign = 0;
Bill Wendling86f0d332010-02-25 23:52:44 +0000741 }
Bill Wendlingb0d9c3e2009-07-28 22:23:45 +0000742
Bill Wendling28275fd2009-09-10 06:50:01 +0000743 // SjLj Exception handling
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000744 if (IsSJLJ) {
Chris Lattnerca6190b2010-04-04 20:04:21 +0000745 Asm->EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
Bill Wendling1869ac82010-02-26 22:17:52 +0000746
747 // Add extra padding if it wasn't added to the TType base offset.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000748 Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
Bill Wendlingeb907212009-05-15 01:12:28 +0000749
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000750 // Emit the landing pad site information.
Jim Grosbach8b818d72009-08-17 16:41:22 +0000751 unsigned idx = 0;
752 for (SmallVectorImpl<CallSiteEntry>::const_iterator
753 I = CallSites.begin(), E = CallSites.end(); I != E; ++I, ++idx) {
754 const CallSiteEntry &S = *I;
Bill Wendlinga583c552009-08-20 22:02:24 +0000755
756 // Offset of the landing pad, counted in 16-byte bundles relative to the
757 // @LPStart address.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000758 Asm->EmitULEB128(idx, "Landing pad");
Bill Wendlinga583c552009-08-20 22:02:24 +0000759
760 // Offset of the first associated action record, relative to the start of
761 // the action table. This value is biased by 1 (1 indicates the start of
762 // the action table), and 0 indicates that there are no actions.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000763 Asm->EmitULEB128(S.Action, "Action");
Bill Wendlingeb907212009-05-15 01:12:28 +0000764 }
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000765 } else {
766 // DWARF Exception handling
Chris Lattner84ac8b72010-04-05 00:26:50 +0000767 assert(Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf);
Bill Wendlingeb907212009-05-15 01:12:28 +0000768
Bill Wendlinga583c552009-08-20 22:02:24 +0000769 // The call-site table is a list of all call sites that may throw an
770 // exception (including C++ 'throw' statements) in the procedure
771 // fragment. It immediately follows the LSDA header. Each entry indicates,
772 // for a given call, the first corresponding action record and corresponding
773 // landing pad.
774 //
775 // The table begins with the number of bytes, stored as an LEB128
776 // compressed, unsigned integer. The records immediately follow the record
777 // count. They are sorted in increasing call-site address. Each record
778 // indicates:
779 //
780 // * The position of the call-site.
781 // * The position of the landing pad.
782 // * The first action record for that call site.
783 //
784 // A missing entry in the call-site table indicates that a call is not
Bill Wendling28275fd2009-09-10 06:50:01 +0000785 // supposed to throw.
Bill Wendlinga583c552009-08-20 22:02:24 +0000786
787 // Emit the landing pad call site table.
Chris Lattnerca6190b2010-04-04 20:04:21 +0000788 Asm->EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
Bill Wendling1869ac82010-02-26 22:17:52 +0000789
790 // Add extra padding if it wasn't added to the TType base offset.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000791 Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
Bill Wendlingeb907212009-05-15 01:12:28 +0000792
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000793 for (SmallVectorImpl<CallSiteEntry>::const_iterator
794 I = CallSites.begin(), E = CallSites.end(); I != E; ++I) {
795 const CallSiteEntry &S = *I;
Chris Lattner16112732010-03-14 01:41:15 +0000796
Chris Lattnerc0215722010-04-04 19:25:43 +0000797 MCSymbol *EHFuncBeginSym =
Chris Lattner84ac8b72010-04-05 00:26:50 +0000798 Asm->GetTempSymbol("eh_func_begin", Asm->getFunctionNumber());
Chris Lattner16112732010-03-14 01:41:15 +0000799
800 MCSymbol *BeginLabel = S.BeginLabel;
801 if (BeginLabel == 0)
802 BeginLabel = EHFuncBeginSym;
803 MCSymbol *EndLabel = S.EndLabel;
804 if (EndLabel == 0)
Chris Lattner84ac8b72010-04-05 00:26:50 +0000805 EndLabel = Asm->GetTempSymbol("eh_func_end", Asm->getFunctionNumber());
Chris Lattner16112732010-03-14 01:41:15 +0000806
Bill Wendlinga583c552009-08-20 22:02:24 +0000807 // Offset of the call site relative to the previous call site, counted in
808 // number of 16-byte bundles. The first call site is counted relative to
809 // the start of the procedure fragment.
Chris Lattner233f52b2010-03-09 23:52:58 +0000810 Asm->OutStreamer.AddComment("Region start");
Chris Lattnerf88dce12010-04-04 21:31:54 +0000811 Asm->EmitLabelDifference(BeginLabel, EHFuncBeginSym, 4);
Chris Lattner16112732010-03-14 01:41:15 +0000812
Chris Lattner233f52b2010-03-09 23:52:58 +0000813 Asm->OutStreamer.AddComment("Region length");
Chris Lattnera6437182010-04-04 19:58:12 +0000814 Asm->EmitLabelDifference(EndLabel, BeginLabel, 4);
Bill Wendlingeb907212009-05-15 01:12:28 +0000815
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000816
Bill Wendlinga583c552009-08-20 22:02:24 +0000817 // Offset of the landing pad, counted in 16-byte bundles relative to the
818 // @LPStart address.
Chris Lattner233f52b2010-03-09 23:52:58 +0000819 Asm->OutStreamer.AddComment("Landing pad");
Chris Lattner16112732010-03-14 01:41:15 +0000820 if (!S.PadLabel)
Chris Lattnerbcb83e52010-01-20 07:41:15 +0000821 Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
Chris Lattner16112732010-03-14 01:41:15 +0000822 else
Chris Lattnerf88dce12010-04-04 21:31:54 +0000823 Asm->EmitLabelDifference(S.PadLabel, EHFuncBeginSym, 4);
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000824
Bill Wendlinga583c552009-08-20 22:02:24 +0000825 // Offset of the first associated action record, relative to the start of
826 // the action table. This value is biased by 1 (1 indicates the start of
827 // the action table), and 0 indicates that there are no actions.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000828 Asm->EmitULEB128(S.Action, "Action");
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000829 }
Bill Wendlingeb907212009-05-15 01:12:28 +0000830 }
831
Bill Wendlinga583c552009-08-20 22:02:24 +0000832 // Emit the Action Table.
Chris Lattner233f52b2010-03-09 23:52:58 +0000833 if (Actions.size() != 0) {
834 Asm->OutStreamer.AddComment("-- Action Record Table --");
835 Asm->OutStreamer.AddBlankLine();
836 }
837
Bill Wendling5cff4872009-07-28 23:44:43 +0000838 for (SmallVectorImpl<ActionEntry>::const_iterator
839 I = Actions.begin(), E = Actions.end(); I != E; ++I) {
840 const ActionEntry &Action = *I;
Chris Lattner233f52b2010-03-09 23:52:58 +0000841 Asm->OutStreamer.AddComment("Action Record");
842 Asm->OutStreamer.AddBlankLine();
Bill Wendlinga583c552009-08-20 22:02:24 +0000843
844 // Type Filter
845 //
846 // Used by the runtime to match the type of the thrown exception to the
847 // type of the catch clauses or the types in the exception specification.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000848 Asm->EmitSLEB128(Action.ValueForTypeID, " TypeInfo index");
Bill Wendlinga583c552009-08-20 22:02:24 +0000849
850 // Action Record
851 //
852 // Self-relative signed displacement in bytes of the next action record,
853 // or 0 if there is no next action record.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000854 Asm->EmitSLEB128(Action.NextAction, " Next action");
Bill Wendlingeb907212009-05-15 01:12:28 +0000855 }
856
Bill Wendling48dc29e2009-10-22 20:48:59 +0000857 // Emit the Catch TypeInfos.
Chris Lattner233f52b2010-03-09 23:52:58 +0000858 if (!TypeInfos.empty()) {
859 Asm->OutStreamer.AddComment("-- Catch TypeInfos --");
860 Asm->OutStreamer.AddBlankLine();
861 }
Dan Gohman46510a72010-04-15 01:51:59 +0000862 for (std::vector<const GlobalVariable *>::const_reverse_iterator
Bill Wendling01c69372009-11-19 00:09:14 +0000863 I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) {
Bill Wendlingfb7634f2009-11-19 19:21:09 +0000864 const GlobalVariable *GV = *I;
Bill Wendlingec044582009-11-18 23:18:46 +0000865
Chris Lattner90e4af72010-03-10 00:09:21 +0000866 Asm->OutStreamer.AddComment("TypeInfo");
867 if (GV)
Chris Lattnerd2af7852010-04-04 20:20:50 +0000868 Asm->EmitReference(GV, TTypeEncoding);
Chris Lattner90e4af72010-03-10 00:09:21 +0000869 else
Chris Lattnerd2af7852010-04-04 20:20:50 +0000870 Asm->OutStreamer.EmitIntValue(0,Asm->GetSizeOfEncodedValue(TTypeEncoding),
871 0);
Bill Wendlingeb907212009-05-15 01:12:28 +0000872 }
873
Bill Wendling48dc29e2009-10-22 20:48:59 +0000874 // Emit the Exception Specifications.
Chris Lattner233f52b2010-03-09 23:52:58 +0000875 if (!FilterIds.empty()) {
876 Asm->OutStreamer.AddComment("-- Filter IDs --");
877 Asm->OutStreamer.AddBlankLine();
878 }
Bill Wendling5cff4872009-07-28 23:44:43 +0000879 for (std::vector<unsigned>::const_iterator
880 I = FilterIds.begin(), E = FilterIds.end(); I < E; ++I) {
881 unsigned TypeID = *I;
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000882 Asm->EmitULEB128(TypeID, TypeID != 0 ? "Exception specification" : 0);
Bill Wendlingeb907212009-05-15 01:12:28 +0000883 }
884
Chris Lattner059ea132010-04-28 01:05:45 +0000885 Asm->EmitAlignment(2);
Bill Wendlingeb907212009-05-15 01:12:28 +0000886}
887
Bill Wendlingeb907212009-05-15 01:12:28 +0000888/// EndModule - Emit all exception information that should come after the
889/// content.
890void DwarfException::EndModule() {
Chris Lattner84ac8b72010-04-05 00:26:50 +0000891 if (Asm->MAI->getExceptionHandlingType() != ExceptionHandling::Dwarf)
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000892 return;
Bill Wendlingb4049fe2009-09-09 21:06:24 +0000893
Bill Wendling52783c62009-09-09 23:56:55 +0000894 if (!shouldEmitMovesModule && !shouldEmitTableModule)
895 return;
896
Dan Gohman46510a72010-04-15 01:51:59 +0000897 const std::vector<const Function *> Personalities = MMI->getPersonalities();
Bill Wendlingb4049fe2009-09-09 21:06:24 +0000898
Bill Wendling28275fd2009-09-10 06:50:01 +0000899 for (unsigned I = 0, E = Personalities.size(); I < E; ++I)
900 EmitCIE(Personalities[I], I);
Bill Wendlingeb907212009-05-15 01:12:28 +0000901
Bill Wendling52783c62009-09-09 23:56:55 +0000902 for (std::vector<FunctionEHFrameInfo>::iterator
903 I = EHFrames.begin(), E = EHFrames.end(); I != E; ++I)
904 EmitFDE(*I);
Bill Wendlingeb907212009-05-15 01:12:28 +0000905}
906
Bill Wendling28275fd2009-09-10 06:50:01 +0000907/// BeginFunction - Gather pre-function exception information. Assumes it's
908/// being emitted immediately after the function entry point.
Chris Lattnereec791a2010-01-26 23:18:02 +0000909void DwarfException::BeginFunction(const MachineFunction *MF) {
Bill Wendlingeb907212009-05-15 01:12:28 +0000910 shouldEmitTable = shouldEmitMoves = false;
911
Bill Wendling73c5a612009-09-10 18:28:06 +0000912 // If any landing pads survive, we need an EH table.
Chris Lattner16112732010-03-14 01:41:15 +0000913 shouldEmitTable = !MMI->getLandingPads().empty();
Bill Wendlingeb907212009-05-15 01:12:28 +0000914
Bill Wendling73c5a612009-09-10 18:28:06 +0000915 // See if we need frame move info.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000916 shouldEmitMoves =
917 !Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory;
Bill Wendlingeb907212009-05-15 01:12:28 +0000918
Bill Wendling73c5a612009-09-10 18:28:06 +0000919 if (shouldEmitMoves || shouldEmitTable)
920 // Assumes in correct section after the entry point.
Chris Lattnerc0215722010-04-04 19:25:43 +0000921 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
Chris Lattner84ac8b72010-04-05 00:26:50 +0000922 Asm->getFunctionNumber()));
Bill Wendlingeb907212009-05-15 01:12:28 +0000923
924 shouldEmitTableModule |= shouldEmitTable;
925 shouldEmitMovesModule |= shouldEmitMoves;
Bill Wendlingeb907212009-05-15 01:12:28 +0000926}
927
928/// EndFunction - Gather and emit post-function exception information.
929///
930void DwarfException::EndFunction() {
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000931 if (!shouldEmitMoves && !shouldEmitTable) return;
932
Chris Lattner84ac8b72010-04-05 00:26:50 +0000933 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
934 Asm->getFunctionNumber()));
Chris Lattner16112732010-03-14 01:41:15 +0000935
936 // Record if this personality index uses a landing pad.
937 bool HasLandingPad = !MMI->getLandingPads().empty();
938 UsesLSDA[MMI->getPersonalityIndex()] |= HasLandingPad;
939
940 // Map all labels and get rid of any dead landing pads.
941 MMI->TidyLandingPads();
942
943 if (HasLandingPad)
944 EmitExceptionTable();
Bill Wendlingeb907212009-05-15 01:12:28 +0000945
Chris Lattner09d53fe2010-03-10 07:20:42 +0000946 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
Chris Lattner3a9be0e2010-01-23 05:51:36 +0000947 MCSymbol *FunctionEHSym =
Chris Lattner84ac8b72010-04-05 00:26:50 +0000948 Asm->GetSymbolWithGlobalValueBase(Asm->MF->getFunction(), ".eh",
Chris Lattner09d53fe2010-03-10 07:20:42 +0000949 TLOF.isFunctionEHFrameSymbolPrivate());
Chris Lattner25d812b2009-09-16 00:35:39 +0000950
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000951 // Save EH frame information
Chris Lattner84ac8b72010-04-05 00:26:50 +0000952 EHFrames.push_back(FunctionEHFrameInfo(FunctionEHSym,
953 Asm->getFunctionNumber(),
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000954 MMI->getPersonalityIndex(),
Chris Lattner84ac8b72010-04-05 00:26:50 +0000955 Asm->MF->getFrameInfo()->hasCalls(),
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000956 !MMI->getLandingPads().empty(),
957 MMI->getFrameMoves(),
Chris Lattner84ac8b72010-04-05 00:26:50 +0000958 Asm->MF->getFunction()));
Bill Wendlingeb907212009-05-15 01:12:28 +0000959}