56 using namespace object;
65 SymTab.push_back(&GV);
68 SymTab.push_back(
new (AsmSymbols.Allocate())
AsmSymbol(Name, Flags));
88 MangledName.
reserve(GV.getName().size() + 1);
90 MangledNameMap[MangledName] = &GV;
102 const MCSymbol *Aliasee = Symver.first;
123 const auto *GV = M.getNamedValue(Aliasee->
getName());
126 if (
MI != MangledNameMap.
end())
131 if (GV->hasExternalLinkage())
133 else if (GV->hasLocalLinkage())
135 else if (GV->isWeakForLinker())
142 for (
auto &Alias : Symver.second)
151 if (InlineAsm.
empty())
157 assert(T && T->hasMCAsmParser());
159 std::unique_ptr<MCRegisterInfo>
MRI(T->createMCRegInfo(TT.str()));
163 std::unique_ptr<MCAsmInfo> MAI(T->createMCAsmInfo(*MRI, TT.str()));
167 std::unique_ptr<MCSubtargetInfo> STI(
168 T->createMCSubtargetInfo(TT.str(),
"",
""));
172 std::unique_ptr<MCInstrInfo> MCII(T->createMCInstrInfo());
177 MCContext MCCtx(MAI.get(), MRI.get(), &MOFI);
180 T->createNullTargetStreamer(Streamer);
185 std::unique_ptr<MCAsmParser> Parser(
189 std::unique_ptr<MCTargetAsmParser> TAP(
190 T->createMCAsmParser(*STI, *Parser, *MCII, MCOptions));
194 Parser->setTargetParser(*TAP);
195 if (Parser->Run(
false))
200 for (
auto &KV : Streamer) {
237 if (GV->hasDLLImportStorageClass())
240 Mang.getNameWithPrefix(OS, GV,
false);
250 if (GV->isDeclarationForLinker())
252 else if (GV->hasHiddenVisibility() && !GV->hasLocalLinkage())
255 if (GVar->isConstant())
258 if (dyn_cast_or_null<Function>(GV->getBaseObject()))
260 if (isa<GlobalAlias>(GV))
262 if (GV->hasPrivateLinkage())
264 if (!GV->hasLocalLinkage())
266 if (GV->hasCommonLinkage())
268 if (GV->hasLinkOnceLinkage() || GV->hasWeakLinkage() ||
269 GV->hasExternalWeakLinkage())
272 if (GV->getName().startswith(
"llvm."))
274 else if (
auto *Var = dyn_cast<GlobalVariable>(GV)) {
275 if (Var->getSection() ==
"llvm.metadata")
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
A Module instance is used to store all the information related to an LLVM module. ...
bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
An efficient, type-erasing, non-owning reference to a callable.
iterator find(StringRef Key)
static const Target * lookupTarget(const std::string &Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
void reserve(size_type N)
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
void InitMCObjectFileInfo(const Triple &TT, bool PIC, CodeModel::Model CM, MCContext &ctx)
MCAsmParser * createMCAsmParser(SourceMgr &, MCContext &, MCStreamer &, const MCAsmInfo &, unsigned CB=0)
Create an MCAsmParser instance.
void addModule(Module *M)
static void CollectAsmSymbols(const Module &M, function_ref< void(StringRef, object::BasicSymbolRef::Flags)> AsmSymbol)
Parse inline ASM and collect the symbols that are defined or referenced in the current module...
Context object for machine code objects.
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
std::pair< std::string, uint32_t > AsmSymbol
unsigned const MachineRegisterInfo * MRI
static void handleSymverAliases(const Module &M, RecordStreamer &Streamer)
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
Triple - Helper class for working with autoconf configuration names.
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
State getSymbolState(const MCSymbol *Sym)
Get the state recorded for the given symbol.
T get() const
Returns the value of the specified pointer type.
Module.h This file contains the declarations for the Module class.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Target - Wrapper for Target specific information.
uint32_t getSymbolFlags(Symbol S) const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
llvm_unreachable("Unknown RegBank!")
DenseMap< const MCSymbol *, std::vector< MCSymbol * > > & symverAliases()
Return the map of .symver aliasee to associated aliases.
static std::vector< std::string > Flags
StringRef getName() const
getName - Get the symbol name.
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
void printSymbolName(raw_ostream &OS, Symbol S) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
Represents a location in source code.
int is() const
Test if the Union currently holds the type matching T.
iterator_range< global_value_iterator > global_values()
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...