LLVM: lib/Object/RecordStreamer.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

14

15using namespace llvm;

16

17void RecordStreamer::markDefined(const MCSymbol &Symbol) {

19 switch (S) {

23 break;

28 break;

30 break;

33 }

34}

35

36void RecordStreamer::markGlobal(const MCSymbol &Symbol,

39 switch (S) {

43 break;

44

49 break;

52 break;

53 }

54}

55

56void RecordStreamer::markUsed(const MCSymbol &Symbol) {

58 switch (S) {

64 break;

65

69 break;

70 }

71}

72

73void RecordStreamer::visitUsedSymbol(const MCSymbol &Sym) { markUsed(Sym); }

74

77

79 return Symbols.begin();

80}

81

83

86 markDefined(*Symbol);

87}

88

90 markDefined(*Symbol);

92}

93

99 markUsed(*Symbol);

100 return true;

101}

102

106 markDefined(*Symbol);

107}

108

110 Align ByteAlignment) {

111 markDefined(*Symbol);

112}

113

115 auto SI = Symbols.find(Sym->getName());

116 if (SI == Symbols.end())

118 return SI->second;

119}

120

123 bool KeepOriginalSym) {

124 SymverAliasMap[OriginalSym].push_back(Name);

125}

126

129 return {SymverAliasMap.begin(), SymverAliasMap.end()};

130}

131

133

135

136

140 if (!GV.hasName())

141 continue;

142 MangledName.clear();

143 MangledName.reserve(GV.getName().size() + 1);

144 Mang.getNameWithPrefix(MangledName, &GV, false);

145 MangledNameMap[MangledName] = &GV;

146 }

147

148

149

150 for (auto &Symver : SymverAliasMap) {

151 const MCSymbol *Aliasee = Symver.first;

153 bool IsDefined = false;

154

155

157 switch (state) {

161 break;

165 break;

166 default:

167 break;

168 }

169

170 switch (state) {

174 IsDefined = true;

175 break;

180 break;

181 }

182

185 if (!GV) {

186 auto MI = MangledNameMap.find(Aliasee->getName());

187 if (MI != MangledNameMap.end())

188 GV = MI->second;

189 }

190 if (GV) {

191

192

200 }

202 }

203 }

204

205

206 for (auto AliasName : Symver.second) {

207 std::pair<StringRef, StringRef> Split = AliasName.split("@@@");

209 if (!Split.second.empty() && !Split.second.starts_with("@")) {

210

211

212 const char *Separator = IsDefined ? "@@" : "@";

213 AliasName =

214 (Split.first + Separator + Split.second).toStringRef(NewName);

215 }

217

218

220 if (IsDefined)

221 markDefined(*Alias);

222

226 }

227 }

228}

Module.h This file contains the declarations for the Module class.

bool hasExternalLinkage() const

bool hasLocalLinkage() const

bool isDeclarationForLinker() const

static bool isWeakForLinker(LinkageTypes Linkage)

Whether the definition of this global may be replaced at link time.

Context object for machine code objects.

MCSymbol * getOrCreateSymbol(const Twine &Name)

Lookup the symbol inside with the specified Name.

Base class for the full range of assembler expressions which are needed for parsing.

Instances of this class represent a uniqued identifier for a section in the current translation unit.

Streaming machine code generation interface.

virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value)

Emit an assignment of Value to Symbol.

MCContext & getContext() const

virtual void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc())

Emit a label for Symbol into the current section.

static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

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.

A Module instance is used to store all the information related to an LLVM module.

GlobalValue * getNamedValue(StringRef Name) const

Return the global value in the module with the specified name, of arbitrary type.

iterator_range< global_value_iterator > global_values()

void emitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Align ByteAlignment, SMLoc Loc=SMLoc()) override

Emit the zerofill section and an optional symbol.

bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override

Add the given Attribute to Symbol.

void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment) override

Emit a common symbol.

void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, bool KeepOriginalSym) override

Record .symver aliases for later processing.

void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override

Emit an assignment of Value to Symbol.

iterator_range< const_symver_iterator > symverAliases()

StringMap< State >::const_iterator const_iterator

RecordStreamer(MCContext &Context, const Module &M)

void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override

Emit a label for Symbol into the current section.

void flushSymverDirectives()

Represents a location in source code.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

void reserve(size_type N)

StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...

iterator find(StringRef Key)

StringRef - Represent a constant reference to a string, i.e.

LLVM Value Representation.

A range adaptor for a pair of iterators.

This is an optimization pass for GlobalISel generic memory operations.

@ MCSA_LazyReference

.lazy_reference (MachO)

@ MCSA_Global

.type _foo, @gnu_unique_object

@ MCSA_Invalid

Not a valid directive.

This struct is a compact representation of a valid (non-zero power of two) alignment.