56 cl::desc(
"As secure log file name (initialized from " 57 "AS_SECURE_LOG_FILE env variable)"),
63 :
SrcMgr(mgr), InlineSrcMgr(nullptr), MAI(mai),
MRI(mri), MOFI(mofi),
89 COFFAllocator.DestroyAll();
90 ELFAllocator.DestroyAll();
91 MachOAllocator.DestroyAll();
92 XCOFFAllocator.DestroyAll();
94 MCSubtargetAllocator.DestroyAll();
95 InlineAsmUsedLabelNames.
clear();
100 CompilationDir.
clear();
101 MainFileName.clear();
102 MCDwarfLineTablesCUMap.clear();
103 SectionsForRanges.clear();
104 MCGenDwarfLabelEntries.clear();
106 DwarfCompileUnitID = 0;
111 MachOUniquingMap.clear();
112 ELFUniquingMap.clear();
113 COFFUniquingMap.clear();
114 WasmUniquingMap.clear();
115 XCOFFUniquingMap.clear();
118 AllowTemporaryLabels =
true;
119 DwarfLocSeen =
false;
120 GenDwarfForAssembly =
false;
121 GenDwarfFileNumber = 0;
134 assert(!NameRef.
empty() &&
"Normal symbols cannot be unnamed!");
138 Sym = createSymbol(NameRef,
false,
false);
146 "$frame_escape_" +
Twine(Idx));
151 "$parent_frame_offset");
181 if (CanBeUnnamed && !UseNamesOnTempLabels)
182 return createSymbolImpl(
nullptr,
true);
186 bool IsTemporary = CanBeUnnamed;
187 if (AllowTemporaryLabels && !IsTemporary)
191 bool AddSuffix = AlwaysAddSuffix;
192 unsigned &NextUniqueID = NextID[
Name];
198 auto NameEntry = UsedNames.insert(std::make_pair(NewName,
true));
199 if (NameEntry.second || !NameEntry.first->second) {
202 NameEntry.first->second =
true;
205 return createSymbolImpl(&*NameEntry.first, IsTemporary);
207 assert(IsTemporary &&
"Cannot rename non-temporary symbols");
217 return createSymbol(NameSV, AlwaysAddSuffix, CanBeUnnamed);
223 return createSymbol(NameSV,
true,
false);
230 unsigned MCContext::NextInstance(
unsigned LocalLabelVal) {
231 MCLabel *&Label = Instances[LocalLabelVal];
233 Label =
new (*this)
MCLabel(0);
237 unsigned MCContext::GetInstance(
unsigned LocalLabelVal) {
238 MCLabel *&Label = Instances[LocalLabelVal];
240 Label =
new (*this)
MCLabel(0);
244 MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(
unsigned LocalLabelVal,
246 MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
253 unsigned Instance = NextInstance(LocalLabelVal);
254 return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
259 unsigned Instance = GetInstance(LocalLabelVal);
262 return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
268 return Symbols.
lookup(NameRef);
279 InlineAsmUsedLabelNames[Sym->
getName()] = Sym;
287 unsigned TypeAndAttributes,
289 const char *BeginSymName) {
311 Segment, Section, TypeAndAttributes, Reserved2, Kind, Begin);
317 GroupName = Group->getName();
320 ELFUniquingMap.erase(
322 auto I = ELFUniquingMap.insert(std::make_pair(
323 ELFSectionKey{
Name, GroupName, UniqueID},
344 R = cast<MCSymbolELF>(Sym);
346 auto NameIter = UsedNames.insert(std::make_pair(Section,
false)).first;
347 R =
new (&*NameIter, *
this)
MCSymbolELF(&*NameIter,
false);
355 Section, Type, Flags, K, EntrySize, Group, UniqueID, R, Associated);
358 Ret->getFragmentList().insert(
Ret->begin(),
F);
366 unsigned Flags,
unsigned EntrySize,
371 std::tie(I, Inserted) =
372 RelSecNames.
insert(std::make_pair(Name.
str(),
true));
374 return createELFSectionImpl(
380 const Twine &Suffix,
unsigned Type,
382 unsigned EntrySize) {
383 return getELFSection(Prefix +
"." + Suffix, Type, Flags, EntrySize, Suffix);
387 unsigned Flags,
unsigned EntrySize,
388 const Twine &Group,
unsigned UniqueID,
394 return getELFSection(Section, Type, Flags, EntrySize, GroupSym, UniqueID,
399 unsigned Flags,
unsigned EntrySize,
407 auto IterBool = ELFUniquingMap.insert(
408 std::make_pair(ELFSectionKey{Section.
str(), Group, UniqueID},
nullptr));
409 auto &
Entry = *IterBool.first;
410 if (!IterBool.second)
424 CachedName, Type, Flags, Kind, EntrySize, GroupSym, UniqueID, Associated);
425 Entry.second = Result;
440 const char *BeginSymName) {
442 if (!COMDATSymName.
empty()) {
444 COMDATSymName = COMDATSymbol->
getName();
450 auto IterBool = COFFUniquingMap.insert(std::make_pair(
T,
nullptr));
451 auto Iter = IterBool.first;
452 if (!IterBool.second)
459 StringRef CachedName = Iter->first.SectionName;
461 CachedName, Characteristics, COMDATSymbol, Selection, Kind, Begin);
463 Iter->second = Result;
470 const char *BeginSymName) {
497 const Twine &Group,
unsigned UniqueID,
498 const char *BeginSymName) {
505 return getWasmSection(Section, K, GroupSym, UniqueID, BeginSymName);
511 const char *BeginSymName) {
516 auto IterBool = WasmUniquingMap.insert(
517 std::make_pair(WasmSectionKey{Section.
str(), Group, UniqueID},
nullptr));
518 auto &
Entry = *IterBool.first;
519 if (!IterBool.second)
524 MCSymbol *Begin = createSymbol(CachedName,
false,
false);
529 Entry.second = Result;
533 F->setParent(Result);
544 const char *BeginSymName) {
546 auto IterBool = XCOFFUniquingMap.insert(
547 std::make_pair(XCOFFSectionKey{Section.
str(), SMC},
nullptr));
548 auto &
Entry = *IterBool.first;
549 if (!IterBool.second)
562 CachedName, SMC, Type, SC, Kind, cast<MCSymbolXCOFF>(QualName), Begin);
563 Entry.second = Result;
567 F->setParent(Result);
580 const std::string &To) {
581 DebugPrefixMap.insert(std::make_pair(From, To));
585 const auto &DebugPrefixMap = this->DebugPrefixMap;
586 const auto RemapDebugPath = [&DebugPrefixMap](std::string &Path) {
587 for (
const auto &
Entry : DebugPrefixMap)
589 std::string RemappedPath =
591 Path.swap(RemappedPath);
596 std::string CompDir = CompilationDir.
str();
597 RemapDebugPath(CompDir);
598 CompilationDir = CompDir;
601 for (
auto &CUIDTablePair : MCDwarfLineTablesCUMap)
602 for (
auto &Dir : CUIDTablePair.second.getMCDwarfDirs())
631 if (FileNameBuf.
empty() || FileNameBuf ==
"-")
632 FileNameBuf =
"<stdin>";
657 return Table.
tryGetFile(Directory, FileName, Checksum, Source, DwarfVersion,
676 SectionsForRanges.remove_if(
681 if (!CVContext.get())
683 return *CVContext.get();
698 else if (InlineSrcMgr)
714 else if (InlineSrcMgr)
Instances of this class represent a uniqued identifier for a section in the current translation unit...
bool is_separator(char value, Style style=Style::native)
Check whether the given char is a path separator on the host OS.
MCSymbol * getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before)
Create and return a directional local symbol for numbered label (used for "1b" or 1f" references)...
void remove_filename(SmallVectorImpl< char > &path, Style style=Style::native)
Remove the last component from path unless it is the root dir.
SectionKind getKind() const
This represents a section on a Mach-O system (used by Mac OS X).
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
unsigned getNumBuffers() const
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
StringRef getLinkerPrivateGlobalPrefix() const
void push_back(const T &Elt)
MCSymbol * getOrCreateFrameAllocSymbol(StringRef FuncName, unsigned Idx)
Gets a symbol that will be defined to the final stack offset of a local variable after codegen...
void reset()
reset - return object to right after construction state to prepare to process a new module ...
bool isTriviallyEmpty() const
Check if this twine is trivially empty; a false return value does not necessarily mean the twine is e...
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
bool consume_front(StringRef Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
MCSectionWasm * getWasmSection(const Twine &Section, SectionKind K)
MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions)...
MCSymbol * getOrCreateParentFrameOffsetSymbol(StringRef FuncName)
void setGenDwarfRootFile(StringRef FileName, StringRef Buffer)
Specifies information about the "root file" for assembler clients (e.g., llvm-mc).
A raw_ostream that writes to an SmallVector or SmallString.
uint16_t getDwarfVersion() const
StringRef getPrivateGlobalPrefix() const
MCSectionCOFF * getCOFFSection(StringRef Section, unsigned Characteristics, SectionKind Kind, StringRef COMDATSymName, int Selection, unsigned UniqueID=GenericSectionID, const char *BeginSymName=nullptr)
MCSectionCOFF * getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym, unsigned UniqueID=GenericSectionID)
Gets or creates a section equivalent to Sec that is associated with the section containing KeySym...
This represents a section on Windows.
void setComdat(bool isComdat)
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, const Twine &Msg, ArrayRef< SMRange > Ranges=None, ArrayRef< SMFixIt > FixIts=None, bool ShowColors=true) const
Emit a message about the specified location with the specified string.
#define DWARF2_FLAG_IS_STMT
MCSymbol * createLinkerPrivateTempSymbol()
Create and return a new linker temporary symbol with a unique but unspecified name.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void Reset()
Deallocate all but the current slab and reset the current pointer to the beginning of it...
void renameELFSection(MCSectionELF *Section, StringRef Name)
LLVM_NODISCARD StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
void update(ArrayRef< uint8_t > Data)
Updates the hash for the byte stream provided.
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionsForRanges, to avoid generating useless debug info for them...
bool isInSection() const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
void setFragment(MCFragment *F) const
Mark the symbol as defined in the fragment F.
Tagged union holding either a T or a Error.
MCDwarfLineTable & getMCDwarfLineTable(unsigned CUID)
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
static cl::opt< char * > AsSecureLogFileName("as-secure-log-file-name", cl::desc("As secure log file name (initialized from " "AS_SECURE_LOG_FILE env variable)"), cl::init(getenv("AS_SECURE_LOG_FILE")), cl::Hidden)
StringRef str() const
Explicit conversion to StringRef.
Expected< unsigned > getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
const MemoryBuffer * getMemoryBuffer(unsigned i) const
MCSectionXCOFF * getXCOFFSection(StringRef Section, XCOFF::StorageMappingClass MappingClass, XCOFF::SymbolType CSectType, XCOFF::StorageClass StorageClass, SectionKind K, const char *BeginSymName=nullptr)
MCSectionMachO * getMachOSection(StringRef Segment, StringRef Section, unsigned TypeAndAttributes, unsigned Reserved2, SectionKind K, const char *BeginSymName=nullptr)
Return the MCSection for the specified mach-o section.
Instances of this class represent the information from a dwarf .loc directive.
unsigned getCharacteristics() const
LLVM_NODISCARD size_t size() const
size - Get the string size.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L, const Twine &Msg)
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
MCContext(const MCAsmInfo *MAI, const MCRegisterInfo *MRI, const MCObjectFileInfo *MOFI, const SourceMgr *Mgr=nullptr, MCTargetOptions const *TargetOpts=nullptr, bool DoAutoReset=true)
unsigned getMainFileID() const
This class is intended to be used as a base class for asm properties and features specific to the tar...
unsigned getUniqueID() const
initializer< Ty > init(const Ty &Val)
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles() const
Streaming machine code generation interface.
MCSymbol * createTempSymbol(bool CanBeUnnamed=true)
Create and return a new assembler temporary symbol with a unique but unspecified name.
unsigned const MachineRegisterInfo * MRI
const MCSymbolELF * getGroup() const
The instances of the Type class are immutable: once they are created, they are never changed...
StorageMappingClass
Storage Mapping Class definitions.
This represents a section on wasm.
void RunInterruptHandlers()
This function runs all the registered interrupt handlers, including the removal of files registered b...
virtual bool mayHaveInstructions(MCSection &Sec) const
void reportError(SMLoc L, const Twine &Msg)
SectionKind - This is a simple POD value that classifies the properties of a section.
MCSectionELF * getELFNamedSection(const Twine &Prefix, const Twine &Suffix, unsigned Type, unsigned Flags, unsigned EntrySize=0)
Get a section with the provided group identifier.
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Environment getObjectFileType() const
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
StringRef getMappingClassString(XCOFF::StorageMappingClass SMC)
StringRef getSectionName() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID=0)
isValidDwarfFileNumber - takes a dwarf file number and returns true if it currently is assigned and f...
void setType(unsigned Type) const
StringRef getCompilationDir() const
Get the compilation directory for DW_AT_comp_dir The compilation directory should be set with setComp...
MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *RelInfoSection)
void registerInlineAsmLabel(MCSymbol *Sym)
registerInlineAsmLabel - Records that the name is a label referenced in inline assembly.
unsigned incInstance()
Increment the current instance of this Directional Local Label.
BlockVerifier::State From
MCSymbol * getOrCreateLSDASymbol(StringRef FuncName)
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
void setBinding(unsigned Binding) const
CHAIN = SC CHAIN, Imm128 - System call.
MCSymbol * getBeginSymbol()
void reportWarning(SMLoc L, const Twine &Msg)
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
amdgpu AMDGPU DAG DAG Pattern Instruction Selection
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
void setSymbolValue(MCStreamer &Streamer, StringRef Sym, uint64_t Val)
Set value for a symbol.
iterator insert(iterator where, pointer New)
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
LLVM_NODISCARD bool empty() const
unsigned getInstance() const
Get the current instance of this Directional Local Label.
void addDebugPrefixMapEntry(const std::string &From, const std::string &To)
Add an entry to the debug prefix map.
COFFYAML::WeakExternalCharacteristics Characteristics
Generic base class for all target subtargets.
This represents a section on linux, lots of unix variants and some bare metal systems.
const std::string & getMainFileName() const
Get the main file name for use in error messages and debug info.
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group)
std::string str() const
Return the twine contents as a std::string.
StringRef getName() const
getName - Get the symbol name.
CodeViewContext & getCVContext()
Fragment for data and encoded instructions.
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
Instances of this class represent a label name in the MC file, and MCLabel are created and uniqued by...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM_NODISCARD char front() const
front - Get the first character in the string.
void setMCLineTableRootFile(unsigned CUID, StringRef CompilationDir, StringRef Filename, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source)
Specifies the "root" file and directory of the compilation unit.
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
void final(MD5Result &Result)
Finishes off the hash and puts the result in result.
StringRef - Represent a constant reference to a string, i.e.
Expected< unsigned > tryGetFile(StringRef &Directory, StringRef &FileName, Optional< MD5::MD5Result > Checksum, Optional< StringRef > Source, uint16_t DwarfVersion, unsigned FileNumber=0)
Represents a location in source code.
MCSection::FragmentListType & getFragmentList()
static SectionKind getReadOnly()
StringRef getSectionName() const
static SectionKind getExecuteOnly()
static SectionKind getText()
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Holds state from .cv_file and .cv_loc directives for later emission.