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