LLVM  9.0.0svn
MCDwarf.h
Go to the documentation of this file.
1 //===- MCDwarf.h - Machine Code Dwarf support -------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains the declaration of the MCDwarfFile to support the dwarf
10 // .file directive and the .loc directive.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_MC_MCDWARF_H
15 #define LLVM_MC_MCDWARF_H
16 
17 #include "llvm/ADT/MapVector.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/StringMap.h"
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/MC/MCSection.h"
23 #include "llvm/Support/Error.h"
24 #include "llvm/Support/MD5.h"
25 #include <cassert>
26 #include <cstdint>
27 #include <string>
28 #include <utility>
29 #include <vector>
30 
31 namespace llvm {
32 
33 template <typename T> class ArrayRef;
34 class MCAsmBackend;
35 class MCContext;
36 class MCDwarfLineStr;
37 class MCObjectStreamer;
38 class MCStreamer;
39 class MCSymbol;
40 class raw_ostream;
41 class SMLoc;
42 class SourceMgr;
43 
44 /// Instances of this class represent the name of the dwarf .file directive and
45 /// its associated dwarf file number in the MC file. MCDwarfFile's are created
46 /// and uniqued by the MCContext class. In Dwarf 4 file numbers start from 1;
47 /// i.e. the entry with file number 1 is the first element in the vector of
48 /// DwarfFiles and there is no MCDwarfFile with file number 0. In Dwarf 5 file
49 /// numbers start from 0, with the MCDwarfFile with file number 0 being the
50 /// primary source file, and file numbers correspond to their index in the
51 /// vector.
52 struct MCDwarfFile {
53  // The base name of the file without its directory path.
54  std::string Name;
55 
56  // The index into the list of directory names for this file name.
57  unsigned DirIndex;
58 
59  /// The MD5 checksum, if there is one. Non-owning pointer to data allocated
60  /// in MCContext.
62 
63  /// The source code of the file. Non-owning reference to data allocated in
64  /// MCContext.
66 };
67 
68 /// Instances of this class represent the information from a
69 /// dwarf .loc directive.
70 class MCDwarfLoc {
71  uint32_t FileNum;
72  uint32_t Line;
73  uint16_t Column;
74  // Flags (see #define's below)
75  uint8_t Flags;
76  uint8_t Isa;
77  uint32_t Discriminator;
78 
79 // Flag that indicates the initial value of the is_stmt_start flag.
80 #define DWARF2_LINE_DEFAULT_IS_STMT 1
81 
82 #define DWARF2_FLAG_IS_STMT (1 << 0)
83 #define DWARF2_FLAG_BASIC_BLOCK (1 << 1)
84 #define DWARF2_FLAG_PROLOGUE_END (1 << 2)
85 #define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3)
86 
87 private: // MCContext manages these
88  friend class MCContext;
89  friend class MCDwarfLineEntry;
90 
91  MCDwarfLoc(unsigned fileNum, unsigned line, unsigned column, unsigned flags,
92  unsigned isa, unsigned discriminator)
93  : FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa),
94  Discriminator(discriminator) {}
95 
96  // Allow the default copy constructor and assignment operator to be used
97  // for an MCDwarfLoc object.
98 
99 public:
100  /// Get the FileNum of this MCDwarfLoc.
101  unsigned getFileNum() const { return FileNum; }
102 
103  /// Get the Line of this MCDwarfLoc.
104  unsigned getLine() const { return Line; }
105 
106  /// Get the Column of this MCDwarfLoc.
107  unsigned getColumn() const { return Column; }
108 
109  /// Get the Flags of this MCDwarfLoc.
110  unsigned getFlags() const { return Flags; }
111 
112  /// Get the Isa of this MCDwarfLoc.
113  unsigned getIsa() const { return Isa; }
114 
115  /// Get the Discriminator of this MCDwarfLoc.
116  unsigned getDiscriminator() const { return Discriminator; }
117 
118  /// Set the FileNum of this MCDwarfLoc.
119  void setFileNum(unsigned fileNum) { FileNum = fileNum; }
120 
121  /// Set the Line of this MCDwarfLoc.
122  void setLine(unsigned line) { Line = line; }
123 
124  /// Set the Column of this MCDwarfLoc.
125  void setColumn(unsigned column) {
126  assert(column <= UINT16_MAX);
127  Column = column;
128  }
129 
130  /// Set the Flags of this MCDwarfLoc.
131  void setFlags(unsigned flags) {
132  assert(flags <= UINT8_MAX);
133  Flags = flags;
134  }
135 
136  /// Set the Isa of this MCDwarfLoc.
137  void setIsa(unsigned isa) {
138  assert(isa <= UINT8_MAX);
139  Isa = isa;
140  }
141 
142  /// Set the Discriminator of this MCDwarfLoc.
143  void setDiscriminator(unsigned discriminator) {
144  Discriminator = discriminator;
145  }
146 };
147 
148 /// Instances of this class represent the line information for
149 /// the dwarf line table entries. Which is created after a machine
150 /// instruction is assembled and uses an address from a temporary label
151 /// created at the current address in the current section and the info from
152 /// the last .loc directive seen as stored in the context.
153 class MCDwarfLineEntry : public MCDwarfLoc {
154  MCSymbol *Label;
155 
156 private:
157  // Allow the default copy constructor and assignment operator to be used
158  // for an MCDwarfLineEntry object.
159 
160 public:
161  // Constructor to create an MCDwarfLineEntry given a symbol and the dwarf loc.
163  : MCDwarfLoc(loc), Label(label) {}
164 
165  MCSymbol *getLabel() const { return Label; }
166 
167  // This is called when an instruction is assembled into the specified
168  // section and if there is information from the last .loc directive that
169  // has yet to have a line entry made for it is made.
170  static void Make(MCObjectStreamer *MCOS, MCSection *Section);
171 };
172 
173 /// Instances of this class represent the line information for a compile
174 /// unit where machine instructions have been assembled after seeing .loc
175 /// directives. This is the information used to build the dwarf line
176 /// table for a section.
178 public:
179  // Add an entry to this MCLineSection's line entries.
180  void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec) {
181  MCLineDivisions[Sec].push_back(LineEntry);
182  }
183 
184  using MCDwarfLineEntryCollection = std::vector<MCDwarfLineEntry>;
185  using iterator = MCDwarfLineEntryCollection::iterator;
186  using const_iterator = MCDwarfLineEntryCollection::const_iterator;
188 
189 private:
190  // A collection of MCDwarfLineEntry for each section.
191  MCLineDivisionMap MCLineDivisions;
192 
193 public:
194  // Returns the collection of MCDwarfLineEntry for a given Compile Unit ID.
196  return MCLineDivisions;
197  }
198 };
199 
201  /// First special line opcode - leave room for the standard opcodes.
202  /// Note: If you want to change this, you'll have to update the
203  /// "StandardOpcodeLengths" table that is emitted in
204  /// \c Emit().
205  uint8_t DWARF2LineOpcodeBase = 13;
206  /// Minimum line offset in a special line info. opcode. The value
207  /// -5 was chosen to give a reasonable range of values.
208  int8_t DWARF2LineBase = -5;
209  /// Range of line offsets in a special line info. opcode.
210  uint8_t DWARF2LineRange = 14;
211 };
212 
214  MCSymbol *Label = nullptr;
218  std::string CompilationDir;
220  bool HasSource = false;
221 private:
222  bool HasAllMD5 = true;
223  bool HasAnyMD5 = false;
224 
225 public:
226  MCDwarfLineTableHeader() = default;
227 
228  Expected<unsigned> tryGetFile(StringRef &Directory, StringRef &FileName,
231  uint16_t DwarfVersion,
232  unsigned FileNumber = 0);
233  std::pair<MCSymbol *, MCSymbol *>
234  Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
235  Optional<MCDwarfLineStr> &LineStr) const;
236  std::pair<MCSymbol *, MCSymbol *>
237  Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
238  ArrayRef<char> SpecialOpcodeLengths,
239  Optional<MCDwarfLineStr> &LineStr) const;
240  void resetMD5Usage() {
241  HasAllMD5 = true;
242  HasAnyMD5 = false;
243  }
244  void trackMD5Usage(bool MD5Used) {
245  HasAllMD5 &= MD5Used;
246  HasAnyMD5 |= MD5Used;
247  }
248  bool isMD5UsageConsistent() const {
249  return MCDwarfFiles.empty() || (HasAllMD5 == HasAnyMD5);
250  }
251 
252  void setRootFile(StringRef Directory, StringRef FileName,
255  CompilationDir = Directory;
256  RootFile.Name = FileName;
257  RootFile.DirIndex = 0;
258  RootFile.Checksum = Checksum;
259  RootFile.Source = Source;
260  trackMD5Usage(Checksum.hasValue());
261  HasSource = Source.hasValue();
262  }
263 
264 private:
265  void emitV2FileDirTables(MCStreamer *MCOS) const;
266  void emitV5FileDirTables(MCStreamer *MCOS, Optional<MCDwarfLineStr> &LineStr) const;
267 };
268 
270  MCDwarfLineTableHeader Header;
271  bool HasSplitLineTable = false;
272 
273 public:
274  void maybeSetRootFile(StringRef Directory, StringRef FileName,
277  if (!Header.RootFile.Name.empty())
278  return;
279  Header.setRootFile(Directory, FileName, Checksum, Source);
280  }
281 
282  unsigned getFile(StringRef Directory, StringRef FileName,
283  Optional<MD5::MD5Result> Checksum, uint16_t DwarfVersion,
285  HasSplitLineTable = true;
286  return cantFail(Header.tryGetFile(Directory, FileName, Checksum, Source,
287  DwarfVersion));
288  }
289 
290  void Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params,
291  MCSection *Section) const;
292 };
293 
295  MCDwarfLineTableHeader Header;
296  MCLineSection MCLineSections;
297 
298 public:
299  // This emits the Dwarf file and the line tables for all Compile Units.
300  static void Emit(MCObjectStreamer *MCOS, MCDwarfLineTableParams Params);
301 
302  // This emits the Dwarf file and the line tables for a given Compile Unit.
303  void EmitCU(MCObjectStreamer *MCOS, MCDwarfLineTableParams Params,
304  Optional<MCDwarfLineStr> &LineStr) const;
305 
306  Expected<unsigned> tryGetFile(StringRef &Directory, StringRef &FileName,
309  uint16_t DwarfVersion,
310  unsigned FileNumber = 0);
311  unsigned getFile(StringRef &Directory, StringRef &FileName,
313  uint16_t DwarfVersion, unsigned FileNumber = 0) {
314  return cantFail(tryGetFile(Directory, FileName, Checksum, Source,
315  DwarfVersion, FileNumber));
316  }
317 
318  void setRootFile(StringRef Directory, StringRef FileName,
320  Header.CompilationDir = Directory;
321  Header.RootFile.Name = FileName;
322  Header.RootFile.DirIndex = 0;
323  Header.RootFile.Checksum = Checksum;
324  Header.RootFile.Source = Source;
325  Header.trackMD5Usage(Checksum.hasValue());
326  Header.HasSource = Source.hasValue();
327  }
328 
329  void resetRootFile() {
330  assert(Header.MCDwarfFiles.empty());
331  Header.RootFile.Name.clear();
332  Header.resetMD5Usage();
333  Header.HasSource = false;
334  }
335 
336  bool hasRootFile() const { return !Header.RootFile.Name.empty(); }
337 
338  const MCDwarfFile &getRootFile() const { return Header.RootFile; }
339 
340  // Report whether MD5 usage has been consistent (all-or-none).
341  bool isMD5UsageConsistent() const { return Header.isMD5UsageConsistent(); }
342 
343  MCSymbol *getLabel() const {
344  return Header.Label;
345  }
346 
347  void setLabel(MCSymbol *Label) {
348  Header.Label = Label;
349  }
350 
352  return Header.MCDwarfDirs;
353  }
354 
356  return Header.MCDwarfDirs;
357  }
358 
360  return Header.MCDwarfFiles;
361  }
362 
364  return Header.MCDwarfFiles;
365  }
366 
368  return MCLineSections;
369  }
371  return MCLineSections;
372  }
373 };
374 
376 public:
377  /// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas.
378  static void Encode(MCContext &Context, MCDwarfLineTableParams Params,
379  int64_t LineDelta, uint64_t AddrDelta, raw_ostream &OS);
380 
381  /// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas using
382  /// fixed length operands.
383  static bool FixedEncode(MCContext &Context,
384  MCDwarfLineTableParams Params,
385  int64_t LineDelta, uint64_t AddrDelta,
387 
388  /// Utility function to emit the encoding to a streamer.
389  static void Emit(MCStreamer *MCOS, MCDwarfLineTableParams Params,
390  int64_t LineDelta, uint64_t AddrDelta);
391 };
392 
394 public:
395  //
396  // When generating dwarf for assembly source files this emits the Dwarf
397  // sections.
398  //
399  static void Emit(MCStreamer *MCOS);
400 };
401 
402 // When generating dwarf for assembly source files this is the info that is
403 // needed to be gathered for each symbol that will have a dwarf label.
405 private:
406  // Name of the symbol without a leading underbar, if any.
407  StringRef Name;
408  // The dwarf file number this symbol is in.
409  unsigned FileNumber;
410  // The line number this symbol is at.
411  unsigned LineNumber;
412  // The low_pc for the dwarf label is taken from this symbol.
413  MCSymbol *Label;
414 
415 public:
416  MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber,
417  MCSymbol *label)
418  : Name(name), FileNumber(fileNumber), LineNumber(lineNumber),
419  Label(label) {}
420 
421  StringRef getName() const { return Name; }
422  unsigned getFileNumber() const { return FileNumber; }
423  unsigned getLineNumber() const { return LineNumber; }
424  MCSymbol *getLabel() const { return Label; }
425 
426  // This is called when label is created when we are generating dwarf for
427  // assembly source files.
428  static void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr,
429  SMLoc &Loc);
430 };
431 
433 public:
434  enum OpType {
450  OpGnuArgsSize
451  };
452 
453 private:
455  MCSymbol *Label;
456  unsigned Register;
457  union {
458  int Offset;
459  unsigned Register2;
460  };
461  std::vector<char> Values;
462 
463  MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, StringRef V)
464  : Operation(Op), Label(L), Register(R), Offset(O),
465  Values(V.begin(), V.end()) {
466  assert(Op != OpRegister);
467  }
468 
469  MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R1, unsigned R2)
470  : Operation(Op), Label(L), Register(R1), Register2(R2) {
471  assert(Op == OpRegister);
472  }
473 
474 public:
475  /// .cfi_def_cfa defines a rule for computing CFA as: take address from
476  /// Register and add Offset to it.
477  static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register,
478  int Offset) {
479  return MCCFIInstruction(OpDefCfa, L, Register, -Offset, "");
480  }
481 
482  /// .cfi_def_cfa_register modifies a rule for computing CFA. From now
483  /// on Register will be used instead of the old one. Offset remains the same.
484  static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register) {
485  return MCCFIInstruction(OpDefCfaRegister, L, Register, 0, "");
486  }
487 
488  /// .cfi_def_cfa_offset modifies a rule for computing CFA. Register
489  /// remains the same, but offset is new. Note that it is the absolute offset
490  /// that will be added to a defined register to the compute CFA address.
492  return MCCFIInstruction(OpDefCfaOffset, L, 0, -Offset, "");
493  }
494 
495  /// .cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but
496  /// Offset is a relative value that is added/subtracted from the previous
497  /// offset.
498  static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment) {
499  return MCCFIInstruction(OpAdjustCfaOffset, L, 0, Adjustment, "");
500  }
501 
502  /// .cfi_offset Previous value of Register is saved at offset Offset
503  /// from CFA.
504  static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register,
505  int Offset) {
506  return MCCFIInstruction(OpOffset, L, Register, Offset, "");
507  }
508 
509  /// .cfi_rel_offset Previous value of Register is saved at offset
510  /// Offset from the current CFA register. This is transformed to .cfi_offset
511  /// using the known displacement of the CFA register from the CFA.
512  static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register,
513  int Offset) {
514  return MCCFIInstruction(OpRelOffset, L, Register, Offset, "");
515  }
516 
517  /// .cfi_register Previous value of Register1 is saved in
518  /// register Register2.
519  static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1,
520  unsigned Register2) {
521  return MCCFIInstruction(OpRegister, L, Register1, Register2);
522  }
523 
524  /// .cfi_window_save SPARC register window is saved.
526  return MCCFIInstruction(OpWindowSave, L, 0, 0, "");
527  }
528 
529  /// .cfi_negate_ra_state AArch64 negate RA state.
531  return MCCFIInstruction(OpNegateRAState, L, 0, 0, "");
532  }
533 
534  /// .cfi_restore says that the rule for Register is now the same as it
535  /// was at the beginning of the function, after all initial instructions added
536  /// by .cfi_startproc were executed.
537  static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register) {
538  return MCCFIInstruction(OpRestore, L, Register, 0, "");
539  }
540 
541  /// .cfi_undefined From now on the previous value of Register can't be
542  /// restored anymore.
543  static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register) {
544  return MCCFIInstruction(OpUndefined, L, Register, 0, "");
545  }
546 
547  /// .cfi_same_value Current value of Register is the same as in the
548  /// previous frame. I.e., no restoration is needed.
549  static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register) {
550  return MCCFIInstruction(OpSameValue, L, Register, 0, "");
551  }
552 
553  /// .cfi_remember_state Save all current rules for all registers.
555  return MCCFIInstruction(OpRememberState, L, 0, 0, "");
556  }
557 
558  /// .cfi_restore_state Restore the previously saved state.
560  return MCCFIInstruction(OpRestoreState, L, 0, 0, "");
561  }
562 
563  /// .cfi_escape Allows the user to add arbitrary bytes to the unwind
564  /// info.
566  return MCCFIInstruction(OpEscape, L, 0, 0, Vals);
567  }
568 
569  /// A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE
571  return MCCFIInstruction(OpGnuArgsSize, L, 0, Size, "");
572  }
573 
574  OpType getOperation() const { return Operation; }
575  MCSymbol *getLabel() const { return Label; }
576 
577  unsigned getRegister() const {
578  assert(Operation == OpDefCfa || Operation == OpOffset ||
579  Operation == OpRestore || Operation == OpUndefined ||
580  Operation == OpSameValue || Operation == OpDefCfaRegister ||
581  Operation == OpRelOffset || Operation == OpRegister);
582  return Register;
583  }
584 
585  unsigned getRegister2() const {
586  assert(Operation == OpRegister);
587  return Register2;
588  }
589 
590  int getOffset() const {
591  assert(Operation == OpDefCfa || Operation == OpOffset ||
592  Operation == OpRelOffset || Operation == OpDefCfaOffset ||
593  Operation == OpAdjustCfaOffset || Operation == OpGnuArgsSize);
594  return Offset;
595  }
596 
598  assert(Operation == OpEscape);
599  return StringRef(&Values[0], Values.size());
600  }
601 };
602 
604  MCDwarfFrameInfo() = default;
605 
606  MCSymbol *Begin = nullptr;
607  MCSymbol *End = nullptr;
608  const MCSymbol *Personality = nullptr;
609  const MCSymbol *Lsda = nullptr;
610  std::vector<MCCFIInstruction> Instructions;
611  unsigned CurrentCfaRegister = 0;
612  unsigned PersonalityEncoding = 0;
613  unsigned LsdaEncoding = 0;
614  uint32_t CompactUnwindEncoding = 0;
615  bool IsSignalFrame = false;
616  bool IsSimple = false;
617  unsigned RAReg = static_cast<unsigned>(INT_MAX);
618  bool IsBKeyFrame = false;
619 };
620 
622 public:
623  //
624  // This emits the frame info section.
625  //
626  static void Emit(MCObjectStreamer &streamer, MCAsmBackend *MAB, bool isEH);
627  static void EmitAdvanceLoc(MCObjectStreamer &Streamer, uint64_t AddrDelta);
628  static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta,
629  raw_ostream &OS);
630 };
631 
632 } // end namespace llvm
633 
634 #endif // LLVM_MC_MCDWARF_H
void cantFail(Error Err, const char *Msg=nullptr)
Report a fatal error if Err is a failure value.
Definition: Error.h:703
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:38
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
unsigned getLine() const
Get the Line of this MCDwarfLoc.
Definition: MCDwarf.h:104
LLVMContext & Context
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
MCDwarfLineEntryCollection::iterator iterator
Definition: MCDwarf.h:185
Optional< StringRef > Source
The source code of the file.
Definition: MCDwarf.h:65
This class represents lattice values for constants.
Definition: AllocatorList.h:23
SmallVectorImpl< std::string > & getMCDwarfDirs()
Definition: MCDwarf.h:355
void maybeSetRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Definition: MCDwarf.h:274
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
static MCCFIInstruction createRememberState(MCSymbol *L)
.cfi_remember_state Save all current rules for all registers.
Definition: MCDwarf.h:554
SourceMgr SrcMgr
Definition: Error.cpp:23
static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_offset Previous value of Register is saved at offset Offset from CFA.
Definition: MCDwarf.h:504
const SmallVectorImpl< std::string > & getMCDwarfDirs() const
Definition: MCDwarf.h:351
unsigned getFlags() const
Get the Flags of this MCDwarfLoc.
Definition: MCDwarf.h:110
SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles()
Definition: MCDwarf.h:363
#define R2(n)
void setIsa(unsigned isa)
Set the Isa of this MCDwarfLoc.
Definition: MCDwarf.h:137
static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset)
.cfi_def_cfa_offset modifies a rule for computing CFA.
Definition: MCDwarf.h:491
static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment)
.cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but Offset is a relative value that is added/subt...
Definition: MCDwarf.h:498
std::vector< MCDwarfLineEntry > MCDwarfLineEntryCollection
Definition: MCDwarf.h:184
void setRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Definition: MCDwarf.h:252
MCDwarfLineEntry(MCSymbol *label, const MCDwarfLoc loc)
Definition: MCDwarf.h:162
std::vector< MCCFIInstruction > Instructions
Definition: MCDwarf.h:610
static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register)
.cfi_undefined From now on the previous value of Register can&#39;t be restored anymore.
Definition: MCDwarf.h:543
std::string Name
Definition: MCDwarf.h:54
bool isMD5UsageConsistent() const
Definition: MCDwarf.h:341
StringRef getName() const
Definition: MCDwarf.h:421
const MCLineDivisionMap & getMCLineEntries() const
Definition: MCDwarf.h:195
void setRootFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Definition: MCDwarf.h:318
Tagged union holding either a T or a Error.
Definition: CachePruning.h:22
Context object for machine code objects.
Definition: MCContext.h:62
void setLine(unsigned line)
Set the Line of this MCDwarfLoc.
Definition: MCDwarf.h:122
Optional< MD5::MD5Result > Checksum
The MD5 checksum, if there is one.
Definition: MCDwarf.h:61
Streaming object file generation interface.
Instances of this class represent the information from a dwarf .loc directive.
Definition: MCDwarf.h:70
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
unsigned getFileNumber() const
Definition: MCDwarf.h:422
MCSymbol * getLabel() const
Definition: MCDwarf.h:575
unsigned getFileNum() const
Get the FileNum of this MCDwarfLoc.
Definition: MCDwarf.h:101
static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register)
.cfi_same_value Current value of Register is the same as in the previous frame.
Definition: MCDwarf.h:549
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Definition: MCDwarf.h:359
static MCCFIInstruction createNegateRAState(MCSymbol *L)
.cfi_negate_ra_state AArch64 negate RA state.
Definition: MCDwarf.h:530
Streaming machine code generation interface.
Definition: MCStreamer.h:188
static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, int Offset)
.cfi_def_cfa defines a rule for computing CFA as: take address from Register and add Offset to it...
Definition: MCDwarf.h:477
unsigned getRegister2() const
Definition: MCDwarf.h:585
static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register)
.cfi_def_cfa_register modifies a rule for computing CFA.
Definition: MCDwarf.h:484
PowerPC Reduce CR logical Operation
Instances of this class represent the line information for a compile unit where machine instructions ...
Definition: MCDwarf.h:177
static MCCFIInstruction createWindowSave(MCSymbol *L)
.cfi_window_save SPARC register window is saved.
Definition: MCDwarf.h:525
void addLineEntry(const MCDwarfLineEntry &LineEntry, MCSection *Sec)
Definition: MCDwarf.h:180
static MCCFIInstruction createGnuArgsSize(MCSymbol *L, int Size)
A special wrapper for .cfi_escape that indicates GNU_ARGS_SIZE.
Definition: MCDwarf.h:570
int getOffset() const
Definition: MCDwarf.h:590
OpType getOperation() const
Definition: MCDwarf.h:574
static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int Offset)
.cfi_rel_offset Previous value of Register is saved at offset Offset from the current CFA register...
Definition: MCDwarf.h:512
static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register)
.cfi_restore says that the rule for Register is now the same as it was at the beginning of the functi...
Definition: MCDwarf.h:537
const MCDwarfFile & getRootFile() const
Definition: MCDwarf.h:338
unsigned getDiscriminator() const
Get the Discriminator of this MCDwarfLoc.
Definition: MCDwarf.h:116
unsigned getFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
Definition: MCDwarf.h:311
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Definition: SourceMgr.h:41
StringRef getValues() const
Definition: MCDwarf.h:597
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
Definition: MCDwarf.cpp:555
const MCLineSection & getMCLineSections() const
Definition: MCDwarf.h:367
static MCCFIInstruction createRestoreState(MCSymbol *L)
.cfi_restore_state Restore the previously saved state.
Definition: MCDwarf.h:559
unsigned getIsa() const
Get the Isa of this MCDwarfLoc.
Definition: MCDwarf.h:113
bool hasRootFile() const
Definition: MCDwarf.h:336
unsigned getRegister() const
Definition: MCDwarf.h:577
void trackMD5Usage(bool MD5Used)
Definition: MCDwarf.h:244
MCDwarfLineEntryCollection::const_iterator const_iterator
Definition: MCDwarf.h:186
Promote Memory to Register
Definition: Mem2Reg.cpp:109
std::string CompilationDir
Definition: MCDwarf.h:218
LLVM_NODISCARD bool isa(const Y &Val)
Definition: Casting.h:141
Instances of this class represent the line information for the dwarf line table entries.
Definition: MCDwarf.h:153
bool hasValue() const
Definition: Optional.h:259
MCLineSection & getMCLineSections()
Definition: MCDwarf.h:370
MCSymbol * getLabel() const
Definition: MCDwarf.h:165
MCSymbol * getLabel() const
Definition: MCDwarf.h:424
StringMap< unsigned > SourceIdMap
Definition: MCDwarf.h:217
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:55
unsigned getColumn() const
Get the Column of this MCDwarfLoc.
Definition: MCDwarf.h:107
uint32_t Size
Definition: Profile.cpp:46
void setFileNum(unsigned fileNum)
Set the FileNum of this MCDwarfLoc.
Definition: MCDwarf.h:119
void setFlags(unsigned flags)
Set the Flags of this MCDwarfLoc.
Definition: MCDwarf.h:131
unsigned getFile(StringRef Directory, StringRef FileName, Optional< MD5::MD5Result > Checksum, uint16_t DwarfVersion, Optional< StringRef > Source)
Definition: MCDwarf.h:282
unsigned DirIndex
Definition: MCDwarf.h:57
MCSymbol * getLabel() const
Definition: MCDwarf.h:343
MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber, MCSymbol *label)
Definition: MCDwarf.h:416
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:41
static const char * name
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:45
SmallVector< MCDwarfFile, 3 > MCDwarfFiles
Definition: MCDwarf.h:216
void setColumn(unsigned column)
Set the Column of this MCDwarfLoc.
Definition: MCDwarf.h:125
bool isMD5UsageConsistent() const
Definition: MCDwarf.h:248
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:48
Instances of this class represent the name of the dwarf .file directive and its associated dwarf file...
Definition: MCDwarf.h:52
Represents a location in source code.
Definition: SMLoc.h:23
static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals)
.cfi_escape Allows the user to add arbitrary bytes to the unwind info.
Definition: MCDwarf.h:565
unsigned getLineNumber() const
Definition: MCDwarf.h:423
SmallVector< std::string, 3 > MCDwarfDirs
Definition: MCDwarf.h:215
void setDiscriminator(unsigned discriminator)
Set the Discriminator of this MCDwarfLoc.
Definition: MCDwarf.h:143
void setLabel(MCSymbol *Label)
Definition: MCDwarf.h:347
static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2)
.cfi_register Previous value of Register1 is saved in register Register2.
Definition: MCDwarf.h:519