blob: 72c97a43085cef5174a1ac711f467f67cb22e1fc [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"
Chris Lattner6c2f9e12009-08-19 05:49:37 +000036#include "llvm/Support/Timer.h"
Jim Grosbachc40d9f92009-09-01 18:49:12 +000037#include "llvm/ADT/SmallString.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000038#include "llvm/ADT/StringExtras.h"
Bill Wendling1f8075d2010-02-09 22:49:16 +000039#include "llvm/ADT/Twine.h"
Bill Wendlingeb907212009-05-15 01:12:28 +000040using namespace llvm;
41
Chris Lattner75f50722010-04-04 07:48:20 +000042DwarfException::DwarfException(AsmPrinter *A)
Chris Lattner84ac8b72010-04-05 00:26:50 +000043 : Asm(A), MMI(Asm->MMI), shouldEmitTable(false), shouldEmitMoves(false),
Bill Wendlingbc0d23a2009-05-15 01:18:50 +000044 shouldEmitTableModule(false), shouldEmitMovesModule(false),
45 ExceptionTimer(0) {
Eric Christopherdbfcdb92009-08-28 22:33:43 +000046 if (TimePassesIsEnabled)
Chris Lattner0b86a6f2009-12-28 07:41:18 +000047 ExceptionTimer = new Timer("DWARF Exception Writer");
Bill Wendlingbc0d23a2009-05-15 01:18:50 +000048}
49
50DwarfException::~DwarfException() {
51 delete ExceptionTimer;
52}
53
Bill Wendling7ccda0f2009-08-25 08:08:33 +000054/// EmitCIE - Emit a Common Information Entry (CIE). This holds information that
55/// is shared among many Frame Description Entries. There is at least one CIE
56/// in every non-empty .debug_frame section.
Chris Lattner8c6ed052009-09-16 01:46:41 +000057void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
Bill Wendlingeb907212009-05-15 01:12:28 +000058 // Size and sign of stack growth.
Chris Lattner84ac8b72010-04-05 00:26:50 +000059 int stackGrowth = Asm->getTargetData().getPointerSize();
60 if (Asm->TM.getFrameInfo()->getStackGrowthDirection() ==
61 TargetFrameInfo::StackGrowsDown)
62 stackGrowth *= -1;
Bill Wendlingeb907212009-05-15 01:12:28 +000063
Chris Lattner8c6ed052009-09-16 01:46:41 +000064 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
Anton Korobeynikov9184b252010-02-15 22:35:59 +000065
Bill Wendlingeb907212009-05-15 01:12:28 +000066 // Begin eh frame section.
Chris Lattner8c6ed052009-09-16 01:46:41 +000067 Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection());
Bill Wendlingeb907212009-05-15 01:12:28 +000068
Chris Lattner974c0fb2010-03-10 02:48:06 +000069 MCSymbol *EHFrameSym;
Chris Lattner09d53fe2010-03-10 07:20:42 +000070 if (TLOF.isFunctionEHFrameSymbolPrivate())
Chris Lattnerc0215722010-04-04 19:25:43 +000071 EHFrameSym = Asm->GetTempSymbol("EH_frame", Index);
Chris Lattner974c0fb2010-03-10 02:48:06 +000072 else
73 EHFrameSym = Asm->OutContext.GetOrCreateSymbol(Twine("EH_frame") +
74 Twine(Index));
75 Asm->OutStreamer.EmitLabel(EHFrameSym);
Chris Lattner8c6ed052009-09-16 01:46:41 +000076
Chris Lattnerc0215722010-04-04 19:25:43 +000077 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("section_eh_frame", Index));
Bill Wendlingeb907212009-05-15 01:12:28 +000078
79 // Define base labels.
Chris Lattnerc0215722010-04-04 19:25:43 +000080 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common", Index));
Bill Wendlingeb907212009-05-15 01:12:28 +000081
82 // Define the eh frame length.
Chris Lattner233f52b2010-03-09 23:52:58 +000083 Asm->OutStreamer.AddComment("Length of Common Information Entry");
Chris Lattnera6437182010-04-04 19:58:12 +000084 Asm->EmitLabelDifference(Asm->GetTempSymbol("eh_frame_common_end", Index),
85 Asm->GetTempSymbol("eh_frame_common_begin", Index),
86 4);
Bill Wendlingeb907212009-05-15 01:12:28 +000087
88 // EH frame header.
Chris Lattnerc0215722010-04-04 19:25:43 +000089 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_begin",Index));
Chris Lattner233f52b2010-03-09 23:52:58 +000090 Asm->OutStreamer.AddComment("CIE Identifier Tag");
Chris Lattnerbcb83e52010-01-20 07:41:15 +000091 Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
Chris Lattner233f52b2010-03-09 23:52:58 +000092 Asm->OutStreamer.AddComment("DW_CIE_VERSION");
Chris Lattner066c9ac2010-01-22 22:23:57 +000093 Asm->OutStreamer.EmitIntValue(dwarf::DW_CIE_VERSION, 1/*size*/, 0/*addr*/);
Bill Wendlingeb907212009-05-15 01:12:28 +000094
95 // The personality presence indicates that language specific information will
Chris Lattner8c6ed052009-09-16 01:46:41 +000096 // show up in the eh frame. Find out how we are supposed to lower the
97 // personality function reference:
Anton Korobeynikov9184b252010-02-15 22:35:59 +000098
99 unsigned LSDAEncoding = TLOF.getLSDAEncoding();
100 unsigned FDEEncoding = TLOF.getFDEEncoding();
101 unsigned PerEncoding = TLOF.getPersonalityEncoding();
Bill Wendling52783c62009-09-09 23:56:55 +0000102
Chris Lattner4cf202b2010-01-23 03:11:46 +0000103 char Augmentation[6] = { 0 };
Bill Wendling52783c62009-09-09 23:56:55 +0000104 unsigned AugmentationSize = 0;
105 char *APtr = Augmentation + 1;
106
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000107 if (PersonalityFn) {
Bill Wendling52783c62009-09-09 23:56:55 +0000108 // There is a personality function.
109 *APtr++ = 'P';
Chris Lattnerd2af7852010-04-04 20:20:50 +0000110 AugmentationSize += 1 + Asm->GetSizeOfEncodedValue(PerEncoding);
Bill Wendling52783c62009-09-09 23:56:55 +0000111 }
112
113 if (UsesLSDA[Index]) {
114 // An LSDA pointer is in the FDE augmentation.
115 *APtr++ = 'L';
116 ++AugmentationSize;
117 }
118
119 if (FDEEncoding != dwarf::DW_EH_PE_absptr) {
120 // A non-default pointer encoding for the FDE.
121 *APtr++ = 'R';
122 ++AugmentationSize;
123 }
124
125 if (APtr != Augmentation + 1)
126 Augmentation[0] = 'z';
127
Chris Lattner233f52b2010-03-09 23:52:58 +0000128 Asm->OutStreamer.AddComment("CIE Augmentation");
Chris Lattner4cf202b2010-01-23 03:11:46 +0000129 Asm->OutStreamer.EmitBytes(StringRef(Augmentation, strlen(Augmentation)+1),0);
Bill Wendlingeb907212009-05-15 01:12:28 +0000130
131 // Round out reader.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000132 Asm->EmitULEB128(1, "CIE Code Alignment Factor");
133 Asm->EmitSLEB128(stackGrowth, "CIE Data Alignment Factor");
Chris Lattner233f52b2010-03-09 23:52:58 +0000134 Asm->OutStreamer.AddComment("CIE Return Address Column");
Chris Lattner84ac8b72010-04-05 00:26:50 +0000135
136 const TargetRegisterInfo *RI = Asm->TM.getRegisterInfo();
Bill Wendlingeb907212009-05-15 01:12:28 +0000137 Asm->EmitInt8(RI->getDwarfRegNum(RI->getRARegister(), true));
Bill Wendlingeb907212009-05-15 01:12:28 +0000138
Anton Korobeynikovac8a3d02010-02-15 22:36:41 +0000139 if (Augmentation[0]) {
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000140 Asm->EmitULEB128(AugmentationSize, "Augmentation Size");
Bill Wendling52783c62009-09-09 23:56:55 +0000141
Anton Korobeynikovac8a3d02010-02-15 22:36:41 +0000142 // If there is a personality, we need to indicate the function's location.
143 if (PersonalityFn) {
Chris Lattnerca6190b2010-04-04 20:04:21 +0000144 Asm->EmitEncodingByte(PerEncoding, "Personality");
Chris Lattner233f52b2010-03-09 23:52:58 +0000145 Asm->OutStreamer.AddComment("Personality");
Chris Lattnerd2af7852010-04-04 20:20:50 +0000146 Asm->EmitReference(PersonalityFn, PerEncoding);
Anton Korobeynikovac8a3d02010-02-15 22:36:41 +0000147 }
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000148 if (UsesLSDA[Index])
Chris Lattnerca6190b2010-04-04 20:04:21 +0000149 Asm->EmitEncodingByte(LSDAEncoding, "LSDA");
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000150 if (FDEEncoding != dwarf::DW_EH_PE_absptr)
Chris Lattnerca6190b2010-04-04 20:04:21 +0000151 Asm->EmitEncodingByte(FDEEncoding, "FDE");
Bill Wendlingeb907212009-05-15 01:12:28 +0000152 }
153
154 // Indicate locations of general callee saved registers in frame.
155 std::vector<MachineMove> Moves;
156 RI->getInitialFrameState(Moves);
Chris Lattner02b86b92010-04-04 23:41:46 +0000157 Asm->EmitFrameMoves(Moves, 0, true);
Bill Wendlingeb907212009-05-15 01:12:28 +0000158
159 // On Darwin the linker honors the alignment of eh_frame, which means it must
160 // be 8-byte on 64-bit targets to match what gcc does. Otherwise you get
161 // holes which confuse readers of eh_frame.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000162 Asm->EmitAlignment(Asm->getTargetData().getPointerSize() == 4 ? 2 : 3,
163 0, 0, false);
Chris Lattnerc0215722010-04-04 19:25:43 +0000164 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_common_end", Index));
Bill Wendlingeb907212009-05-15 01:12:28 +0000165}
166
Bill Wendling7ccda0f2009-08-25 08:08:33 +0000167/// EmitFDE - Emit the Frame Description Entry (FDE) for the function.
168void DwarfException::EmitFDE(const FunctionEHFrameInfo &EHFrameInfo) {
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000169 assert(!EHFrameInfo.function->hasAvailableExternallyLinkage() &&
Bill Wendlingeb907212009-05-15 01:12:28 +0000170 "Should not emit 'available externally' functions at all");
171
Chris Lattner3e0f60b2009-07-17 21:00:50 +0000172 const Function *TheFunc = EHFrameInfo.function;
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000173 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000174
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000175 unsigned LSDAEncoding = TLOF.getLSDAEncoding();
176 unsigned FDEEncoding = TLOF.getFDEEncoding();
177
178 Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection());
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000179
Bill Wendlingeb907212009-05-15 01:12:28 +0000180 // Externally visible entry into the functions eh frame info. If the
181 // corresponding function is static, this should not be externally visible.
Chris Lattner09d53fe2010-03-10 07:20:42 +0000182 if (!TheFunc->hasLocalLinkage() && TLOF.isFunctionEHSymbolGlobal())
183 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,MCSA_Global);
Bill Wendlingeb907212009-05-15 01:12:28 +0000184
185 // If corresponding function is weak definition, this should be too.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000186 if (TheFunc->isWeakForLinker() && Asm->MAI->getWeakDefDirective())
Chris Lattner974c0fb2010-03-10 02:48:06 +0000187 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
188 MCSA_WeakDefinition);
Bill Wendlingee161a62009-11-11 01:24:59 +0000189
190 // If corresponding function is hidden, this should be too.
191 if (TheFunc->hasHiddenVisibility())
Chris Lattner84ac8b72010-04-05 00:26:50 +0000192 if (MCSymbolAttr HiddenAttr = Asm->MAI->getHiddenVisibilityAttr())
Chris Lattner152a29b2010-01-23 06:53:23 +0000193 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
194 HiddenAttr);
Bill Wendlingeb907212009-05-15 01:12:28 +0000195
196 // If there are no calls then you can't unwind. This may mean we can omit the
197 // EH Frame, but some environments do not handle weak absolute symbols. If
198 // UnwindTablesMandatory is set we cannot do this optimization; the unwind
199 // info is to be available for non-EH uses.
Chris Lattner3e0f60b2009-07-17 21:00:50 +0000200 if (!EHFrameInfo.hasCalls && !UnwindTablesMandatory &&
201 (!TheFunc->isWeakForLinker() ||
Chris Lattner84ac8b72010-04-05 00:26:50 +0000202 !Asm->MAI->getWeakDefDirective() ||
Chris Lattner09d53fe2010-03-10 07:20:42 +0000203 TLOF.getSupportsWeakOmittedEHFrame())) {
Chris Lattner974c0fb2010-03-10 02:48:06 +0000204 Asm->OutStreamer.EmitAssignment(EHFrameInfo.FunctionEHSym,
205 MCConstantExpr::Create(0, Asm->OutContext));
Bill Wendlingeb907212009-05-15 01:12:28 +0000206 // This name has no connection to the function, so it might get
207 // dead-stripped when the function is not, erroneously. Prohibit
208 // dead-stripping unconditionally.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000209 if (Asm->MAI->hasNoDeadStrip())
Chris Lattner3a9be0e2010-01-23 05:51:36 +0000210 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
Chris Lattnera5ad93a2010-01-23 06:39:22 +0000211 MCSA_NoDeadStrip);
Bill Wendlingeb907212009-05-15 01:12:28 +0000212 } else {
Chris Lattner974c0fb2010-03-10 02:48:06 +0000213 Asm->OutStreamer.EmitLabel(EHFrameInfo.FunctionEHSym);
Bill Wendlingeb907212009-05-15 01:12:28 +0000214
215 // EH frame header.
Chris Lattner233f52b2010-03-09 23:52:58 +0000216 Asm->OutStreamer.AddComment("Length of Frame Information Entry");
Chris Lattnera6437182010-04-04 19:58:12 +0000217 Asm->EmitLabelDifference(
218 Asm->GetTempSymbol("eh_frame_end", EHFrameInfo.Number),
219 Asm->GetTempSymbol("eh_frame_begin", EHFrameInfo.Number), 4);
Bill Wendlingeb907212009-05-15 01:12:28 +0000220
Chris Lattnerc0215722010-04-04 19:25:43 +0000221 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_begin",
222 EHFrameInfo.Number));
Bill Wendlingeb907212009-05-15 01:12:28 +0000223
Chris Lattner233f52b2010-03-09 23:52:58 +0000224 Asm->OutStreamer.AddComment("FDE CIE offset");
Chris Lattnerf88dce12010-04-04 21:31:54 +0000225 Asm->EmitLabelDifference(
226 Asm->GetTempSymbol("eh_frame_begin", EHFrameInfo.Number),
227 Asm->GetTempSymbol("eh_frame_common",
228 EHFrameInfo.PersonalityIndex), 4);
Bill Wendlingeb907212009-05-15 01:12:28 +0000229
Chris Lattnerc0215722010-04-04 19:25:43 +0000230 MCSymbol *EHFuncBeginSym =
231 Asm->GetTempSymbol("eh_func_begin", EHFrameInfo.Number);
Bill Wendlingeb907212009-05-15 01:12:28 +0000232
Chris Lattner233f52b2010-03-09 23:52:58 +0000233 Asm->OutStreamer.AddComment("FDE initial location");
Chris Lattnerd2af7852010-04-04 20:20:50 +0000234 Asm->EmitReference(EHFuncBeginSym, FDEEncoding);
Chris Lattnerfb658072010-03-13 07:40:56 +0000235
Chris Lattner233f52b2010-03-09 23:52:58 +0000236 Asm->OutStreamer.AddComment("FDE address range");
Chris Lattnera6437182010-04-04 19:58:12 +0000237 Asm->EmitLabelDifference(Asm->GetTempSymbol("eh_func_end",
238 EHFrameInfo.Number),
Chris Lattnerd2af7852010-04-04 20:20:50 +0000239 EHFuncBeginSym,
240 Asm->GetSizeOfEncodedValue(FDEEncoding));
Bill Wendlingeb907212009-05-15 01:12:28 +0000241
242 // If there is a personality and landing pads then point to the language
243 // specific data area in the exception table.
Eric Christopherd44fff72009-08-26 21:30:49 +0000244 if (MMI->getPersonalities()[0] != NULL) {
Chris Lattnerd2af7852010-04-04 20:20:50 +0000245 unsigned Size = Asm->GetSizeOfEncodedValue(LSDAEncoding);
Duncan Sandsc69d74a2009-08-31 16:45:16 +0000246
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000247 Asm->EmitULEB128(Size, "Augmentation size");
Chris Lattner233f52b2010-03-09 23:52:58 +0000248 Asm->OutStreamer.AddComment("Language Specific Data Area");
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000249 if (EHFrameInfo.hasLandingPads)
Chris Lattnerd2af7852010-04-04 20:20:50 +0000250 Asm->EmitReference(Asm->GetTempSymbol("exception", EHFrameInfo.Number),
251 LSDAEncoding);
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000252 else
253 Asm->OutStreamer.EmitIntValue(0, Size/*size*/, 0/*addrspace*/);
Bill Wendlingd58e9cb2010-01-16 01:40:55 +0000254
Bill Wendlingeb907212009-05-15 01:12:28 +0000255 } else {
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000256 Asm->EmitULEB128(0, "Augmentation size");
Bill Wendlingeb907212009-05-15 01:12:28 +0000257 }
258
259 // Indicate locations of function specific callee saved registers in frame.
Chris Lattner02b86b92010-04-04 23:41:46 +0000260 Asm->EmitFrameMoves(EHFrameInfo.Moves, EHFuncBeginSym, true);
Bill Wendlingeb907212009-05-15 01:12:28 +0000261
262 // On Darwin the linker honors the alignment of eh_frame, which means it
263 // must be 8-byte on 64-bit targets to match what gcc does. Otherwise you
264 // get holes which confuse readers of eh_frame.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000265 Asm->EmitAlignment(Asm->getTargetData().getPointerSize() == 4 ? 2 : 3,
Bill Wendlingeb907212009-05-15 01:12:28 +0000266 0, 0, false);
Chris Lattnerc0215722010-04-04 19:25:43 +0000267 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_frame_end",
268 EHFrameInfo.Number));
Bill Wendlingeb907212009-05-15 01:12:28 +0000269
270 // If the function is marked used, this table should be also. We cannot
271 // make the mark unconditional in this case, since retaining the table also
272 // retains the function in this case, and there is code around that depends
273 // on unused functions (calling undefined externals) being dead-stripped to
274 // link correctly. Yes, there really is.
Chris Lattner401e10c2009-07-20 06:14:25 +0000275 if (MMI->isUsedFunction(EHFrameInfo.function))
Chris Lattner84ac8b72010-04-05 00:26:50 +0000276 if (Asm->MAI->hasNoDeadStrip())
Chris Lattner3a9be0e2010-01-23 05:51:36 +0000277 Asm->OutStreamer.EmitSymbolAttribute(EHFrameInfo.FunctionEHSym,
Chris Lattnera5ad93a2010-01-23 06:39:22 +0000278 MCSA_NoDeadStrip);
Bill Wendlingeb907212009-05-15 01:12:28 +0000279 }
Chris Lattner188a87d2010-03-10 01:04:13 +0000280 Asm->OutStreamer.AddBlankLine();
Bill Wendlingeb907212009-05-15 01:12:28 +0000281}
282
Bill Wendlingeb907212009-05-15 01:12:28 +0000283/// SharedTypeIds - How many leading type ids two landing pads have in common.
284unsigned DwarfException::SharedTypeIds(const LandingPadInfo *L,
285 const LandingPadInfo *R) {
286 const std::vector<int> &LIds = L->TypeIds, &RIds = R->TypeIds;
287 unsigned LSize = LIds.size(), RSize = RIds.size();
288 unsigned MinSize = LSize < RSize ? LSize : RSize;
289 unsigned Count = 0;
290
291 for (; Count != MinSize; ++Count)
292 if (LIds[Count] != RIds[Count])
293 return Count;
294
295 return Count;
296}
297
298/// PadLT - Order landing pads lexicographically by type id.
299bool DwarfException::PadLT(const LandingPadInfo *L, const LandingPadInfo *R) {
300 const std::vector<int> &LIds = L->TypeIds, &RIds = R->TypeIds;
301 unsigned LSize = LIds.size(), RSize = RIds.size();
302 unsigned MinSize = LSize < RSize ? LSize : RSize;
303
304 for (unsigned i = 0; i != MinSize; ++i)
305 if (LIds[i] != RIds[i])
306 return LIds[i] < RIds[i];
307
308 return LSize < RSize;
309}
310
Bill Wendlingd4609622009-07-28 23:23:00 +0000311/// ComputeActionsTable - Compute the actions table and gather the first action
312/// index for each landing pad site.
Bill Wendlingade025c2009-07-29 00:31:35 +0000313unsigned DwarfException::
314ComputeActionsTable(const SmallVectorImpl<const LandingPadInfo*> &LandingPads,
315 SmallVectorImpl<ActionEntry> &Actions,
316 SmallVectorImpl<unsigned> &FirstActions) {
Bill Wendlinga583c552009-08-20 22:02:24 +0000317
318 // The action table follows the call-site table in the LSDA. The individual
319 // records are of two types:
320 //
321 // * Catch clause
322 // * Exception specification
323 //
324 // The two record kinds have the same format, with only small differences.
325 // They are distinguished by the "switch value" field: Catch clauses
326 // (TypeInfos) have strictly positive switch values, and exception
327 // specifications (FilterIds) have strictly negative switch values. Value 0
328 // indicates a catch-all clause.
329 //
Bill Wendling5e953dd2009-07-28 23:22:13 +0000330 // Negative type IDs index into FilterIds. Positive type IDs index into
331 // TypeInfos. The value written for a positive type ID is just the type ID
332 // itself. For a negative type ID, however, the value written is the
Bill Wendlingeb907212009-05-15 01:12:28 +0000333 // (negative) byte offset of the corresponding FilterIds entry. The byte
Bill Wendling5e953dd2009-07-28 23:22:13 +0000334 // offset is usually equal to the type ID (because the FilterIds entries are
335 // written using a variable width encoding, which outputs one byte per entry
336 // as long as the value written is not too large) but can differ. This kind
337 // of complication does not occur for positive type IDs because type infos are
Bill Wendlingeb907212009-05-15 01:12:28 +0000338 // output using a fixed width encoding. FilterOffsets[i] holds the byte
339 // offset corresponding to FilterIds[i].
Bill Wendling409914b2009-07-29 21:19:44 +0000340
341 const std::vector<unsigned> &FilterIds = MMI->getFilterIds();
Bill Wendlingeb907212009-05-15 01:12:28 +0000342 SmallVector<int, 16> FilterOffsets;
343 FilterOffsets.reserve(FilterIds.size());
344 int Offset = -1;
Bill Wendling409914b2009-07-29 21:19:44 +0000345
346 for (std::vector<unsigned>::const_iterator
347 I = FilterIds.begin(), E = FilterIds.end(); I != E; ++I) {
Bill Wendlingeb907212009-05-15 01:12:28 +0000348 FilterOffsets.push_back(Offset);
Chris Lattneraf76e592009-08-22 20:48:53 +0000349 Offset -= MCAsmInfo::getULEB128Size(*I);
Bill Wendlingeb907212009-05-15 01:12:28 +0000350 }
351
Bill Wendlingeb907212009-05-15 01:12:28 +0000352 FirstActions.reserve(LandingPads.size());
353
354 int FirstAction = 0;
355 unsigned SizeActions = 0;
Bill Wendling5e953dd2009-07-28 23:22:13 +0000356 const LandingPadInfo *PrevLPI = 0;
Bill Wendling409914b2009-07-29 21:19:44 +0000357
Bill Wendling5cff4872009-07-28 23:44:43 +0000358 for (SmallVectorImpl<const LandingPadInfo *>::const_iterator
Bill Wendling5e953dd2009-07-28 23:22:13 +0000359 I = LandingPads.begin(), E = LandingPads.end(); I != E; ++I) {
360 const LandingPadInfo *LPI = *I;
361 const std::vector<int> &TypeIds = LPI->TypeIds;
Chris Lattner9be49132010-04-04 20:10:41 +0000362 unsigned NumShared = PrevLPI ? SharedTypeIds(LPI, PrevLPI) : 0;
Bill Wendlingeb907212009-05-15 01:12:28 +0000363 unsigned SizeSiteActions = 0;
364
365 if (NumShared < TypeIds.size()) {
366 unsigned SizeAction = 0;
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000367 unsigned PrevAction = (unsigned)-1;
Bill Wendlingeb907212009-05-15 01:12:28 +0000368
369 if (NumShared) {
Chris Lattner9be49132010-04-04 20:10:41 +0000370 unsigned SizePrevIds = PrevLPI->TypeIds.size();
Bill Wendlingeb907212009-05-15 01:12:28 +0000371 assert(Actions.size());
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000372 PrevAction = Actions.size() - 1;
373 SizeAction =
374 MCAsmInfo::getSLEB128Size(Actions[PrevAction].NextAction) +
375 MCAsmInfo::getSLEB128Size(Actions[PrevAction].ValueForTypeID);
Bill Wendlingeb907212009-05-15 01:12:28 +0000376
377 for (unsigned j = NumShared; j != SizePrevIds; ++j) {
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000378 assert(PrevAction != (unsigned)-1 && "PrevAction is invalid!");
Bill Wendlingeb907212009-05-15 01:12:28 +0000379 SizeAction -=
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000380 MCAsmInfo::getSLEB128Size(Actions[PrevAction].ValueForTypeID);
381 SizeAction += -Actions[PrevAction].NextAction;
382 PrevAction = Actions[PrevAction].Previous;
Bill Wendlingeb907212009-05-15 01:12:28 +0000383 }
384 }
385
386 // Compute the actions.
Bill Wendling5e953dd2009-07-28 23:22:13 +0000387 for (unsigned J = NumShared, M = TypeIds.size(); J != M; ++J) {
388 int TypeID = TypeIds[J];
389 assert(-1 - TypeID < (int)FilterOffsets.size() && "Unknown filter id!");
Bill Wendlingeb907212009-05-15 01:12:28 +0000390 int ValueForTypeID = TypeID < 0 ? FilterOffsets[-1 - TypeID] : TypeID;
Chris Lattneraf76e592009-08-22 20:48:53 +0000391 unsigned SizeTypeID = MCAsmInfo::getSLEB128Size(ValueForTypeID);
Bill Wendlingeb907212009-05-15 01:12:28 +0000392
393 int NextAction = SizeAction ? -(SizeAction + SizeTypeID) : 0;
Chris Lattneraf76e592009-08-22 20:48:53 +0000394 SizeAction = SizeTypeID + MCAsmInfo::getSLEB128Size(NextAction);
Bill Wendlingeb907212009-05-15 01:12:28 +0000395 SizeSiteActions += SizeAction;
396
Bill Wendlinga583c552009-08-20 22:02:24 +0000397 ActionEntry Action = { ValueForTypeID, NextAction, PrevAction };
Bill Wendlingeb907212009-05-15 01:12:28 +0000398 Actions.push_back(Action);
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000399 PrevAction = Actions.size() - 1;
Bill Wendlingeb907212009-05-15 01:12:28 +0000400 }
401
402 // Record the first action of the landing pad site.
403 FirstAction = SizeActions + SizeSiteActions - SizeAction + 1;
404 } // else identical - re-use previous FirstAction
405
Bill Wendlinga583c552009-08-20 22:02:24 +0000406 // Information used when created the call-site table. The action record
407 // field of the call site record is the offset of the first associated
408 // action record, relative to the start of the actions table. This value is
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000409 // biased by 1 (1 indicating the start of the actions table), and 0
Bill Wendlinga583c552009-08-20 22:02:24 +0000410 // indicates that there are no actions.
Bill Wendlingeb907212009-05-15 01:12:28 +0000411 FirstActions.push_back(FirstAction);
412
413 // Compute this sites contribution to size.
414 SizeActions += SizeSiteActions;
Bill Wendling5e953dd2009-07-28 23:22:13 +0000415
416 PrevLPI = LPI;
Bill Wendlingeb907212009-05-15 01:12:28 +0000417 }
418
Bill Wendling5e953dd2009-07-28 23:22:13 +0000419 return SizeActions;
420}
421
Bill Wendlinged060dc2009-11-12 21:59:20 +0000422/// CallToNoUnwindFunction - Return `true' if this is a call to a function
423/// marked `nounwind'. Return `false' otherwise.
424bool DwarfException::CallToNoUnwindFunction(const MachineInstr *MI) {
425 assert(MI->getDesc().isCall() && "This should be a call instruction!");
426
427 bool MarkedNoUnwind = false;
428 bool SawFunc = false;
429
430 for (unsigned I = 0, E = MI->getNumOperands(); I != E; ++I) {
431 const MachineOperand &MO = MI->getOperand(I);
432
Chris Lattnercfd31882010-03-31 06:09:04 +0000433 if (!MO.isGlobal()) continue;
434
435 Function *F = dyn_cast<Function>(MO.getGlobal());
436 if (F == 0) continue;
Bill Wendlingecc260e2009-11-12 23:13:08 +0000437
Chris Lattnercfd31882010-03-31 06:09:04 +0000438 if (SawFunc) {
439 // Be conservative. If we have more than one function operand for this
440 // call, then we can't make the assumption that it's the callee and
441 // not a parameter to the call.
442 //
443 // FIXME: Determine if there's a way to say that `F' is the callee or
444 // parameter.
445 MarkedNoUnwind = false;
446 break;
Bill Wendlinged060dc2009-11-12 21:59:20 +0000447 }
Chris Lattnercfd31882010-03-31 06:09:04 +0000448
449 MarkedNoUnwind = F->doesNotThrow();
450 SawFunc = true;
Bill Wendlinged060dc2009-11-12 21:59:20 +0000451 }
452
453 return MarkedNoUnwind;
454}
455
Bill Wendlingade025c2009-07-29 00:31:35 +0000456/// ComputeCallSiteTable - Compute the call-site table. The entry for an invoke
Bill Wendlinga583c552009-08-20 22:02:24 +0000457/// has a try-range containing the call, a non-zero landing pad, and an
Bill Wendlingade025c2009-07-29 00:31:35 +0000458/// appropriate action. The entry for an ordinary call has a try-range
459/// containing the call and zero for the landing pad and the action. Calls
460/// marked 'nounwind' have no entry and must not be contained in the try-range
461/// of any entry - they form gaps in the table. Entries must be ordered by
462/// try-range address.
463void DwarfException::
464ComputeCallSiteTable(SmallVectorImpl<CallSiteEntry> &CallSites,
465 const RangeMapType &PadMap,
466 const SmallVectorImpl<const LandingPadInfo *> &LandingPads,
467 const SmallVectorImpl<unsigned> &FirstActions) {
Bill Wendlingeb907212009-05-15 01:12:28 +0000468 // The end label of the previous invoke or nounwind try-range.
Chris Lattner16112732010-03-14 01:41:15 +0000469 MCSymbol *LastLabel = 0;
Bill Wendlingeb907212009-05-15 01:12:28 +0000470
471 // Whether there is a potentially throwing instruction (currently this means
472 // an ordinary call) between the end of the previous try-range and now.
473 bool SawPotentiallyThrowing = false;
474
Bill Wendling5cff4872009-07-28 23:44:43 +0000475 // Whether the last CallSite entry was for an invoke.
Bill Wendlingeb907212009-05-15 01:12:28 +0000476 bool PreviousIsInvoke = false;
477
478 // Visit all instructions in order of address.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000479 for (MachineFunction::const_iterator I = Asm->MF->begin(), E = Asm->MF->end();
Bill Wendlingeb907212009-05-15 01:12:28 +0000480 I != E; ++I) {
481 for (MachineBasicBlock::const_iterator MI = I->begin(), E = I->end();
482 MI != E; ++MI) {
483 if (!MI->isLabel()) {
Bill Wendlinged060dc2009-11-12 21:59:20 +0000484 if (MI->getDesc().isCall())
485 SawPotentiallyThrowing |= !CallToNoUnwindFunction(MI);
Bill Wendlingeb907212009-05-15 01:12:28 +0000486 continue;
487 }
488
Bill Wendlingeb907212009-05-15 01:12:28 +0000489 // End of the previous try-range?
Chris Lattner0397ada2010-03-14 08:17:53 +0000490 MCSymbol *BeginLabel = MI->getOperand(0).getMCSymbol();
Bill Wendlingeb907212009-05-15 01:12:28 +0000491 if (BeginLabel == LastLabel)
492 SawPotentiallyThrowing = false;
493
494 // Beginning of a new try-range?
Jeffrey Yasskin81cf4322009-11-10 01:02:17 +0000495 RangeMapType::const_iterator L = PadMap.find(BeginLabel);
Bill Wendlingeb907212009-05-15 01:12:28 +0000496 if (L == PadMap.end())
497 // Nope, it was just some random label.
498 continue;
499
Bill Wendlinga583c552009-08-20 22:02:24 +0000500 const PadRange &P = L->second;
Bill Wendlingeb907212009-05-15 01:12:28 +0000501 const LandingPadInfo *LandingPad = LandingPads[P.PadIndex];
Bill Wendlingeb907212009-05-15 01:12:28 +0000502 assert(BeginLabel == LandingPad->BeginLabels[P.RangeIndex] &&
503 "Inconsistent landing pad map!");
504
Bill Wendlinga583c552009-08-20 22:02:24 +0000505 // For Dwarf exception handling (SjLj handling doesn't use this). If some
506 // instruction between the previous try-range and this one may throw,
507 // create a call-site entry with no landing pad for the region between the
508 // try-ranges.
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000509 if (SawPotentiallyThrowing &&
Chris Lattner84ac8b72010-04-05 00:26:50 +0000510 Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
Bill Wendlinga583c552009-08-20 22:02:24 +0000511 CallSiteEntry Site = { LastLabel, BeginLabel, 0, 0 };
Bill Wendlingeb907212009-05-15 01:12:28 +0000512 CallSites.push_back(Site);
513 PreviousIsInvoke = false;
514 }
515
516 LastLabel = LandingPad->EndLabels[P.RangeIndex];
517 assert(BeginLabel && LastLabel && "Invalid landing pad!");
518
Chris Lattnercfd31882010-03-31 06:09:04 +0000519 if (!LandingPad->LandingPadLabel) {
520 // Create a gap.
521 PreviousIsInvoke = false;
522 } else {
Bill Wendlingeb907212009-05-15 01:12:28 +0000523 // This try-range is for an invoke.
Bill Wendlinga583c552009-08-20 22:02:24 +0000524 CallSiteEntry Site = {
525 BeginLabel,
526 LastLabel,
527 LandingPad->LandingPadLabel,
528 FirstActions[P.PadIndex]
529 };
Bill Wendlingeb907212009-05-15 01:12:28 +0000530
Jim Grosbach33668c02009-09-01 17:19:13 +0000531 // Try to merge with the previous call-site. SJLJ doesn't do this
532 if (PreviousIsInvoke &&
Chris Lattner84ac8b72010-04-05 00:26:50 +0000533 Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
Bill Wendlingeb907212009-05-15 01:12:28 +0000534 CallSiteEntry &Prev = CallSites.back();
535 if (Site.PadLabel == Prev.PadLabel && Site.Action == Prev.Action) {
536 // Extend the range of the previous entry.
537 Prev.EndLabel = Site.EndLabel;
538 continue;
539 }
540 }
541
542 // Otherwise, create a new call-site.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000543 if (Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf)
Jim Grosbachca752c92010-01-28 01:45:32 +0000544 CallSites.push_back(Site);
545 else {
546 // SjLj EH must maintain the call sites in the order assigned
547 // to them by the SjLjPrepare pass.
548 unsigned SiteNo = MMI->getCallSiteBeginLabel(BeginLabel);
549 if (CallSites.size() < SiteNo)
550 CallSites.resize(SiteNo);
551 CallSites[SiteNo - 1] = Site;
552 }
Bill Wendlingeb907212009-05-15 01:12:28 +0000553 PreviousIsInvoke = true;
Bill Wendlingeb907212009-05-15 01:12:28 +0000554 }
555 }
556 }
557
558 // If some instruction between the previous try-range and the end of the
559 // function may throw, create a call-site entry with no landing pad for the
560 // region following the try-range.
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000561 if (SawPotentiallyThrowing &&
Chris Lattner84ac8b72010-04-05 00:26:50 +0000562 Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
Bill Wendlinga583c552009-08-20 22:02:24 +0000563 CallSiteEntry Site = { LastLabel, 0, 0, 0 };
Bill Wendlingeb907212009-05-15 01:12:28 +0000564 CallSites.push_back(Site);
565 }
Bill Wendlingade025c2009-07-29 00:31:35 +0000566}
567
Bill Wendling0dafca92009-07-29 00:50:05 +0000568/// EmitExceptionTable - Emit landing pads and actions.
569///
570/// The general organization of the table is complex, but the basic concepts are
571/// easy. First there is a header which describes the location and organization
572/// of the three components that follow.
Eric Christopherdbfcdb92009-08-28 22:33:43 +0000573///
Bill Wendling0dafca92009-07-29 00:50:05 +0000574/// 1. The landing pad site information describes the range of code covered by
575/// the try. In our case it's an accumulation of the ranges covered by the
576/// invokes in the try. There is also a reference to the landing pad that
577/// handles the exception once processed. Finally an index into the actions
578/// table.
Bill Wendlinga583c552009-08-20 22:02:24 +0000579/// 2. The action table, in our case, is composed of pairs of type IDs and next
Bill Wendling0dafca92009-07-29 00:50:05 +0000580/// action offset. Starting with the action index from the landing pad
Bill Wendlinga583c552009-08-20 22:02:24 +0000581/// site, each type ID is checked for a match to the current exception. If
Bill Wendling0dafca92009-07-29 00:50:05 +0000582/// it matches then the exception and type id are passed on to the landing
583/// pad. Otherwise the next action is looked up. This chain is terminated
Bill Wendling28275fd2009-09-10 06:50:01 +0000584/// with a next action of zero. If no type id is found then the frame is
Bill Wendling0dafca92009-07-29 00:50:05 +0000585/// unwound and handling continues.
Bill Wendlinga583c552009-08-20 22:02:24 +0000586/// 3. Type ID table contains references to all the C++ typeinfo for all
Bill Wendling28275fd2009-09-10 06:50:01 +0000587/// catches in the function. This tables is reverse indexed base 1.
Bill Wendlingade025c2009-07-29 00:31:35 +0000588void DwarfException::EmitExceptionTable() {
589 const std::vector<GlobalVariable *> &TypeInfos = MMI->getTypeInfos();
590 const std::vector<unsigned> &FilterIds = MMI->getFilterIds();
591 const std::vector<LandingPadInfo> &PadInfos = MMI->getLandingPads();
Bill Wendlingade025c2009-07-29 00:31:35 +0000592
593 // Sort the landing pads in order of their type ids. This is used to fold
594 // duplicate actions.
595 SmallVector<const LandingPadInfo *, 64> LandingPads;
596 LandingPads.reserve(PadInfos.size());
597
598 for (unsigned i = 0, N = PadInfos.size(); i != N; ++i)
599 LandingPads.push_back(&PadInfos[i]);
600
601 std::sort(LandingPads.begin(), LandingPads.end(), PadLT);
602
603 // Compute the actions table and gather the first action index for each
604 // landing pad site.
605 SmallVector<ActionEntry, 32> Actions;
606 SmallVector<unsigned, 64> FirstActions;
Bill Wendling0a9abcb2010-02-10 21:41:57 +0000607 unsigned SizeActions=ComputeActionsTable(LandingPads, Actions, FirstActions);
Bill Wendlingade025c2009-07-29 00:31:35 +0000608
609 // Invokes and nounwind calls have entries in PadMap (due to being bracketed
610 // by try-range labels when lowered). Ordinary calls do not, so appropriate
Bill Wendling28275fd2009-09-10 06:50:01 +0000611 // try-ranges for them need be deduced when using DWARF exception handling.
Bill Wendlingade025c2009-07-29 00:31:35 +0000612 RangeMapType PadMap;
613 for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) {
614 const LandingPadInfo *LandingPad = LandingPads[i];
615 for (unsigned j = 0, E = LandingPad->BeginLabels.size(); j != E; ++j) {
Chris Lattner16112732010-03-14 01:41:15 +0000616 MCSymbol *BeginLabel = LandingPad->BeginLabels[j];
Bill Wendlingade025c2009-07-29 00:31:35 +0000617 assert(!PadMap.count(BeginLabel) && "Duplicate landing pad labels!");
618 PadRange P = { i, j };
619 PadMap[BeginLabel] = P;
620 }
621 }
622
623 // Compute the call-site table.
624 SmallVector<CallSiteEntry, 64> CallSites;
Jim Grosbach8b818d72009-08-17 16:41:22 +0000625 ComputeCallSiteTable(CallSites, PadMap, LandingPads, FirstActions);
Bill Wendlingeb907212009-05-15 01:12:28 +0000626
627 // Final tallies.
628
629 // Call sites.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000630 bool IsSJLJ = Asm->MAI->getExceptionHandlingType() == ExceptionHandling::SjLj;
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000631 bool HaveTTData = IsSJLJ ? (!TypeInfos.empty() || !FilterIds.empty()) : true;
Chris Lattner9be49132010-04-04 20:10:41 +0000632
Bill Wendling3dc9b482010-02-24 23:34:35 +0000633 unsigned CallSiteTableLength;
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000634 if (IsSJLJ)
Bill Wendling3dc9b482010-02-24 23:34:35 +0000635 CallSiteTableLength = 0;
Chris Lattner9be49132010-04-04 20:10:41 +0000636 else {
637 unsigned SiteStartSize = 4; // dwarf::DW_EH_PE_udata4
638 unsigned SiteLengthSize = 4; // dwarf::DW_EH_PE_udata4
639 unsigned LandingPadSize = 4; // dwarf::DW_EH_PE_udata4
640 CallSiteTableLength =
641 CallSites.size() * (SiteStartSize + SiteLengthSize + LandingPadSize);
642 }
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000643
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000644 for (unsigned i = 0, e = CallSites.size(); i < e; ++i) {
Bill Wendling3dc9b482010-02-24 23:34:35 +0000645 CallSiteTableLength += MCAsmInfo::getULEB128Size(CallSites[i].Action);
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000646 if (IsSJLJ)
Bill Wendling3dc9b482010-02-24 23:34:35 +0000647 CallSiteTableLength += MCAsmInfo::getULEB128Size(i);
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000648 }
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000649
Bill Wendlingeb907212009-05-15 01:12:28 +0000650 // Type infos.
Chris Lattnerd5bbb072009-08-02 01:34:32 +0000651 const MCSection *LSDASection = Asm->getObjFileLowering().getLSDASection();
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000652 unsigned TTypeEncoding;
Bill Wendlinga2f64492009-09-10 06:27:16 +0000653 unsigned TypeFormatSize;
Bill Wendlingeb907212009-05-15 01:12:28 +0000654
Bill Wendling43e484f2009-09-10 01:12:47 +0000655 if (!HaveTTData) {
Bill Wendling28275fd2009-09-10 06:50:01 +0000656 // For SjLj exceptions, if there is no TypeInfo, then we just explicitly say
657 // that we're omitting that bit.
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000658 TTypeEncoding = dwarf::DW_EH_PE_omit;
Chris Lattner84ac8b72010-04-05 00:26:50 +0000659 // dwarf::DW_EH_PE_absptr
660 TypeFormatSize = Asm->getTargetData().getPointerSize();
Chris Lattner81c9a062009-07-31 22:03:47 +0000661 } else {
Chris Lattnerad88bc42009-08-02 03:59:56 +0000662 // Okay, we have actual filters or typeinfos to emit. As such, we need to
663 // pick a type encoding for them. We're about to emit a list of pointers to
664 // typeinfo objects at the end of the LSDA. However, unless we're in static
665 // mode, this reference will require a relocation by the dynamic linker.
Chris Lattner46b754c2009-07-31 22:18:14 +0000666 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000667 // Because of this, we have a couple of options:
Bill Wendling28275fd2009-09-10 06:50:01 +0000668 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000669 // 1) If we are in -static mode, we can always use an absolute reference
670 // from the LSDA, because the static linker will resolve it.
Bill Wendling28275fd2009-09-10 06:50:01 +0000671 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000672 // 2) Otherwise, if the LSDA section is writable, we can output the direct
673 // reference to the typeinfo and allow the dynamic linker to relocate
674 // it. Since it is in a writable section, the dynamic linker won't
675 // have a problem.
Bill Wendling28275fd2009-09-10 06:50:01 +0000676 //
Chris Lattnerad88bc42009-08-02 03:59:56 +0000677 // 3) Finally, if we're in PIC mode and the LDSA section isn't writable,
678 // we need to use some form of indirection. For example, on Darwin,
679 // we can output a statically-relocatable reference to a dyld stub. The
680 // offset to the stub is constant, but the contents are in a section
681 // that is updated by the dynamic linker. This is easy enough, but we
682 // need to tell the personality function of the unwinder to indirect
683 // through the dyld stub.
684 //
Bill Wendling43e484f2009-09-10 01:12:47 +0000685 // FIXME: When (3) is actually implemented, we'll have to emit the stubs
Chris Lattnerad88bc42009-08-02 03:59:56 +0000686 // somewhere. This predicate should be moved to a shared location that is
687 // in target-independent code.
688 //
Anton Korobeynikov9184b252010-02-15 22:35:59 +0000689 TTypeEncoding = Asm->getObjFileLowering().getTTypeEncoding();
Chris Lattnerd2af7852010-04-04 20:20:50 +0000690 TypeFormatSize = Asm->GetSizeOfEncodedValue(TTypeEncoding);
Bill Wendlingfe220282009-09-10 02:07:37 +0000691 }
Bill Wendling43e484f2009-09-10 01:12:47 +0000692
Bill Wendlingfe220282009-09-10 02:07:37 +0000693 // Begin the exception table.
694 Asm->OutStreamer.SwitchSection(LSDASection);
695 Asm->EmitAlignment(2, 0, 0, false);
Bill Wendling43e484f2009-09-10 01:12:47 +0000696
Bill Wendling3dc9b482010-02-24 23:34:35 +0000697 // Emit the LSDA.
Chris Lattner974c0fb2010-03-10 02:48:06 +0000698 MCSymbol *GCCETSym =
699 Asm->OutContext.GetOrCreateSymbol(Twine("GCC_except_table")+
Chris Lattner84ac8b72010-04-05 00:26:50 +0000700 Twine(Asm->getFunctionNumber()));
Chris Lattner974c0fb2010-03-10 02:48:06 +0000701 Asm->OutStreamer.EmitLabel(GCCETSym);
Chris Lattner84ac8b72010-04-05 00:26:50 +0000702 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("exception",
703 Asm->getFunctionNumber()));
Bill Wendlingfe220282009-09-10 02:07:37 +0000704
Chris Lattner974c0fb2010-03-10 02:48:06 +0000705 if (IsSJLJ)
Chris Lattnerc0215722010-04-04 19:25:43 +0000706 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("_LSDA_",
707 Asm->getFunctionNumber()));
Bill Wendlingfe220282009-09-10 02:07:37 +0000708
Bill Wendling3dc9b482010-02-24 23:34:35 +0000709 // Emit the LSDA header.
Chris Lattnerca6190b2010-04-04 20:04:21 +0000710 Asm->EmitEncodingByte(dwarf::DW_EH_PE_omit, "@LPStart");
711 Asm->EmitEncodingByte(TTypeEncoding, "@TType");
Bill Wendlingfe220282009-09-10 02:07:37 +0000712
Bill Wendling3dc9b482010-02-24 23:34:35 +0000713 // The type infos need to be aligned. GCC does this by inserting padding just
714 // before the type infos. However, this changes the size of the exception
715 // table, so you need to take this into account when you output the exception
716 // table size. However, the size is output using a variable length encoding.
717 // So by increasing the size by inserting padding, you may increase the number
718 // of bytes used for writing the size. If it increases, say by one byte, then
719 // you now need to output one less byte of padding to get the type infos
720 // aligned. However this decreases the size of the exception table. This
721 // changes the value you have to output for the exception table size. Due to
722 // the variable length encoding, the number of bytes used for writing the
723 // length may decrease. If so, you then have to increase the amount of
724 // padding. And so on. If you look carefully at the GCC code you will see that
725 // it indeed does this in a loop, going on and on until the values stabilize.
726 // We chose another solution: don't output padding inside the table like GCC
727 // does, instead output it before the table.
728 unsigned SizeTypes = TypeInfos.size() * TypeFormatSize;
729 unsigned CallSiteTableLengthSize =
730 MCAsmInfo::getULEB128Size(CallSiteTableLength);
731 unsigned TTypeBaseOffset =
732 sizeof(int8_t) + // Call site format
733 CallSiteTableLengthSize + // Call site table length size
734 CallSiteTableLength + // Call site table length
735 SizeActions + // Actions size
736 SizeTypes;
737 unsigned TTypeBaseOffsetSize = MCAsmInfo::getULEB128Size(TTypeBaseOffset);
738 unsigned TotalSize =
739 sizeof(int8_t) + // LPStart format
740 sizeof(int8_t) + // TType format
741 (HaveTTData ? TTypeBaseOffsetSize : 0) + // TType base offset size
742 TTypeBaseOffset; // TType base offset
743 unsigned SizeAlign = (4 - TotalSize) & 3;
744
Bill Wendling86f0d332010-02-25 23:52:44 +0000745 if (HaveTTData) {
Bill Wendling6507eca2010-02-26 21:31:01 +0000746 // Account for any extra padding that will be added to the call site table
Bill Wendlingf7e90ae2010-02-25 21:19:47 +0000747 // length.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000748 Asm->EmitULEB128(TTypeBaseOffset, "@TType base offset", SizeAlign);
Bill Wendling1869ac82010-02-26 22:17:52 +0000749 SizeAlign = 0;
Bill Wendling86f0d332010-02-25 23:52:44 +0000750 }
Bill Wendlingb0d9c3e2009-07-28 22:23:45 +0000751
Bill Wendling28275fd2009-09-10 06:50:01 +0000752 // SjLj Exception handling
Bill Wendlingd1a5b372009-09-10 00:17:04 +0000753 if (IsSJLJ) {
Chris Lattnerca6190b2010-04-04 20:04:21 +0000754 Asm->EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
Bill Wendling1869ac82010-02-26 22:17:52 +0000755
756 // Add extra padding if it wasn't added to the TType base offset.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000757 Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
Bill Wendlingeb907212009-05-15 01:12:28 +0000758
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000759 // Emit the landing pad site information.
Jim Grosbach8b818d72009-08-17 16:41:22 +0000760 unsigned idx = 0;
761 for (SmallVectorImpl<CallSiteEntry>::const_iterator
762 I = CallSites.begin(), E = CallSites.end(); I != E; ++I, ++idx) {
763 const CallSiteEntry &S = *I;
Bill Wendlinga583c552009-08-20 22:02:24 +0000764
765 // Offset of the landing pad, counted in 16-byte bundles relative to the
766 // @LPStart address.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000767 Asm->EmitULEB128(idx, "Landing pad");
Bill Wendlinga583c552009-08-20 22:02:24 +0000768
769 // Offset of the first associated action record, relative to the start of
770 // the action table. This value is biased by 1 (1 indicates the start of
771 // the action table), and 0 indicates that there are no actions.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000772 Asm->EmitULEB128(S.Action, "Action");
Bill Wendlingeb907212009-05-15 01:12:28 +0000773 }
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000774 } else {
775 // DWARF Exception handling
Chris Lattner84ac8b72010-04-05 00:26:50 +0000776 assert(Asm->MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf);
Bill Wendlingeb907212009-05-15 01:12:28 +0000777
Bill Wendlinga583c552009-08-20 22:02:24 +0000778 // The call-site table is a list of all call sites that may throw an
779 // exception (including C++ 'throw' statements) in the procedure
780 // fragment. It immediately follows the LSDA header. Each entry indicates,
781 // for a given call, the first corresponding action record and corresponding
782 // landing pad.
783 //
784 // The table begins with the number of bytes, stored as an LEB128
785 // compressed, unsigned integer. The records immediately follow the record
786 // count. They are sorted in increasing call-site address. Each record
787 // indicates:
788 //
789 // * The position of the call-site.
790 // * The position of the landing pad.
791 // * The first action record for that call site.
792 //
793 // A missing entry in the call-site table indicates that a call is not
Bill Wendling28275fd2009-09-10 06:50:01 +0000794 // supposed to throw.
Bill Wendlinga583c552009-08-20 22:02:24 +0000795
796 // Emit the landing pad call site table.
Chris Lattnerca6190b2010-04-04 20:04:21 +0000797 Asm->EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
Bill Wendling1869ac82010-02-26 22:17:52 +0000798
799 // Add extra padding if it wasn't added to the TType base offset.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000800 Asm->EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
Bill Wendlingeb907212009-05-15 01:12:28 +0000801
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000802 for (SmallVectorImpl<CallSiteEntry>::const_iterator
803 I = CallSites.begin(), E = CallSites.end(); I != E; ++I) {
804 const CallSiteEntry &S = *I;
Chris Lattner16112732010-03-14 01:41:15 +0000805
Chris Lattnerc0215722010-04-04 19:25:43 +0000806 MCSymbol *EHFuncBeginSym =
Chris Lattner84ac8b72010-04-05 00:26:50 +0000807 Asm->GetTempSymbol("eh_func_begin", Asm->getFunctionNumber());
Chris Lattner16112732010-03-14 01:41:15 +0000808
809 MCSymbol *BeginLabel = S.BeginLabel;
810 if (BeginLabel == 0)
811 BeginLabel = EHFuncBeginSym;
812 MCSymbol *EndLabel = S.EndLabel;
813 if (EndLabel == 0)
Chris Lattner84ac8b72010-04-05 00:26:50 +0000814 EndLabel = Asm->GetTempSymbol("eh_func_end", Asm->getFunctionNumber());
Chris Lattner16112732010-03-14 01:41:15 +0000815
Bill Wendlinga583c552009-08-20 22:02:24 +0000816 // Offset of the call site relative to the previous call site, counted in
817 // number of 16-byte bundles. The first call site is counted relative to
818 // the start of the procedure fragment.
Chris Lattner233f52b2010-03-09 23:52:58 +0000819 Asm->OutStreamer.AddComment("Region start");
Chris Lattnerf88dce12010-04-04 21:31:54 +0000820 Asm->EmitLabelDifference(BeginLabel, EHFuncBeginSym, 4);
Chris Lattner16112732010-03-14 01:41:15 +0000821
Chris Lattner233f52b2010-03-09 23:52:58 +0000822 Asm->OutStreamer.AddComment("Region length");
Chris Lattnera6437182010-04-04 19:58:12 +0000823 Asm->EmitLabelDifference(EndLabel, BeginLabel, 4);
Bill Wendlingeb907212009-05-15 01:12:28 +0000824
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000825
Bill Wendlinga583c552009-08-20 22:02:24 +0000826 // Offset of the landing pad, counted in 16-byte bundles relative to the
827 // @LPStart address.
Chris Lattner233f52b2010-03-09 23:52:58 +0000828 Asm->OutStreamer.AddComment("Landing pad");
Chris Lattner16112732010-03-14 01:41:15 +0000829 if (!S.PadLabel)
Chris Lattnerbcb83e52010-01-20 07:41:15 +0000830 Asm->OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
Chris Lattner16112732010-03-14 01:41:15 +0000831 else
Chris Lattnerf88dce12010-04-04 21:31:54 +0000832 Asm->EmitLabelDifference(S.PadLabel, EHFuncBeginSym, 4);
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000833
Bill Wendlinga583c552009-08-20 22:02:24 +0000834 // Offset of the first associated action record, relative to the start of
835 // the action table. This value is biased by 1 (1 indicates the start of
836 // the action table), and 0 indicates that there are no actions.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000837 Asm->EmitULEB128(S.Action, "Action");
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000838 }
Bill Wendlingeb907212009-05-15 01:12:28 +0000839 }
840
Bill Wendlinga583c552009-08-20 22:02:24 +0000841 // Emit the Action Table.
Chris Lattner233f52b2010-03-09 23:52:58 +0000842 if (Actions.size() != 0) {
843 Asm->OutStreamer.AddComment("-- Action Record Table --");
844 Asm->OutStreamer.AddBlankLine();
845 }
846
Bill Wendling5cff4872009-07-28 23:44:43 +0000847 for (SmallVectorImpl<ActionEntry>::const_iterator
848 I = Actions.begin(), E = Actions.end(); I != E; ++I) {
849 const ActionEntry &Action = *I;
Chris Lattner233f52b2010-03-09 23:52:58 +0000850 Asm->OutStreamer.AddComment("Action Record");
851 Asm->OutStreamer.AddBlankLine();
Bill Wendlinga583c552009-08-20 22:02:24 +0000852
853 // Type Filter
854 //
855 // Used by the runtime to match the type of the thrown exception to the
856 // type of the catch clauses or the types in the exception specification.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000857 Asm->EmitSLEB128(Action.ValueForTypeID, " TypeInfo index");
Bill Wendlinga583c552009-08-20 22:02:24 +0000858
859 // Action Record
860 //
861 // Self-relative signed displacement in bytes of the next action record,
862 // or 0 if there is no next action record.
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000863 Asm->EmitSLEB128(Action.NextAction, " Next action");
Bill Wendlingeb907212009-05-15 01:12:28 +0000864 }
865
Bill Wendling48dc29e2009-10-22 20:48:59 +0000866 // Emit the Catch TypeInfos.
Chris Lattner233f52b2010-03-09 23:52:58 +0000867 if (!TypeInfos.empty()) {
868 Asm->OutStreamer.AddComment("-- Catch TypeInfos --");
869 Asm->OutStreamer.AddBlankLine();
870 }
Bill Wendlingec044582009-11-18 23:18:46 +0000871 for (std::vector<GlobalVariable *>::const_reverse_iterator
Bill Wendling01c69372009-11-19 00:09:14 +0000872 I = TypeInfos.rbegin(), E = TypeInfos.rend(); I != E; ++I) {
Bill Wendlingfb7634f2009-11-19 19:21:09 +0000873 const GlobalVariable *GV = *I;
Bill Wendlingec044582009-11-18 23:18:46 +0000874
Chris Lattner90e4af72010-03-10 00:09:21 +0000875 Asm->OutStreamer.AddComment("TypeInfo");
876 if (GV)
Chris Lattnerd2af7852010-04-04 20:20:50 +0000877 Asm->EmitReference(GV, TTypeEncoding);
Chris Lattner90e4af72010-03-10 00:09:21 +0000878 else
Chris Lattnerd2af7852010-04-04 20:20:50 +0000879 Asm->OutStreamer.EmitIntValue(0,Asm->GetSizeOfEncodedValue(TTypeEncoding),
880 0);
Bill Wendlingeb907212009-05-15 01:12:28 +0000881 }
882
Bill Wendling48dc29e2009-10-22 20:48:59 +0000883 // Emit the Exception Specifications.
Chris Lattner233f52b2010-03-09 23:52:58 +0000884 if (!FilterIds.empty()) {
885 Asm->OutStreamer.AddComment("-- Filter IDs --");
886 Asm->OutStreamer.AddBlankLine();
887 }
Bill Wendling5cff4872009-07-28 23:44:43 +0000888 for (std::vector<unsigned>::const_iterator
889 I = FilterIds.begin(), E = FilterIds.end(); I < E; ++I) {
890 unsigned TypeID = *I;
Chris Lattner7e1a8f82010-04-04 19:09:29 +0000891 Asm->EmitULEB128(TypeID, TypeID != 0 ? "Exception specification" : 0);
Bill Wendlingeb907212009-05-15 01:12:28 +0000892 }
893
894 Asm->EmitAlignment(2, 0, 0, false);
895}
896
Bill Wendlingeb907212009-05-15 01:12:28 +0000897/// EndModule - Emit all exception information that should come after the
898/// content.
899void DwarfException::EndModule() {
Chris Lattner84ac8b72010-04-05 00:26:50 +0000900 if (Asm->MAI->getExceptionHandlingType() != ExceptionHandling::Dwarf)
Jim Grosbach1b747ad2009-08-11 00:09:57 +0000901 return;
Bill Wendlingb4049fe2009-09-09 21:06:24 +0000902
Bill Wendling52783c62009-09-09 23:56:55 +0000903 if (!shouldEmitMovesModule && !shouldEmitTableModule)
904 return;
905
Chris Lattnerc3b228c2010-03-29 20:39:38 +0000906 TimeRegion Timer(ExceptionTimer);
Bill Wendlingeb907212009-05-15 01:12:28 +0000907
Bill Wendling52783c62009-09-09 23:56:55 +0000908 const std::vector<Function *> Personalities = MMI->getPersonalities();
Bill Wendlingb4049fe2009-09-09 21:06:24 +0000909
Bill Wendling28275fd2009-09-10 06:50:01 +0000910 for (unsigned I = 0, E = Personalities.size(); I < E; ++I)
911 EmitCIE(Personalities[I], I);
Bill Wendlingeb907212009-05-15 01:12:28 +0000912
Bill Wendling52783c62009-09-09 23:56:55 +0000913 for (std::vector<FunctionEHFrameInfo>::iterator
914 I = EHFrames.begin(), E = EHFrames.end(); I != E; ++I)
915 EmitFDE(*I);
Bill Wendlingeb907212009-05-15 01:12:28 +0000916}
917
Bill Wendling28275fd2009-09-10 06:50:01 +0000918/// BeginFunction - Gather pre-function exception information. Assumes it's
919/// being emitted immediately after the function entry point.
Chris Lattnereec791a2010-01-26 23:18:02 +0000920void DwarfException::BeginFunction(const MachineFunction *MF) {
Chris Lattnerc3b228c2010-03-29 20:39:38 +0000921 TimeRegion Timer(ExceptionTimer);
Bill Wendlingeb907212009-05-15 01:12:28 +0000922 shouldEmitTable = shouldEmitMoves = false;
923
Bill Wendling73c5a612009-09-10 18:28:06 +0000924 // If any landing pads survive, we need an EH table.
Chris Lattner16112732010-03-14 01:41:15 +0000925 shouldEmitTable = !MMI->getLandingPads().empty();
Bill Wendlingeb907212009-05-15 01:12:28 +0000926
Bill Wendling73c5a612009-09-10 18:28:06 +0000927 // See if we need frame move info.
Chris Lattner84ac8b72010-04-05 00:26:50 +0000928 shouldEmitMoves =
929 !Asm->MF->getFunction()->doesNotThrow() || UnwindTablesMandatory;
Bill Wendlingeb907212009-05-15 01:12:28 +0000930
Bill Wendling73c5a612009-09-10 18:28:06 +0000931 if (shouldEmitMoves || shouldEmitTable)
932 // Assumes in correct section after the entry point.
Chris Lattnerc0215722010-04-04 19:25:43 +0000933 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_begin",
Chris Lattner84ac8b72010-04-05 00:26:50 +0000934 Asm->getFunctionNumber()));
Bill Wendlingeb907212009-05-15 01:12:28 +0000935
936 shouldEmitTableModule |= shouldEmitTable;
937 shouldEmitMovesModule |= shouldEmitMoves;
Bill Wendlingeb907212009-05-15 01:12:28 +0000938}
939
940/// EndFunction - Gather and emit post-function exception information.
941///
942void DwarfException::EndFunction() {
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000943 if (!shouldEmitMoves && !shouldEmitTable) return;
944
Chris Lattnerc3b228c2010-03-29 20:39:38 +0000945 TimeRegion Timer(ExceptionTimer);
Chris Lattner84ac8b72010-04-05 00:26:50 +0000946 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
947 Asm->getFunctionNumber()));
Chris Lattner16112732010-03-14 01:41:15 +0000948
949 // Record if this personality index uses a landing pad.
950 bool HasLandingPad = !MMI->getLandingPads().empty();
951 UsesLSDA[MMI->getPersonalityIndex()] |= HasLandingPad;
952
953 // Map all labels and get rid of any dead landing pads.
954 MMI->TidyLandingPads();
955
956 if (HasLandingPad)
957 EmitExceptionTable();
Bill Wendlingeb907212009-05-15 01:12:28 +0000958
Chris Lattner09d53fe2010-03-10 07:20:42 +0000959 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
Chris Lattner3a9be0e2010-01-23 05:51:36 +0000960 MCSymbol *FunctionEHSym =
Chris Lattner84ac8b72010-04-05 00:26:50 +0000961 Asm->GetSymbolWithGlobalValueBase(Asm->MF->getFunction(), ".eh",
Chris Lattner09d53fe2010-03-10 07:20:42 +0000962 TLOF.isFunctionEHFrameSymbolPrivate());
Chris Lattner25d812b2009-09-16 00:35:39 +0000963
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000964 // Save EH frame information
Chris Lattner84ac8b72010-04-05 00:26:50 +0000965 EHFrames.push_back(FunctionEHFrameInfo(FunctionEHSym,
966 Asm->getFunctionNumber(),
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000967 MMI->getPersonalityIndex(),
Chris Lattner84ac8b72010-04-05 00:26:50 +0000968 Asm->MF->getFrameInfo()->hasCalls(),
Bill Wendling7b09a6c2009-09-09 21:08:12 +0000969 !MMI->getLandingPads().empty(),
970 MMI->getFrameMoves(),
Chris Lattner84ac8b72010-04-05 00:26:50 +0000971 Asm->MF->getFunction()));
Bill Wendlingeb907212009-05-15 01:12:28 +0000972}