Kevin Enderby | 7cbf73a | 2010-07-28 20:55:35 +0000 | [diff] [blame] | 1 | //===- lib/MC/MCDwarf.cpp - MCDwarf implementation ------------------------===// |
| 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 | |
Rafael Espindola | 767b1be | 2010-12-04 00:31:13 +0000 | [diff] [blame] | 10 | #include "llvm/MC/MCAsmInfo.h" |
Kevin Enderby | 7cbf73a | 2010-07-28 20:55:35 +0000 | [diff] [blame] | 11 | #include "llvm/MC/MCDwarf.h" |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 12 | #include "llvm/MC/MCAssembler.h" |
Rafael Espindola | ad8aaa0 | 2010-11-22 11:53:17 +0000 | [diff] [blame] | 13 | #include "llvm/MC/MCStreamer.h" |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 14 | #include "llvm/MC/MCSymbol.h" |
| 15 | #include "llvm/MC/MCExpr.h" |
| 16 | #include "llvm/MC/MCContext.h" |
| 17 | #include "llvm/MC/MCObjectWriter.h" |
| 18 | #include "llvm/ADT/SmallString.h" |
Kevin Enderby | 7cbf73a | 2010-07-28 20:55:35 +0000 | [diff] [blame] | 19 | #include "llvm/Support/Debug.h" |
| 20 | #include "llvm/Support/raw_ostream.h" |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 21 | #include "llvm/Target/TargetAsmBackend.h" |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 22 | #include "llvm/Target/TargetAsmInfo.h" |
Kevin Enderby | 7cbf73a | 2010-07-28 20:55:35 +0000 | [diff] [blame] | 23 | using namespace llvm; |
| 24 | |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 25 | // Given a special op, return the address skip amount (in units of |
| 26 | // DWARF2_LINE_MIN_INSN_LENGTH. |
| 27 | #define SPECIAL_ADDR(op) (((op) - DWARF2_LINE_OPCODE_BASE)/DWARF2_LINE_RANGE) |
| 28 | |
| 29 | // The maximum address skip amount that can be encoded with a special op. |
| 30 | #define MAX_SPECIAL_ADDR_DELTA SPECIAL_ADDR(255) |
| 31 | |
| 32 | // First special line opcode - leave room for the standard opcodes. |
| 33 | // Note: If you want to change this, you'll have to update the |
| 34 | // "standard_opcode_lengths" table that is emitted in DwarfFileTable::Emit(). |
| 35 | #define DWARF2_LINE_OPCODE_BASE 13 |
| 36 | |
| 37 | // Minimum line offset in a special line info. opcode. This value |
| 38 | // was chosen to give a reasonable range of values. |
| 39 | #define DWARF2_LINE_BASE -5 |
| 40 | |
| 41 | // Range of line offsets in a special line info. opcode. |
| 42 | # define DWARF2_LINE_RANGE 14 |
| 43 | |
| 44 | // Define the architecture-dependent minimum instruction length (in bytes). |
| 45 | // This value should be rather too small than too big. |
| 46 | # define DWARF2_LINE_MIN_INSN_LENGTH 1 |
| 47 | |
| 48 | // Note: when DWARF2_LINE_MIN_INSN_LENGTH == 1 which is the current setting, |
| 49 | // this routine is a nop and will be optimized away. |
| 50 | static inline uint64_t ScaleAddrDelta(uint64_t AddrDelta) |
| 51 | { |
| 52 | if (DWARF2_LINE_MIN_INSN_LENGTH == 1) |
| 53 | return AddrDelta; |
| 54 | if (AddrDelta % DWARF2_LINE_MIN_INSN_LENGTH != 0) { |
| 55 | // TODO: report this error, but really only once. |
| 56 | ; |
| 57 | } |
| 58 | return AddrDelta / DWARF2_LINE_MIN_INSN_LENGTH; |
| 59 | } |
| 60 | |
| 61 | // |
| 62 | // This is called when an instruction is assembled into the specified section |
| 63 | // and if there is information from the last .loc directive that has yet to have |
| 64 | // a line entry made for it is made. |
| 65 | // |
Rafael Espindola | 195a0ce | 2010-11-19 02:26:16 +0000 | [diff] [blame] | 66 | void MCLineEntry::Make(MCStreamer *MCOS, const MCSection *Section) { |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 67 | if (!MCOS->getContext().getDwarfLocSeen()) |
| 68 | return; |
| 69 | |
| 70 | // Create a symbol at in the current section for use in the line entry. |
| 71 | MCSymbol *LineSym = MCOS->getContext().CreateTempSymbol(); |
| 72 | // Set the value of the symbol to use for the MCLineEntry. |
| 73 | MCOS->EmitLabel(LineSym); |
| 74 | |
| 75 | // Get the current .loc info saved in the context. |
| 76 | const MCDwarfLoc &DwarfLoc = MCOS->getContext().getCurrentDwarfLoc(); |
| 77 | |
| 78 | // Create a (local) line entry with the symbol and the current .loc info. |
| 79 | MCLineEntry LineEntry(LineSym, DwarfLoc); |
| 80 | |
| 81 | // clear DwarfLocSeen saying the current .loc info is now used. |
Kevin Enderby | 3f55c24 | 2010-10-04 20:17:24 +0000 | [diff] [blame] | 82 | MCOS->getContext().ClearDwarfLocSeen(); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 83 | |
| 84 | // Get the MCLineSection for this section, if one does not exist for this |
| 85 | // section create it. |
Rafael Espindola | 17fd7bd | 2010-11-19 07:41:23 +0000 | [diff] [blame] | 86 | const DenseMap<const MCSection *, MCLineSection *> &MCLineSections = |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 87 | MCOS->getContext().getMCLineSections(); |
Rafael Espindola | 17fd7bd | 2010-11-19 07:41:23 +0000 | [diff] [blame] | 88 | MCLineSection *LineSection = MCLineSections.lookup(Section); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 89 | if (!LineSection) { |
| 90 | // Create a new MCLineSection. This will be deleted after the dwarf line |
| 91 | // table is created using it by iterating through the MCLineSections |
| 92 | // DenseMap. |
| 93 | LineSection = new MCLineSection; |
| 94 | // Save a pointer to the new LineSection into the MCLineSections DenseMap. |
Rafael Espindola | 17fd7bd | 2010-11-19 07:41:23 +0000 | [diff] [blame] | 95 | MCOS->getContext().addMCLineSection(Section, LineSection); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | // Add the line entry to this section's entries. |
| 99 | LineSection->addLineEntry(LineEntry); |
| 100 | } |
| 101 | |
| 102 | // |
| 103 | // This helper routine returns an expression of End - Start + IntVal . |
| 104 | // |
Rafael Espindola | 5fad7a9 | 2010-12-09 23:08:35 +0000 | [diff] [blame] | 105 | static inline const MCExpr *MakeStartMinusEndExpr(const MCStreamer &MCOS, |
| 106 | const MCSymbol &Start, |
| 107 | const MCSymbol &End, |
| 108 | int IntVal) { |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 109 | MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; |
| 110 | const MCExpr *Res = |
Rafael Espindola | 5fad7a9 | 2010-12-09 23:08:35 +0000 | [diff] [blame] | 111 | MCSymbolRefExpr::Create(&End, Variant, MCOS.getContext()); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 112 | const MCExpr *RHS = |
Rafael Espindola | 5fad7a9 | 2010-12-09 23:08:35 +0000 | [diff] [blame] | 113 | MCSymbolRefExpr::Create(&Start, Variant, MCOS.getContext()); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 114 | const MCExpr *Res1 = |
Rafael Espindola | 5fad7a9 | 2010-12-09 23:08:35 +0000 | [diff] [blame] | 115 | MCBinaryExpr::Create(MCBinaryExpr::Sub, Res, RHS, MCOS.getContext()); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 116 | const MCExpr *Res2 = |
Rafael Espindola | 5fad7a9 | 2010-12-09 23:08:35 +0000 | [diff] [blame] | 117 | MCConstantExpr::Create(IntVal, MCOS.getContext()); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 118 | const MCExpr *Res3 = |
Rafael Espindola | 5fad7a9 | 2010-12-09 23:08:35 +0000 | [diff] [blame] | 119 | MCBinaryExpr::Create(MCBinaryExpr::Sub, Res1, Res2, MCOS.getContext()); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 120 | return Res3; |
| 121 | } |
| 122 | |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 123 | // |
| 124 | // This emits the Dwarf line table for the specified section from the entries |
| 125 | // in the LineSection. |
| 126 | // |
Rafael Espindola | 195a0ce | 2010-11-19 02:26:16 +0000 | [diff] [blame] | 127 | static inline void EmitDwarfLineTable(MCStreamer *MCOS, |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 128 | const MCSection *Section, |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 129 | const MCLineSection *LineSection) { |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 130 | unsigned FileNum = 1; |
| 131 | unsigned LastLine = 1; |
| 132 | unsigned Column = 0; |
| 133 | unsigned Flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0; |
| 134 | unsigned Isa = 0; |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 135 | MCSymbol *LastLabel = NULL; |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 136 | |
| 137 | // Loop through each MCLineEntry and encode the dwarf line number table. |
Rafael Espindola | 17fd7bd | 2010-11-19 07:41:23 +0000 | [diff] [blame] | 138 | for (MCLineSection::const_iterator |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 139 | it = LineSection->getMCLineEntries()->begin(), |
| 140 | ie = LineSection->getMCLineEntries()->end(); it != ie; ++it) { |
| 141 | |
| 142 | if (FileNum != it->getFileNum()) { |
| 143 | FileNum = it->getFileNum(); |
| 144 | MCOS->EmitIntValue(dwarf::DW_LNS_set_file, 1); |
Rafael Espindola | 3ff5709 | 2010-11-02 17:22:24 +0000 | [diff] [blame] | 145 | MCOS->EmitULEB128IntValue(FileNum); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 146 | } |
| 147 | if (Column != it->getColumn()) { |
| 148 | Column = it->getColumn(); |
| 149 | MCOS->EmitIntValue(dwarf::DW_LNS_set_column, 1); |
Rafael Espindola | 3ff5709 | 2010-11-02 17:22:24 +0000 | [diff] [blame] | 150 | MCOS->EmitULEB128IntValue(Column); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 151 | } |
| 152 | if (Isa != it->getIsa()) { |
| 153 | Isa = it->getIsa(); |
| 154 | MCOS->EmitIntValue(dwarf::DW_LNS_set_isa, 1); |
Rafael Espindola | 3ff5709 | 2010-11-02 17:22:24 +0000 | [diff] [blame] | 155 | MCOS->EmitULEB128IntValue(Isa); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 156 | } |
| 157 | if ((it->getFlags() ^ Flags) & DWARF2_FLAG_IS_STMT) { |
| 158 | Flags = it->getFlags(); |
| 159 | MCOS->EmitIntValue(dwarf::DW_LNS_negate_stmt, 1); |
| 160 | } |
| 161 | if (it->getFlags() & DWARF2_FLAG_BASIC_BLOCK) |
| 162 | MCOS->EmitIntValue(dwarf::DW_LNS_set_basic_block, 1); |
| 163 | if (it->getFlags() & DWARF2_FLAG_PROLOGUE_END) |
| 164 | MCOS->EmitIntValue(dwarf::DW_LNS_set_prologue_end, 1); |
| 165 | if (it->getFlags() & DWARF2_FLAG_EPILOGUE_BEGIN) |
| 166 | MCOS->EmitIntValue(dwarf::DW_LNS_set_epilogue_begin, 1); |
| 167 | |
Rafael Espindola | 64185cc | 2010-11-13 01:06:27 +0000 | [diff] [blame] | 168 | int64_t LineDelta = static_cast<int64_t>(it->getLine()) - LastLine; |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 169 | MCSymbol *Label = it->getLabel(); |
| 170 | |
| 171 | // At this point we want to emit/create the sequence to encode the delta in |
| 172 | // line numbers and the increment of the address from the previous Label |
| 173 | // and the current Label. |
Rafael Espindola | 32a006e | 2010-12-03 00:55:40 +0000 | [diff] [blame] | 174 | MCOS->EmitDwarfAdvanceLineAddr(LineDelta, LastLabel, Label); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 175 | |
| 176 | LastLine = it->getLine(); |
| 177 | LastLabel = Label; |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | // Emit a DW_LNE_end_sequence for the end of the section. |
| 181 | // Using the pointer Section create a temporary label at the end of the |
| 182 | // section and use that and the LastLabel to compute the address delta |
| 183 | // and use INT64_MAX as the line delta which is the signal that this is |
| 184 | // actually a DW_LNE_end_sequence. |
| 185 | |
| 186 | // Switch to the section to be able to create a symbol at its end. |
| 187 | MCOS->SwitchSection(Section); |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 188 | |
| 189 | MCContext &context = MCOS->getContext(); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 190 | // Create a symbol at the end of the section. |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 191 | MCSymbol *SectionEnd = context.CreateTempSymbol(); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 192 | // Set the value of the symbol, as we are at the end of the section. |
| 193 | MCOS->EmitLabel(SectionEnd); |
| 194 | |
| 195 | // Switch back the the dwarf line section. |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 196 | MCOS->SwitchSection(context.getTargetAsmInfo().getDwarfLineSection()); |
Rafael Espindola | 195a0ce | 2010-11-19 02:26:16 +0000 | [diff] [blame] | 197 | |
Rafael Espindola | 32a006e | 2010-12-03 00:55:40 +0000 | [diff] [blame] | 198 | MCOS->EmitDwarfAdvanceLineAddr(INT64_MAX, LastLabel, SectionEnd); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | // |
| 202 | // This emits the Dwarf file and the line tables. |
| 203 | // |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 204 | void MCDwarfFileTable::Emit(MCStreamer *MCOS) { |
| 205 | MCContext &context = MCOS->getContext(); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 206 | // Switch to the section where the table will be emitted into. |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 207 | MCOS->SwitchSection(context.getTargetAsmInfo().getDwarfLineSection()); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 208 | |
| 209 | // Create a symbol at the beginning of this section. |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 210 | MCSymbol *LineStartSym = context.CreateTempSymbol(); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 211 | // Set the value of the symbol, as we are at the start of the section. |
| 212 | MCOS->EmitLabel(LineStartSym); |
| 213 | |
| 214 | // Create a symbol for the end of the section (to be set when we get there). |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 215 | MCSymbol *LineEndSym = context.CreateTempSymbol(); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 216 | |
| 217 | // The first 4 bytes is the total length of the information for this |
| 218 | // compilation unit (not including these 4 bytes for the length). |
Rafael Espindola | 5fad7a9 | 2010-12-09 23:08:35 +0000 | [diff] [blame] | 219 | MCOS->EmitAbsValue(MakeStartMinusEndExpr(*MCOS, *LineStartSym, *LineEndSym,4), |
Rafael Espindola | 0bbe0b4 | 2010-12-06 17:27:56 +0000 | [diff] [blame] | 220 | 4); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 221 | |
| 222 | // Next 2 bytes is the Version, which is Dwarf 2. |
| 223 | MCOS->EmitIntValue(2, 2); |
| 224 | |
| 225 | // Create a symbol for the end of the prologue (to be set when we get there). |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 226 | MCSymbol *ProEndSym = context.CreateTempSymbol(); // Lprologue_end |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 227 | |
| 228 | // Length of the prologue, is the next 4 bytes. Which is the start of the |
| 229 | // section to the end of the prologue. Not including the 4 bytes for the |
| 230 | // total length, the 2 bytes for the version, and these 4 bytes for the |
| 231 | // length of the prologue. |
Rafael Espindola | 5fad7a9 | 2010-12-09 23:08:35 +0000 | [diff] [blame] | 232 | MCOS->EmitAbsValue(MakeStartMinusEndExpr(*MCOS, *LineStartSym, *ProEndSym, |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 233 | (4 + 2 + 4)), |
Rafael Espindola | 5d4918d | 2010-12-04 03:21:47 +0000 | [diff] [blame] | 234 | 4, 0); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 235 | |
| 236 | // Parameters of the state machine, are next. |
| 237 | MCOS->EmitIntValue(DWARF2_LINE_MIN_INSN_LENGTH, 1); |
| 238 | MCOS->EmitIntValue(DWARF2_LINE_DEFAULT_IS_STMT, 1); |
| 239 | MCOS->EmitIntValue(DWARF2_LINE_BASE, 1); |
| 240 | MCOS->EmitIntValue(DWARF2_LINE_RANGE, 1); |
| 241 | MCOS->EmitIntValue(DWARF2_LINE_OPCODE_BASE, 1); |
| 242 | |
| 243 | // Standard opcode lengths |
| 244 | MCOS->EmitIntValue(0, 1); // length of DW_LNS_copy |
| 245 | MCOS->EmitIntValue(1, 1); // length of DW_LNS_advance_pc |
| 246 | MCOS->EmitIntValue(1, 1); // length of DW_LNS_advance_line |
| 247 | MCOS->EmitIntValue(1, 1); // length of DW_LNS_set_file |
| 248 | MCOS->EmitIntValue(1, 1); // length of DW_LNS_set_column |
| 249 | MCOS->EmitIntValue(0, 1); // length of DW_LNS_negate_stmt |
| 250 | MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_basic_block |
| 251 | MCOS->EmitIntValue(0, 1); // length of DW_LNS_const_add_pc |
| 252 | MCOS->EmitIntValue(1, 1); // length of DW_LNS_fixed_advance_pc |
| 253 | MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_prologue_end |
| 254 | MCOS->EmitIntValue(0, 1); // length of DW_LNS_set_epilogue_begin |
| 255 | MCOS->EmitIntValue(1, 1); // DW_LNS_set_isa |
| 256 | |
| 257 | // Put out the directory and file tables. |
| 258 | |
| 259 | // First the directory table. |
| 260 | const std::vector<StringRef> &MCDwarfDirs = |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 261 | context.getMCDwarfDirs(); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 262 | for (unsigned i = 0; i < MCDwarfDirs.size(); i++) { |
| 263 | MCOS->EmitBytes(MCDwarfDirs[i], 0); // the DirectoryName |
| 264 | MCOS->EmitBytes(StringRef("\0", 1), 0); // the null term. of the string |
| 265 | } |
| 266 | MCOS->EmitIntValue(0, 1); // Terminate the directory list |
| 267 | |
| 268 | // Second the file table. |
| 269 | const std::vector<MCDwarfFile *> &MCDwarfFiles = |
| 270 | MCOS->getContext().getMCDwarfFiles(); |
| 271 | for (unsigned i = 1; i < MCDwarfFiles.size(); i++) { |
| 272 | MCOS->EmitBytes(MCDwarfFiles[i]->getName(), 0); // FileName |
| 273 | MCOS->EmitBytes(StringRef("\0", 1), 0); // the null term. of the string |
Rafael Espindola | 3ff5709 | 2010-11-02 17:22:24 +0000 | [diff] [blame] | 274 | // the Directory num |
| 275 | MCOS->EmitULEB128IntValue(MCDwarfFiles[i]->getDirIndex()); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 276 | MCOS->EmitIntValue(0, 1); // last modification timestamp (always 0) |
| 277 | MCOS->EmitIntValue(0, 1); // filesize (always 0) |
| 278 | } |
| 279 | MCOS->EmitIntValue(0, 1); // Terminate the file list |
| 280 | |
| 281 | // This is the end of the prologue, so set the value of the symbol at the |
| 282 | // end of the prologue (that was used in a previous expression). |
| 283 | MCOS->EmitLabel(ProEndSym); |
| 284 | |
| 285 | // Put out the line tables. |
Rafael Espindola | 17fd7bd | 2010-11-19 07:41:23 +0000 | [diff] [blame] | 286 | const DenseMap<const MCSection *, MCLineSection *> &MCLineSections = |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 287 | MCOS->getContext().getMCLineSections(); |
Rafael Espindola | 17fd7bd | 2010-11-19 07:41:23 +0000 | [diff] [blame] | 288 | const std::vector<const MCSection *> &MCLineSectionOrder = |
| 289 | MCOS->getContext().getMCLineSectionOrder(); |
| 290 | for (std::vector<const MCSection*>::const_iterator it = |
| 291 | MCLineSectionOrder.begin(), ie = MCLineSectionOrder.end(); it != ie; |
| 292 | ++it) { |
| 293 | const MCSection *Sec = *it; |
| 294 | const MCLineSection *Line = MCLineSections.lookup(Sec); |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 295 | EmitDwarfLineTable(MCOS, Sec, Line); |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 296 | |
| 297 | // Now delete the MCLineSections that were created in MCLineEntry::Make() |
| 298 | // and used to emit the line table. |
Rafael Espindola | 17fd7bd | 2010-11-19 07:41:23 +0000 | [diff] [blame] | 299 | delete Line; |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 300 | } |
| 301 | |
Rafael Espindola | 767b1be | 2010-12-04 00:31:13 +0000 | [diff] [blame] | 302 | if (MCOS->getContext().getAsmInfo().getLinkerRequiresNonEmptyDwarfLines() |
| 303 | && MCLineSectionOrder.begin() == MCLineSectionOrder.end()) { |
Rafael Espindola | a8de83c | 2010-12-03 23:36:59 +0000 | [diff] [blame] | 304 | // The darwin9 linker has a bug (see PR8715). For for 32-bit architectures |
| 305 | // it requires: |
| 306 | // total_length >= prologue_length + 10 |
| 307 | // We are 4 bytes short, since we have total_length = 51 and |
| 308 | // prologue_length = 45 |
Devang Patel | 5113cdb | 2010-12-03 00:10:48 +0000 | [diff] [blame] | 309 | |
Rafael Espindola | a8de83c | 2010-12-03 23:36:59 +0000 | [diff] [blame] | 310 | // The regular end_sequence should be sufficient. |
| 311 | MCDwarfLineAddr::Emit(MCOS, INT64_MAX, 0); |
Devang Patel | 5113cdb | 2010-12-03 00:10:48 +0000 | [diff] [blame] | 312 | } |
| 313 | |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 314 | // This is the end of the section, so set the value of the symbol at the end |
| 315 | // of this section (that was used in a previous expression). |
| 316 | MCOS->EmitLabel(LineEndSym); |
| 317 | } |
| 318 | |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 319 | /// Utility function to write the encoding to an object writer. |
| 320 | void MCDwarfLineAddr::Write(MCObjectWriter *OW, int64_t LineDelta, |
| 321 | uint64_t AddrDelta) { |
| 322 | SmallString<256> Tmp; |
| 323 | raw_svector_ostream OS(Tmp); |
| 324 | MCDwarfLineAddr::Encode(LineDelta, AddrDelta, OS); |
| 325 | OW->WriteBytes(OS.str()); |
| 326 | } |
| 327 | |
| 328 | /// Utility function to emit the encoding to a streamer. |
Rafael Espindola | 195a0ce | 2010-11-19 02:26:16 +0000 | [diff] [blame] | 329 | void MCDwarfLineAddr::Emit(MCStreamer *MCOS, int64_t LineDelta, |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 330 | uint64_t AddrDelta) { |
| 331 | SmallString<256> Tmp; |
| 332 | raw_svector_ostream OS(Tmp); |
| 333 | MCDwarfLineAddr::Encode(LineDelta, AddrDelta, OS); |
| 334 | MCOS->EmitBytes(OS.str(), /*AddrSpace=*/0); |
| 335 | } |
| 336 | |
| 337 | /// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas. |
| 338 | void MCDwarfLineAddr::Encode(int64_t LineDelta, uint64_t AddrDelta, |
| 339 | raw_ostream &OS) { |
| 340 | uint64_t Temp, Opcode; |
| 341 | bool NeedCopy = false; |
| 342 | |
| 343 | // Scale the address delta by the minimum instruction length. |
| 344 | AddrDelta = ScaleAddrDelta(AddrDelta); |
| 345 | |
| 346 | // A LineDelta of INT64_MAX is a signal that this is actually a |
| 347 | // DW_LNE_end_sequence. We cannot use special opcodes here, since we want the |
| 348 | // end_sequence to emit the matrix entry. |
| 349 | if (LineDelta == INT64_MAX) { |
| 350 | if (AddrDelta == MAX_SPECIAL_ADDR_DELTA) |
| 351 | OS << char(dwarf::DW_LNS_const_add_pc); |
| 352 | else { |
| 353 | OS << char(dwarf::DW_LNS_advance_pc); |
| 354 | SmallString<32> Tmp; |
| 355 | raw_svector_ostream OSE(Tmp); |
| 356 | MCObjectWriter::EncodeULEB128(AddrDelta, OSE); |
| 357 | OS << OSE.str(); |
| 358 | } |
| 359 | OS << char(dwarf::DW_LNS_extended_op); |
| 360 | OS << char(1); |
| 361 | OS << char(dwarf::DW_LNE_end_sequence); |
| 362 | return; |
| 363 | } |
| 364 | |
| 365 | // Bias the line delta by the base. |
| 366 | Temp = LineDelta - DWARF2_LINE_BASE; |
| 367 | |
| 368 | // If the line increment is out of range of a special opcode, we must encode |
| 369 | // it with DW_LNS_advance_line. |
| 370 | if (Temp >= DWARF2_LINE_RANGE) { |
| 371 | OS << char(dwarf::DW_LNS_advance_line); |
| 372 | SmallString<32> Tmp; |
| 373 | raw_svector_ostream OSE(Tmp); |
| 374 | MCObjectWriter::EncodeSLEB128(LineDelta, OSE); |
| 375 | OS << OSE.str(); |
| 376 | |
| 377 | LineDelta = 0; |
| 378 | Temp = 0 - DWARF2_LINE_BASE; |
| 379 | NeedCopy = true; |
| 380 | } |
| 381 | |
| 382 | // Use DW_LNS_copy instead of a "line +0, addr +0" special opcode. |
| 383 | if (LineDelta == 0 && AddrDelta == 0) { |
| 384 | OS << char(dwarf::DW_LNS_copy); |
| 385 | return; |
| 386 | } |
| 387 | |
| 388 | // Bias the opcode by the special opcode base. |
| 389 | Temp += DWARF2_LINE_OPCODE_BASE; |
| 390 | |
| 391 | // Avoid overflow when addr_delta is large. |
| 392 | if (AddrDelta < 256 + MAX_SPECIAL_ADDR_DELTA) { |
| 393 | // Try using a special opcode. |
| 394 | Opcode = Temp + AddrDelta * DWARF2_LINE_RANGE; |
| 395 | if (Opcode <= 255) { |
| 396 | OS << char(Opcode); |
| 397 | return; |
| 398 | } |
| 399 | |
| 400 | // Try using DW_LNS_const_add_pc followed by special op. |
| 401 | Opcode = Temp + (AddrDelta - MAX_SPECIAL_ADDR_DELTA) * DWARF2_LINE_RANGE; |
| 402 | if (Opcode <= 255) { |
| 403 | OS << char(dwarf::DW_LNS_const_add_pc); |
| 404 | OS << char(Opcode); |
| 405 | return; |
| 406 | } |
| 407 | } |
| 408 | |
| 409 | // Otherwise use DW_LNS_advance_pc. |
| 410 | OS << char(dwarf::DW_LNS_advance_pc); |
| 411 | SmallString<32> Tmp; |
| 412 | raw_svector_ostream OSE(Tmp); |
| 413 | MCObjectWriter::EncodeULEB128(AddrDelta, OSE); |
| 414 | OS << OSE.str(); |
| 415 | |
| 416 | if (NeedCopy) |
| 417 | OS << char(dwarf::DW_LNS_copy); |
| 418 | else |
| 419 | OS << char(Temp); |
| 420 | } |
| 421 | |
Kevin Enderby | 7cbf73a | 2010-07-28 20:55:35 +0000 | [diff] [blame] | 422 | void MCDwarfFile::print(raw_ostream &OS) const { |
| 423 | OS << '"' << getName() << '"'; |
| 424 | } |
| 425 | |
| 426 | void MCDwarfFile::dump() const { |
| 427 | print(dbgs()); |
| 428 | } |
Kevin Enderby | c095793 | 2010-09-30 16:52:03 +0000 | [diff] [blame] | 429 | |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 430 | static int getDataAlignmentFactor(MCStreamer &streamer) { |
| 431 | MCContext &context = streamer.getContext(); |
| 432 | const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); |
| 433 | int size = asmInfo.getPointerSize(); |
| 434 | if (asmInfo.getStackGrowthDirection() == TargetFrameInfo::StackGrowsUp) |
| 435 | return size; |
| 436 | else |
| 437 | return -size; |
| 438 | } |
| 439 | |
| 440 | /// EmitFrameMoves - Emit frame instructions to describe the layout of the |
| 441 | /// frame. |
| 442 | static void EmitFrameMoves(MCStreamer &streamer, |
| 443 | const std::vector<MachineMove> &Moves, |
| 444 | MCSymbol *BaseLabel, bool isEH) { |
| 445 | MCContext &context = streamer.getContext(); |
| 446 | const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); |
| 447 | int dataAlignmentFactor = getDataAlignmentFactor(streamer); |
| 448 | |
| 449 | for (unsigned i = 0, N = Moves.size(); i < N; ++i) { |
| 450 | const MachineMove &Move = Moves[i]; |
| 451 | MCSymbol *Label = Move.getLabel(); |
| 452 | // Throw out move if the label is invalid. |
| 453 | if (Label && !Label->isDefined()) continue; // Not emitted, in dead code. |
| 454 | |
| 455 | const MachineLocation &Dst = Move.getDestination(); |
| 456 | const MachineLocation &Src = Move.getSource(); |
| 457 | |
| 458 | // Advance row if new location. |
| 459 | if (BaseLabel && Label) { |
| 460 | MCSymbol *ThisSym = Label; |
| 461 | if (ThisSym != BaseLabel) { |
| 462 | streamer.EmitIntValue(dwarf::DW_CFA_advance_loc4, 1); |
| 463 | const MCExpr *Length = MakeStartMinusEndExpr(streamer, *BaseLabel, |
| 464 | *ThisSym, 4); |
| 465 | streamer.EmitValue(Length, 4); |
| 466 | BaseLabel = ThisSym; |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | // If advancing cfa. |
| 471 | if (Dst.isReg() && Dst.getReg() == MachineLocation::VirtualFP) { |
| 472 | assert(!Src.isReg() && "Machine move not supported yet."); |
| 473 | |
| 474 | if (Src.getReg() == MachineLocation::VirtualFP) { |
| 475 | streamer.EmitIntValue(dwarf::DW_CFA_def_cfa_offset, 1); |
| 476 | } else { |
| 477 | streamer.EmitIntValue(dwarf::DW_CFA_def_cfa, 1); |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 478 | streamer.EmitULEB128IntValue(asmInfo.getDwarfRegNum(Src.getReg(), |
| 479 | isEH)); |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | streamer.EmitULEB128IntValue(-Src.getOffset(), 1); |
| 483 | continue; |
| 484 | } |
| 485 | |
| 486 | if (Src.isReg() && Src.getReg() == MachineLocation::VirtualFP) { |
| 487 | assert(Dst.isReg() && "Machine move not supported yet."); |
| 488 | streamer.EmitIntValue(dwarf::DW_CFA_def_cfa_register, 1); |
| 489 | streamer.EmitULEB128IntValue(asmInfo.getDwarfRegNum(Dst.getReg(), isEH)); |
| 490 | continue; |
| 491 | } |
| 492 | |
| 493 | unsigned Reg = asmInfo.getDwarfRegNum(Src.getReg(), isEH); |
| 494 | int Offset = Dst.getOffset() / dataAlignmentFactor; |
| 495 | |
| 496 | if (Offset < 0) { |
| 497 | streamer.EmitIntValue(dwarf::DW_CFA_offset_extended_sf, 1); |
| 498 | streamer.EmitULEB128IntValue(Reg); |
| 499 | streamer.EmitSLEB128IntValue(Offset); |
| 500 | } else if (Reg < 64) { |
| 501 | streamer.EmitIntValue(dwarf::DW_CFA_offset + Reg, 1); |
| 502 | streamer.EmitULEB128IntValue(Offset, 1); |
| 503 | } else { |
| 504 | streamer.EmitIntValue(dwarf::DW_CFA_offset_extended, 1); |
| 505 | streamer.EmitULEB128IntValue(Reg, 1); |
| 506 | streamer.EmitULEB128IntValue(Offset, 1); |
| 507 | } |
| 508 | } |
| 509 | } |
| 510 | |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 511 | static const MCSymbol &EmitCIE(MCStreamer &streamer, |
Rafael Espindola | 3a83c40 | 2010-12-27 00:36:05 +0000 | [diff] [blame^] | 512 | const MCSymbol *personality, |
| 513 | unsigned personalityEncoding) { |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 514 | MCContext &context = streamer.getContext(); |
| 515 | const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); |
| 516 | const MCSection §ion = *asmInfo.getEHFrameSection(); |
| 517 | streamer.SwitchSection(§ion); |
| 518 | MCSymbol *sectionStart = streamer.getContext().CreateTempSymbol(); |
| 519 | MCSymbol *sectionEnd = streamer.getContext().CreateTempSymbol(); |
| 520 | |
| 521 | // Length |
| 522 | const MCExpr *Length = MakeStartMinusEndExpr(streamer, *sectionStart, |
| 523 | *sectionEnd, 4); |
| 524 | streamer.EmitLabel(sectionStart); |
| 525 | streamer.EmitValue(Length, 4); |
| 526 | |
| 527 | // CIE ID |
| 528 | streamer.EmitIntValue(0, 4); |
| 529 | |
| 530 | // Version |
| 531 | streamer.EmitIntValue(dwarf::DW_CIE_VERSION, 1); |
| 532 | |
| 533 | // Augmentation String |
| 534 | SmallString<8> Augmentation; |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 535 | Augmentation += "z"; |
| 536 | if (personality) |
| 537 | Augmentation += "P"; |
| 538 | Augmentation += "R"; |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 539 | streamer.EmitBytes(Augmentation.str(), 0); |
| 540 | streamer.EmitIntValue(0, 1); |
| 541 | |
| 542 | // Code Alignment Factor |
| 543 | streamer.EmitULEB128IntValue(1); |
| 544 | |
| 545 | // Data Alignment Factor |
| 546 | streamer.EmitSLEB128IntValue(getDataAlignmentFactor(streamer)); |
| 547 | |
| 548 | // Return Address Register |
| 549 | streamer.EmitULEB128IntValue(asmInfo.getDwarfRARegNum(true)); |
| 550 | |
| 551 | // Augmentation Data Length (optional) |
| 552 | MCSymbol *augmentationStart = streamer.getContext().CreateTempSymbol(); |
| 553 | MCSymbol *augmentationEnd = streamer.getContext().CreateTempSymbol(); |
| 554 | const MCExpr *augmentationLength = MakeStartMinusEndExpr(streamer, |
| 555 | *augmentationStart, |
| 556 | *augmentationEnd, 0); |
| 557 | streamer.EmitULEB128Value(augmentationLength); |
| 558 | |
| 559 | // Augmentation Data (optional) |
| 560 | streamer.EmitLabel(augmentationStart); |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 561 | if (personality) { |
| 562 | // Personality Encoding |
Rafael Espindola | 3a83c40 | 2010-12-27 00:36:05 +0000 | [diff] [blame^] | 563 | streamer.EmitIntValue(personalityEncoding, 1); |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 564 | // Personality |
Rafael Espindola | 3a83c40 | 2010-12-27 00:36:05 +0000 | [diff] [blame^] | 565 | unsigned format = personalityEncoding & 0x0f; |
| 566 | unsigned application = personalityEncoding & 0xf0; |
| 567 | unsigned size; |
| 568 | switch (format) { |
| 569 | default: |
| 570 | assert(0 && "Unknown Encoding"); |
| 571 | break; |
| 572 | case dwarf::DW_EH_PE_absptr: |
| 573 | case dwarf::DW_EH_PE_signed: |
| 574 | size = asmInfo.getPointerSize(); |
| 575 | break; |
| 576 | case dwarf::DW_EH_PE_udata2: |
| 577 | case dwarf::DW_EH_PE_sdata2: |
| 578 | size = 2; |
| 579 | break; |
| 580 | case dwarf::DW_EH_PE_udata4: |
| 581 | case dwarf::DW_EH_PE_sdata4: |
| 582 | size = 4; |
| 583 | break; |
| 584 | case dwarf::DW_EH_PE_udata8: |
| 585 | case dwarf::DW_EH_PE_sdata8: |
| 586 | size = 8; |
| 587 | break; |
| 588 | } |
| 589 | switch (application) { |
| 590 | default: |
| 591 | assert(0 && "Unknown Encoding"); |
| 592 | break; |
| 593 | case 0: |
| 594 | case dwarf::DW_EH_PE_indirect: |
| 595 | streamer.EmitSymbolValue(personality, size); |
| 596 | break; |
| 597 | case dwarf::DW_EH_PE_pcrel: |
| 598 | streamer.EmitPCRelSymbolValue(personality, size); |
| 599 | break; |
| 600 | } |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 601 | } |
| 602 | // Encoding of the FDE pointers |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 603 | streamer.EmitIntValue(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4, 1); |
| 604 | streamer.EmitLabel(augmentationEnd); |
| 605 | |
| 606 | // Initial Instructions |
| 607 | |
| 608 | const std::vector<MachineMove> Moves = asmInfo.getInitialFrameState(); |
| 609 | |
| 610 | EmitFrameMoves(streamer, Moves, NULL, true); |
| 611 | |
| 612 | // Padding |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 613 | streamer.EmitValueToAlignment(4); |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 614 | |
| 615 | streamer.EmitLabel(sectionEnd); |
| 616 | return *sectionStart; |
| 617 | } |
| 618 | |
Rafael Espindola | dfe125c | 2010-12-17 00:28:02 +0000 | [diff] [blame] | 619 | static MCSymbol *EmitFDE(MCStreamer &streamer, |
| 620 | const MCSymbol &cieStart, |
| 621 | const MCDwarfFrameInfo &frame) { |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 622 | MCSymbol *fdeStart = streamer.getContext().CreateTempSymbol(); |
| 623 | MCSymbol *fdeEnd = streamer.getContext().CreateTempSymbol(); |
| 624 | |
| 625 | // Length |
| 626 | const MCExpr *Length = MakeStartMinusEndExpr(streamer, *fdeStart, *fdeEnd, 0); |
| 627 | streamer.EmitValue(Length, 4); |
| 628 | |
| 629 | streamer.EmitLabel(fdeStart); |
| 630 | // CIE Pointer |
| 631 | const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart, |
| 632 | 0); |
| 633 | streamer.EmitValue(offset, 4); |
| 634 | |
| 635 | // PC Begin |
| 636 | streamer.EmitPCRelSymbolValue(frame.Begin, 4); |
| 637 | |
| 638 | // PC Range |
| 639 | const MCExpr *Range = MakeStartMinusEndExpr(streamer, *frame.Begin, |
| 640 | *frame.End, 0); |
| 641 | streamer.EmitValue(Range, 4); |
| 642 | |
| 643 | // Augmentation Data Length |
| 644 | streamer.EmitULEB128IntValue(0); |
| 645 | |
| 646 | // Augmentation Data |
| 647 | // Call Frame Instructions |
| 648 | |
| 649 | // Padding |
Rafael Espindola | dfe125c | 2010-12-17 00:28:02 +0000 | [diff] [blame] | 650 | streamer.EmitValueToAlignment(4); |
| 651 | |
| 652 | return fdeEnd; |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 653 | } |
| 654 | |
| 655 | void MCDwarfFrameEmitter::Emit(MCStreamer &streamer) { |
Rafael Espindola | dfe125c | 2010-12-17 00:28:02 +0000 | [diff] [blame] | 656 | const MCContext &context = streamer.getContext(); |
| 657 | const TargetAsmInfo &asmInfo = context.getTargetAsmInfo(); |
Rafael Espindola | dfe125c | 2010-12-17 00:28:02 +0000 | [diff] [blame] | 658 | MCSymbol *fdeEnd = NULL; |
Rafael Espindola | 3a83c40 | 2010-12-27 00:36:05 +0000 | [diff] [blame^] | 659 | typedef std::pair<const MCSymbol*, unsigned> personalityKey; |
| 660 | DenseMap<personalityKey, const MCSymbol*> personalities; |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 661 | |
Rafael Espindola | dfe125c | 2010-12-17 00:28:02 +0000 | [diff] [blame] | 662 | for (unsigned i = 0, n = streamer.getNumFrameInfos(); i < n; ++i) { |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 663 | const MCDwarfFrameInfo &frame = streamer.getFrameInfo(i); |
Rafael Espindola | 3a83c40 | 2010-12-27 00:36:05 +0000 | [diff] [blame^] | 664 | personalityKey key(frame.Personality, frame.PersonalityEncoding); |
| 665 | const MCSymbol *&cieStart = personalities[key]; |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 666 | if (!cieStart) |
Rafael Espindola | 3a83c40 | 2010-12-27 00:36:05 +0000 | [diff] [blame^] | 667 | cieStart = &EmitCIE(streamer, frame.Personality, |
| 668 | frame.PersonalityEncoding); |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 669 | fdeEnd = EmitFDE(streamer, *cieStart, frame); |
Rafael Espindola | dfe125c | 2010-12-17 00:28:02 +0000 | [diff] [blame] | 670 | if (i != n - 1) |
| 671 | streamer.EmitLabel(fdeEnd); |
| 672 | } |
Rafael Espindola | d7c8cca | 2010-12-26 20:20:31 +0000 | [diff] [blame] | 673 | |
Rafael Espindola | dfe125c | 2010-12-17 00:28:02 +0000 | [diff] [blame] | 674 | streamer.EmitValueToAlignment(asmInfo.getPointerSize()); |
| 675 | if (fdeEnd) |
| 676 | streamer.EmitLabel(fdeEnd); |
Rafael Espindola | 89b9372 | 2010-12-10 07:39:47 +0000 | [diff] [blame] | 677 | } |