LLVM 17.0.0git
DwarfCompileUnit.cpp
Go to the documentation of this file.
1//===- llvm/CodeGen/DwarfCompileUnit.cpp - Dwarf Compile Units ------------===//
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 support for constructing a dwarf compile unit.
10//
11//===----------------------------------------------------------------------===//
12
13#include "DwarfCompileUnit.h"
14#include "AddressPool.h"
15#include "DwarfExpression.h"
16#include "llvm/ADT/STLExtras.h"
20#include "llvm/CodeGen/DIE.h"
26#include "llvm/IR/DataLayout.h"
27#include "llvm/IR/DebugInfo.h"
29#include "llvm/MC/MCSection.h"
30#include "llvm/MC/MCStreamer.h"
31#include "llvm/MC/MCSymbol.h"
37#include <iterator>
38#include <optional>
39#include <string>
40#include <utility>
41
42using namespace llvm;
43
45
46 // According to DWARF Debugging Information Format Version 5,
47 // 3.1.2 Skeleton Compilation Unit Entries:
48 // "When generating a split DWARF object file (see Section 7.3.2
49 // on page 187), the compilation unit in the .debug_info section
50 // is a "skeleton" compilation unit with the tag DW_TAG_skeleton_unit"
51 if (DW->getDwarfVersion() >= 5 && Kind == UnitKind::Skeleton)
52 return dwarf::DW_TAG_skeleton_unit;
53
54 return dwarf::DW_TAG_compile_unit;
55}
56
59 DwarfFile *DWU, UnitKind Kind)
60 : DwarfUnit(GetCompileUnitType(Kind, DW), Node, A, DW, DWU), UniqueID(UID) {
61 insertDIE(Node, &getUnitDie());
62 MacroLabelBegin = Asm->createTempSymbol("cu_macro_begin");
63}
64
65/// addLabelAddress - Add a dwarf label attribute data and value using
66/// DW_FORM_addr or DW_FORM_GNU_addr_index.
68 const MCSymbol *Label) {
69 if ((Skeleton || !DD->useSplitDwarf()) && Label)
70 DD->addArangeLabel(SymbolCU(this, Label));
71
72 // Don't use the address pool in non-fission or in the skeleton unit itself.
73 if ((!DD->useSplitDwarf() || !Skeleton) && DD->getDwarfVersion() < 5)
74 return addLocalLabelAddress(Die, Attribute, Label);
75
76 bool UseAddrOffsetFormOrExpressions =
78
79 const MCSymbol *Base = nullptr;
80 if (Label->isInSection() && UseAddrOffsetFormOrExpressions)
81 Base = DD->getSectionLabel(&Label->getSection());
82
83 if (!Base || Base == Label) {
84 unsigned idx = DD->getAddressPool().getIndex(Label);
86 DD->getDwarfVersion() >= 5 ? dwarf::DW_FORM_addrx
87 : dwarf::DW_FORM_GNU_addr_index,
88 DIEInteger(idx));
89 return;
90 }
91
92 // Could be extended to work with DWARFv4 Split DWARF if that's important for
93 // someone. In that case DW_FORM_data would be used.
94 assert(DD->getDwarfVersion() >= 5 &&
95 "Addr+offset expressions are only valuable when using debug_addr (to "
96 "reduce relocations) available in DWARFv5 or higher");
98 auto *Loc = new (DIEValueAllocator) DIEBlock();
99 addPoolOpAddress(*Loc, Label);
100 addBlock(Die, Attribute, dwarf::DW_FORM_exprloc, Loc);
101 } else
102 addAttribute(Die, Attribute, dwarf::DW_FORM_LLVM_addrx_offset,
104 DD->getAddressPool().getIndex(Base), Label, Base));
105}
106
109 const MCSymbol *Label) {
110 if (Label)
111 addAttribute(Die, Attribute, dwarf::DW_FORM_addr, DIELabel(Label));
112 else
113 addAttribute(Die, Attribute, dwarf::DW_FORM_addr, DIEInteger(0));
114}
115
117 // If we print assembly, we can't separate .file entries according to
118 // compile units. Thus all files will belong to the default compile unit.
119
120 // FIXME: add a better feature test than hasRawTextSupport. Even better,
121 // extend .file to support this.
122 unsigned CUID = Asm->OutStreamer->hasRawTextSupport() ? 0 : getUniqueID();
123 if (!File)
124 return Asm->OutStreamer->emitDwarfFileDirective(0, "", "", std::nullopt,
125 std::nullopt, CUID);
126
127 if (LastFile != File) {
128 LastFile = File;
129 LastFileID = Asm->OutStreamer->emitDwarfFileDirective(
130 0, File->getDirectory(), File->getFilename(), DD->getMD5AsBytes(File),
131 File->getSource(), CUID);
132 }
133 return LastFileID;
134}
135
137 const DIGlobalVariable *GV, ArrayRef<GlobalExpr> GlobalExprs) {
138 // Check for pre-existence.
139 if (DIE *Die = getDIE(GV))
140 return Die;
141
142 assert(GV);
143
144 auto *GVContext = GV->getScope();
145 const DIType *GTy = GV->getType();
146
147 auto *CB = GVContext ? dyn_cast<DICommonBlock>(GVContext) : nullptr;
148 DIE *ContextDIE = CB ? getOrCreateCommonBlock(CB, GlobalExprs)
149 : getOrCreateContextDIE(GVContext);
150
151 // Add to map.
152 DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV);
154 if (auto *SDMDecl = GV->getStaticDataMemberDeclaration()) {
155 DeclContext = SDMDecl->getScope();
156 assert(SDMDecl->isStaticMember() && "Expected static member decl");
157 assert(GV->isDefinition());
158 // We need the declaration DIE that is in the static member's class.
159 DIE *VariableSpecDIE = getOrCreateStaticMemberDIE(SDMDecl);
160 addDIEEntry(*VariableDIE, dwarf::DW_AT_specification, *VariableSpecDIE);
161 // If the global variable's type is different from the one in the class
162 // member type, assume that it's more specific and also emit it.
163 if (GTy != SDMDecl->getBaseType())
164 addType(*VariableDIE, GTy);
165 } else {
166 DeclContext = GV->getScope();
167 // Add name and type.
168 StringRef DisplayName = GV->getDisplayName();
169 if (!DisplayName.empty())
170 addString(*VariableDIE, dwarf::DW_AT_name, GV->getDisplayName());
171 if (GTy)
172 addType(*VariableDIE, GTy);
173
174 // Add scoping info.
175 if (!GV->isLocalToUnit())
176 addFlag(*VariableDIE, dwarf::DW_AT_external);
177
178 // Add line number info.
179 addSourceLine(*VariableDIE, GV);
180 }
181
182 if (!GV->isDefinition())
183 addFlag(*VariableDIE, dwarf::DW_AT_declaration);
184 else
185 addGlobalName(GV->getName(), *VariableDIE, DeclContext);
186
187 addAnnotation(*VariableDIE, GV->getAnnotations());
188
189 if (uint32_t AlignInBytes = GV->getAlignInBytes())
190 addUInt(*VariableDIE, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
191 AlignInBytes);
192
193 if (MDTuple *TP = GV->getTemplateParams())
194 addTemplateParams(*VariableDIE, DINodeArray(TP));
195
196 // Add location.
197 addLocationAttribute(VariableDIE, GV, GlobalExprs);
198
199 return VariableDIE;
200}
201
203 DIE *VariableDIE, const DIGlobalVariable *GV, ArrayRef<GlobalExpr> GlobalExprs) {
204 bool addToAccelTable = false;
205 DIELoc *Loc = nullptr;
206 std::optional<unsigned> NVPTXAddressSpace;
207 std::unique_ptr<DIEDwarfExpression> DwarfExpr;
208 for (const auto &GE : GlobalExprs) {
209 const GlobalVariable *Global = GE.Var;
210 const DIExpression *Expr = GE.Expr;
211
212 // For compatibility with DWARF 3 and earlier,
213 // DW_AT_location(DW_OP_constu, X, DW_OP_stack_value) or
214 // DW_AT_location(DW_OP_consts, X, DW_OP_stack_value) becomes
215 // DW_AT_const_value(X).
216 if (GlobalExprs.size() == 1 && Expr && Expr->isConstant()) {
217 addToAccelTable = true;
219 *VariableDIE,
221 *Expr->isConstant(),
222 Expr->getElement(1));
223 break;
224 }
225
226 // We cannot describe the location of dllimport'd variables: the
227 // computation of their address requires loads from the IAT.
228 if (Global && Global->hasDLLImportStorageClass())
229 continue;
230
231 // Nothing to describe without address or constant.
232 if (!Global && (!Expr || !Expr->isConstant()))
233 continue;
234
235 if (Global && Global->isThreadLocal() &&
237 continue;
238
239 if (!Loc) {
240 addToAccelTable = true;
241 Loc = new (DIEValueAllocator) DIELoc;
242 DwarfExpr = std::make_unique<DIEDwarfExpression>(*Asm, *this, *Loc);
243 }
244
245 if (Expr) {
246 // According to
247 // https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
248 // cuda-gdb requires DW_AT_address_class for all variables to be able to
249 // correctly interpret address space of the variable address.
250 // Decode DW_OP_constu <DWARF Address Space> DW_OP_swap DW_OP_xderef
251 // sequence for the NVPTX + gdb target.
252 unsigned LocalNVPTXAddressSpace;
253 if (Asm->TM.getTargetTriple().isNVPTX() && DD->tuneForGDB()) {
254 const DIExpression *NewExpr =
255 DIExpression::extractAddressClass(Expr, LocalNVPTXAddressSpace);
256 if (NewExpr != Expr) {
257 Expr = NewExpr;
258 NVPTXAddressSpace = LocalNVPTXAddressSpace;
259 }
260 }
261 DwarfExpr->addFragmentOffset(Expr);
262 }
263
264 if (Global) {
265 const MCSymbol *Sym = Asm->getSymbol(Global);
266 // 16-bit platforms like MSP430 and AVR take this path, so sink this
267 // assert to platforms that use it.
268 auto GetPointerSizedFormAndOp = [this]() {
269 unsigned PointerSize = Asm->getDataLayout().getPointerSize();
270 assert((PointerSize == 4 || PointerSize == 8) &&
271 "Add support for other sizes if necessary");
272 struct FormAndOp {
275 };
276 return PointerSize == 4
277 ? FormAndOp{dwarf::DW_FORM_data4, dwarf::DW_OP_const4u}
278 : FormAndOp{dwarf::DW_FORM_data8, dwarf::DW_OP_const8u};
279 };
280 if (Global->isThreadLocal()) {
281 if (Asm->TM.getTargetTriple().isWasm()) {
282 // FIXME This is not guaranteed, but in practice, in static linking,
283 // if present, __tls_base's index is 1. This doesn't hold for dynamic
284 // linking, so TLS variables used in dynamic linking won't have
285 // correct debug info for now. See
286 // https://github.com/llvm/llvm-project/blob/19afbfe33156d211fa959dadeea46cd17b9c723c/lld/wasm/Driver.cpp#L786-L823
287 addWasmRelocBaseGlobal(Loc, "__tls_base", 1);
288 addOpAddress(*Loc, Sym);
289 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
290 } else if (Asm->TM.useEmulatedTLS()) {
291 // TODO: add debug info for emulated thread local mode.
292 } else {
293 // FIXME: Make this work with -gsplit-dwarf.
294 // Based on GCC's support for TLS:
295 if (!DD->useSplitDwarf()) {
296 auto FormAndOp = GetPointerSizedFormAndOp();
297 // 1) Start with a constNu of the appropriate pointer size
298 addUInt(*Loc, dwarf::DW_FORM_data1, FormAndOp.Op);
299 // 2) containing the (relocated) offset of the TLS variable
300 // within the module's TLS block.
301 addExpr(*Loc, FormAndOp.Form,
303 } else {
304 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_GNU_const_index);
305 addUInt(*Loc, dwarf::DW_FORM_udata,
306 DD->getAddressPool().getIndex(Sym, /* TLS */ true));
307 }
308 // 3) followed by an OP to make the debugger do a TLS lookup.
309 addUInt(*Loc, dwarf::DW_FORM_data1,
310 DD->useGNUTLSOpcode() ? dwarf::DW_OP_GNU_push_tls_address
311 : dwarf::DW_OP_form_tls_address);
312 }
313 } else if (Asm->TM.getTargetTriple().isWasm() &&
315 // FIXME This is not guaranteed, but in practice, if present,
316 // __memory_base's index is 1. See
317 // https://github.com/llvm/llvm-project/blob/19afbfe33156d211fa959dadeea46cd17b9c723c/lld/wasm/Driver.cpp#L786-L823
318 addWasmRelocBaseGlobal(Loc, "__memory_base", 1);
319 addOpAddress(*Loc, Sym);
320 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
321 } else if ((Asm->TM.getRelocationModel() == Reloc::RWPI ||
325 .isReadOnly()) {
326 auto FormAndOp = GetPointerSizedFormAndOp();
327 // Constant
328 addUInt(*Loc, dwarf::DW_FORM_data1, FormAndOp.Op);
329 // Relocation offset
330 addExpr(*Loc, FormAndOp.Form,
332 // Base register
334 BaseReg = Asm->TM.getMCRegisterInfo()->getDwarfRegNum(BaseReg, false);
335 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + BaseReg);
336 // Offset from base register
337 addSInt(*Loc, dwarf::DW_FORM_sdata, 0);
338 // Operation
339 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus);
340 } else {
341 DD->addArangeLabel(SymbolCU(this, Sym));
342 addOpAddress(*Loc, Sym);
343 }
344 }
345 // Global variables attached to symbols are memory locations.
346 // It would be better if this were unconditional, but malformed input that
347 // mixes non-fragments and fragments for the same variable is too expensive
348 // to detect in the verifier.
349 if (DwarfExpr->isUnknownLocation())
350 DwarfExpr->setMemoryLocationKind();
351 DwarfExpr->addExpression(Expr);
352 }
353 if (Asm->TM.getTargetTriple().isNVPTX() && DD->tuneForGDB()) {
354 // According to
355 // https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
356 // cuda-gdb requires DW_AT_address_class for all variables to be able to
357 // correctly interpret address space of the variable address.
358 const unsigned NVPTX_ADDR_global_space = 5;
359 addUInt(*VariableDIE, dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,
360 NVPTXAddressSpace.value_or(NVPTX_ADDR_global_space));
361 }
362 if (Loc)
363 addBlock(*VariableDIE, dwarf::DW_AT_location, DwarfExpr->finalize());
364
365 if (DD->useAllLinkageNames())
366 addLinkageName(*VariableDIE, GV->getLinkageName());
367
368 if (addToAccelTable) {
369 DD->addAccelName(*CUNode, GV->getName(), *VariableDIE);
370
371 // If the linkage name is different than the name, go ahead and output
372 // that as well into the name table.
373 if (GV->getLinkageName() != "" && GV->getName() != GV->getLinkageName() &&
375 DD->addAccelName(*CUNode, GV->getLinkageName(), *VariableDIE);
376 }
377}
378
380 const DICommonBlock *CB, ArrayRef<GlobalExpr> GlobalExprs) {
381 // Check for pre-existence.
382 if (DIE *NDie = getDIE(CB))
383 return NDie;
384 DIE *ContextDIE = getOrCreateContextDIE(CB->getScope());
385 DIE &NDie = createAndAddDIE(dwarf::DW_TAG_common_block, *ContextDIE, CB);
386 StringRef Name = CB->getName().empty() ? "_BLNK_" : CB->getName();
387 addString(NDie, dwarf::DW_AT_name, Name);
388 addGlobalName(Name, NDie, CB->getScope());
389 if (CB->getFile())
390 addSourceLine(NDie, CB->getLineNo(), CB->getFile());
391 if (DIGlobalVariable *V = CB->getDecl())
392 getCU().addLocationAttribute(&NDie, V, GlobalExprs);
393 return &NDie;
394}
395
397 DD->insertSectionLabel(Range.Begin);
398
399 auto *PrevCU = DD->getPrevCU();
400 bool SameAsPrevCU = this == PrevCU;
401 DD->setPrevCU(this);
402 // If we have no current ranges just add the range and return, otherwise,
403 // check the current section and CU against the previous section and CU we
404 // emitted into and the subprogram was contained within. If these are the
405 // same then extend our current range, otherwise add this as a new range.
406 if (CURanges.empty() || !SameAsPrevCU ||
407 (&CURanges.back().End->getSection() !=
408 &Range.End->getSection())) {
409 // Before a new range is added, always terminate the prior line table.
410 if (PrevCU)
411 DD->terminateLineTable(PrevCU);
412 CURanges.push_back(Range);
413 return;
414 }
415
416 CURanges.back().End = Range.End;
417}
418
421 return;
422
425 LineTableStartSym = TLOF.getDwarfLineSection()->getBeginSymbol();
426 } else {
427 LineTableStartSym =
428 Asm->OutStreamer->getDwarfLineTableSymbol(getUniqueID());
429 }
430
431 // DW_AT_stmt_list is a offset of line number information for this
432 // compile unit in debug_line section. For split dwarf this is
433 // left in the skeleton CU and so not included.
434 // The line table entries are not always emitted in assembly, so it
435 // is not okay to use line_table_start here.
436 addSectionLabel(getUnitDie(), dwarf::DW_AT_stmt_list, LineTableStartSym,
438}
439
442 addSectionLabel(D, dwarf::DW_AT_stmt_list, LineTableStartSym,
444}
445
447 const MCSymbol *End) {
448 assert(Begin && "Begin label should not be null!");
449 assert(End && "End label should not be null!");
450 assert(Begin->isDefined() && "Invalid starting label");
451 assert(End->isDefined() && "Invalid end label");
452
453 addLabelAddress(D, dwarf::DW_AT_low_pc, Begin);
454 if (DD->getDwarfVersion() < 4)
455 addLabelAddress(D, dwarf::DW_AT_high_pc, End);
456 else
457 addLabelDelta(D, dwarf::DW_AT_high_pc, End, Begin);
458}
459
460// Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
461// and DW_AT_high_pc attributes. If there are global variables in this
462// scope then create and insert DIEs for these variables.
465 auto *ContextCU = static_cast<DwarfCompileUnit *>(SPDie->getUnit());
466 return ContextCU->updateSubprogramScopeDIEImpl(SP, SPDie);
467}
468
469// Add info for Wasm-global-based relocation.
470// 'GlobalIndex' is used for split dwarf, which currently relies on a few
471// assumptions that are not guaranteed in a formal way but work in practice.
472void DwarfCompileUnit::addWasmRelocBaseGlobal(DIELoc *Loc, StringRef GlobalName,
473 uint64_t GlobalIndex) {
474 // FIXME: duplicated from Target/WebAssembly/WebAssembly.h
475 // don't want to depend on target specific headers in this code?
476 const unsigned TI_GLOBAL_RELOC = 3;
477 unsigned PointerSize = Asm->getDataLayout().getPointerSize();
478 auto *Sym = cast<MCSymbolWasm>(Asm->GetExternalSymbolSymbol(GlobalName));
479 // FIXME: this repeats what WebAssemblyMCInstLower::
480 // GetExternalSymbolSymbol does, since if there's no code that
481 // refers to this symbol, we have to set it here.
482 Sym->setType(wasm::WASM_SYMBOL_TYPE_GLOBAL);
483 Sym->setGlobalType(wasm::WasmGlobalType{
484 static_cast<uint8_t>(PointerSize == 4 ? wasm::WASM_TYPE_I32
486 true});
487 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_WASM_location);
488 addSInt(*Loc, dwarf::DW_FORM_sdata, TI_GLOBAL_RELOC);
489 if (!isDwoUnit()) {
490 addLabel(*Loc, dwarf::DW_FORM_data4, Sym);
491 } else {
492 // FIXME: when writing dwo, we need to avoid relocations. Probably
493 // the "right" solution is to treat globals the way func and data
494 // symbols are (with entries in .debug_addr).
495 // For now we hardcode the indices in the callsites. Global indices are not
496 // fixed, but in practice a few are fixed; for example, __stack_pointer is
497 // always index 0.
498 addUInt(*Loc, dwarf::DW_FORM_data4, GlobalIndex);
499 }
500}
501
503 DIE *SPDie) {
505 // If basic block sections are on, ranges for each basic block section has
506 // to be emitted separately.
507 for (const auto &R : Asm->MBBSectionRanges)
508 BB_List.push_back({R.second.BeginLabel, R.second.EndLabel});
509
510 attachRangesOrLowHighPC(*SPDie, BB_List);
511
515 addFlag(*SPDie, dwarf::DW_AT_APPLE_omit_frame_ptr);
516
517 // Only include DW_AT_frame_base in full debug info
521 TFI->getDwarfFrameBase(*Asm->MF);
522 switch (FrameBase.Kind) {
525 MachineLocation Location(FrameBase.Location.Reg);
526 addAddress(*SPDie, dwarf::DW_AT_frame_base, Location);
527 }
528 break;
529 }
531 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
532 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_call_frame_cfa);
533 addBlock(*SPDie, dwarf::DW_AT_frame_base, Loc);
534 break;
535 }
537 // FIXME: duplicated from Target/WebAssembly/WebAssembly.h
538 const unsigned TI_GLOBAL_RELOC = 3;
539 if (FrameBase.Location.WasmLoc.Kind == TI_GLOBAL_RELOC) {
540 // These need to be relocatable.
541 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
542 assert(FrameBase.Location.WasmLoc.Index == 0); // Only SP so far.
543 // For now, since we only ever use index 0, this should work as-is.
544 addWasmRelocBaseGlobal(Loc, "__stack_pointer",
545 FrameBase.Location.WasmLoc.Index);
546 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_stack_value);
547 addBlock(*SPDie, dwarf::DW_AT_frame_base, Loc);
548 } else {
549 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
550 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
551 DIExpressionCursor Cursor({});
552 DwarfExpr.addWasmLocation(FrameBase.Location.WasmLoc.Kind,
553 FrameBase.Location.WasmLoc.Index);
554 DwarfExpr.addExpression(std::move(Cursor));
555 addBlock(*SPDie, dwarf::DW_AT_frame_base, DwarfExpr.finalize());
556 }
557 break;
558 }
559 }
560 }
561
562 // Add name to the name table, we do this here because we're guaranteed
563 // to have concrete versions of our DW_TAG_subprogram nodes.
564 DD->addSubprogramNames(*CUNode, SP, *SPDie);
565
566 return *SPDie;
567}
568
569// Construct a DIE for this scope.
571 DIE &ParentScopeDIE) {
572 if (!Scope || !Scope->getScopeNode())
573 return;
574
575 auto *DS = Scope->getScopeNode();
576
577 assert((Scope->getInlinedAt() || !isa<DISubprogram>(DS)) &&
578 "Only handle inlined subprograms here, use "
579 "constructSubprogramScopeDIE for non-inlined "
580 "subprograms");
581
582 // Emit inlined subprograms.
583 if (Scope->getParent() && isa<DISubprogram>(DS)) {
584 DIE *ScopeDIE = constructInlinedScopeDIE(Scope, ParentScopeDIE);
585 assert(ScopeDIE && "Scope DIE should not be null.");
586 createAndAddScopeChildren(Scope, *ScopeDIE);
587 return;
588 }
589
590 // Early exit when we know the scope DIE is going to be null.
591 if (DD->isLexicalScopeDIENull(Scope))
592 return;
593
594 // Emit lexical blocks.
595 DIE *ScopeDIE = constructLexicalScopeDIE(Scope);
596 assert(ScopeDIE && "Scope DIE should not be null.");
597
598 ParentScopeDIE.addChild(ScopeDIE);
599 createAndAddScopeChildren(Scope, *ScopeDIE);
600}
601
604
605 HasRangeLists = true;
606
607 // Add the range list to the set of ranges to be emitted.
608 auto IndexAndList =
609 (DD->getDwarfVersion() < 5 && Skeleton ? Skeleton->DU : DU)
610 ->addRange(*(Skeleton ? Skeleton : this), std::move(Range));
611
612 uint32_t Index = IndexAndList.first;
613 auto &List = *IndexAndList.second;
614
615 // Under fission, ranges are specified by constant offsets relative to the
616 // CU's DW_AT_GNU_ranges_base.
617 // FIXME: For DWARF v5, do not generate the DW_AT_ranges attribute under
618 // fission until we support the forms using the .debug_addr section
619 // (DW_RLE_startx_endx etc.).
620 if (DD->getDwarfVersion() >= 5)
621 addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_rnglistx, Index);
622 else {
624 const MCSymbol *RangeSectionSym =
626 if (isDwoUnit())
627 addSectionDelta(ScopeDIE, dwarf::DW_AT_ranges, List.Label,
628 RangeSectionSym);
629 else
630 addSectionLabel(ScopeDIE, dwarf::DW_AT_ranges, List.Label,
631 RangeSectionSym);
632 }
633}
634
636 DIE &Die, SmallVector<RangeSpan, 2> Ranges) {
637 assert(!Ranges.empty());
638 if (!DD->useRangesSection() ||
639 (Ranges.size() == 1 &&
640 (!DD->alwaysUseRanges() ||
641 DD->getSectionLabel(&Ranges.front().Begin->getSection()) ==
642 Ranges.front().Begin))) {
643 const RangeSpan &Front = Ranges.front();
644 const RangeSpan &Back = Ranges.back();
645 attachLowHighPC(Die, Front.Begin, Back.End);
646 } else
647 addScopeRangeList(Die, std::move(Ranges));
648}
649
651 DIE &Die, const SmallVectorImpl<InsnRange> &Ranges) {
653 List.reserve(Ranges.size());
654 for (const InsnRange &R : Ranges) {
655 auto *BeginLabel = DD->getLabelBeforeInsn(R.first);
656 auto *EndLabel = DD->getLabelAfterInsn(R.second);
657
658 const auto *BeginMBB = R.first->getParent();
659 const auto *EndMBB = R.second->getParent();
660
661 const auto *MBB = BeginMBB;
662 // Basic block sections allows basic block subsets to be placed in unique
663 // sections. For each section, the begin and end label must be added to the
664 // list. If there is more than one range, debug ranges must be used.
665 // Otherwise, low/high PC can be used.
666 // FIXME: Debug Info Emission depends on block order and this assumes that
667 // the order of blocks will be frozen beyond this point.
668 do {
669 if (MBB->sameSection(EndMBB) || MBB->isEndSection()) {
670 auto MBBSectionRange = Asm->MBBSectionRanges[MBB->getSectionIDNum()];
671 List.push_back(
672 {MBB->sameSection(BeginMBB) ? BeginLabel
673 : MBBSectionRange.BeginLabel,
674 MBB->sameSection(EndMBB) ? EndLabel : MBBSectionRange.EndLabel});
675 }
676 if (MBB->sameSection(EndMBB))
677 break;
678 MBB = MBB->getNextNode();
679 } while (true);
680 }
681 attachRangesOrLowHighPC(Die, std::move(List));
682}
683
685 DIE &ParentScopeDIE) {
686 assert(Scope->getScopeNode());
687 auto *DS = Scope->getScopeNode();
688 auto *InlinedSP = getDISubprogram(DS);
689 // Find the subprogram's DwarfCompileUnit in the SPMap in case the subprogram
690 // was inlined from another compile unit.
691 DIE *OriginDIE = getAbstractSPDies()[InlinedSP];
692 assert(OriginDIE && "Unable to find original DIE for an inlined subprogram.");
693
694 auto ScopeDIE = DIE::get(DIEValueAllocator, dwarf::DW_TAG_inlined_subroutine);
695 ParentScopeDIE.addChild(ScopeDIE);
696 addDIEEntry(*ScopeDIE, dwarf::DW_AT_abstract_origin, *OriginDIE);
697
698 attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges());
699
700 // Add the call site information to the DIE.
701 const DILocation *IA = Scope->getInlinedAt();
702 addUInt(*ScopeDIE, dwarf::DW_AT_call_file, std::nullopt,
703 getOrCreateSourceID(IA->getFile()));
704 addUInt(*ScopeDIE, dwarf::DW_AT_call_line, std::nullopt, IA->getLine());
705 if (IA->getColumn())
706 addUInt(*ScopeDIE, dwarf::DW_AT_call_column, std::nullopt, IA->getColumn());
707 if (IA->getDiscriminator() && DD->getDwarfVersion() >= 4)
708 addUInt(*ScopeDIE, dwarf::DW_AT_GNU_discriminator, std::nullopt,
709 IA->getDiscriminator());
710
711 // Add name to the name table, we do this here because we're guaranteed
712 // to have concrete versions of our DW_TAG_inlined_subprogram nodes.
713 DD->addSubprogramNames(*CUNode, InlinedSP, *ScopeDIE);
714
715 return ScopeDIE;
716}
717
718// Construct new DW_TAG_lexical_block for this scope and attach
719// DW_AT_low_pc/DW_AT_high_pc labels.
721 if (DD->isLexicalScopeDIENull(Scope))
722 return nullptr;
723
724 auto ScopeDIE = DIE::get(DIEValueAllocator, dwarf::DW_TAG_lexical_block);
725 if (Scope->isAbstractScope())
726 return ScopeDIE;
727
728 attachRangesOrLowHighPC(*ScopeDIE, Scope->getRanges());
729
730 return ScopeDIE;
731}
732
733/// constructVariableDIE - Construct a DIE for the given DbgVariable.
735 auto D = constructVariableDIEImpl(DV, Abstract);
736 DV.setDIE(*D);
737 return D;
738}
739
741 const LexicalScope &Scope) {
742 auto LabelDie = DIE::get(DIEValueAllocator, DL.getTag());
743 insertDIE(DL.getLabel(), LabelDie);
744 DL.setDIE(*LabelDie);
745
746 if (Scope.isAbstractScope())
747 applyLabelAttributes(DL, *LabelDie);
748
749 return LabelDie;
750}
751
752DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
753 bool Abstract) {
754 // Define variable debug information entry.
755 auto VariableDie = DIE::get(DIEValueAllocator, DV.getTag());
756 insertDIE(DV.getVariable(), VariableDie);
757
758 if (Abstract) {
759 applyVariableAttributes(DV, *VariableDie);
760 return VariableDie;
761 }
762
763 // Add variable address.
764
765 unsigned Index = DV.getDebugLocListIndex();
766 if (Index != ~0U) {
767 addLocationList(*VariableDie, dwarf::DW_AT_location, Index);
768 auto TagOffset = DV.getDebugLocListTagOffset();
769 if (TagOffset)
770 addUInt(*VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
771 *TagOffset);
772 return VariableDie;
773 }
774
775 // Check if variable has a single location description.
776 if (auto *DVal = DV.getValueLoc()) {
777 if (!DVal->isVariadic()) {
778 const DbgValueLocEntry *Entry = DVal->getLocEntries().begin();
779 if (Entry->isLocation()) {
780 addVariableAddress(DV, *VariableDie, Entry->getLoc());
781 } else if (Entry->isInt()) {
782 auto *Expr = DV.getSingleExpression();
783 if (Expr && Expr->getNumElements()) {
784 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
785 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
786 // If there is an expression, emit raw unsigned bytes.
787 DwarfExpr.addFragmentOffset(Expr);
788 DwarfExpr.addUnsignedConstant(Entry->getInt());
789 DwarfExpr.addExpression(Expr);
790 addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
791 if (DwarfExpr.TagOffset)
792 addUInt(*VariableDie, dwarf::DW_AT_LLVM_tag_offset,
793 dwarf::DW_FORM_data1, *DwarfExpr.TagOffset);
794 } else
795 addConstantValue(*VariableDie, Entry->getInt(), DV.getType());
796 } else if (Entry->isConstantFP()) {
797 addConstantFPValue(*VariableDie, Entry->getConstantFP());
798 } else if (Entry->isConstantInt()) {
799 addConstantValue(*VariableDie, Entry->getConstantInt(), DV.getType());
800 } else if (Entry->isTargetIndexLocation()) {
801 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
802 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
803 const DIBasicType *BT = dyn_cast<DIBasicType>(
804 static_cast<const Metadata *>(DV.getVariable()->getType()));
805 DwarfDebug::emitDebugLocValue(*Asm, BT, *DVal, DwarfExpr);
806 addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
807 }
808 return VariableDie;
809 }
810 // If any of the location entries are registers with the value 0, then the
811 // location is undefined.
812 if (any_of(DVal->getLocEntries(), [](const DbgValueLocEntry &Entry) {
813 return Entry.isLocation() && !Entry.getLoc().getReg();
814 }))
815 return VariableDie;
816 const DIExpression *Expr = DV.getSingleExpression();
817 assert(Expr && "Variadic Debug Value must have an Expression.");
818 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
819 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
820 DwarfExpr.addFragmentOffset(Expr);
821 DIExpressionCursor Cursor(Expr);
823
824 auto AddEntry = [&](const DbgValueLocEntry &Entry,
825 DIExpressionCursor &Cursor) {
826 if (Entry.isLocation()) {
827 if (!DwarfExpr.addMachineRegExpression(TRI, Cursor,
828 Entry.getLoc().getReg()))
829 return false;
830 } else if (Entry.isInt()) {
831 // If there is an expression, emit raw unsigned bytes.
832 DwarfExpr.addUnsignedConstant(Entry.getInt());
833 } else if (Entry.isConstantFP()) {
834 // DwarfExpression does not support arguments wider than 64 bits
835 // (see PR52584).
836 // TODO: Consider chunking expressions containing overly wide
837 // arguments into separate pointer-sized fragment expressions.
838 APInt RawBytes = Entry.getConstantFP()->getValueAPF().bitcastToAPInt();
839 if (RawBytes.getBitWidth() > 64)
840 return false;
841 DwarfExpr.addUnsignedConstant(RawBytes.getZExtValue());
842 } else if (Entry.isConstantInt()) {
843 APInt RawBytes = Entry.getConstantInt()->getValue();
844 if (RawBytes.getBitWidth() > 64)
845 return false;
846 DwarfExpr.addUnsignedConstant(RawBytes.getZExtValue());
847 } else if (Entry.isTargetIndexLocation()) {
848 TargetIndexLocation Loc = Entry.getTargetIndexLocation();
849 // TODO TargetIndexLocation is a target-independent. Currently only the
850 // WebAssembly-specific encoding is supported.
852 DwarfExpr.addWasmLocation(Loc.Index, static_cast<uint64_t>(Loc.Offset));
853 } else {
854 llvm_unreachable("Unsupported Entry type.");
855 }
856 return true;
857 };
858
859 if (!DwarfExpr.addExpression(
860 std::move(Cursor),
861 [&](unsigned Idx, DIExpressionCursor &Cursor) -> bool {
862 return AddEntry(DVal->getLocEntries()[Idx], Cursor);
863 }))
864 return VariableDie;
865
866 // Now attach the location information to the DIE.
867 addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
868 if (DwarfExpr.TagOffset)
869 addUInt(*VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
870 *DwarfExpr.TagOffset);
871
872 return VariableDie;
873 }
874
875 // .. else use frame index.
876 if (!DV.hasFrameIndexExprs())
877 return VariableDie;
878
879 std::optional<unsigned> NVPTXAddressSpace;
880 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
881 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
882 for (const auto &Fragment : DV.getFrameIndexExprs()) {
883 Register FrameReg;
884 const DIExpression *Expr = Fragment.Expr;
887 TFI->getFrameIndexReference(*Asm->MF, Fragment.FI, FrameReg);
888 DwarfExpr.addFragmentOffset(Expr);
889
890 auto *TRI = Asm->MF->getSubtarget().getRegisterInfo();
892 TRI->getOffsetOpcodes(Offset, Ops);
893
894 // According to
895 // https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
896 // cuda-gdb requires DW_AT_address_class for all variables to be able to
897 // correctly interpret address space of the variable address.
898 // Decode DW_OP_constu <DWARF Address Space> DW_OP_swap DW_OP_xderef
899 // sequence for the NVPTX + gdb target.
900 unsigned LocalNVPTXAddressSpace;
901 if (Asm->TM.getTargetTriple().isNVPTX() && DD->tuneForGDB()) {
902 const DIExpression *NewExpr =
903 DIExpression::extractAddressClass(Expr, LocalNVPTXAddressSpace);
904 if (NewExpr != Expr) {
905 Expr = NewExpr;
906 NVPTXAddressSpace = LocalNVPTXAddressSpace;
907 }
908 }
909 if (Expr)
910 Ops.append(Expr->elements_begin(), Expr->elements_end());
911 DIExpressionCursor Cursor(Ops);
912 DwarfExpr.setMemoryLocationKind();
913 if (const MCSymbol *FrameSymbol = Asm->getFunctionFrameSymbol())
914 addOpAddress(*Loc, FrameSymbol);
915 else
916 DwarfExpr.addMachineRegExpression(
917 *Asm->MF->getSubtarget().getRegisterInfo(), Cursor, FrameReg);
918 DwarfExpr.addExpression(std::move(Cursor));
919 }
920 if (Asm->TM.getTargetTriple().isNVPTX() && DD->tuneForGDB()) {
921 // According to
922 // https://docs.nvidia.com/cuda/archive/10.0/ptx-writers-guide-to-interoperability/index.html#cuda-specific-dwarf
923 // cuda-gdb requires DW_AT_address_class for all variables to be able to
924 // correctly interpret address space of the variable address.
925 const unsigned NVPTX_ADDR_local_space = 6;
926 addUInt(*VariableDie, dwarf::DW_AT_address_class, dwarf::DW_FORM_data1,
927 NVPTXAddressSpace.value_or(NVPTX_ADDR_local_space));
928 }
929 addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize());
930 if (DwarfExpr.TagOffset)
931 addUInt(*VariableDie, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
932 *DwarfExpr.TagOffset);
933
934 return VariableDie;
935}
936
938 const LexicalScope &Scope,
939 DIE *&ObjectPointer) {
940 auto Var = constructVariableDIE(DV, Scope.isAbstractScope());
941 if (DV.isObjectPointer())
942 ObjectPointer = Var;
943 return Var;
944}
945
946/// Return all DIVariables that appear in count: expressions.
949 auto *Array = dyn_cast<DICompositeType>(Var->getType());
950 if (!Array || Array->getTag() != dwarf::DW_TAG_array_type)
951 return Result;
952 if (auto *DLVar = Array->getDataLocation())
953 Result.push_back(DLVar);
954 if (auto *AsVar = Array->getAssociated())
955 Result.push_back(AsVar);
956 if (auto *AlVar = Array->getAllocated())
957 Result.push_back(AlVar);
958 for (auto *El : Array->getElements()) {
959 if (auto *Subrange = dyn_cast<DISubrange>(El)) {
960 if (auto Count = Subrange->getCount())
961 if (auto *Dependency = Count.dyn_cast<DIVariable *>())
962 Result.push_back(Dependency);
963 if (auto LB = Subrange->getLowerBound())
964 if (auto *Dependency = LB.dyn_cast<DIVariable *>())
965 Result.push_back(Dependency);
966 if (auto UB = Subrange->getUpperBound())
967 if (auto *Dependency = UB.dyn_cast<DIVariable *>())
968 Result.push_back(Dependency);
969 if (auto ST = Subrange->getStride())
970 if (auto *Dependency = ST.dyn_cast<DIVariable *>())
971 Result.push_back(Dependency);
972 } else if (auto *GenericSubrange = dyn_cast<DIGenericSubrange>(El)) {
973 if (auto Count = GenericSubrange->getCount())
974 if (auto *Dependency = Count.dyn_cast<DIVariable *>())
975 Result.push_back(Dependency);
976 if (auto LB = GenericSubrange->getLowerBound())
977 if (auto *Dependency = LB.dyn_cast<DIVariable *>())
978 Result.push_back(Dependency);
979 if (auto UB = GenericSubrange->getUpperBound())
980 if (auto *Dependency = UB.dyn_cast<DIVariable *>())
981 Result.push_back(Dependency);
982 if (auto ST = GenericSubrange->getStride())
983 if (auto *Dependency = ST.dyn_cast<DIVariable *>())
984 Result.push_back(Dependency);
985 }
986 }
987 return Result;
988}
989
990/// Sort local variables so that variables appearing inside of helper
991/// expressions come first.
996 // Map back from a DIVariable to its containing DbgVariable.
998 // Set of DbgVariables in Result.
1000 // For cycle detection.
1002
1003 // Initialize the worklist and the DIVariable lookup table.
1004 for (auto *Var : reverse(Input)) {
1005 DbgVar.insert({Var->getVariable(), Var});
1006 WorkList.push_back({Var, 0});
1007 }
1008
1009 // Perform a stable topological sort by doing a DFS.
1010 while (!WorkList.empty()) {
1011 auto Item = WorkList.back();
1012 DbgVariable *Var = Item.getPointer();
1013 bool visitedAllDependencies = Item.getInt();
1014 WorkList.pop_back();
1015
1016 assert(Var);
1017
1018 // Already handled.
1019 if (Visited.count(Var))
1020 continue;
1021
1022 // Add to Result if all dependencies are visited.
1023 if (visitedAllDependencies) {
1024 Visited.insert(Var);
1025 Result.push_back(Var);
1026 continue;
1027 }
1028
1029 // Detect cycles.
1030 auto Res = Visiting.insert(Var);
1031 if (!Res.second) {
1032 assert(false && "dependency cycle in local variables");
1033 return Result;
1034 }
1035
1036 // Push dependencies and this node onto the worklist, so that this node is
1037 // visited again after all of its dependencies are handled.
1038 WorkList.push_back({Var, 1});
1039 for (const auto *Dependency : dependencies(Var)) {
1040 // Don't add dependency if it is in a different lexical scope or a global.
1041 if (const auto *Dep = dyn_cast<const DILocalVariable>(Dependency))
1042 if (DbgVariable *Var = DbgVar.lookup(Dep))
1043 WorkList.push_back({Var, 0});
1044 }
1045 }
1046 return Result;
1047}
1048
1050 LexicalScope *Scope) {
1051 DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
1052 auto *ContextCU = static_cast<DwarfCompileUnit *>(ScopeDIE.getUnit());
1053
1054 if (Scope) {
1055 assert(!Scope->getInlinedAt());
1056 assert(!Scope->isAbstractScope());
1057 // Collect lexical scope children first.
1058 // ObjectPointer might be a local (non-argument) local variable if it's a
1059 // block's synthetic this pointer.
1060 if (DIE *ObjectPointer =
1061 ContextCU->createAndAddScopeChildren(Scope, ScopeDIE))
1062 ContextCU->addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer,
1063 *ObjectPointer);
1064 }
1065
1066 // If this is a variadic function, add an unspecified parameter.
1067 DITypeRefArray FnArgs = Sub->getType()->getTypeArray();
1068
1069 // If we have a single element of null, it is a function that returns void.
1070 // If we have more than one elements and the last one is null, it is a
1071 // variadic function.
1072 if (FnArgs.size() > 1 && !FnArgs[FnArgs.size() - 1] &&
1074 ScopeDIE.addChild(
1075 DIE::get(DIEValueAllocator, dwarf::DW_TAG_unspecified_parameters));
1076
1077 return ScopeDIE;
1078}
1079
1081 DIE &ScopeDIE) {
1082 DIE *ObjectPointer = nullptr;
1083
1084 // Emit function arguments (order is significant).
1085 auto Vars = DU->getScopeVariables().lookup(Scope);
1086 for (auto &DV : Vars.Args)
1087 ScopeDIE.addChild(constructVariableDIE(*DV.second, *Scope, ObjectPointer));
1088
1089 // Emit local variables.
1090 auto Locals = sortLocalVars(Vars.Locals);
1091 for (DbgVariable *DV : Locals)
1092 ScopeDIE.addChild(constructVariableDIE(*DV, *Scope, ObjectPointer));
1093
1094 // Emit imported entities (skipped in gmlt-like data).
1096 for (const auto *IE : ImportedEntities[Scope->getScopeNode()])
1097 ScopeDIE.addChild(constructImportedEntityDIE(cast<DIImportedEntity>(IE)));
1098 }
1099
1100 // Emit labels.
1101 for (DbgLabel *DL : DU->getScopeLabels().lookup(Scope))
1102 ScopeDIE.addChild(constructLabelDIE(*DL, *Scope));
1103
1104 // Emit inner lexical scopes.
1105 auto needToEmitLexicalScope = [this](LexicalScope *LS) {
1106 if (isa<DISubprogram>(LS->getScopeNode()))
1107 return true;
1108 auto Vars = DU->getScopeVariables().lookup(LS);
1109 if (!Vars.Args.empty() || !Vars.Locals.empty())
1110 return true;
1112 !ImportedEntities[LS->getScopeNode()].empty())
1113 return true;
1114 return false;
1115 };
1116 for (LexicalScope *LS : Scope->getChildren()) {
1117 // If the lexical block doesn't have non-scope children, skip
1118 // its emission and put its children directly to the parent scope.
1119 if (needToEmitLexicalScope(LS))
1120 constructScopeDIE(LS, ScopeDIE);
1121 else
1122 createAndAddScopeChildren(LS, ScopeDIE);
1123 }
1124
1125 return ObjectPointer;
1126}
1127
1129 LexicalScope *Scope) {
1130 DIE *&AbsDef = getAbstractSPDies()[Scope->getScopeNode()];
1131 if (AbsDef)
1132 return;
1133
1134 auto *SP = cast<DISubprogram>(Scope->getScopeNode());
1135
1136 DIE *ContextDIE;
1137 DwarfCompileUnit *ContextCU = this;
1138
1140 ContextDIE = &getUnitDie();
1141 // Some of this is duplicated from DwarfUnit::getOrCreateSubprogramDIE, with
1142 // the important distinction that the debug node is not associated with the
1143 // DIE (since the debug node will be associated with the concrete DIE, if
1144 // any). It could be refactored to some common utility function.
1145 else if (auto *SPDecl = SP->getDeclaration()) {
1146 ContextDIE = &getUnitDie();
1148 } else {
1149 ContextDIE = getOrCreateContextDIE(SP->getScope());
1150 // The scope may be shared with a subprogram that has already been
1151 // constructed in another CU, in which case we need to construct this
1152 // subprogram in the same CU.
1153 ContextCU = DD->lookupCU(ContextDIE->getUnitDie());
1154 }
1155
1156 // Passing null as the associated node because the abstract definition
1157 // shouldn't be found by lookup.
1158 AbsDef = &ContextCU->createAndAddDIE(dwarf::DW_TAG_subprogram, *ContextDIE, nullptr);
1159 ContextCU->applySubprogramAttributesToDefinition(SP, *AbsDef);
1160 ContextCU->addSInt(*AbsDef, dwarf::DW_AT_inline,
1161 DD->getDwarfVersion() <= 4 ? std::optional<dwarf::Form>()
1162 : dwarf::DW_FORM_implicit_const,
1164 if (DIE *ObjectPointer = ContextCU->createAndAddScopeChildren(Scope, *AbsDef))
1165 ContextCU->addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
1166}
1167
1169 return DD->getDwarfVersion() == 4 && !DD->tuneForLLDB();
1170}
1171
1174 return Tag;
1175 switch (Tag) {
1176 case dwarf::DW_TAG_call_site:
1177 return dwarf::DW_TAG_GNU_call_site;
1178 case dwarf::DW_TAG_call_site_parameter:
1179 return dwarf::DW_TAG_GNU_call_site_parameter;
1180 default:
1181 llvm_unreachable("DWARF5 tag with no GNU analog");
1182 }
1183}
1184
1188 return Attr;
1189 switch (Attr) {
1190 case dwarf::DW_AT_call_all_calls:
1191 return dwarf::DW_AT_GNU_all_call_sites;
1192 case dwarf::DW_AT_call_target:
1193 return dwarf::DW_AT_GNU_call_site_target;
1194 case dwarf::DW_AT_call_origin:
1195 return dwarf::DW_AT_abstract_origin;
1196 case dwarf::DW_AT_call_return_pc:
1197 return dwarf::DW_AT_low_pc;
1198 case dwarf::DW_AT_call_value:
1199 return dwarf::DW_AT_GNU_call_site_value;
1200 case dwarf::DW_AT_call_tail_call:
1201 return dwarf::DW_AT_GNU_tail_call;
1202 default:
1203 llvm_unreachable("DWARF5 attribute with no GNU analog");
1204 }
1205}
1206
1210 return Loc;
1211 switch (Loc) {
1212 case dwarf::DW_OP_entry_value:
1213 return dwarf::DW_OP_GNU_entry_value;
1214 default:
1215 llvm_unreachable("DWARF5 location atom with no GNU analog");
1216 }
1217}
1218
1220 const DISubprogram *CalleeSP,
1221 bool IsTail,
1222 const MCSymbol *PCAddr,
1223 const MCSymbol *CallAddr,
1224 unsigned CallReg) {
1225 // Insert a call site entry DIE within ScopeDIE.
1226 DIE &CallSiteDIE = createAndAddDIE(getDwarf5OrGNUTag(dwarf::DW_TAG_call_site),
1227 ScopeDIE, nullptr);
1228
1229 if (CallReg) {
1230 // Indirect call.
1231 addAddress(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_target),
1232 MachineLocation(CallReg));
1233 } else {
1234 DIE *CalleeDIE = getOrCreateSubprogramDIE(CalleeSP);
1235 assert(CalleeDIE && "Could not create DIE for call site entry origin");
1236 addDIEEntry(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_origin),
1237 *CalleeDIE);
1238 }
1239
1240 if (IsTail) {
1241 // Attach DW_AT_call_tail_call to tail calls for standards compliance.
1242 addFlag(CallSiteDIE, getDwarf5OrGNUAttr(dwarf::DW_AT_call_tail_call));
1243
1244 // Attach the address of the branch instruction to allow the debugger to
1245 // show where the tail call occurred. This attribute has no GNU analog.
1246 //
1247 // GDB works backwards from non-standard usage of DW_AT_low_pc (in DWARF4
1248 // mode -- equivalently, in DWARF5 mode, DW_AT_call_return_pc) at tail-call
1249 // site entries to figure out the PC of tail-calling branch instructions.
1250 // This means it doesn't need the compiler to emit DW_AT_call_pc, so we
1251 // don't emit it here.
1252 //
1253 // There's no need to tie non-GDB debuggers to this non-standardness, as it
1254 // adds unnecessary complexity to the debugger. For non-GDB debuggers, emit
1255 // the standard DW_AT_call_pc info.
1257 addLabelAddress(CallSiteDIE, dwarf::DW_AT_call_pc, CallAddr);
1258 }
1259
1260 // Attach the return PC to allow the debugger to disambiguate call paths
1261 // from one function to another.
1262 //
1263 // The return PC is only really needed when the call /isn't/ a tail call, but
1264 // GDB expects it in DWARF4 mode, even for tail calls (see the comment above
1265 // the DW_AT_call_pc emission logic for an explanation).
1266 if (!IsTail || useGNUAnalogForDwarf5Feature()) {
1267 assert(PCAddr && "Missing return PC information for a call");
1268 addLabelAddress(CallSiteDIE,
1269 getDwarf5OrGNUAttr(dwarf::DW_AT_call_return_pc), PCAddr);
1270 }
1271
1272 return CallSiteDIE;
1273}
1274
1276 DIE &CallSiteDIE, SmallVector<DbgCallSiteParam, 4> &Params) {
1277 for (const auto &Param : Params) {
1278 unsigned Register = Param.getRegister();
1279 auto CallSiteDieParam =
1281 getDwarf5OrGNUTag(dwarf::DW_TAG_call_site_parameter));
1282 insertDIE(CallSiteDieParam);
1283 addAddress(*CallSiteDieParam, dwarf::DW_AT_location,
1285
1286 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
1287 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
1288 DwarfExpr.setCallSiteParamValueFlag();
1289
1290 DwarfDebug::emitDebugLocValue(*Asm, nullptr, Param.getValue(), DwarfExpr);
1291
1292 addBlock(*CallSiteDieParam, getDwarf5OrGNUAttr(dwarf::DW_AT_call_value),
1293 DwarfExpr.finalize());
1294
1295 CallSiteDIE.addChild(CallSiteDieParam);
1296 }
1297}
1298
1300 const DIImportedEntity *Module) {
1301 DIE *IMDie = DIE::get(DIEValueAllocator, (dwarf::Tag)Module->getTag());
1302 insertDIE(Module, IMDie);
1303 DIE *EntityDie;
1304 auto *Entity = Module->getEntity();
1305 if (auto *NS = dyn_cast<DINamespace>(Entity))
1306 EntityDie = getOrCreateNameSpace(NS);
1307 else if (auto *M = dyn_cast<DIModule>(Entity))
1308 EntityDie = getOrCreateModule(M);
1309 else if (auto *SP = dyn_cast<DISubprogram>(Entity))
1310 EntityDie = getOrCreateSubprogramDIE(SP);
1311 else if (auto *T = dyn_cast<DIType>(Entity))
1312 EntityDie = getOrCreateTypeDIE(T);
1313 else if (auto *GV = dyn_cast<DIGlobalVariable>(Entity))
1314 EntityDie = getOrCreateGlobalVariableDIE(GV, {});
1315 else
1316 EntityDie = getDIE(Entity);
1317 assert(EntityDie);
1318 addSourceLine(*IMDie, Module->getLine(), Module->getFile());
1319 addDIEEntry(*IMDie, dwarf::DW_AT_import, *EntityDie);
1321 if (!Name.empty()) {
1322 addString(*IMDie, dwarf::DW_AT_name, Name);
1323
1324 // FIXME: if consumers ever start caring about handling
1325 // unnamed import declarations such as `using ::nullptr_t`
1326 // or `using namespace std::ranges`, we could add the
1327 // import declaration into the accelerator table with the
1328 // name being the one of the entity being imported.
1329 DD->addAccelNamespace(*CUNode, Name, *IMDie);
1330 }
1331
1332 // This is for imported module with renamed entities (such as variables and
1333 // subprograms).
1334 DINodeArray Elements = Module->getElements();
1335 for (const auto *Element : Elements) {
1336 if (!Element)
1337 continue;
1338 IMDie->addChild(
1339 constructImportedEntityDIE(cast<DIImportedEntity>(Element)));
1340 }
1341
1342 return IMDie;
1343}
1344
1346 DIE *D = getDIE(SP);
1347 if (DIE *AbsSPDIE = getAbstractSPDies().lookup(SP)) {
1348 if (D)
1349 // If this subprogram has an abstract definition, reference that
1350 addDIEEntry(*D, dwarf::DW_AT_abstract_origin, *AbsSPDIE);
1351 } else {
1353 if (D)
1354 // And attach the attributes
1356 }
1357}
1358
1360 DbgEntity *AbsEntity = getExistingAbstractEntity(Entity->getEntity());
1361
1362 auto *Die = Entity->getDIE();
1363 /// Label may be used to generate DW_AT_low_pc, so put it outside
1364 /// if/else block.
1365 const DbgLabel *Label = nullptr;
1366 if (AbsEntity && AbsEntity->getDIE()) {
1367 addDIEEntry(*Die, dwarf::DW_AT_abstract_origin, *AbsEntity->getDIE());
1368 Label = dyn_cast<const DbgLabel>(Entity);
1369 } else {
1370 if (const DbgVariable *Var = dyn_cast<const DbgVariable>(Entity))
1371 applyVariableAttributes(*Var, *Die);
1372 else if ((Label = dyn_cast<const DbgLabel>(Entity)))
1373 applyLabelAttributes(*Label, *Die);
1374 else
1375 llvm_unreachable("DbgEntity must be DbgVariable or DbgLabel.");
1376 }
1377
1378 if (Label)
1379 if (const auto *Sym = Label->getSymbol())
1380 addLabelAddress(*Die, dwarf::DW_AT_low_pc, Sym);
1381}
1382
1384 auto &AbstractEntities = getAbstractEntities();
1385 auto I = AbstractEntities.find(Node);
1386 if (I != AbstractEntities.end())
1387 return I->second.get();
1388 return nullptr;
1389}
1390
1392 LexicalScope *Scope) {
1393 assert(Scope && Scope->isAbstractScope());
1394 auto &Entity = getAbstractEntities()[Node];
1395 if (isa<const DILocalVariable>(Node)) {
1396 Entity = std::make_unique<DbgVariable>(
1397 cast<const DILocalVariable>(Node), nullptr /* IA */);;
1398 DU->addScopeVariable(Scope, cast<DbgVariable>(Entity.get()));
1399 } else if (isa<const DILabel>(Node)) {
1400 Entity = std::make_unique<DbgLabel>(
1401 cast<const DILabel>(Node), nullptr /* IA */);
1402 DU->addScopeLabel(Scope, cast<DbgLabel>(Entity.get()));
1403 }
1404}
1405
1406void DwarfCompileUnit::emitHeader(bool UseOffsets) {
1407 // Don't bother labeling the .dwo unit, as its offset isn't used.
1408 if (!Skeleton && !DD->useSectionsAsReferences()) {
1409 LabelBegin = Asm->createTempSymbol("cu_begin");
1410 Asm->OutStreamer->emitLabel(LabelBegin);
1411 }
1412
1413 dwarf::UnitType UT = Skeleton ? dwarf::DW_UT_split_compile
1414 : DD->useSplitDwarf() ? dwarf::DW_UT_skeleton
1415 : dwarf::DW_UT_compile;
1416 DwarfUnit::emitCommonHeader(UseOffsets, UT);
1417 if (DD->getDwarfVersion() >= 5 && UT != dwarf::DW_UT_compile)
1419}
1420
1422 switch (CUNode->getNameTableKind()) {
1424 return false;
1425 // Opting in to GNU Pubnames/types overrides the default to ensure these are
1426 // generated for things like Gold's gdb_index generation.
1428 return true;
1430 return DD->tuneForGDB() && !includeMinimalInlineScopes() &&
1433 DD->getDwarfVersion() < 5;
1434 }
1435 llvm_unreachable("Unhandled DICompileUnit::DebugNameTableKind enum");
1436}
1437
1438/// addGlobalName - Add a new global name to the compile unit.
1440 const DIScope *Context) {
1441 if (!hasDwarfPubSections())
1442 return;
1443 std::string FullName = getParentContextString(Context) + Name.str();
1444 GlobalNames[FullName] = &Die;
1445}
1446
1448 const DIScope *Context) {
1449 if (!hasDwarfPubSections())
1450 return;
1451 std::string FullName = getParentContextString(Context) + Name.str();
1452 // Insert, allowing the entry to remain as-is if it's already present
1453 // This way the CU-level type DIE is preferred over the "can't describe this
1454 // type as a unit offset because it's not really in the CU at all, it's only
1455 // in a type unit"
1456 GlobalNames.insert(std::make_pair(std::move(FullName), &getUnitDie()));
1457}
1458
1459/// Add a new global type to the unit.
1460void DwarfCompileUnit::addGlobalType(const DIType *Ty, const DIE &Die,
1461 const DIScope *Context) {
1462 if (!hasDwarfPubSections())
1463 return;
1464 std::string FullName = getParentContextString(Context) + Ty->getName().str();
1465 GlobalTypes[FullName] = &Die;
1466}
1467
1469 const DIScope *Context) {
1470 if (!hasDwarfPubSections())
1471 return;
1472 std::string FullName = getParentContextString(Context) + Ty->getName().str();
1473 // Insert, allowing the entry to remain as-is if it's already present
1474 // This way the CU-level type DIE is preferred over the "can't describe this
1475 // type as a unit offset because it's not really in the CU at all, it's only
1476 // in a type unit"
1477 GlobalTypes.insert(std::make_pair(std::move(FullName), &getUnitDie()));
1478}
1479
1481 MachineLocation Location) {
1482 if (DV.hasComplexAddress())
1483 addComplexAddress(DV, Die, dwarf::DW_AT_location, Location);
1484 else
1485 addAddress(Die, dwarf::DW_AT_location, Location);
1486}
1487
1488/// Add an address attribute to a die based on the location provided.
1490 const MachineLocation &Location) {
1491 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
1492 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
1493 if (Location.isIndirect())
1494 DwarfExpr.setMemoryLocationKind();
1495
1496 DIExpressionCursor Cursor({});
1498 if (!DwarfExpr.addMachineRegExpression(TRI, Cursor, Location.getReg()))
1499 return;
1500 DwarfExpr.addExpression(std::move(Cursor));
1501
1502 // Now attach the location information to the DIE.
1503 addBlock(Die, Attribute, DwarfExpr.finalize());
1504
1505 if (DwarfExpr.TagOffset)
1506 addUInt(Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
1507 *DwarfExpr.TagOffset);
1508}
1509
1510/// Start with the address based on the location provided, and generate the
1511/// DWARF information necessary to find the actual variable given the extra
1512/// address information encoded in the DbgVariable, starting from the starting
1513/// location. Add the DWARF information to the die.
1516 const MachineLocation &Location) {
1517 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
1518 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
1519 const DIExpression *DIExpr = DV.getSingleExpression();
1520 DwarfExpr.addFragmentOffset(DIExpr);
1521 DwarfExpr.setLocation(Location, DIExpr);
1522
1523 DIExpressionCursor Cursor(DIExpr);
1524
1525 if (DIExpr->isEntryValue())
1526 DwarfExpr.beginEntryValueExpression(Cursor);
1527
1529 if (!DwarfExpr.addMachineRegExpression(TRI, Cursor, Location.getReg()))
1530 return;
1531 DwarfExpr.addExpression(std::move(Cursor));
1532
1533 // Now attach the location information to the DIE.
1534 addBlock(Die, Attribute, DwarfExpr.finalize());
1535
1536 if (DwarfExpr.TagOffset)
1537 addUInt(Die, dwarf::DW_AT_LLVM_tag_offset, dwarf::DW_FORM_data1,
1538 *DwarfExpr.TagOffset);
1539}
1540
1541/// Add a Dwarf loclistptr attribute data and value.
1543 unsigned Index) {
1545 ? dwarf::DW_FORM_loclistx
1548}
1549
1551 DIE &VariableDie) {
1552 StringRef Name = Var.getName();
1553 if (!Name.empty())
1554 addString(VariableDie, dwarf::DW_AT_name, Name);
1555 const auto *DIVar = Var.getVariable();
1556 if (DIVar) {
1557 if (uint32_t AlignInBytes = DIVar->getAlignInBytes())
1558 addUInt(VariableDie, dwarf::DW_AT_alignment, dwarf::DW_FORM_udata,
1559 AlignInBytes);
1560 addAnnotation(VariableDie, DIVar->getAnnotations());
1561 }
1562
1563 addSourceLine(VariableDie, DIVar);
1564 addType(VariableDie, Var.getType());
1565 if (Var.isArtificial())
1566 addFlag(VariableDie, dwarf::DW_AT_artificial);
1567}
1568
1570 DIE &LabelDie) {
1571 StringRef Name = Label.getName();
1572 if (!Name.empty())
1573 addString(LabelDie, dwarf::DW_AT_name, Name);
1574 const auto *DILabel = Label.getLabel();
1575 addSourceLine(LabelDie, DILabel);
1576}
1577
1578/// Add a Dwarf expression attribute data and value.
1580 const MCExpr *Expr) {
1581 addAttribute(Die, (dwarf::Attribute)0, Form, DIEExpr(Expr));
1582}
1583
1585 const DISubprogram *SP, DIE &SPDie) {
1586 auto *SPDecl = SP->getDeclaration();
1587 auto *Context = SPDecl ? SPDecl->getScope() : SP->getScope();
1589 addGlobalName(SP->getName(), SPDie, Context);
1590}
1591
1592bool DwarfCompileUnit::isDwoUnit() const {
1593 return DD->useSplitDwarf() && Skeleton;
1594}
1595
1596void DwarfCompileUnit::finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) {
1597 constructTypeDIE(D, CTy);
1598}
1599
1602 (DD->useSplitDwarf() && !Skeleton);
1603}
1604
1607 MCSymbol *Label = DD->getAddressPool().getLabel();
1609 DD->getDwarfVersion() >= 5 ? dwarf::DW_AT_addr_base
1610 : dwarf::DW_AT_GNU_addr_base,
1611 Label, TLOF.getDwarfAddrSection()->getBeginSymbol());
1612}
1613
1615 addAttribute(Die, (dwarf::Attribute)0, dwarf::DW_FORM_udata,
1616 new (DIEValueAllocator) DIEBaseTypeRef(this, Idx));
1617}
1618
1620 // Insert the base_type DIEs directly after the CU so that their offsets will
1621 // fit in the fixed size ULEB128 used inside the location expressions.
1622 // Maintain order by iterating backwards and inserting to the front of CU
1623 // child list.
1624 for (auto &Btr : reverse(ExprRefedBaseTypes)) {
1625 DIE &Die = getUnitDie().addChildFront(
1626 DIE::get(DIEValueAllocator, dwarf::DW_TAG_base_type));
1627 SmallString<32> Str;
1628 addString(Die, dwarf::DW_AT_name,
1630 "_" + Twine(Btr.BitSize)).toStringRef(Str));
1631 addUInt(Die, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, Btr.Encoding);
1632 // Round up to smallest number of bytes that contains this number of bits.
1633 addUInt(Die, dwarf::DW_AT_byte_size, std::nullopt,
1634 divideCeil(Btr.BitSize, 8));
1635
1636 Btr.Die = &Die;
1637 }
1638}
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
static SmallVector< DbgVariable *, 8 > sortLocalVars(SmallVectorImpl< DbgVariable * > &Input)
Sort local variables so that variables appearing inside of helper expressions come first.
static SmallVector< const DIVariable *, 2 > dependencies(DbgVariable *Var)
Return all DIVariables that appear in count: expressions.
static dwarf::Tag GetCompileUnitType(UnitKind Kind, DwarfDebug *DW)
This file contains constants used for implementing Dwarf debug support.
std::string Name
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
Definition: InlineInfo.cpp:109
#define I(x, y, z)
Definition: MD5.cpp:58
unsigned const TargetRegisterInfo * TRI
LLVMContext & Context
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains some templates that are useful if you are working with the STL at all.
This file defines the SmallString class.
Class for arbitrary precision integers.
Definition: APInt.h:75
uint64_t getZExtValue() const
Get zero extended value.
Definition: APInt.h:1494
unsigned getBitWidth() const
Return the number of bits in the APInt.
Definition: APInt.h:1439
unsigned getIndex(const MCSymbol *Sym, bool TLS=false)
Returns the index into the address pool with the given label/symbol.
Definition: AddressPool.cpp:19
MCSymbol * getLabel()
Definition: AddressPool.h:53
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:163
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:84
const TargetLoweringObjectFile & getObjFileLowering() const
Return information about object file lowering.
Definition: AsmPrinter.cpp:379
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: AsmPrinter.cpp:662
TargetMachine & TM
Target machine description.
Definition: AsmPrinter.h:87
MachineFunction * MF
The current machine function.
Definition: AsmPrinter.h:102
MapVector< unsigned, MBBSectionRange > MBBSectionRanges
Definition: AsmPrinter.h:138
virtual const MCSymbol * getFunctionFrameSymbol() const
Return symbol for the function pseudo stack if the stack frame is not a register based.
Definition: AsmPrinter.h:276
MCSymbol * createTempSymbol(const Twine &Name) const
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
Return the MCSymbol for the specified ExternalSymbol.
std::unique_ptr< MCStreamer > OutStreamer
This is the MCStreamer object for the file we are generating.
Definition: AsmPrinter.h:99
const DataLayout & getDataLayout() const
Return information about data layout.
Definition: AsmPrinter.cpp:383
void emitInt64(uint64_t Value) const
Emit a long long directive and value.
Basic type, like 'int' or 'float'.
DIFile * getFile() const
unsigned getLineNo() const
StringRef getName() const
DIScope * getScope() const
DIGlobalVariable * getDecl() const
bool isDebugDirectivesOnly() const
static std::optional< DebugNameTableKind > getNameTableKind(StringRef Str)
static std::optional< DebugEmissionKind > getEmissionKind(StringRef Str)
A BaseTypeRef DIE.
Definition: DIE.h:355
A BaseTypeRef DIE.
Definition: DIE.h:240
DIEBlock - Represents a block of values.
Definition: DIE.h:971
DwarfExpression implementation for singular DW_AT_location.
An expression DIE.
Definition: DIE.h:206
An integer value DIE.
Definition: DIE.h:168
A label DIE.
Definition: DIE.h:223
Represents a pointer to a location list in the debug_loc section.
Definition: DIE.h:337
DIELoc - Represents an expression location.
Definition: DIE.h:935
DIE & getUnitDie()
Definition: DIE.h:924
A list of DIE values.
Definition: DIE.h:667
A structured debug information entry.
Definition: DIE.h:744
DIE & addChild(DIE *Child)
Add a child to the DIE.
Definition: DIE.h:859
DIE & addChildFront(DIE *Child)
Definition: DIE.h:866
static DIE * get(BumpPtrAllocator &Alloc, dwarf::Tag Tag)
Definition: DIE.h:774
DIEUnit * getUnit() const
Climb up the parent chain to get the compile unit or type unit that this DIE belongs to.
Definition: DIE.cpp:209
const DIE * getUnitDie() const
Climb up the parent chain to get the compile unit or type unit DIE that this DIE belongs to.
Definition: DIE.cpp:197
Holds a DIExpression and keeps track of how many operands have been consumed so far.
DWARF expression.
element_iterator elements_end() const
bool isEntryValue() const
Check if the expression consists of exactly one entry value operand.
element_iterator elements_begin() const
uint64_t getElement(unsigned I) const
std::optional< SignedOrUnsignedConstant > isConstant() const
Determine whether this represents a constant value, if so.
static const DIExpression * extractAddressClass(const DIExpression *Expr, unsigned &AddrClass)
Checks if the last 4 elements of the expression are DW_OP_constu <DWARF Address Space> DW_OP_swap DW_...
DIDerivedType * getStaticDataMemberDeclaration() const
MDTuple * getTemplateParams() const
StringRef getLinkageName() const
StringRef getDisplayName() const
DINodeArray getAnnotations() const
An imported module (C++ using directive or similar).
Debug location.
Tagged DWARF-like metadata node.
dwarf::Tag getTag() const
Base class for scope-like contexts.
StringRef getName() const
DIScope * getScope() const
Subprogram description.
unsigned size() const
Base class for types.
StringRef getName() const
Base class for variables.
uint32_t getAlignInBytes() const
DIScope * getScope() const
DIType * getType() const
StringRef getName() const
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
Definition: DataLayout.cpp:728
This class is defined as the common parent of DbgVariable and DbgLabel such that it could levarage po...
Definition: DwarfDebug.h:65
const DINode * getEntity() const
Accessors.
Definition: DwarfDebug.h:85
void setDIE(DIE &D)
Definition: DwarfDebug.h:91
DIE * getDIE() const
Definition: DwarfDebug.h:87
This class is used to track label information.
Definition: DwarfDebug.h:234
A single location or constant within a variable location description, with either a single entry (wit...
Definition: DebugLocEntry.h:40
This class is used to track local variable information.
Definition: DwarfDebug.h:115
bool hasComplexAddress() const
Definition: DwarfDebug.h:214
bool isArtificial() const
Return true if DbgVariable is artificial.
Definition: DwarfDebug.h:198
dwarf::Tag getTag() const
Definition: DwarfDebug.h:189
bool isObjectPointer() const
Definition: DwarfDebug.h:206
const DILocalVariable * getVariable() const
Definition: DwarfDebug.h:166
std::optional< uint8_t > getDebugLocListTagOffset() const
Definition: DwarfDebug.h:178
unsigned getDebugLocListIndex() const
Definition: DwarfDebug.h:176
StringRef getName() const
Definition: DwarfDebug.h:181
const DIType * getType() const
Definition: DwarfDebug.cpp:229
bool hasFrameIndexExprs() const
Definition: DwarfDebug.h:185
const DbgValueLoc * getValueLoc() const
Definition: DwarfDebug.h:182
const DIExpression * getSingleExpression() const
Definition: DwarfDebug.h:170
ArrayRef< FrameIndexExpr > getFrameIndexExprs() const
Get the FI entries, sorted by fragment offset.
Definition: DwarfDebug.cpp:273
MCSymbol * getLabelBeforeInsn(const MachineInstr *MI)
Return Label preceding the instruction.
MCSymbol * getLabelAfterInsn(const MachineInstr *MI)
Return Label immediately following the instruction.
A DeclContext is a named program scope that is used for ODR uniquing of types.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:202
bool empty() const
Definition: DenseMap.h:98
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:220
bool useGNUAnalogForDwarf5Feature() const
Whether to use the GNU analog for a DWARF5 tag, attribute, or location atom.
void constructCallSiteParmEntryDIEs(DIE &CallSiteDIE, SmallVector< DbgCallSiteParam, 4 > &Params)
Construct call site parameter DIEs for the CallSiteDIE.
void attachLowHighPC(DIE &D, const MCSymbol *Begin, const MCSymbol *End)
void emitHeader(bool UseOffsets) override
Emit the header for this unit, not including the initial length field.
dwarf::Tag getDwarf5OrGNUTag(dwarf::Tag Tag) const
This takes a DWARF 5 tag and returns it or a GNU analog.
DIE & updateSubprogramScopeDIE(const DISubprogram *SP)
Find DIE for the given subprogram and attach appropriate DW_AT_low_pc and DW_AT_high_pc attributes.
void constructAbstractSubprogramScopeDIE(LexicalScope *Scope)
bool includeMinimalInlineScopes() const
void addBaseTypeRef(DIEValueList &Die, int64_t Idx)
void addGlobalNameForTypeUnit(StringRef Name, const DIScope *Context)
Add a new global name present in a type unit to this compile unit.
void finishEntityDefinition(const DbgEntity *Entity)
DIE * constructImportedEntityDIE(const DIImportedEntity *Module)
Construct import_module DIE.
void addRange(RangeSpan Range)
addRange - Add an address range to the list of ranges for this unit.
void addAddrTableBase()
Add the DW_AT_addr_base attribute to the unit DIE.
DIE & constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram *CalleeSP, bool IsTail, const MCSymbol *PCAddr, const MCSymbol *CallAddr, unsigned CallReg)
Construct a call site entry DIE describing a call within Scope to a callee described by CalleeSP.
std::vector< BaseTypeRef > ExprRefedBaseTypes
DIE * constructInlinedScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE)
This scope represents an inlined body of a function.
void addComplexAddress(const DbgVariable &DV, DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)
Start with the address based on the location provided, and generate the DWARF information necessary t...
void addGlobalType(const DIType *Ty, const DIE &Die, const DIScope *Context) override
Add a new global type to the compile unit.
void addScopeRangeList(DIE &ScopeDIE, SmallVector< RangeSpan, 2 > Range)
A helper function to construct a RangeSpanList for a given lexical scope.
uint64_t getDWOId() const
DIE * getOrCreateCommonBlock(const DICommonBlock *CB, ArrayRef< GlobalExpr > GlobalExprs)
void addVariableAddress(const DbgVariable &DV, DIE &Die, MachineLocation Location)
Add DW_AT_location attribute for a DbgVariable based on provided MachineLocation.
void addGlobalName(StringRef Name, const DIE &Die, const DIScope *Context) override
Add a new global name to the compile unit.
void createAbstractEntity(const DINode *Node, LexicalScope *Scope)
void applyStmtList(DIE &D)
Apply the DW_AT_stmt_list from this compile unit to the specified DIE.
DIE * constructVariableDIE(DbgVariable &DV, bool Abstract=false)
constructVariableDIE - Construct a DIE for the given DbgVariable.
void applyVariableAttributes(const DbgVariable &Var, DIE &VariableDie)
dwarf::LocationAtom getDwarf5OrGNULocationAtom(dwarf::LocationAtom Loc) const
This takes a DWARF 5 location atom and either returns it or a GNU analog.
DIE & constructSubprogramScopeDIE(const DISubprogram *Sub, LexicalScope *Scope)
Construct a DIE for this subprogram scope.
DIE * getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV, ArrayRef< GlobalExpr > GlobalExprs)
Get or create global variable DIE.
void addLocationAttribute(DIE *ToDIE, const DIGlobalVariable *GV, ArrayRef< GlobalExpr > GlobalExprs)
void applySubprogramAttributesToDefinition(const DISubprogram *SP, DIE &SPDie)
DIE * createAndAddScopeChildren(LexicalScope *Scope, DIE &ScopeDIE)
DIE & updateSubprogramScopeDIEImpl(const DISubprogram *SP, DIE *SPDie)
void addExpr(DIELoc &Die, dwarf::Form Form, const MCExpr *Expr)
Add a Dwarf expression attribute data and value.
dwarf::Attribute getDwarf5OrGNUAttr(dwarf::Attribute Attr) const
This takes a DWARF 5 attribute and returns it or a GNU analog.
unsigned getUniqueID() const
void addAddress(DIE &Die, dwarf::Attribute Attribute, const MachineLocation &Location)
Add an address attribute to a die based on the location provided.
void applyLabelAttributes(const DbgLabel &Label, DIE &LabelDie)
void addLocalLabelAddress(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label)
addLocalLabelAddress - Add a dwarf label attribute data and value using DW_FORM_addr only.
DIE * constructLexicalScopeDIE(LexicalScope *Scope)
Construct new DW_TAG_lexical_block for this scope and attach DW_AT_low_pc/DW_AT_high_pc labels.
unsigned getOrCreateSourceID(const DIFile *File) override
Look up the source ID for the given file.
void constructScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE)
DwarfCompileUnit(unsigned UID, const DICompileUnit *Node, AsmPrinter *A, DwarfDebug *DW, DwarfFile *DWU, UnitKind Kind=UnitKind::Full)
DIE * constructLabelDIE(DbgLabel &DL, const LexicalScope &Scope)
Construct a DIE for the given DbgLabel.
void addGlobalTypeUnitType(const DIType *Ty, const DIScope *Context)
Add a new global type present in a type unit to this compile unit.
DbgEntity * getExistingAbstractEntity(const DINode *Node)
void addLabelAddress(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label)
addLabelAddress - Add a dwarf label attribute data and value using either DW_FORM_addr or DW_FORM_GNU...
void addLocationList(DIE &Die, dwarf::Attribute Attribute, unsigned Index)
Add a Dwarf loclistptr attribute data and value.
DwarfCompileUnit & getCU() override
void attachRangesOrLowHighPC(DIE &D, SmallVector< RangeSpan, 2 > Ranges)
void finishSubprogramDefinition(const DISubprogram *SP)
Collects and handles dwarf debug information.
Definition: DwarfDebug.h:296
std::optional< MD5::MD5Result > getMD5AsBytes(const DIFile *File) const
If the File has an MD5 checksum, return it as an MD5Result allocated in the MCContext.
bool alwaysUseRanges() const
Returns whether range encodings should be used for single entry range lists.
Definition: DwarfDebug.h:699
bool useGNUTLSOpcode() const
Returns whether to use DW_OP_GNU_push_tls_address, instead of the standard DW_OP_form_tls_address opc...
Definition: DwarfDebug.h:685
bool useAddrOffsetForm() const
Definition: DwarfDebug.h:711
const DwarfCompileUnit * getPrevCU() const
Returns the previous CU that was being updated.
Definition: DwarfDebug.h:769
uint16_t getDwarfVersion() const
Returns the Dwarf Version.
bool useAllLinkageNames() const
Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
Definition: DwarfDebug.h:681
void insertSectionLabel(const MCSymbol *S)
void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP, DIE &Die)
Definition: DwarfDebug.cpp:500
dwarf::Form getDwarfSectionOffsetForm() const
Returns a suitable DWARF form to represent a section offset, i.e.
bool useAppleExtensionAttributes() const
Definition: DwarfDebug.h:731
void setPrevCU(const DwarfCompileUnit *PrevCU)
Definition: DwarfDebug.h:770
const MachineFunction * getCurrentFunction() const
Definition: DwarfDebug.h:803
void addArangeLabel(SymbolCU SCU)
Add a label so that arange data can be generated for it.
Definition: DwarfDebug.h:671
AddressPool & getAddressPool()
Definition: DwarfDebug.h:791
void addAccelNamespace(const DICompileUnit &CU, StringRef Name, const DIE &Die)
bool useSectionsAsReferences() const
Returns whether to use sections as labels rather than temp symbols.
Definition: DwarfDebug.h:716
void terminateLineTable(const DwarfCompileUnit *CU)
Terminate the line table by adding the last range label.
void addAccelName(const DICompileUnit &CU, StringRef Name, const DIE &Die)
DwarfCompileUnit * lookupCU(const DIE *Die)
Find the matching DwarfCompileUnit for the given CU DIE.
Definition: DwarfDebug.h:810
const MCSymbol * getSectionLabel(const MCSection *S)
static void emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT, const DbgValueLoc &Value, DwarfExpression &DwarfExpr)
bool useSplitDwarf() const
Returns whether or not to change the current debug info for the split dwarf proposal support.
Definition: DwarfDebug.h:737
bool useAddrOffsetExpressions() const
Definition: DwarfDebug.h:705
bool useRangesSection() const
Returns whether ranges section should be emitted.
Definition: DwarfDebug.h:695
bool isLexicalScopeDIENull(LexicalScope *Scope)
A helper function to check whether the DIE for a given Scope is going to be null.
Definition: DwarfDebug.cpp:534
AccelTableKind getAccelTableKind() const
Returns what kind (if any) of accelerator tables to emit.
Definition: DwarfDebug.h:729
void setLocation(const MachineLocation &Loc, const DIExpression *DIExpr)
Set the location (Loc) and DIExpression (DIExpr) to describe.
void addFragmentOffset(const DIExpression *Expr)
If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to the fragment described by Ex...
void setMemoryLocationKind()
Lock this down to become a memory location description.
std::optional< uint8_t > TagOffset
void setCallSiteParamValueFlag()
Lock this down to become a call site parameter location.
bool addMachineRegExpression(const TargetRegisterInfo &TRI, DIExpressionCursor &Expr, llvm::Register MachineReg, unsigned FragmentOffsetInBits=0)
Emit a machine register location.
void addExpression(DIExpressionCursor &&Expr)
Emit all remaining operations in the DIExpressionCursor.
void addWasmLocation(unsigned Index, uint64_t Offset)
Emit location information expressed via WebAssembly location + offset The Index is an identifier for ...
void beginEntryValueExpression(DIExpressionCursor &ExprCursor)
Begin emission of an entry value dwarf operation.
void addScopeLabel(LexicalScope *LS, DbgLabel *Label)
Definition: DwarfFile.cpp:122
DenseMap< LexicalScope *, ScopeVars > & getScopeVariables()
Definition: DwarfFile.h:157
DenseMap< LexicalScope *, LabelList > & getScopeLabels()
Definition: DwarfFile.h:161
bool addScopeVariable(LexicalScope *LS, DbgVariable *Var)
Definition: DwarfFile.cpp:105
This dwarf writer support class manages information associated with a source file.
Definition: DwarfUnit.h:35
DIE * getOrCreateTypeDIE(const MDNode *TyNode)
Find existing DIE or create new DIE for the given type.
Definition: DwarfUnit.cpp:606
void addAnnotation(DIE &Buffer, DINodeArray Annotations)
Add DW_TAG_LLVM_annotation.
Definition: DwarfUnit.cpp:852
void addBlock(DIE &Die, dwarf::Attribute Attribute, DIELoc *Loc)
Add block data.
Definition: DwarfUnit.cpp:390
void addTemplateParams(DIE &Buffer, DINodeArray TParams)
Add template parameters in buffer.
Definition: DwarfUnit.cpp:515
DIE * getOrCreateContextDIE(const DIScope *Context)
Get context owner's DIE.
Definition: DwarfUnit.cpp:545
void addAttribute(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, T &&Value)
Definition: DwarfUnit.h:79
void addOpAddress(DIELoc &Die, const MCSymbol *Sym)
Add a dwarf op address data and value using the form given and an op of either DW_FORM_addr or DW_FOR...
Definition: DwarfUnit.cpp:331
void addUInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, uint64_t Integer)
Add an unsigned integer attribute data and value.
Definition: DwarfUnit.cpp:220
void addString(DIE &Die, dwarf::Attribute Attribute, StringRef Str)
Add a string attribute data and value.
Definition: DwarfUnit.cpp:246
void addConstantValue(DIE &Die, const ConstantInt *CI, const DIType *Ty)
Add constant value entry in variable DIE.
Definition: DwarfUnit.cpp:458
DIE * getOrCreateNameSpace(const DINamespace *NS)
Definition: DwarfUnit.cpp:1101
void insertDIE(const DINode *Desc, DIE *D)
Insert DIE into the map.
Definition: DwarfUnit.cpp:201
void addSectionDelta(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
addSectionDelta - Add a label delta attribute data and value.
Definition: DwarfUnit.cpp:1791
DwarfDebug * DD
Definition: DwarfUnit.h:50
const DICompileUnit * CUNode
MDNode for the compile unit.
Definition: DwarfUnit.h:38
DIE * getDIE(const DINode *D) const
Returns the DIE map slot for the specified debug variable.
Definition: DwarfUnit.cpp:195
void addSInt(DIEValueList &Die, dwarf::Attribute Attribute, std::optional< dwarf::Form > Form, int64_t Integer)
Add an signed integer attribute data and value.
Definition: DwarfUnit.cpp:234
void addLabelDelta(DIEValueList &Die, dwarf::Attribute Attribute, const MCSymbol *Hi, const MCSymbol *Lo)
Add a label delta attribute data and value.
Definition: DwarfUnit.cpp:346
void addLinkageName(DIE &Die, StringRef LinkageName)
Add a linkage name, if it isn't empty.
Definition: DwarfUnit.cpp:507
std::string getParentContextString(const DIScope *Context) const
Get string containing language specific context for a global name.
Definition: DwarfUnit.cpp:657
void addSourceLine(DIE &Die, unsigned Line, const DIFile *File)
Add location information to specified debug information entry.
Definition: DwarfUnit.cpp:408
void emitCommonHeader(bool UseOffsets, dwarf::UnitType UT)
Emit the common part of the header for this unit.
Definition: DwarfUnit.cpp:1742
BumpPtrAllocator DIEValueAllocator
Definition: DwarfUnit.h:41
DIE * getOrCreateModule(const DIModule *M)
Definition: DwarfUnit.cpp:1122
const DICompileUnit * getCUNode() const
Definition: DwarfUnit.h:99
DIE & createAndAddDIE(dwarf::Tag Tag, DIE &Parent, const DINode *N=nullptr)
Create a DIE with the given Tag, add the DIE to its parent, and call insertDIE if MD is not null.
Definition: DwarfUnit.cpp:383
DwarfFile * DU
Definition: DwarfUnit.h:51
DIE * getOrCreateStaticMemberDIE(const DIDerivedType *DT)
Create new static data member DIE.
Definition: DwarfUnit.cpp:1703
void addLabel(DIEValueList &Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Label)
Add a Dwarf label attribute data and value.
Definition: DwarfUnit.cpp:279
void addConstantFPValue(DIE &Die, const ConstantFP *CFP)
Add constant value entry in variable DIE.
Definition: DwarfUnit.cpp:453
DIE * getOrCreateSubprogramDIE(const DISubprogram *SP, bool Minimal=false)
Definition: DwarfUnit.cpp:1153
void addSectionLabel(DIE &Die, dwarf::Attribute Attribute, const MCSymbol *Label, const MCSymbol *Sec)
Add a Dwarf section label attribute data and value.
Definition: DwarfUnit.cpp:1797
void addPoolOpAddress(DIEValueList &Die, const MCSymbol *Label)
Definition: DwarfUnit.cpp:306
void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy)
Definition: DwarfUnit.cpp:873
MCSymbol * EndLabel
Emitted at the end of the CU and used to compute the CU Length field.
Definition: DwarfUnit.h:47
void addFlag(DIE &Die, dwarf::Attribute Attribute)
Add a flag that is true to the DIE.
Definition: DwarfUnit.cpp:213
AsmPrinter * Asm
Target of Dwarf emission.
Definition: DwarfUnit.h:44
void addType(DIE &Entity, const DIType *Ty, dwarf::Attribute Attribute=dwarf::DW_AT_type)
Add a new type attribute to the specified entity.
Definition: DwarfUnit.cpp:651
void applySubprogramAttributes(const DISubprogram *SP, DIE &SPDie, bool SkipSPAttributes=false)
Definition: DwarfUnit.cpp:1238
void addDIEEntry(DIE &Die, dwarf::Attribute Attribute, DIE &Entry)
Add a DIE attribute data and value.
Definition: DwarfUnit.cpp:352
LexicalScope - This class is used to track scope information.
Definition: LexicalScopes.h:44
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
MCSection * getDwarfRangesSection() const
MCSection * getDwarfAddrSection() const
MCSection * getDwarfLineSection() const
int getDwarfRegNum(MCRegister RegNum, bool isEH) const
Map a target register to an equivalent dwarf register number.
MCSymbol * getBeginSymbol()
Definition: MCSection.h:129
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
Definition: MCSymbol.h:248
Tuple of metadata.
Definition: Metadata.h:1328
bool sameSection(const MachineBasicBlock *MBB) const
Returns true if this and MBB belong to the same section.
unsigned getSectionIDNum() const
Returns the unique section ID number of this basic block.
bool isEndSection() const
Returns true if this block ends any section.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
Root of the metadata hierarchy.
Definition: Metadata.h:61
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
StringRef getName() const
Get a short "name" for the module.
Definition: Module.h:245
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
Definition: Register.h:65
bool isReadOnly() const
Definition: SectionKind.h:131
Implements a dense probed hash-table based set with some number of buckets stored inline.
Definition: DenseSet.h:290
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
bool empty() const
Definition: SmallVector.h:94
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:577
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:687
void push_back(const T &Elt)
Definition: SmallVector.h:416
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StackOffset holds a fixed and a scalable offset in bytes.
Definition: TypeSize.h:36
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:222
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
Information about stack frame layout on the target.
virtual DwarfFrameBase getDwarfFrameBase(const MachineFunction &MF) const
Return the frame base information to be encoded in the DWARF subprogram debug info.
virtual StackOffset getFrameIndexReference(const MachineFunction &MF, int FI, Register &FrameReg) const
getFrameIndexReference - This method should return the base register and offset used to reference a f...
virtual MCRegister getStaticBase() const
Returns the register used as static base in RWPI variants.
static SectionKind getKindForGlobal(const GlobalObject *GO, const TargetMachine &TM)
Classify the specified global variable into a set of target independent categories embodied in Sectio...
bool supportDebugThreadLocalLocation() const
Target supports TLS offset relocation in debug section?
virtual const MCExpr * getIndirectSymViaRWPI(const MCSymbol *Sym) const
Get the target specific RWPI relocation.
virtual const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const
Create a symbol reference to describe the given TLS variable when emitting the address in debug info.
const Triple & getTargetTriple() const
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
TargetOptions Options
const MCRegisterInfo * getMCRegisterInfo() const
bool DisableFramePointerElim(const MachineFunction &MF) const
DisableFramePointerElim - This returns true if frame pointer elimination optimization should be disab...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
virtual const TargetRegisterInfo * getRegisterInfo() const
getRegisterInfo - If register information is available, return it.
virtual const TargetFrameLowering * getFrameLowering() const
bool isNVPTX() const
Tests whether the target is NVPTX (32- or 64-bit).
Definition: Triple.h:772
bool isWasm() const
Tests whether the target is wasm (32- and 64-bit).
Definition: Triple.h:949
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
Definition: Twine.h:473
std::pair< iterator, bool > insert(const ValueT &V)
Definition: DenseSet.h:206
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Definition: DenseSet.h:97
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
Definition: ilist_node.h:289
bool tuneForGDB() const
Definition: DwarfDebug.h:829
bool tuneForLLDB() const
Definition: DwarfDebug.h:830
StringRef AttributeEncodingString(unsigned Encoding)
Definition: Dwarf.cpp:197
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ ROPI_RWPI
Definition: CodeGen.h:25
@ DW_INL_inlined
Definition: Dwarf.h:424
Attribute
Attributes.
Definition: Dwarf.h:123
UnitType
Constants for unit types in DWARF v5.
Definition: Dwarf.h:543
LocationAtom
Definition: Dwarf.h:136
@ WASM_SYMBOL_TYPE_GLOBAL
Definition: Wasm.h:385
@ WASM_TYPE_I64
Definition: Wasm.h:262
@ WASM_TYPE_I32
Definition: Wasm.h:261
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
uint64_t divideCeil(uint64_t Numerator, uint64_t Denominator)
Returns the integer ceil(Numerator / Denominator).
Definition: MathExtras.h:522
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1826
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:511
@ Apple
.apple_names, .apple_namespaces, .apple_types, .apple_objc.
@ Global
Append to llvm.global_dtors.
std::pair< const MachineInstr *, const MachineInstr * > InsnRange
InsnRange - This is used to track range of instructions with identical lexical scope.
Definition: LexicalScopes.h:39
DISubprogram * getDISubprogram(const MDNode *Scope)
Find subprogram that is enclosing this scope.
Definition: DebugInfo.cpp:120
const MCSymbol * End
Definition: DwarfFile.h:38
const MCSymbol * Begin
Definition: DwarfFile.h:37
Helper used to pair up a symbol and its DWARF compile unit.
Definition: DwarfDebug.h:280
union llvm::TargetFrameLowering::DwarfFrameBase::@233 Location
enum llvm::TargetFrameLowering::DwarfFrameBase::FrameBaseKind Kind
This struct describes target specific location.
Definition: DebugLocEntry.h:24