39 cl::desc(
"As secure log file name (initialized from "
40 "AS_SECURE_LOG_FILE env variable)"),
51 AllowTemporaryLabels(
true), DwarfCompileUnitID(0),
52 AutoReset(DoAutoReset), HadError(
false) {
55 SecureLogUsed =
false;
76 COFFAllocator.DestroyAll();
77 ELFAllocator.DestroyAll();
78 MachOAllocator.DestroyAll();
80 MCSubtargetAllocator.DestroyAll();
83 SectionSymbols.clear();
86 CompilationDir.
clear();
88 MCDwarfLineTablesCUMap.clear();
89 SectionsForRanges.clear();
90 MCGenDwarfLabelEntries.clear();
92 DwarfCompileUnitID = 0;
97 MachOUniquingMap.clear();
98 ELFUniquingMap.clear();
99 COFFUniquingMap.clear();
102 AllowTemporaryLabels =
true;
103 DwarfLocSeen =
false;
104 GenDwarfForAssembly =
false;
105 GenDwarfFileNumber = 0;
118 assert(!NameRef.
empty() &&
"Normal symbols cannot be unnamed!");
122 Sym = createSymbol(NameRef,
false,
false);
130 return cast<MCSymbolELF>(Sym);
133 auto NameIter = UsedNames.insert(std::make_pair(Name,
false)).first;
134 Sym =
new (&*NameIter, *
this)
MCSymbolELF(&*NameIter,
false);
136 return cast<MCSymbolELF>(Sym);
142 "$frame_escape_" +
Twine(Idx));
147 "$parent_frame_offset");
173 if (CanBeUnnamed && !UseNamesOnTempLabels)
174 return createSymbolImpl(
nullptr,
true);
178 bool IsTemporary = CanBeUnnamed;
179 if (AllowTemporaryLabels && !IsTemporary)
183 bool AddSuffix = AlwaysAddSuffix;
184 unsigned &NextUniqueID = NextID[
Name];
190 auto NameEntry = UsedNames.insert(std::make_pair(NewName,
true));
191 if (NameEntry.second || !NameEntry.first->second) {
194 NameEntry.first->second =
true;
197 return createSymbolImpl(&*NameEntry.first, IsTemporary);
199 assert(IsTemporary &&
"Cannot rename non-temporary symbols");
209 return createSymbol(NameSV, AlwaysAddSuffix, CanBeUnnamed);
215 return createSymbol(NameSV,
true,
false);
222 unsigned MCContext::NextInstance(
unsigned LocalLabelVal) {
223 MCLabel *&Label = Instances[LocalLabelVal];
225 Label =
new (*this)
MCLabel(0);
229 unsigned MCContext::GetInstance(
unsigned LocalLabelVal) {
230 MCLabel *&Label = Instances[LocalLabelVal];
232 Label =
new (*this)
MCLabel(0);
236 MCSymbol *MCContext::getOrCreateDirectionalLocalSymbol(
unsigned LocalLabelVal,
238 MCSymbol *&Sym = LocalSymbols[std::make_pair(LocalLabelVal, Instance)];
245 unsigned Instance = NextInstance(LocalLabelVal);
246 return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
251 unsigned Instance = GetInstance(LocalLabelVal);
254 return getOrCreateDirectionalLocalSymbol(LocalLabelVal, Instance);
260 return Symbols.
lookup(NameRef);
275 unsigned TypeAndAttributes,
277 const char *BeginSymName) {
300 Segment, Section, TypeAndAttributes, Reserved2, Kind, Begin);
306 GroupName = Group->getName();
309 ELFUniquingMap.erase(
311 auto I = ELFUniquingMap.insert(std::make_pair(
312 ELFSectionKey{
Name, GroupName, UniqueID},
320 unsigned Flags,
unsigned EntrySize,
325 std::tie(I, Inserted) =
326 ELFRelSecNames.
insert(std::make_pair(Name.
str(),
true));
328 return new (ELFAllocator.Allocate())
330 EntrySize, Group,
true,
nullptr, Associated);
336 unsigned EntrySize) {
337 return getELFSection(Prefix +
"." + Suffix, Type, Flags, EntrySize, Suffix);
341 unsigned Flags,
unsigned EntrySize,
342 const Twine &Group,
unsigned UniqueID,
343 const char *BeginSymName) {
348 return getELFSection(Section, Type, Flags, EntrySize, GroupSym, UniqueID,
349 BeginSymName,
nullptr);
353 unsigned Flags,
unsigned EntrySize,
356 const char *BeginSymName,
362 auto IterBool = ELFUniquingMap.insert(
363 std::make_pair(ELFSectionKey{Section.
str(), Group, UniqueID},
nullptr));
364 auto &Entry = *IterBool.first;
365 if (!IterBool.second)
368 StringRef CachedName = Entry.first.SectionName;
383 MCSectionELF(CachedName, Type, Flags, Kind, EntrySize, GroupSym, UniqueID,
385 Entry.second = Result;
392 Group, ~0,
nullptr,
nullptr);
401 const char *BeginSymName) {
403 if (!COMDATSymName.
empty()) {
405 COMDATSymName = COMDATSymbol->
getName();
410 COFFSectionKey
T{
Section, COMDATSymName, Selection, UniqueID};
411 auto IterBool = COFFUniquingMap.insert(std::make_pair(
T,
nullptr));
412 auto Iter = IterBool.first;
413 if (!IterBool.second)
420 StringRef CachedName = Iter->first.SectionName;
422 CachedName, Characteristics, COMDATSymbol, Selection, Kind, Begin);
424 Iter->second = Result;
431 const char *BeginSymName) {
438 auto Iter = COFFUniquingMap.find(
T);
439 if (Iter == COFFUniquingMap.end())
478 unsigned FileNumber,
unsigned CUID) {
480 return Table.
getFile(Directory, FileName, FileNumber);
487 if (FileNumber == 0 || FileNumber >= MCDwarfFiles.
size())
490 return !MCDwarfFiles[FileNumber].Name.
empty();
496 SectionsForRanges.remove_if(
501 if (!CVContext.get())
503 return *CVContext.get();
MCSymbolELF * getOrCreateSectionSymbol(const MCSectionELF &Section)
Instances of this class represent a uniqued identifier for a section in the current translation unit...
void push_back(const T &Elt)
MCSymbol * getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before)
Create and return a directional local symbol for numbered label (used for "1b" or 1f" references)...
StringRef getSectionName() const
This represents a section on a Mach-O system (used by Mac OS X).
MCSectionELF * createELFRelSection(const Twine &Name, unsigned Type, unsigned Flags, unsigned EntrySize, const MCSymbolELF *Group, const MCSectionELF *Associated)
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
const SmallVectorImpl< MCDwarfFile > & getMCDwarfFiles(unsigned CUID=0)
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 ...
MCSymbol * createDirectionalLocalSymbol(unsigned LocalLabelVal)
Create the definition of a directional local symbol for numbered label (used for "1:" definitions)...
unsigned getUniqueID() const
MCSymbol * getOrCreateParentFrameOffsetSymbol(StringRef FuncName)
A raw_ostream that writes to an SmallVector or SmallString.
MCSymbol * lookupSymbol(const Twine &Name) const
Get the symbol for Name, or null.
unsigned getInstance() const
Get the current instance of this Directional Local Label.
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.
unsigned getMainFileID() const
std::string str() const
Return the twine contents as a std::string.
#define DWARF2_FLAG_IS_STMT
MCSymbol * createLinkerPrivateTempSymbol()
Create and return a new linker temporary symbol with a unique but unspecified name.
struct fuzzer::@269 Flags
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)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void finalizeDwarfSections(MCStreamer &MCOS)
Remove empty sections from SectionStartEndSyms, to avoid generating useless debug info for them...
StringRef getPrivateGlobalPrefix() const
virtual bool mayHaveInstructions(MCSection &Sec) const
LLVM_NODISCARD bool empty() const
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value)
Emit an assignment of Value to Symbol.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
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.
Environment getObjectFileType() const
Instances of this class represent the information from a dwarf .loc directive.
Function Alias Analysis false
const MCSymbolELF * getGroup() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
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...
This class is intended to be used as a base class for asm properties and features specific to the tar...
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)
initializer< Ty > init(const Ty &Val)
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
The instances of the Type class are immutable: once they are created, they are never changed...
unsigned getNumBuffers() const
void RunInterruptHandlers()
This function runs all the registered interrupt handlers, including the removal of files registered b...
Greedy Register Allocator
cl::opt< int > DwarfVersion("dwarf-version", cl::desc("Dwarf version"), cl::init(0))
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.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
unsigned getCharacteristics() 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...
unsigned incInstance()
Increment the current instance of this Directional Local Label.
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
SectionKind getKind() const
MCSymbol * getOrCreateLSDASymbol(StringRef FuncName)
StringRef getSectionName() const
StringRef toStringRef(SmallVectorImpl< char > &Out) const
This returns the twine as a single StringRef if it can be represented as such.
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"...
Pass this value as the UniqueID during section creation to get the generic section with the given nam...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
void setSymbolValue(MCStreamer &Streamer, StringRef Sym, uint64_t Val)
Set value for a symbol.
StringRef getName() const
getName - Get the symbol name.
const MemoryBuffer * getMemoryBuffer(unsigned i) const
MCSymbol * getOrCreateSymbol(const Twine &Name)
Lookup the symbol inside with the specified Name.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
COFFYAML::WeakExternalCharacteristics Characteristics
MCSubtargetInfo - Generic base class for all target subtargets.
This represents a section on linux, lots of unix variants and some bare metal systems.
MCSectionELF * createELFGroupSection(const MCSymbolELF *Group)
CodeViewContext & getCVContext()
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())
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
unsigned getDwarfFile(StringRef Directory, StringRef FileName, unsigned FileNumber, unsigned CUID)
Creates an entry in the dwarf file and directory tables.
StringRef getLinkerPrivateGlobalPrefix() const
bool isTriviallyEmpty() const
Check if this twine is trivially empty; a false return value does not necessarily mean the twine is e...
StringRef - Represent a constant reference to a string, i.e.
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.
Represents a location in source code.
unsigned getFile(StringRef &Directory, StringRef &FileName, unsigned FileNumber=0)
static SectionKind getReadOnly()
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
static SectionKind getExecuteOnly()
static SectionKind getText()
MCSubtargetInfo & getSubtargetCopy(const MCSubtargetInfo &STI)
Holds state from .cv_file and .cv_loc directives for later emission.