blob: 0a1e763bd5a24075333206569f7925ee60e43e0b [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"
16#include "llvm/CodeGen/MachineModuleInfo.h"
17#include "llvm/CodeGen/MachineFrameInfo.h"
David Greenefc4da0c2009-08-19 21:55:33 +000018#include "llvm/CodeGen/MachineFunction.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000019#include "llvm/CodeGen/MachineLocation.h"
Chris Lattner8c6ed052009-09-16 01:46:41 +000020#include "llvm/MC/MCAsmInfo.h"
21#include "llvm/MC/MCContext.h"
22#include "llvm/MC/MCExpr.h"
Bill Wendling43e484f2009-09-10 01:12:47 +000023#include "llvm/MC/MCSection.h"
Chris Lattner6c2f9e12009-08-19 05:49:37 +000024#include "llvm/MC/MCStreamer.h"
Chris Lattner7a2ba942010-01-16 18:37:32 +000025#include "llvm/MC/MCSymbol.h"
Chris Lattner45111d12010-01-16 21:57:06 +000026#include "llvm/Target/Mangler.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000027#include "llvm/Target/TargetData.h"
28#include "llvm/Target/TargetFrameInfo.h"
Chris Lattnerd5bbb072009-08-02 01:34:32 +000029#include "llvm/Target/TargetLoweringObjectFile.h"
Chris Lattner9d1c1ad2010-04-04 18:06:11 +000030#include "llvm/Target/TargetMachine.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000031#include "llvm/Target/TargetOptions.h"
Chris Lattnerd5bbb072009-08-02 01:34:32 +000032#include "llvm/Target/TargetRegisterInfo.h"
Chris Lattner6c2f9e12009-08-19 05:49:37 +000033#include "llvm/Support/Dwarf.h"
Chris Lattner0ad9c912010-01-22 22:09:00 +000034#include "llvm/Support/FormattedStream.h"
Chris Lattner6c2f9e12009-08-19 05:49:37 +000035#include "llvm/Support/Timer.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 Wendlingbc0d23a2009-05-15 01:18:50 +000043 shouldEmitTableModule(false), shouldEmitMovesModule(false),
44 ExceptionTimer(0) {
Eric Christopherdbfcdb92009-08-28 22:33:43 +000045 if (TimePassesIsEnabled)
Chris Lattner0b86a6f2009-12-28 07:41:18 +000046 ExceptionTimer = new Timer("DWARF Exception Writer");
Bill Wendlingbc0d23a2009-05-15 01:18:50 +000047}
48
49DwarfException::~DwarfException() {
50 delete ExceptionTimer;
51}
52
Bill Wendling7ccda0f2009-08-25 08:08:33 +000053/// EmitCIE - Emit a Common Information Entry (CIE). This holds information that
54/// is shared among many Frame Description Entries. There is at least one CIE
55/// in every non-empty .debug_frame section.
Chris Lattner8c6ed052009-09-16 01:46:41 +000056void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
Bill Wendlingeb907212009-05-15 01:12:28 +000057 // Size and sign of stack growth.
Chris Lattner84ac8b72010-04-05 00:26:50 +000058 int stackGrowth = Asm->getTargetData().getPointerSize();
59 if (Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
60 TargetFrameInfo::StackGrowsDown)
61 stackGrowth *= -1;
Bill Wendlingeb907212009-05-15 01:12:28 +000062
Chris Lattner8c6ed052009-09-16 01:46:41 +000063 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
Anton Korobeynikov9184b252010-02-15 22:35:59 +000064
Bill Wendlingeb907212009-05-15 01:12:28 +000065 // Begin eh frame section.
Chris Lattner8c6ed052009-09-16 01:46:41 +000066 Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection());
Bill Wendlingeb907212009-05-15 01:12:28 +000067
Chris Lattner974c0fb2010-03-10 02:48:06 +000068 MCSymbol *EHFrameSym;
Chris Lattner09d53fe2010-03-10 07:20:42 +000069 if (TLOF.isFunctionEHFrameSymbolPrivate())
Chris Lattnerc0215722010-04-04 19:25:43 +000070 EHFrameSym = Asm->GetTempSymbol("EH_frame", Index);
Chris Lattner974c0fb2010-03-10 02:48:06 +000071 else
72 EHFrameSym = Asm->OutContext.GetOrCreateSymbol(Twine("EH_frame") +
73 Twine(Index));
74 Asm->OutStreamer.EmitLabel(EHFrameSym);
Chris Lattner8c6ed052009-09-16 01:46:41 +000075
Chris Lattnerc0215722010-04-04 19:25:43 +000076 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_eh_frame", Index));
Bill Wendlingeb907212009-05-15 01:12:28 +000077
78 // Define base labels.
Chris Lattnerc0215722010-04-04 19:25:43 +000079 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common", Index));
Bill Wendlingeb907212009-05-15 01:12:28 +000080
81 // Define the eh frame length.
Chris Lattner233f52b2010-03-09 23:52:58 +000082 Asm->OutStreamer.AddComment("Length of Common Information Entry");
Chris Lattnera6437182010-04-04 19:58:12 +000083 Asm->EmitLabelDifference(Asm->GetTempSymbol("eh_frame_common_end", Index),
84 Asm->GetTempSymbol("eh_frame_common_begin", Index),
85 4);
Bill Wendlingeb907212009-05-15 01:12:28 +000086
87 // EH frame header.
Chris Lattnerc0215722010-04-04 19:25:43 +000088 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_begin",Index));
Chris Lattner233f52b2010-03-09 23:52:58 +000089 Asm->OutStreamer.AddComment("CIE Identifier Tag");
Chris Lattnerbcb83e52010-01-20 07:41:15 +000090 Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
Chris Lattner233f52b2010-03-09 23:52:58 +000091 Asm->OutStreamer.AddComment("DW_CIE_VERSION");
Chris Lattner066c9ac2010-01-22 22:23:57 +000092 Asm->OutStreamer.EmitIntValue(dwarf::DW_CIE_VERSION, 1/*size*/, 0/*addr*/);
Bill Wendlingeb907212009-05-15 01:12:28 +000093
94 // The personality presence indicates that language specific information will
Chris Lattner8c6ed052009-09-16 01:46:41 +000095 // show up in the eh frame. Find out how we are supposed to lower the
96 // personality function reference:
Anton Korobeynikov9184b252010-02-15 22:35:59 +000097
98 unsigned LSDAEncoding = TLOF.getLSDAEncoding();
99 unsigned FDEEncoding = TLOF.getFDEEncoding();
100 unsigned PerEncoding = TLOF.getPersonalityEncoding();
Bill Wendling52783c62009-09-09 23:56:55 +0000101
Chris Lattner4cf202b2010-01-23 03:11:46 +0000102 char Augmentation[6] = { 0 };
Bill Wendling52783c62009-09-09 23:56:55 +0000103 unsigned AugmentationSize = 0;
104 char *APtr = Augmentation + 1;
105
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000106 if (PersonalityFn) {
Bill Wendling52783c62009-09-09 23:56:55 +0000107 // There is a personality function.
108 *APtr++ = 'P';
Chris Lattnerd2af7852010-04-04 20:20:50 +0000109 AugmentationSize += 1 + Asm->GetSizeOfEncodedValue(PerEncoding);
Bill Wendling52783c62009-09-09 23:56:55 +0000110 }
111
112 if (UsesLSDA[Index]) {
113 // An LSDA pointer is in the FDE augmentation.
114 *APtr++ = 'L';
115 ++AugmentationSize;
116 }
117
118 if (FDEEncoding != dwarf::DW_EH_PE_absptr) {
119 // A non-default pointer encoding for the FDE.
120 *APtr++ = 'R';
121 ++AugmentationSize;
122 }
123
124 if (APtr != Augmentation + 1)
125 Augmentation[0] = 'z';
126
Chris Lattner233f52b2010-03-09 23:52:58 +0000127 Asm->OutStreamer.AddComment("CIE Augmentation");
Chris Lattner4cf202b2010-01-23 03:11:46 +0000128 Asm->OutStreamer.EmitBytes(StringRef(Augmentation, strlen(Augmentation)+1),0);
Bill Wendlingeb907212009-05-15 01:12:28 +0000129
130 // Round out reader.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000131 Asm->EmitULEB128(1, "CIE Code Alignment Factor");
132 Asm->EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
Chris Lattner233f52b2010-03-09 23:52:58 +0000133 Asm->OutStreamer.AddComment("CIE Return Address Column");
Chris Lattner84ac8b72010-04-05 00:26:50 +0000134
135 const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
Bill Wendlingeb907212009-05-15 01:12:28 +0000136 Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true));
Bill Wendlingeb907212009-05-15 01:12:28 +0000137
Anton Korobeynikovac8a3d02010-02-15 22:36:41 +0000138 if (Augmentation[0]) {
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000139 Asm->EmitULEB128(AugmentationSize, "Augmentation Size");
Bill Wendling52783c62009-09-09 23:56:55 +0000140
Anton Korobeynikovac8a3d02010-02-15 22:36:41 +0000141 // If there is a personality, we need to indicate the function's location.
142 if (PersonalityFn) {
Chris Lattnerca6190b2010-04-04 20:04:21 +0000143 Asm->EmitEncodingByte(PerEncoding, "Personality");
Chris Lattner233f52b2010-03-09 23:52:58 +0000144 Asm->OutStreamer.AddComment("Personality");
Chris Lattnerd2af7852010-04-04 20:20:50 +0000145 Asm->EmitReference(PersonalityFn, PerEncoding);
Anton Korobeynikovac8a3d02010-02-15 22:36:41 +0000146 }
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000147 if (UsesLSDA[Index])
Chris Lattnerca6190b2010-04-04 20:04:21 +0000148 Asm->EmitEncodingByte(LSDAEncoding, "LSDA");
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000149 if (FDEEncoding != dwarf::DW_EH_PE_absptr)
Chris Lattnerca6190b2010-04-04 20:04:21 +0000150 Asm->EmitEncodingByte(FDEEncoding, "FDE");
Bill Wendlingeb907212009-05-15 01:12:28 +0000151 }
152
153 // Indicate locations of general callee saved registers in frame.
154 std::vector<MachineMove> Moves;
155 RI->getInitialFrameState(Moves);
Chris Lattner02b86b92010-04-04 23:41:46 +0000156 Asm->EmitFrameMoves(Moves, 0, true);
Bill Wendlingeb907212009-05-15 01:12:28 +0000157
158 // On Darwin the linker honors the alignment of eh_frame, which means it must
159 // be 8-byte on 64-bit targets to match what gcc does. Otherwise you get
160 // holes which confuse readers of eh_frame.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000161 Asm->EmitAlignment(Asm->getTargetData().getPointerSize() == 4 ? 2 : 3,
162 0, 0, false);
Chris Lattnerc0215722010-04-04 19:25:43 +0000163 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_end", Index));
Bill Wendlingeb907212009-05-15 01:12:28 +0000164}
165
Bill Wendling7ccda0f2009-08-25 08:08:33 +0000166/// EmitFDE - Emit the Frame Description Entry (FDE) for the function.
167void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000168 assert(!EHFrameInfo.function->hasAvailableExternallyLinkage() &&
Bill Wendlingeb907212009-05-15 01:12:28 +0000169 "Should not emit 'available externally' functions at all");
170
Chris Lattner3e0f60b2009-07-17 21:00:50 +0000171 const Function *TheFunc = EHFrameInfo.function;
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000172 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000173
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000174 unsigned LSDAEncoding = TLOF.getLSDAEncoding();
175 unsigned FDEEncoding = TLOF.getFDEEncoding();
176
177 Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection());
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000178
Bill Wendlingeb907212009-05-15 01:12:28 +0000179 // Externally visible entry into the functions eh frame info. If the
180 // corresponding function is static, this should not be externally visible.
Chris Lattner09d53fe2010-03-10 07:20:42 +0000181 if (!TheFunc->hasLocalLinkage() && TLOF.isFunctionEHSymbolGlobal())
182 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,MCSA_Global);
Bill Wendlingeb907212009-05-15 01:12:28 +0000183
184 // If corresponding function is weak definition, this should be too.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000185 if (TheFunc->isWeakForLinker() && Asm->MAI->getWeakDefDirective())
Chris Lattner974c0fb2010-03-10 02:48:06 +0000186 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
187 MCSA_WeakDefinition);
Bill Wendlingee161a62009-11-11 01:24:59 +0000188
189 // If corresponding function is hidden, this should be too.
190 if (TheFunc->hasHiddenVisibility())
Chris Lattner84ac8b72010-04-05 00:26:50 +0000191 if (MCSymbolAttr HiddenAttr = Asm->MAI->getHiddenVisibilityAttr())
Chris Lattner152a29b2010-01-23 06:53:23 +0000192 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
193 HiddenAttr);
Bill Wendlingeb907212009-05-15 01:12:28 +0000194
195 // If there are no calls then you can't unwind. This may mean we can omit the
196 // EH Frame, but some environments do not handle weak absolute symbols. If
197 // UnwindTablesMandatory is set we cannot do this optimization; the unwind
198 // info is to be available for non-EH uses.
Chris Lattner3e0f60b2009-07-17 21:00:50 +0000199 if (!EHFrameInfo.hasCalls && !UnwindTablesMandatory &&
200 (!TheFunc->isWeakForLinker() ||
Chris Lattner84ac8b72010-04-05 00:26:50 +0000201 !Asm->MAI->getWeakDefDirective() ||
Chris Lattner09d53fe2010-03-10 07:20:42 +0000202 TLOF.getSupportsWeakOmittedEHFrame())) {
Chris Lattner974c0fb2010-03-10 02:48:06 +0000203 Asm->OutStreamer.EmitAssignment(EHFrameInfo.FunctionEHSym,
204 MCConstantExpr::Create(0, Asm->OutContext));
Bill Wendlingeb907212009-05-15 01:12:28 +0000205 // This name has no connection to the function, so it might get
206 // dead-stripped when the function is not, erroneously. Prohibit
207 // dead-stripping unconditionally.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000208 if (Asm->MAI->hasNoDeadStrip())
Chris Lattner3a9be0e2010-01-23 05:51:36 +0000209 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
Chris Lattnera5ad93a2010-01-23 06:39:22 +0000210 MCSA_NoDeadStrip);
Bill Wendlingeb907212009-05-15 01:12:28 +0000211 } else {
Chris Lattner974c0fb2010-03-10 02:48:06 +0000212 Asm->OutStreamer.EmitLabel(EHFrameInfo.FunctionEHSym);
Bill Wendlingeb907212009-05-15 01:12:28 +0000213
214 // EH frame header.
Chris Lattner233f52b2010-03-09 23:52:58 +0000215 Asm->OutStreamer.AddComment("Length of Frame Information Entry");
Chris Lattnera6437182010-04-04 19:58:12 +0000216 Asm->EmitLabelDifference(
217 Asm->GetTempSymbol("eh_frame_end", EHFrameInfo.Number),
218 Asm->GetTempSymbol("eh_frame_begin", EHFrameInfo.Number), 4);
Bill Wendlingeb907212009-05-15 01:12:28 +0000219
Chris Lattnerc0215722010-04-04 19:25:43 +0000220 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_begin",
221 EHFrameInfo.Number));
Bill Wendlingeb907212009-05-15 01:12:28 +0000222
Chris Lattner233f52b2010-03-09 23:52:58 +0000223 Asm->OutStreamer.AddComment("FDE CIE offset");
Chris Lattnerf88dce12010-04-04 21:31:54 +0000224 Asm->EmitLabelDifference(
225 Asm->GetTempSymbol("eh_frame_begin", EHFrameInfo.Number),
226 Asm->GetTempSymbol("eh_frame_common",
227 EHFrameInfo.PersonalityIndex), 4);
Bill Wendlingeb907212009-05-15 01:12:28 +0000228
Chris Lattnerc0215722010-04-04 19:25:43 +0000229 MCSymbol *EHFuncBeginSym =
230 Asm->GetTempSymbol("eh_func_begin", EHFrameInfo.Number);
Bill Wendlingeb907212009-05-15 01:12:28 +0000231
Chris Lattner233f52b2010-03-09 23:52:58 +0000232 Asm->OutStreamer.AddComment("FDE initial location");
Chris Lattnerd2af7852010-04-04 20:20:50 +0000233 Asm->EmitReference(EHFuncBeginSym, FDEEncoding);
Chris Lattnerfb658072010-03-13 07:40:56 +0000234
Chris Lattner233f52b2010-03-09 23:52:58 +0000235 Asm->OutStreamer.AddComment("FDE address range");
Chris Lattnera6437182010-04-04 19:58:12 +0000236 Asm->EmitLabelDifference(Asm->GetTempSymbol("eh_func_end",
237 EHFrameInfo.Number),
Chris Lattnerd2af7852010-04-04 20:20:50 +0000238 EHFuncBeginSym,
239 Asm->GetSizeOfEncodedValue(FDEEncoding));
Bill Wendlingeb907212009-05-15 01:12:28 +0000240
241 // If there is a personality and landing pads then point to the language
242 // specific data area in the exception table.
Eric Christopherd44fff72009-08-26 21:30:49 +0000243 if (MMI->getPersonalities()[0] != NULL) {
Chris Lattnerd2af7852010-04-04 20:20:50 +0000244 unsigned Size = Asm->GetSizeOfEncodedValue(LSDAEncoding);
Duncan Sandsc69d74a2009-08-31 16:45:16 +0000245
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000246 Asm->EmitULEB128(Size, "Augmentation size");
Chris Lattner233f52b2010-03-09 23:52:58 +0000247 Asm->OutStreamer.AddComment("Language Specific Data Area");
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000248 if (EHFrameInfo.hasLandingPads)
Chris Lattnerd2af7852010-04-04 20:20:50 +0000249 Asm->EmitReference(Asm->GetTempSymbol("exception", EHFrameInfo.Number),
250 LSDAEncoding);
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000251 else
252 Asm->OutStreamer.EmitIntValue(0, Size/*size*/, 0/*addrspace*/);
Bill Wendlingd58e9cb2010-01-16 01:40:55 +0000253
Bill Wendlingeb907212009-05-15 01:12:28 +0000254 } else {
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000255 Asm->EmitULEB128(0, "Augmentation size");
Bill Wendlingeb907212009-05-15 01:12:28 +0000256 }
257
258 // Indicate locations of function specific callee saved registers in frame.
Chris Lattner02b86b92010-04-04 23:41:46 +0000259 Asm->EmitFrameMoves(EHFrameInfo.Moves, EHFuncBeginSym, true);
Bill Wendlingeb907212009-05-15 01:12:28 +0000260
261 // On Darwin the linker honors the alignment of eh_frame, which means it
262 // must be 8-byte on 64-bit targets to match what gcc does. Otherwise you
263 // get holes which confuse readers of eh_frame.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000264 Asm->EmitAlignment(Asm->getTargetData().getPointerSize() == 4 ? 2 : 3,
Bill Wendlingeb907212009-05-15 01:12:28 +0000265 0, 0, false);
Chris Lattnerc0215722010-04-04 19:25:43 +0000266 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_end",
267 EHFrameInfo.Number));
Bill Wendlingeb907212009-05-15 01:12:28 +0000268
269 // If the function is marked used, this table should be also. We cannot
270 // make the mark unconditional in this case, since retaining the table also
271 // retains the function in this case, and there is code around that depends
272 // on unused functions (calling undefined externals) being dead-stripped to
273 // link correctly. Yes, there really is.
Chris Lattner401e10c2009-07-20 06:14:25 +0000274 if (MMI->isUsedFunction(EHFrameInfo.function))
Chris Lattner84ac8b72010-04-05 00:26:50 +0000275 if (Asm->MAI->hasNoDeadStrip())
Chris Lattner3a9be0e2010-01-23 05:51:36 +0000276 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
Chris Lattnera5ad93a2010-01-23 06:39:22 +0000277 MCSA_NoDeadStrip);
Bill Wendlingeb907212009-05-15 01:12:28 +0000278 }
Chris Lattner188a87d2010-03-10 01:04:13 +0000279 Asm->OutStreamer.AddBlankLine();
Bill Wendlingeb907212009-05-15 01:12:28 +0000280}
281
Bill Wendlingeb907212009-05-15 01:12:28 +0000282/// SharedTypeIds - How many leading type ids two landing pads have in common.
283unsigned DwarfException::SharedTypeIds(const LandingPadInfo *L,
284 const LandingPadInfo *R) {
285 const std::vector<int> &LIds = L->TypeIds, &RIds = R->TypeIds;
286 unsigned LSize = LIds.size(), RSize = RIds.size();
287 unsigned MinSize = LSize < RSize ? LSize : RSize;
288 unsigned Count = 0;
289
290 for (; Count != MinSize; ++Count)
291 if (LIds[Count] != RIds[Count])
292 return Count;
293
294 return Count;
295}
296
297/// PadLT - Order landing pads lexicographically by type id.
298bool DwarfException::PadLT(const LandingPadInfo *L, const LandingPadInfo *R) {
299 const std::vector<int> &LIds = L->TypeIds, &RIds = R->TypeIds;
300 unsigned LSize = LIds.size(), RSize = RIds.size();
301 unsigned MinSize = LSize < RSize ? LSize : RSize;
302
303 for (unsigned i = 0; i != MinSize; ++i)
304 if (LIds[i] != RIds[i])
305 return LIds[i] < RIds[i];
306
307 return LSize < RSize;
308}
309
Bill Wendlingd4609622009-07-28 23:23:00 +0000310/// ComputeActionsTable - Compute the actions table and gather the first action
311/// index for each landing pad site.
Bill Wendlingade025c2009-07-29 00:31:35 +0000312unsigned DwarfException::
313ComputeActionsTable(const SmallVectorImpl<const LandingPadInfo*> &LandingPads,
314 SmallVectorImpl<ActionEntry> &Actions,
315 SmallVectorImpl<unsigned> &FirstActions) {
Bill Wendlinga583c552009-08-20 22:02:24 +0000316
317 // The action table follows the call-site table in the LSDA. The individual
318 // records are of two types:
319 //
320 // * Catch clause
321 // * Exception specification
322 //
323 // The two record kinds have the same format, with only small differences.
324 // They are distinguished by the "switch value" field: Catch clauses
325 // (TypeInfos) have strictly positive switch values, and exception
326 // specifications (FilterIds) have strictly negative switch values. Value 0
327 // indicates a catch-all clause.
328 //
Bill Wendling5e953dd2009-07-28 23:22:13 +0000329 // Negative type IDs index into FilterIds. Positive type IDs index into
330 // TypeInfos. The value written for a positive type ID is just the type ID
331 // itself. For a negative type ID, however, the value written is the
Bill Wendlingeb907212009-05-15 01:12:28 +0000332 // (negative) byte offset of the corresponding FilterIds entry. The byte
Bill Wendling5e953dd2009-07-28 23:22:13 +0000333 // offset is usually equal to the type ID (because the FilterIds entries are
334 // written using a variable width encoding, which outputs one byte per entry
335 // as long as the value written is not too large) but can differ. This kind
336 // of complication does not occur for positive type IDs because type infos are
Bill Wendlingeb907212009-05-15 01:12:28 +0000337 // output using a fixed width encoding. FilterOffsets[i] holds the byte
338 // offset corresponding to FilterIds[i].
Bill Wendling409914b2009-07-29 21:19:44 +0000339
340 const std::vector<unsigned> &FilterIds = MMI->getFilterIds();
Bill Wendlingeb907212009-05-15 01:12:28 +0000341 SmallVector<int, 16> FilterOffsets;
342 FilterOffsets.reserve(FilterIds.size());
343 int Offset = -1;
Bill Wendling409914b2009-07-29 21:19:44 +0000344
345 for (std::vector<unsigned>::const_iterator
346 I = FilterIds.begin(), E = FilterIds.end(); I != E; ++I) {
Bill Wendlingeb907212009-05-15 01:12:28 +0000347 FilterOffsets.push_back(Offset);
Chris Lattneraf76e592009-08-22 20:48:53 +0000348 Offset -= MCAsmInfo::getULEB128Size(*I);
Bill Wendlingeb907212009-05-15 01:12:28 +0000349 }
350
Bill Wendlingeb907212009-05-15 01:12:28 +0000351 FirstActions.reserve(LandingPads.size());
352
353 int FirstAction = 0;
354 unsigned SizeActions = 0;
Bill Wendling5e953dd2009-07-28 23:22:13 +0000355 const LandingPadInfo *PrevLPI = 0;
Bill Wendling409914b2009-07-29 21:19:44 +0000356
Bill Wendling5cff4872009-07-28 23:44:43 +0000357 for (SmallVectorImpl<const LandingPadInfo *>::const_iterator
Bill Wendling5e953dd2009-07-28 23:22:13 +0000358 I = LandingPads.begin(), E = LandingPads.end(); I != E; ++I) {
359 const LandingPadInfo *LPI = *I;
360 const std::vector<int> &TypeIds = LPI->TypeIds;
Chris Lattner9be49132010-04-04 20:10:41 +0000361 unsigned NumShared = PrevLPI ? SharedTypeIds(LPI, PrevLPI) : 0;
Bill Wendlingeb907212009-05-15 01:12:28 +0000362 unsigned SizeSiteActions = 0;
363
364 if (NumShared < TypeIds.size()) {
365 unsigned SizeAction = 0;
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000366 unsigned PrevAction = (unsigned)-1;
Bill Wendlingeb907212009-05-15 01:12:28 +0000367
368 if (NumShared) {
Chris Lattner9be49132010-04-04 20:10:41 +0000369 unsigned SizePrevIds = PrevLPI->TypeIds.size();
Bill Wendlingeb907212009-05-15 01:12:28 +0000370 assert(Actions.size());
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000371 PrevAction = Actions.size() - 1;
372 SizeAction =
373 MCAsmInfo::getSLEB128Size(Actions[PrevAction].NextAction) +
374 MCAsmInfo::getSLEB128Size(Actions[PrevAction].ValueForTypeID);
Bill Wendlingeb907212009-05-15 01:12:28 +0000375
376 for (unsigned j = NumShared; j != SizePrevIds; ++j) {
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000377 assert(PrevAction != (unsigned)-1 && "PrevAction is invalid!");
Bill Wendlingeb907212009-05-15 01:12:28 +0000378 SizeAction -=
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000379 MCAsmInfo::getSLEB128Size(Actions[PrevAction].ValueForTypeID);
380 SizeAction += -Actions[PrevAction].NextAction;
381 PrevAction = Actions[PrevAction].Previous;
Bill Wendlingeb907212009-05-15 01:12:28 +0000382 }
383 }
384
385 // Compute the actions.
Bill Wendling5e953dd2009-07-28 23:22:13 +0000386 for (unsigned J = NumShared, M = TypeIds.size(); J != M; ++J) {
387 int TypeID = TypeIds[J];
388 assert(-1 - TypeID < (int)FilterOffsets.size() && "Unknown filter id!");
Bill Wendlingeb907212009-05-15 01:12:28 +0000389 int ValueForTypeID = TypeID < 0 ? FilterOffsets[-1 - TypeID] : TypeID;
Chris Lattneraf76e592009-08-22 20:48:53 +0000390 unsigned SizeTypeID = MCAsmInfo::getSLEB128Size(ValueForTypeID);
Bill Wendlingeb907212009-05-15 01:12:28 +0000391
392 int NextAction = SizeAction ? -(SizeAction + SizeTypeID) : 0;
Chris Lattneraf76e592009-08-22 20:48:53 +0000393 SizeAction = SizeTypeID + MCAsmInfo::getSLEB128Size(NextAction);
Bill Wendlingeb907212009-05-15 01:12:28 +0000394 SizeSiteActions += SizeAction;
395
Bill Wendlinga583c552009-08-20 22:02:24 +0000396 ActionEntry Action = { ValueForTypeID, NextAction, PrevAction };
Bill Wendlingeb907212009-05-15 01:12:28 +0000397 Actions.push_back(Action);
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000398 PrevAction = Actions.size() - 1;
Bill Wendlingeb907212009-05-15 01:12:28 +0000399 }
400
401 // Record the first action of the landing pad site.
402 FirstAction = SizeActions + SizeSiteActions - SizeAction + 1;
403 } // else identical - re-use previous FirstAction
404
Bill Wendlinga583c552009-08-20 22:02:24 +0000405 // Information used when created the call-site table. The action record
406 // field of the call site record is the offset of the first associated
407 // action record, relative to the start of the actions table. This value is
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000408 // biased by 1 (1 indicating the start of the actions table), and 0
Bill Wendlinga583c552009-08-20 22:02:24 +0000409 // indicates that there are no actions.
Bill Wendlingeb907212009-05-15 01:12:28 +0000410 FirstActions.push_back(FirstAction);
411
412 // Compute this sites contribution to size.
413 SizeActions += SizeSiteActions;
Bill Wendling5e953dd2009-07-28 23:22:13 +0000414
415 PrevLPI = LPI;
Bill Wendlingeb907212009-05-15 01:12:28 +0000416 }
417
Bill Wendling5e953dd2009-07-28 23:22:13 +0000418 return SizeActions;
419}
420
Bill Wendlinged060dc2009-11-12 21:59:20 +0000421/// CallToNoUnwindFunction - Return `true' if this is a call to a function
422/// marked `nounwind'. Return `false' otherwise.
423bool DwarfException::CallToNoUnwindFunction(const MachineInstr *MI) {
424 assert(MI->getDesc().isCall() && "This should be a call instruction!");
425
426 bool MarkedNoUnwind = false;
427 bool SawFunc = false;
428
429 for (unsigned I = 0, E = MI->getNumOperands(); I != E; ++I) {
430 const MachineOperand &MO = MI->getOperand(I);
431
Chris Lattnercfd31882010-03-31 06:09:04 +0000432 if (!MO.isGlobal()) continue;
433
434 Function *F = dyn_cast<Function>(MO.getGlobal());
435 if (F == 0) continue;
Bill Wendlingecc260e2009-11-12 23:13:08 +0000436
Chris Lattnercfd31882010-03-31 06:09:04 +0000437 if (SawFunc) {
438 // Be conservative. If we have more than one function operand for this
439 // call, then we can't make the assumption that it's the callee and
440 // not a parameter to the call.
441 //
442 // FIXME: Determine if there's a way to say that `F' is the callee or
443 // parameter.
444 MarkedNoUnwind = false;
445 break;
Bill Wendlinged060dc2009-11-12 21:59:20 +0000446 }
Chris Lattnercfd31882010-03-31 06:09:04 +0000447
448 MarkedNoUnwind = F->doesNotThrow();
449 SawFunc = true;
Bill Wendlinged060dc2009-11-12 21:59:20 +0000450 }
451
452 return MarkedNoUnwind;
453}
454
Bill Wendlingade025c2009-07-29 00:31:35 +0000455/// ComputeCallSiteTable - Compute the call-site table. The entry for an invoke
Bill Wendlinga583c552009-08-20 22:02:24 +0000456/// has a try-range containing the call, a non-zero landing pad, and an
Bill Wendlingade025c2009-07-29 00:31:35 +0000457/// appropriate action. The entry for an ordinary call has a try-range
458/// containing the call and zero for the landing pad and the action. Calls
459/// marked 'nounwind' have no entry and must not be contained in the try-range
460/// of any entry - they form gaps in the table. Entries must be ordered by
461/// try-range address.
462void DwarfException::
463ComputeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
464 const RangeMapType &PadMap,
465 const SmallVectorImpl<const LandingPadInfo *> &LandingPads,
466 const SmallVectorImpl<unsigned> &FirstActions) {
Bill Wendlingeb907212009-05-15 01:12:28 +0000467 // The end label of the previous invoke or nounwind try-range.
Chris Lattner16112732010-03-14 01:41:15 +0000468 MCSymbol *LastLabel = 0;
Bill Wendlingeb907212009-05-15 01:12:28 +0000469
470 // Whether there is a potentially throwing instruction (currently this means
471 // an ordinary call) between the end of the previous try-range and now.
472 bool SawPotentiallyThrowing = false;
473
Bill Wendling5cff4872009-07-28 23:44:43 +0000474 // Whether the last CallSite entry was for an invoke.
Bill Wendlingeb907212009-05-15 01:12:28 +0000475 bool PreviousIsInvoke = false;
476
477 // Visit all instructions in order of address.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000478 for (MachineFunction::const_iterator I = Asm->MF->begin(), E = Asm->MF->end();
Bill Wendlingeb907212009-05-15 01:12:28 +0000479 I != E; ++I) {
480 for (MachineBasicBlock::const_iterator MI = I->begin(), E = I->end();
481 MI != E; ++MI) {
482 if (!MI->isLabel()) {
Bill Wendlinged060dc2009-11-12 21:59:20 +0000483 if (MI->getDesc().isCall())
484 SawPotentiallyThrowing |= !CallToNoUnwindFunction(MI);
Bill Wendlingeb907212009-05-15 01:12:28 +0000485 continue;
486 }
487
Bill Wendlingeb907212009-05-15 01:12:28 +0000488 // End of the previous try-range?
Chris Lattner0397ada2010-03-14 08:17:53 +0000489 MCSymbol *BeginLabel = MI->getOperand(0).getMCSymbol();
Bill Wendlingeb907212009-05-15 01:12:28 +0000490 if (BeginLabel == LastLabel)
491 SawPotentiallyThrowing = false;
492
493 // Beginning of a new try-range?
Jeffrey Yasskin81cf4322009-11-10 01:02:17 +0000494 RangeMapType::const_iterator L = PadMap.find(BeginLabel);
Bill Wendlingeb907212009-05-15 01:12:28 +0000495 if (L == PadMap.end())
496 // Nope, it was just some random label.
497 continue;
498
Bill Wendlinga583c552009-08-20 22:02:24 +0000499 const PadRange &P = L->second;
Bill Wendlingeb907212009-05-15 01:12:28 +0000500 const LandingPadInfo *LandingPad = LandingPads[P.PadIndex];
Bill Wendlingeb907212009-05-15 01:12:28 +0000501 assert(BeginLabel == LandingPad->BeginLabels[P.RangeIndex] &&
502 "Inconsistent landing pad map!");
503
Bill Wendlinga583c552009-08-20 22:02:24 +0000504 // For Dwarf exception handling (SjLj handling doesn't use this). If some
505 // instruction between the previous try-range and this one may throw,
506 // create a call-site entry with no landing pad for the region between the
507 // try-ranges.
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000508 if (SawPotentiallyThrowing &&
Chris Lattner84ac8b72010-04-05 00:26:50 +0000509 Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
Bill Wendlinga583c552009-08-20 22:02:24 +0000510 CallSiteEntry Site = { LastLabel, BeginLabel, 0, 0 };
Bill Wendlingeb907212009-05-15 01:12:28 +0000511 CallSites.push_back(Site);
512 PreviousIsInvoke = false;
513 }
514
515 LastLabel = LandingPad->EndLabels[P.RangeIndex];
516 assert(BeginLabel && LastLabel && "Invalid landing pad!");
517
Chris Lattnercfd31882010-03-31 06:09:04 +0000518 if (!LandingPad->LandingPadLabel) {
519 // Create a gap.
520 PreviousIsInvoke = false;
521 } else {
Bill Wendlingeb907212009-05-15 01:12:28 +0000522 // This try-range is for an invoke.
Bill Wendlinga583c552009-08-20 22:02:24 +0000523 CallSiteEntry Site = {
524 BeginLabel,
525 LastLabel,
526 LandingPad->LandingPadLabel,
527 FirstActions[P.PadIndex]
528 };
Bill Wendlingeb907212009-05-15 01:12:28 +0000529
Jim Grosbach33668c02009-09-01 17:19:13 +0000530 // Try to merge with the previous call-site. SJLJ doesn't do this
531 if (PreviousIsInvoke &&
Chris Lattner84ac8b72010-04-05 00:26:50 +0000532 Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
Bill Wendlingeb907212009-05-15 01:12:28 +0000533 CallSiteEntry &Prev = CallSites.back();
534 if (Site.PadLabel == Prev.PadLabel && Site.Action == Prev.Action) {
535 // Extend the range of the previous entry.
536 Prev.EndLabel = Site.EndLabel;
537 continue;
538 }
539 }
540
541 // Otherwise, create a new call-site.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000542 if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf)
Jim Grosbachca752c92010-01-28 01:45:32 +0000543 CallSites.push_back(Site);
544 else {
545 // SjLj EH must maintain the call sites in the order assigned
546 // to them by the SjLjPrepare pass.
547 unsigned SiteNo = MMI->getCallSiteBeginLabel(BeginLabel);
548 if (CallSites.size() < SiteNo)
549 CallSites.resize(SiteNo);
550 CallSites[SiteNo - 1] = Site;
551 }
Bill Wendlingeb907212009-05-15 01:12:28 +0000552 PreviousIsInvoke = true;
Bill Wendlingeb907212009-05-15 01:12:28 +0000553 }
554 }
555 }
556
557 // If some instruction between the previous try-range and the end of the
558 // function may throw, create a call-site entry with no landing pad for the
559 // region following the try-range.
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000560 if (SawPotentiallyThrowing &&
Chris Lattner84ac8b72010-04-05 00:26:50 +0000561 Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
Bill Wendlinga583c552009-08-20 22:02:24 +0000562 CallSiteEntry Site = { LastLabel, 0, 0, 0 };
Bill Wendlingeb907212009-05-15 01:12:28 +0000563 CallSites.push_back(Site);
564 }
Bill Wendlingade025c2009-07-29 00:31:35 +0000565}
566
Bill Wendling0dafca92009-07-29 00:50:05 +0000567/// EmitExceptionTable - Emit landing pads and actions.
568///
569/// The general organization of the table is complex, but the basic concepts are
570/// easy. First there is a header which describes the location and organization
571/// of the three components that follow.
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000572///
Bill Wendling0dafca92009-07-29 00:50:05 +0000573/// 1. The landing pad site information describes the range of code covered by
574/// the try. In our case it's an accumulation of the ranges covered by the
575/// invokes in the try. There is also a reference to the landing pad that
576/// handles the exception once processed. Finally an index into the actions
577/// table.
Bill Wendlinga583c552009-08-20 22:02:24 +0000578/// 2. The action table, in our case, is composed of pairs of type IDs and next
Bill Wendling0dafca92009-07-29 00:50:05 +0000579/// action offset. Starting with the action index from the landing pad
Bill Wendlinga583c552009-08-20 22:02:24 +0000580/// site, each type ID is checked for a match to the current exception. If
Bill Wendling0dafca92009-07-29 00:50:05 +0000581/// it matches then the exception and type id are passed on to the landing
582/// pad. Otherwise the next action is looked up. This chain is terminated
Bill Wendling28275fd2009-09-10 06:50:01 +0000583/// with a next action of zero. If no type id is found then the frame is
Bill Wendling0dafca92009-07-29 00:50:05 +0000584/// unwound and handling continues.
Bill Wendlinga583c552009-08-20 22:02:24 +0000585/// 3. Type ID table contains references to all the C++ typeinfo for all
Bill Wendling28275fd2009-09-10 06:50:01 +0000586/// catches in the function. This tables is reverse indexed base 1.
Bill Wendlingade025c2009-07-29 00:31:35 +0000587void DwarfException::EmitExceptionTable() {
588 const std::vector<GlobalVariable *> &TypeInfos = MMI->getTypeInfos();
589 const std::vector<unsigned> &FilterIds = MMI->getFilterIds();
590 const std::vector<LandingPadInfo> &PadInfos = MMI->getLandingPads();
Bill Wendlingade025c2009-07-29 00:31:35 +0000591
592 // Sort the landing pads in order of their type ids. This is used to fold
593 // duplicate actions.
594 SmallVector<const LandingPadInfo *, 64> LandingPads;
595 LandingPads.reserve(PadInfos.size());
596
597 for (unsigned i = 0, N = PadInfos.size(); i != N; ++i)
598 LandingPads.push_back(&PadInfos[i]);
599
600 std::sort(LandingPads.begin(), LandingPads.end(), PadLT);
601
602 // Compute the actions table and gather the first action index for each
603 // landing pad site.
604 SmallVector<ActionEntry, 32> Actions;
605 SmallVector<unsigned, 64> FirstActions;
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000606 unsigned SizeActions=ComputeActionsTable(LandingPads, Actions, FirstActions);
Bill Wendlingade025c2009-07-29 00:31:35 +0000607
608 // Invokes and nounwind calls have entries in PadMap (due to being bracketed
609 // by try-range labels when lowered). Ordinary calls do not, so appropriate
Bill Wendling28275fd2009-09-10 06:50:01 +0000610 // try-ranges for them need be deduced when using DWARF exception handling.
Bill Wendlingade025c2009-07-29 00:31:35 +0000611 RangeMapType PadMap;
612 for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) {
613 const LandingPadInfo *LandingPad = LandingPads[i];
614 for (unsigned j = 0, E = LandingPad->BeginLabels.size(); j != E; ++j) {
Chris Lattner16112732010-03-14 01:41:15 +0000615 MCSymbol *BeginLabel = LandingPad->BeginLabels[j];
Bill Wendlingade025c2009-07-29 00:31:35 +0000616 assert(!PadMap.count(BeginLabel) && "Duplicate landing pad labels!");
617 PadRange P = { i, j };
618 PadMap[BeginLabel] = P;
619 }
620 }
621
622 // Compute the call-site table.
623 SmallVector<CallSiteEntry, 64> CallSites;
Jim Grosbach8b818d72009-08-17 16:41:22 +0000624 ComputeCallSiteTable(CallSites, PadMap, LandingPads, FirstActions);
Bill Wendlingeb907212009-05-15 01:12:28 +0000625
626 // Final tallies.
627
628 // Call sites.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000629 bool IsSJLJ = Asm->MAI->getExceptionHandlingType() == ExceptionHandling::SjLj;
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000630 bool HaveTTData = IsSJLJ ? (!TypeInfos.empty() || !FilterIds.empty()) : true;
Chris Lattner9be49132010-04-04 20:10:41 +0000631
Bill Wendling3dc9b482010-02-24 23:34:35 +0000632 unsigned CallSiteTableLength;
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000633 if (IsSJLJ)
Bill Wendling3dc9b482010-02-24 23:34:35 +0000634 CallSiteTableLength = 0;
Chris Lattner9be49132010-04-04 20:10:41 +0000635 else {
636 unsigned SiteStartSize = 4; // dwarf::DW_EH_PE_udata4
637 unsigned SiteLengthSize = 4; // dwarf::DW_EH_PE_udata4
638 unsigned LandingPadSize = 4; // dwarf::DW_EH_PE_udata4
639 CallSiteTableLength =
640 CallSites.size() * (SiteStartSize + SiteLengthSize + LandingPadSize);
641 }
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000642
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000643 for (unsigned i = 0, e = CallSites.size(); i < e; ++i) {
Bill Wendling3dc9b482010-02-24 23:34:35 +0000644 CallSiteTableLength += MCAsmInfo::getULEB128Size(CallSites[i].Action);
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000645 if (IsSJLJ)
Bill Wendling3dc9b482010-02-24 23:34:35 +0000646 CallSiteTableLength += MCAsmInfo::getULEB128Size(i);
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000647 }
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000648
Bill Wendlingeb907212009-05-15 01:12:28 +0000649 // Type infos.
Chris Lattnerd5bbb072009-08-02 01:34:32 +0000650 const MCSection *LSDASection = Asm->getObjFileLowering().getLSDASection();
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000651 unsigned TTypeEncoding;
Bill Wendlinga2f64492009-09-10 06:27:16 +0000652 unsigned TypeFormatSize;
Bill Wendlingeb907212009-05-15 01:12:28 +0000653
Bill Wendling43e484f2009-09-10 01:12:47 +0000654 if (!HaveTTData) {
Bill Wendling28275fd2009-09-10 06:50:01 +0000655 // For SjLj exceptions, if there is no TypeInfo, then we just explicitly say
656 // that we're omitting that bit.
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000657 TTypeEncoding = dwarf::DW_EH_PE_omit;
Chris Lattner84ac8b72010-04-05 00:26:50 +0000658 // dwarf::DW_EH_PE_absptr
659 TypeFormatSize = Asm->getTargetData().getPointerSize();
Chris Lattner81c9a062009-07-31 22:03:47 +0000660 } else {
Chris Lattnerad88bc42009-08-02 03:59:56 +0000661 // Okay, we have actual filters or typeinfos to emit. As such, we need to
662 // pick a type encoding for them. We're about to emit a list of pointers to
663 // typeinfo objects at the end of the LSDA. However, unless we're in static
664 // mode, this reference will require a relocation by the dynamic linker.
Chris Lattner46b754c2009-07-31 22:18:14 +0000665 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000666 // Because of this, we have a couple of options:
Bill Wendling28275fd2009-09-10 06:50:01 +0000667 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000668 // 1) If we are in -static mode, we can always use an absolute reference
669 // from the LSDA, because the static linker will resolve it.
Bill Wendling28275fd2009-09-10 06:50:01 +0000670 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000671 // 2) Otherwise, if the LSDA section is writable, we can output the direct
672 // reference to the typeinfo and allow the dynamic linker to relocate
673 // it. Since it is in a writable section, the dynamic linker won't
674 // have a problem.
Bill Wendling28275fd2009-09-10 06:50:01 +0000675 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000676 // 3) Finally, if we're in PIC mode and the LDSA section isn't writable,
677 // we need to use some form of indirection. For example, on Darwin,
678 // we can output a statically-relocatable reference to a dyld stub. The
679 // offset to the stub is constant, but the contents are in a section
680 // that is updated by the dynamic linker. This is easy enough, but we
681 // need to tell the personality function of the unwinder to indirect
682 // through the dyld stub.
683 //
Bill Wendling43e484f2009-09-10 01:12:47 +0000684 // FIXME: When (3) is actually implemented, we'll have to emit the stubs
Chris Lattnerad88bc42009-08-02 03:59:56 +0000685 // somewhere. This predicate should be moved to a shared location that is
686 // in target-independent code.
687 //
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000688 TTypeEncoding = Asm->getObjFileLowering().getTTypeEncoding();
Chris Lattnerd2af7852010-04-04 20:20:50 +0000689 TypeFormatSize = Asm->GetSizeOfEncodedValue(TTypeEncoding);
Bill Wendlingfe220282009-09-10 02:07:37 +0000690 }
Bill Wendling43e484f2009-09-10 01:12:47 +0000691
Bill Wendlingfe220282009-09-10 02:07:37 +0000692 // Begin the exception table.
693 Asm->OutStreamer.SwitchSection(LSDASection);
694 Asm->EmitAlignment(2, 0, 0, false);
Bill Wendling43e484f2009-09-10 01:12:47 +0000695
Bill Wendling3dc9b482010-02-24 23:34:35 +0000696 // Emit the LSDA.
Chris Lattner974c0fb2010-03-10 02:48:06 +0000697 MCSymbol *GCCETSym =
698 Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+
Chris Lattner84ac8b72010-04-05 00:26:50 +0000699 Twine(Asm->getFunctionNumber()));
Chris Lattner974c0fb2010-03-10 02:48:06 +0000700 Asm->OutStreamer.EmitLabel(GCCETSym);
Chris Lattner84ac8b72010-04-05 00:26:50 +0000701 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("exception",
702 Asm->getFunctionNumber()));
Bill Wendlingfe220282009-09-10 02:07:37 +0000703
Chris Lattner974c0fb2010-03-10 02:48:06 +0000704 if (IsSJLJ)
Chris Lattnerc0215722010-04-04 19:25:43 +0000705 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("_LSDA_",
706 Asm->getFunctionNumber()));
Bill Wendlingfe220282009-09-10 02:07:37 +0000707
Bill Wendling3dc9b482010-02-24 23:34:35 +0000708 // Emit the LSDA header.
Chris Lattnerca6190b2010-04-04 20:04:21 +0000709 Asm->EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
710 Asm->EmitEncodingByte(TTypeEncoding, "@TType");
Bill Wendlingfe220282009-09-10 02:07:37 +0000711
Bill Wendling3dc9b482010-02-24 23:34:35 +0000712 // The type infos need to be aligned. GCC does this by inserting padding just
713 // before the type infos. However, this changes the size of the exception
714 // table, so you need to take this into account when you output the exception
715 // table size. However, the size is output using a variable length encoding.
716 // So by increasing the size by inserting padding, you may increase the number
717 // of bytes used for writing the size. If it increases, say by one byte, then
718 // you now need to output one less byte of padding to get the type infos
719 // aligned. However this decreases the size of the exception table. This
720 // changes the value you have to output for the exception table size. Due to
721 // the variable length encoding, the number of bytes used for writing the
722 // length may decrease. If so, you then have to increase the amount of
723 // padding. And so on. If you look carefully at the GCC code you will see that
724 // it indeed does this in a loop, going on and on until the values stabilize.
725 // We chose another solution: don't output padding inside the table like GCC
726 // does, instead output it before the table.
727 unsigned SizeTypes = TypeInfos.size() * TypeFormatSize;
728 unsigned CallSiteTableLengthSize =
729 MCAsmInfo::getULEB128Size(CallSiteTableLength);
730 unsigned TTypeBaseOffset =
731 sizeof(int8_t) + // Call site format
732 CallSiteTableLengthSize + // Call site table length size
733 CallSiteTableLength + // Call site table length
734 SizeActions + // Actions size
735 SizeTypes;
736 unsigned TTypeBaseOffsetSize = MCAsmInfo::getULEB128Size(TTypeBaseOffset);
737 unsigned TotalSize =
738 sizeof(int8_t) + // LPStart format
739 sizeof(int8_t) + // TType format
740 (HaveTTData ? TTypeBaseOffsetSize : 0) + // TType base offset size
741 TTypeBaseOffset; // TType base offset
742 unsigned SizeAlign = (4 - TotalSize) & 3;
743
Bill Wendling86f0d332010-02-25 23:52:44 +0000744 if (HaveTTData) {
Bill Wendling6507eca2010-02-26 21:31:01 +0000745 // Account for any extra padding that will be added to the call site table
Bill Wendlingf7e90ae2010-02-25 21:19:47 +0000746 // length.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000747 Asm->EmitULEB128(TTypeBaseOffset, "@TType base offset", SizeAlign);
Bill Wendling1869ac82010-02-26 22:17:52 +0000748 SizeAlign = 0;
Bill Wendling86f0d332010-02-25 23:52:44 +0000749 }
Bill Wendlingb0d9c3e2009-07-28 22:23:45 +0000750
Bill Wendling28275fd2009-09-10 06:50:01 +0000751 // SjLj Exception handling
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000752 if (IsSJLJ) {
Chris Lattnerca6190b2010-04-04 20:04:21 +0000753 Asm->EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
Bill Wendling1869ac82010-02-26 22:17:52 +0000754
755 // Add extra padding if it wasn't added to the TType base offset.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000756 Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
Bill Wendlingeb907212009-05-15 01:12:28 +0000757
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000758 // Emit the landing pad site information.
Jim Grosbach8b818d72009-08-17 16:41:22 +0000759 unsigned idx = 0;
760 for (SmallVectorImpl<CallSiteEntry>::const_iterator
761 I = CallSites.begin(), E = CallSites.end(); I != E; ++I, ++idx) {
762 const CallSiteEntry &S = *I;
Bill Wendlinga583c552009-08-20 22:02:24 +0000763
764 // Offset of the landing pad, counted in 16-byte bundles relative to the
765 // @LPStart address.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000766 Asm->EmitULEB128(idx, "Landing pad");
Bill Wendlinga583c552009-08-20 22:02:24 +0000767
768 // Offset of the first associated action record, relative to the start of
769 // the action table. This value is biased by 1 (1 indicates the start of
770 // the action table), and 0 indicates that there are no actions.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000771 Asm->EmitULEB128(S.Action, "Action");
Bill Wendlingeb907212009-05-15 01:12:28 +0000772 }
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000773 } else {
774 // DWARF Exception handling
Chris Lattner84ac8b72010-04-05 00:26:50 +0000775 assert(Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf);
Bill Wendlingeb907212009-05-15 01:12:28 +0000776
Bill Wendlinga583c552009-08-20 22:02:24 +0000777 // The call-site table is a list of all call sites that may throw an
778 // exception (including C++ 'throw' statements) in the procedure
779 // fragment. It immediately follows the LSDA header. Each entry indicates,
780 // for a given call, the first corresponding action record and corresponding
781 // landing pad.
782 //
783 // The table begins with the number of bytes, stored as an LEB128
784 // compressed, unsigned integer. The records immediately follow the record
785 // count. They are sorted in increasing call-site address. Each record
786 // indicates:
787 //
788 // * The position of the call-site.
789 // * The position of the landing pad.
790 // * The first action record for that call site.
791 //
792 // A missing entry in the call-site table indicates that a call is not
Bill Wendling28275fd2009-09-10 06:50:01 +0000793 // supposed to throw.
Bill Wendlinga583c552009-08-20 22:02:24 +0000794
795 // Emit the landing pad call site table.
Chris Lattnerca6190b2010-04-04 20:04:21 +0000796 Asm->EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
Bill Wendling1869ac82010-02-26 22:17:52 +0000797
798 // Add extra padding if it wasn't added to the TType base offset.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000799 Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
Bill Wendlingeb907212009-05-15 01:12:28 +0000800
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000801 for (SmallVectorImpl<CallSiteEntry>::const_iterator
802 I = CallSites.begin(), E = CallSites.end(); I != E; ++I) {
803 const CallSiteEntry &S = *I;
Chris Lattner16112732010-03-14 01:41:15 +0000804
Chris Lattnerc0215722010-04-04 19:25:43 +0000805 MCSymbol *EHFuncBeginSym =
Chris Lattner84ac8b72010-04-05 00:26:50 +0000806 Asm->GetTempSymbol("eh_func_begin", Asm->getFunctionNumber());
Chris Lattner16112732010-03-14 01:41:15 +0000807
808 MCSymbol *BeginLabel = S.BeginLabel;
809 if (BeginLabel == 0)
810 BeginLabel = EHFuncBeginSym;
811 MCSymbol *EndLabel = S.EndLabel;
812 if (EndLabel == 0)
Chris Lattner84ac8b72010-04-05 00:26:50 +0000813 EndLabel = Asm->GetTempSymbol("eh_func_end", Asm->getFunctionNumber());
Chris Lattner16112732010-03-14 01:41:15 +0000814
Bill Wendlinga583c552009-08-20 22:02:24 +0000815 // Offset of the call site relative to the previous call site, counted in
816 // number of 16-byte bundles. The first call site is counted relative to
817 // the start of the procedure fragment.
Chris Lattner233f52b2010-03-09 23:52:58 +0000818 Asm->OutStreamer.AddComment("Region start");
Chris Lattnerf88dce12010-04-04 21:31:54 +0000819 Asm->EmitLabelDifference(BeginLabel, EHFuncBeginSym, 4);
Chris Lattner16112732010-03-14 01:41:15 +0000820
Chris Lattner233f52b2010-03-09 23:52:58 +0000821 Asm->OutStreamer.AddComment("Region length");
Chris Lattnera6437182010-04-04 19:58:12 +0000822 Asm->EmitLabelDifference(EndLabel, BeginLabel, 4);
Bill Wendlingeb907212009-05-15 01:12:28 +0000823
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000824
Bill Wendlinga583c552009-08-20 22:02:24 +0000825 // Offset of the landing pad, counted in 16-byte bundles relative to the
826 // @LPStart address.
Chris Lattner233f52b2010-03-09 23:52:58 +0000827 Asm->OutStreamer.AddComment("Landing pad");
Chris Lattner16112732010-03-14 01:41:15 +0000828 if (!S.PadLabel)
Chris Lattnerbcb83e52010-01-20 07:41:15 +0000829 Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
Chris Lattner16112732010-03-14 01:41:15 +0000830 else
Chris Lattnerf88dce12010-04-04 21:31:54 +0000831 Asm->EmitLabelDifference(S.PadLabel, EHFuncBeginSym, 4);
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000832
Bill Wendlinga583c552009-08-20 22:02:24 +0000833 // Offset of the first associated action record, relative to the start of
834 // the action table. This value is biased by 1 (1 indicates the start of
835 // the action table), and 0 indicates that there are no actions.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000836 Asm->EmitULEB128(S.Action, "Action");
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000837 }
Bill Wendlingeb907212009-05-15 01:12:28 +0000838 }
839
Bill Wendlinga583c552009-08-20 22:02:24 +0000840 // Emit the Action Table.
Chris Lattner233f52b2010-03-09 23:52:58 +0000841 if (Actions.size() != 0) {
842 Asm->OutStreamer.AddComment("-- Action Record Table --");
843 Asm->OutStreamer.AddBlankLine();
844 }
845
Bill Wendling5cff4872009-07-28 23:44:43 +0000846 for (SmallVectorImpl<ActionEntry>::const_iterator
847 I = Actions.begin(), E = Actions.end(); I != E; ++I) {
848 const ActionEntry &Action = *I;
Chris Lattner233f52b2010-03-09 23:52:58 +0000849 Asm->OutStreamer.AddComment("Action Record");
850 Asm->OutStreamer.AddBlankLine();
Bill Wendlinga583c552009-08-20 22:02:24 +0000851
852 // Type Filter
853 //
854 // Used by the runtime to match the type of the thrown exception to the
855 // type of the catch clauses or the types in the exception specification.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000856 Asm->EmitSLEB128(Action.ValueForTypeID, " TypeInfo index");
Bill Wendlinga583c552009-08-20 22:02:24 +0000857
858 // Action Record
859 //
860 // Self-relative signed displacement in bytes of the next action record,
861 // or 0 if there is no next action record.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000862 Asm->EmitSLEB128(Action.NextAction, " Next action");
Bill Wendlingeb907212009-05-15 01:12:28 +0000863 }
864
Bill Wendling48dc29e2009-10-22 20:48:59 +0000865 // Emit the Catch TypeInfos.
Chris Lattner233f52b2010-03-09 23:52:58 +0000866 if (!TypeInfos.empty()) {
867 Asm->OutStreamer.AddComment("-- Catch TypeInfos --");
868 Asm->OutStreamer.AddBlankLine();
869 }
Bill Wendlingec044582009-11-18 23:18:46 +0000870 for (std::vector<GlobalVariable *>::const_reverse_iterator
Bill Wendling01c69372009-11-19 00:09:14 +0000871 I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) {
Bill Wendlingfb7634f2009-11-19 19:21:09 +0000872 const GlobalVariable *GV = *I;
Bill Wendlingec044582009-11-18 23:18:46 +0000873
Chris Lattner90e4af72010-03-10 00:09:21 +0000874 Asm->OutStreamer.AddComment("TypeInfo");
875 if (GV)
Chris Lattnerd2af7852010-04-04 20:20:50 +0000876 Asm->EmitReference(GV, TTypeEncoding);
Chris Lattner90e4af72010-03-10 00:09:21 +0000877 else
Chris Lattnerd2af7852010-04-04 20:20:50 +0000878 Asm->OutStreamer.EmitIntValue(0,Asm->GetSizeOfEncodedValue(TTypeEncoding),
879 0);
Bill Wendlingeb907212009-05-15 01:12:28 +0000880 }
881
Bill Wendling48dc29e2009-10-22 20:48:59 +0000882 // Emit the Exception Specifications.
Chris Lattner233f52b2010-03-09 23:52:58 +0000883 if (!FilterIds.empty()) {
884 Asm->OutStreamer.AddComment("-- Filter IDs --");
885 Asm->OutStreamer.AddBlankLine();
886 }
Bill Wendling5cff4872009-07-28 23:44:43 +0000887 for (std::vector<unsigned>::const_iterator
888 I = FilterIds.begin(), E = FilterIds.end(); I < E; ++I) {
889 unsigned TypeID = *I;
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000890 Asm->EmitULEB128(TypeID, TypeID != 0 ? "Exception specification" : 0);
Bill Wendlingeb907212009-05-15 01:12:28 +0000891 }
892
893 Asm->EmitAlignment(2, 0, 0, false);
894}
895
Bill Wendlingeb907212009-05-15 01:12:28 +0000896/// EndModule - Emit all exception information that should come after the
897/// content.
898void DwarfException::EndModule() {
Chris Lattner84ac8b72010-04-05 00:26:50 +0000899 if (Asm->MAI->getExceptionHandlingType() != ExceptionHandling::Dwarf)
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000900 return;
Bill Wendlingb4049fe2009-09-09 21:06:24 +0000901
Bill Wendling52783c62009-09-09 23:56:55 +0000902 if (!shouldEmitMovesModule && !shouldEmitTableModule)
903 return;
904
Chris Lattnerc3b228c2010-03-29 20:39:38 +0000905 TimeRegion Timer(ExceptionTimer);
Bill Wendlingeb907212009-05-15 01:12:28 +0000906
Bill Wendling52783c62009-09-09 23:56:55 +0000907 const std::vector<Function *> Personalities = MMI->getPersonalities();
Bill Wendlingb4049fe2009-09-09 21:06:24 +0000908
Bill Wendling28275fd2009-09-10 06:50:01 +0000909 for (unsigned I = 0, E = Personalities.size(); I < E; ++I)
910 EmitCIE(Personalities[I], I);
Bill Wendlingeb907212009-05-15 01:12:28 +0000911
Bill Wendling52783c62009-09-09 23:56:55 +0000912 for (std::vector<FunctionEHFrameInfo>::iterator
913 I = EHFrames.begin(), E = EHFrames.end(); I != E; ++I)
914 EmitFDE(*I);
Bill Wendlingeb907212009-05-15 01:12:28 +0000915}
916
Bill Wendling28275fd2009-09-10 06:50:01 +0000917/// BeginFunction - Gather pre-function exception information. Assumes it's
918/// being emitted immediately after the function entry point.
Chris Lattnereec791a2010-01-26 23:18:02 +0000919void DwarfException::BeginFunction(const MachineFunction *MF) {
Chris Lattner84ac8b72010-04-05 00:26:50 +0000920 if (!MMI || !Asm->MAI->doesSupportExceptionHandling()) return;
Bill Wendling73c5a612009-09-10 18:28:06 +0000921
Chris Lattnerc3b228c2010-03-29 20:39:38 +0000922 TimeRegion Timer(ExceptionTimer);
Bill Wendlingeb907212009-05-15 01:12:28 +0000923 shouldEmitTable = shouldEmitMoves = false;
924
Bill Wendling73c5a612009-09-10 18:28:06 +0000925 // If any landing pads survive, we need an EH table.
Chris Lattner16112732010-03-14 01:41:15 +0000926 shouldEmitTable = !MMI->getLandingPads().empty();
Bill Wendlingeb907212009-05-15 01:12:28 +0000927
Bill Wendling73c5a612009-09-10 18:28:06 +0000928 // See if we need frame move info.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000929 shouldEmitMoves =
930 !Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory;
Bill Wendlingeb907212009-05-15 01:12:28 +0000931
Bill Wendling73c5a612009-09-10 18:28:06 +0000932 if (shouldEmitMoves || shouldEmitTable)
933 // Assumes in correct section after the entry point.
Chris Lattnerc0215722010-04-04 19:25:43 +0000934 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
Chris Lattner84ac8b72010-04-05 00:26:50 +0000935 Asm->getFunctionNumber()));
Bill Wendlingeb907212009-05-15 01:12:28 +0000936
937 shouldEmitTableModule |= shouldEmitTable;
938 shouldEmitMovesModule |= shouldEmitMoves;
Bill Wendlingeb907212009-05-15 01:12:28 +0000939}
940
941/// EndFunction - Gather and emit post-function exception information.
942///
943void DwarfException::EndFunction() {
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000944 if (!shouldEmitMoves && !shouldEmitTable) return;
945
Chris Lattnerc3b228c2010-03-29 20:39:38 +0000946 TimeRegion Timer(ExceptionTimer);
Chris Lattner84ac8b72010-04-05 00:26:50 +0000947 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
948 Asm->getFunctionNumber()));
Chris Lattner16112732010-03-14 01:41:15 +0000949
950 // Record if this personality index uses a landing pad.
951 bool HasLandingPad = !MMI->getLandingPads().empty();
952 UsesLSDA[MMI->getPersonalityIndex()] |= HasLandingPad;
953
954 // Map all labels and get rid of any dead landing pads.
955 MMI->TidyLandingPads();
956
957 if (HasLandingPad)
958 EmitExceptionTable();
Bill Wendlingeb907212009-05-15 01:12:28 +0000959
Chris Lattner09d53fe2010-03-10 07:20:42 +0000960 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
Chris Lattner3a9be0e2010-01-23 05:51:36 +0000961 MCSymbol *FunctionEHSym =
Chris Lattner84ac8b72010-04-05 00:26:50 +0000962 Asm->GetSymbolWithGlobalValueBase(Asm->MF->getFunction(), ".eh",
Chris Lattner09d53fe2010-03-10 07:20:42 +0000963 TLOF.isFunctionEHFrameSymbolPrivate());
Chris Lattner25d812b2009-09-16 00:35:39 +0000964
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000965 // Save EH frame information
Chris Lattner84ac8b72010-04-05 00:26:50 +0000966 EHFrames.push_back(FunctionEHFrameInfo(FunctionEHSym,
967 Asm->getFunctionNumber(),
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000968 MMI->getPersonalityIndex(),
Chris Lattner84ac8b72010-04-05 00:26:50 +0000969 Asm->MF->getFrameInfo()->hasCalls(),
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000970 !MMI->getLandingPads().empty(),
971 MMI->getFrameMoves(),
Chris Lattner84ac8b72010-04-05 00:26:50 +0000972 Asm->MF->getFunction()));
Bill Wendlingeb907212009-05-15 01:12:28 +0000973}