LLVM  14.0.0git
IRSymtab.cpp
Go to the documentation of this file.
1 //===- IRSymtab.cpp - implementation of IR symbol tables ------------------===//
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 #include "llvm/Object/IRSymtab.h"
10 #include "llvm/ADT/ArrayRef.h"
11 #include "llvm/ADT/DenseMap.h"
12 #include "llvm/ADT/SmallPtrSet.h"
13 #include "llvm/ADT/SmallString.h"
14 #include "llvm/ADT/SmallVector.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/ADT/Triple.h"
17 #include "llvm/Config/llvm-config.h"
18 #include "llvm/IR/Comdat.h"
19 #include "llvm/IR/DataLayout.h"
20 #include "llvm/IR/GlobalAlias.h"
21 #include "llvm/IR/GlobalObject.h"
22 #include "llvm/IR/Mangler.h"
23 #include "llvm/IR/Metadata.h"
24 #include "llvm/IR/Module.h"
30 #include "llvm/Support/Allocator.h"
31 #include "llvm/Support/Casting.h"
32 #include "llvm/Support/Error.h"
34 #include "llvm/Support/VCSRevision.h"
36 #include <cassert>
37 #include <string>
38 #include <utility>
39 #include <vector>
40 
41 using namespace llvm;
42 using namespace irsymtab;
43 
44 static const char *PreservedSymbols[] = {
45 #define HANDLE_LIBCALL(code, name) name,
46 #include "llvm/IR/RuntimeLibcalls.def"
47 #undef HANDLE_LIBCALL
48  // There are global variables, so put it here instead of in
49  // RuntimeLibcalls.def.
50  // TODO: Are there similar such variables?
51  "__ssp_canary_word",
52  "__stack_chk_guard",
53 };
54 
55 namespace {
56 
57 const char *getExpectedProducerName() {
58  static char DefaultName[] = LLVM_VERSION_STRING
59 #ifdef LLVM_REVISION
60  " " LLVM_REVISION
61 #endif
62  ;
63  // Allows for testing of the irsymtab writer and upgrade mechanism. This
64  // environment variable should not be set by users.
65  if (char *OverrideName = getenv("LLVM_OVERRIDE_PRODUCER"))
66  return OverrideName;
67  return DefaultName;
68 }
69 
70 const char *kExpectedProducerName = getExpectedProducerName();
71 
72 /// Stores the temporary state that is required to build an IR symbol table.
73 struct Builder {
74  SmallVector<char, 0> &Symtab;
75  StringTableBuilder &StrtabBuilder;
76  StringSaver Saver;
77 
78  // This ctor initializes a StringSaver using the passed in BumpPtrAllocator.
79  // The StringTableBuilder does not create a copy of any strings added to it,
80  // so this provides somewhere to store any strings that we create.
81  Builder(SmallVector<char, 0> &Symtab, StringTableBuilder &StrtabBuilder,
82  BumpPtrAllocator &Alloc)
83  : Symtab(Symtab), StrtabBuilder(StrtabBuilder), Saver(Alloc) {}
84 
86  Mangler Mang;
87  Triple TT;
88 
89  std::vector<storage::Comdat> Comdats;
90  std::vector<storage::Module> Mods;
91  std::vector<storage::Symbol> Syms;
92  std::vector<storage::Uncommon> Uncommons;
93 
94  std::string COFFLinkerOpts;
95  raw_string_ostream COFFLinkerOptsOS{COFFLinkerOpts};
96 
97  std::vector<storage::Str> DependentLibraries;
98 
99  void setStr(storage::Str &S, StringRef Value) {
100  S.Offset = StrtabBuilder.add(Value);
101  S.Size = Value.size();
102  }
103 
104  template <typename T>
105  void writeRange(storage::Range<T> &R, const std::vector<T> &Objs) {
106  R.Offset = Symtab.size();
107  R.Size = Objs.size();
108  Symtab.insert(Symtab.end(), reinterpret_cast<const char *>(Objs.data()),
109  reinterpret_cast<const char *>(Objs.data() + Objs.size()));
110  }
111 
112  Expected<int> getComdatIndex(const Comdat *C, const Module *M);
113 
114  Error addModule(Module *M);
115  Error addSymbol(const ModuleSymbolTable &Msymtab,
116  const SmallPtrSet<GlobalValue *, 4> &Used,
118 
120 };
121 
122 Error Builder::addModule(Module *M) {
123  if (M->getDataLayoutStr().empty())
124  return make_error<StringError>("input module has no datalayout",
126 
127  // Symbols in the llvm.used list will get the FB_Used bit and will not be
128  // internalized. We do this for llvm.compiler.used as well:
129  //
130  // IR symbol table tracks module-level asm symbol references but not inline
131  // asm. A symbol only referenced by inline asm is not in the IR symbol table,
132  // so we may not know that the definition (in another translation unit) is
133  // referenced. That definition may have __attribute__((used)) (which lowers to
134  // llvm.compiler.used on ELF targets) to communicate to the compiler that it
135  // may be used by inline asm. The usage is perfectly fine, so we treat
136  // llvm.compiler.used conservatively as llvm.used to work around our own
137  // limitation.
139  collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/false);
140  collectUsedGlobalVariables(*M, UsedV, /*CompilerUsed=*/true);
141  SmallPtrSet<GlobalValue *, 4> Used(UsedV.begin(), UsedV.end());
142 
143  ModuleSymbolTable Msymtab;
144  Msymtab.addModule(M);
145 
147  Mod.Begin = Syms.size();
148  Mod.End = Syms.size() + Msymtab.symbols().size();
149  Mod.UncBegin = Uncommons.size();
150  Mods.push_back(Mod);
151 
152  if (TT.isOSBinFormatCOFF()) {
153  if (auto E = M->materializeMetadata())
154  return E;
155  if (NamedMDNode *LinkerOptions =
156  M->getNamedMetadata("llvm.linker.options")) {
157  for (MDNode *MDOptions : LinkerOptions->operands())
158  for (const MDOperand &MDOption : cast<MDNode>(MDOptions)->operands())
159  COFFLinkerOptsOS << " " << cast<MDString>(MDOption)->getString();
160  }
161  }
162 
163  if (TT.isOSBinFormatELF()) {
164  if (auto E = M->materializeMetadata())
165  return E;
166  if (NamedMDNode *N = M->getNamedMetadata("llvm.dependent-libraries")) {
167  for (MDNode *MDOptions : N->operands()) {
168  const auto OperandStr =
169  cast<MDString>(cast<MDNode>(MDOptions)->getOperand(0))->getString();
170  storage::Str Specifier;
171  setStr(Specifier, OperandStr);
172  DependentLibraries.emplace_back(Specifier);
173  }
174  }
175  }
176 
177  for (ModuleSymbolTable::Symbol Msym : Msymtab.symbols())
178  if (Error Err = addSymbol(Msymtab, Used, Msym))
179  return Err;
180 
181  return Error::success();
182 }
183 
184 Expected<int> Builder::getComdatIndex(const Comdat *C, const Module *M) {
185  auto P = ComdatMap.insert(std::make_pair(C, Comdats.size()));
186  if (P.second) {
187  std::string Name;
188  if (TT.isOSBinFormatCOFF()) {
189  const GlobalValue *GV = M->getNamedValue(C->getName());
190  if (!GV)
191  return make_error<StringError>("Could not find leader",
193  // Internal leaders do not affect symbol resolution, therefore they do not
194  // appear in the symbol table.
195  if (GV->hasLocalLinkage()) {
196  P.first->second = -1;
197  return -1;
198  }
200  Mang.getNameWithPrefix(OS, GV, false);
201  } else {
202  Name = std::string(C->getName());
203  }
204 
206  setStr(Comdat.Name, Saver.save(Name));
207  Comdat.SelectionKind = C->getSelectionKind();
208  Comdats.push_back(Comdat);
209  }
210 
211  return P.first->second;
212 }
213 
214 Error Builder::addSymbol(const ModuleSymbolTable &Msymtab,
215  const SmallPtrSet<GlobalValue *, 4> &Used,
217  Syms.emplace_back();
218  storage::Symbol &Sym = Syms.back();
219  Sym = {};
220 
221  storage::Uncommon *Unc = nullptr;
222  auto Uncommon = [&]() -> storage::Uncommon & {
223  if (Unc)
224  return *Unc;
226  Uncommons.emplace_back();
227  Unc = &Uncommons.back();
228  *Unc = {};
229  setStr(Unc->COFFWeakExternFallbackName, "");
230  setStr(Unc->SectionName, "");
231  return *Unc;
232  };
233 
235  {
237  Msymtab.printSymbolName(OS, Msym);
238  }
239  setStr(Sym.Name, Saver.save(Name.str()));
240 
241  auto Flags = Msymtab.getSymbolFlags(Msym);
245  Sym.Flags |= 1 << storage::Symbol::FB_weak;
247  Sym.Flags |= 1 << storage::Symbol::FB_common;
251  Sym.Flags |= 1 << storage::Symbol::FB_global;
256 
257  Sym.ComdatIndex = -1;
258  auto *GV = Msym.dyn_cast<GlobalValue *>();
259  if (!GV) {
260  // Undefined module asm symbols act as GC roots and are implicitly used.
262  Sym.Flags |= 1 << storage::Symbol::FB_used;
263  setStr(Sym.IRName, "");
264  return Error::success();
265  }
266 
267  setStr(Sym.IRName, GV->getName());
268 
269  bool IsPreservedSymbol = llvm::is_contained(PreservedSymbols, GV->getName());
270 
271  if (Used.count(GV) || IsPreservedSymbol)
272  Sym.Flags |= 1 << storage::Symbol::FB_used;
273  if (GV->isThreadLocal())
274  Sym.Flags |= 1 << storage::Symbol::FB_tls;
275  if (GV->hasGlobalUnnamedAddr())
277  if (GV->canBeOmittedFromSymbolTable())
279  Sym.Flags |= unsigned(GV->getVisibility()) << storage::Symbol::FB_visibility;
280 
281  if (Flags & object::BasicSymbolRef::SF_Common) {
282  auto *GVar = dyn_cast<GlobalVariable>(GV);
283  if (!GVar)
284  return make_error<StringError>("Only variables can have common linkage!",
286  Uncommon().CommonSize =
288  Uncommon().CommonAlign = GVar->getAlignment();
289  }
290 
291  const GlobalObject *GO = GV->getAliaseeObject();
292  if (!GO) {
293  if (isa<GlobalIFunc>(GV))
294  GO = cast<GlobalIFunc>(GV)->getResolverFunction();
295  if (!GO)
296  return make_error<StringError>("Unable to determine comdat of alias!",
298  }
299  if (const Comdat *C = GO->getComdat()) {
300  Expected<int> ComdatIndexOrErr = getComdatIndex(C, GV->getParent());
301  if (!ComdatIndexOrErr)
302  return ComdatIndexOrErr.takeError();
303  Sym.ComdatIndex = *ComdatIndexOrErr;
304  }
305 
306  if (TT.isOSBinFormatCOFF()) {
307  emitLinkerFlagsForGlobalCOFF(COFFLinkerOptsOS, GV, TT, Mang);
308 
309  if ((Flags & object::BasicSymbolRef::SF_Weak) &&
311  auto *Fallback = dyn_cast<GlobalValue>(
312  cast<GlobalAlias>(GV)->getAliasee()->stripPointerCasts());
313  if (!Fallback)
314  return make_error<StringError>("Invalid weak external",
316  std::string FallbackName;
317  raw_string_ostream OS(FallbackName);
318  Msymtab.printSymbolName(OS, Fallback);
319  OS.flush();
320  setStr(Uncommon().COFFWeakExternFallbackName, Saver.save(FallbackName));
321  }
322  }
323 
324  if (!GO->getSection().empty())
325  setStr(Uncommon().SectionName, Saver.save(GO->getSection()));
326 
327  return Error::success();
328 }
329 
331  storage::Header Hdr;
332 
333  assert(!IRMods.empty());
335  setStr(Hdr.Producer, kExpectedProducerName);
336  setStr(Hdr.TargetTriple, IRMods[0]->getTargetTriple());
337  setStr(Hdr.SourceFileName, IRMods[0]->getSourceFileName());
338  TT = Triple(IRMods[0]->getTargetTriple());
339 
340  for (auto *M : IRMods)
341  if (Error Err = addModule(M))
342  return Err;
343 
344  COFFLinkerOptsOS.flush();
345  setStr(Hdr.COFFLinkerOpts, Saver.save(COFFLinkerOpts));
346 
347  // We are about to fill in the header's range fields, so reserve space for it
348  // and copy it in afterwards.
349  Symtab.resize(sizeof(storage::Header));
350  writeRange(Hdr.Modules, Mods);
351  writeRange(Hdr.Comdats, Comdats);
352  writeRange(Hdr.Symbols, Syms);
353  writeRange(Hdr.Uncommons, Uncommons);
354  writeRange(Hdr.DependentLibraries, DependentLibraries);
355  *reinterpret_cast<storage::Header *>(Symtab.data()) = Hdr;
356  return Error::success();
357 }
358 
359 } // end anonymous namespace
360 
362  StringTableBuilder &StrtabBuilder,
363  BumpPtrAllocator &Alloc) {
364  return Builder(Symtab, StrtabBuilder, Alloc).build(Mods);
365 }
366 
367 // Upgrade a vector of bitcode modules created by an old version of LLVM by
368 // creating an irsymtab for them in the current format.
371 
372  LLVMContext Ctx;
373  std::vector<Module *> Mods;
374  std::vector<std::unique_ptr<Module>> OwnedMods;
375  for (auto BM : BMs) {
377  BM.getLazyModule(Ctx, /*ShouldLazyLoadMetadata*/ true,
378  /*IsImporting*/ false);
379  if (!MOrErr)
380  return MOrErr.takeError();
381 
382  Mods.push_back(MOrErr->get());
383  OwnedMods.push_back(std::move(*MOrErr));
384  }
385 
387  BumpPtrAllocator Alloc;
388  if (Error E = build(Mods, FC.Symtab, StrtabBuilder, Alloc))
389  return std::move(E);
390 
391  StrtabBuilder.finalizeInOrder();
392  FC.Strtab.resize(StrtabBuilder.getSize());
393  StrtabBuilder.write((uint8_t *)FC.Strtab.data());
394 
395  FC.TheReader = {{FC.Symtab.data(), FC.Symtab.size()},
396  {FC.Strtab.data(), FC.Strtab.size()}};
397  return std::move(FC);
398 }
399 
401  if (BFC.Mods.empty())
402  return make_error<StringError>("Bitcode file does not contain any modules",
404 
405  if (BFC.StrtabForSymtab.empty() ||
406  BFC.Symtab.size() < sizeof(storage::Header))
407  return upgrade(BFC.Mods);
408 
409  // We cannot use the regular reader to read the version and producer, because
410  // it will expect the header to be in the current format. The only thing we
411  // can rely on is that the version and producer will be present as the first
412  // struct elements.
413  auto *Hdr = reinterpret_cast<const storage::Header *>(BFC.Symtab.data());
414  unsigned Version = Hdr->Version;
415  StringRef Producer = Hdr->Producer.get(BFC.StrtabForSymtab);
417  Producer != kExpectedProducerName)
418  return upgrade(BFC.Mods);
419 
421  FC.TheReader = {{BFC.Symtab.data(), BFC.Symtab.size()},
422  {BFC.StrtabForSymtab.data(), BFC.StrtabForSymtab.size()}};
423 
424  // Finally, make sure that the number of modules in the symbol table matches
425  // the number of modules in the bitcode file. If they differ, it may mean that
426  // the bitcode file was created by binary concatenation, so we need to create
427  // a new symbol table from scratch.
428  if (FC.TheReader.getNumModules() != BFC.Mods.size())
429  return upgrade(std::move(BFC.Mods));
430 
431  return std::move(FC);
432 }
llvm::irsymtab::storage::Symbol::FB_has_uncommon
@ FB_has_uncommon
Definition: IRSymtab.h:105
llvm::irsymtab::storage::Header::Symbols
Range< Symbol > Symbols
Definition: IRSymtab.h:149
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
Comdat.h
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1421
llvm::ARM::PredBlockMask::TT
@ TT
llvm::irsymtab::storage::Header::Modules
Range< Module > Modules
Definition: IRSymtab.h:147
Metadata.h
llvm::irsymtab::storage::Str::get
StringRef get(StringRef Strtab) const
Definition: IRSymtab.h:58
llvm::object::BasicSymbolRef::SF_Indirect
@ SF_Indirect
Definition: SymbolicFile.h:113
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::object::BasicSymbolRef::SF_Common
@ SF_Common
Definition: SymbolicFile.h:112
llvm::irsymtab::FileContents
The contents of the irsymtab in a bitcode file.
Definition: IRSymtab.h:369
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:631
llvm::GlobalObject::getSection
StringRef getSection() const
Get the custom section of this global if it has one.
Definition: GlobalObject.h:112
llvm::SmallVector< char, 0 >
llvm::irsymtab::storage::Comdat
This is equivalent to an IR comdat.
Definition: IRSymtab.h:82
llvm::Error::success
static ErrorSuccess success()
Create a success value.
Definition: Error.h:331
llvm::irsymtab::storage::Symbol::FB_used
@ FB_used
Definition: IRSymtab.h:110
llvm::StringTableBuilder::finalizeInOrder
void finalizeInOrder()
Finalize the string table without reording it.
Definition: StringTableBuilder.cpp:133
upgrade
static Expected< FileContents > upgrade(ArrayRef< BitcodeModule > BMs)
Definition: IRSymtab.cpp:369
Allocator.h
R600_InstFlag::FC
@ FC
Definition: R600Defines.h:32
Error.h
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
DenseMap.h
llvm::BitcodeFileContents::Symtab
StringRef Symtab
Definition: BitcodeReader.h:125
Module.h
llvm::irsymtab::storage::Header::DependentLibraries
Range< Str > DependentLibraries
Dependent Library Specifiers.
Definition: IRSymtab.h:158
llvm::irsymtab::storage::Header::Version
Word Version
Version number of the symtab format.
Definition: IRSymtab.h:138
GlobalObject.h
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:449
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:42
llvm::object::BasicSymbolRef::SF_Weak
@ SF_Weak
Definition: SymbolicFile.h:110
SymbolicFile.h
llvm::Mangler
Definition: Mangler.h:27
llvm::irsymtab::storage::Symbol::FB_undefined
@ FB_undefined
Definition: IRSymtab.h:106
llvm::ArrayRef::empty
bool empty() const
empty - Check if the array is empty.
Definition: ArrayRef.h:158
llvm::object::BasicSymbolRef::SF_Executable
@ SF_Executable
Definition: SymbolicFile.h:120
llvm::RISCVFenceField::R
@ R
Definition: RISCVBaseInfo.h:207
llvm::collectUsedGlobalVariables
GlobalVariable * collectUsedGlobalVariables(const Module &M, SmallVectorImpl< GlobalValue * > &Vec, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
Definition: Module.cpp:782
llvm::MDNode::operands
op_range operands() const
Definition: Metadata.h:1135
llvm::irsymtab::storage::Header::Producer
Str Producer
The producer's version string (LLVM_VERSION_STRING " " LLVM_REVISION).
Definition: IRSymtab.h:145
StringTableBuilder.h
SmallString.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::irsymtab::storage::Symbol::Flags
Word Flags
Definition: IRSymtab.h:102
llvm::Comdat::SelectionKind
SelectionKind
Definition: Comdat.h:35
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GlobalObject
Definition: GlobalObject.h:27
llvm::GlobalObject::getComdat
const Comdat * getComdat() const
Definition: GlobalObject.h:123
llvm::Mangler::getNameWithPrefix
void getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV, bool CannotUsePrivateLabel) const
Print the appropriate prefix and the specified global variable's name.
Definition: Mangler.cpp:119
llvm::StringTableBuilder::getSize
size_t getSize() const
Definition: StringTableBuilder.h:82
llvm::SmallVectorImpl::resize
void resize(size_type N)
Definition: SmallVector.h:609
llvm::irsymtab::storage::Header::TargetTriple
Str TargetTriple
Definition: IRSymtab.h:152
SmallPtrSet.h
llvm::ModuleSymbolTable::printSymbolName
void printSymbolName(raw_ostream &OS, Symbol S) const
Definition: ModuleSymbolTable.cpp:179
llvm::GlobalValue::hasGlobalUnnamedAddr
bool hasGlobalUnnamedAddr() const
Definition: GlobalValue.h:196
llvm::ModuleSymbolTable::symbols
ArrayRef< Symbol > symbols() const
Definition: ModuleSymbolTable.h:46
llvm::Comdat
Definition: Comdat.h:33
llvm::irsymtab::storage::Header
Definition: IRSymtab.h:134
llvm::BitcodeFileContents
Definition: BitcodeReader.h:123
llvm::StringTableBuilder::RAW
@ RAW
Definition: StringTableBuilder.h:32
llvm::ModuleSymbolTable::addModule
void addModule(Module *M)
Definition: ModuleSymbolTable.cpp:57
llvm::SmallString< 64 >
llvm::irsymtab::storage::Header::Comdats
Range< Comdat > Comdats
Definition: IRSymtab.h:148
llvm::irsymtab::readBitcode
Expected< FileContents > readBitcode(const BitcodeFileContents &BFC)
Reads the contents of a bitcode file, creating its irsymtab if necessary.
Definition: IRSymtab.cpp:400
StringSaver.h
llvm::irsymtab::storage::Header::SourceFileName
Str SourceFileName
Definition: IRSymtab.h:152
IRObjectFile.h
llvm::irsymtab::storage::Symbol::FB_visibility
@ FB_visibility
Definition: IRSymtab.h:104
IRSymtab.h
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::object::BasicSymbolRef::SF_FormatSpecific
@ SF_FormatSpecific
Definition: SymbolicFile.h:115
llvm::irsymtab::storage::Symbol::FB_common
@ FB_common
Definition: IRSymtab.h:108
llvm::StringRef::empty
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:152
llvm::GlobalValue::getVisibility
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:229
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:578
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
llvm::PointerUnion::dyn_cast
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwise returns null.
Definition: PointerUnion.h:151
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
llvm::DenseMap
Definition: DenseMap.h:714
llvm::irsymtab::storage::Symbol::IRName
Str IRName
The unmangled symbol name, or the empty string if this is not an IR symbol.
Definition: IRSymtab.h:97
llvm::object::BasicSymbolRef::SF_Undefined
@ SF_Undefined
Definition: SymbolicFile.h:108
llvm::is_contained
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
Definition: STLExtras.h:1714
ArrayRef.h
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
PreservedSymbols
static const char * PreservedSymbols[]
Definition: IRSymtab.cpp:44
llvm::GlobalValue::hasLocalLinkage
bool hasLocalLinkage() const
Definition: GlobalValue.h:451
llvm::GlobalValue::isThreadLocal
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
Definition: GlobalValue.h:244
llvm::irsymtab::storage::Uncommon
This data structure contains rarely used symbol fields and is optionally referenced by a Symbol.
Definition: IRSymtab.h:122
llvm::irsymtab::storage::Uncommon::SectionName
Str SectionName
Specified section name, if any.
Definition: IRSymtab.h:130
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::MDNode
Metadata node.
Definition: Metadata.h:906
llvm::StringTableBuilder::write
void write(raw_ostream &OS) const
Definition: StringTableBuilder.cpp:60
llvm::SmallPtrSetImpl::count
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:382
Builder
assume Assume Builder
Definition: AssumeBundleBuilder.cpp:650
llvm::BitcodeFileContents::Mods
std::vector< BitcodeModule > Mods
Definition: BitcodeReader.h:124
llvm::StringSaver
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition: StringSaver.h:21
Mangler.h
Triple.h
ModuleSymbolTable.h
llvm::GlobalValue::canBeOmittedFromSymbolTable
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
Definition: Globals.cpp:356
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
DataLayout.h
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:57
llvm::Expected::get
reference get()
Returns a reference to the stored T value.
Definition: Error.h:569
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::GlobalValue::getAliaseeObject
const GlobalObject * getAliaseeObject() const
Definition: Globals.cpp:331
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
llvm::DenseMapBase< DenseMap< KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition: DenseMap.h:207
llvm::PointerUnion
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:107
llvm::irsymtab::storage::Module
Describes the range of a particular module's symbols within the symbol table.
Definition: IRSymtab.h:74
llvm::irsymtab::storage::Str
A reference to a string in the string table.
Definition: IRSymtab.h:55
llvm::ModuleSymbolTable::getSymbolFlags
uint32_t getSymbolFlags(Symbol S) const
Definition: ModuleSymbolTable.cpp:192
llvm::StringRef::size
constexpr LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:156
llvm::irsymtab::storage::Range
A reference to a range of objects in the symbol table.
Definition: IRSymtab.h:64
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::irsymtab::storage::Uncommon::COFFWeakExternFallbackName
Str COFFWeakExternFallbackName
COFF-specific: the name of the symbol that a weak external resolves to if not defined.
Definition: IRSymtab.h:127
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:77
llvm::irsymtab::storage::Symbol::FB_weak
@ FB_weak
Definition: IRSymtab.h:107
llvm::SectionName
Definition: DWARFSection.h:21
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
Casting.h
llvm::irsymtab::storage::Symbol::FB_may_omit
@ FB_may_omit
Definition: IRSymtab.h:112
llvm::StringTableBuilder::add
size_t add(CachedHashStringRef S)
Add a string to the builder.
Definition: StringTableBuilder.cpp:201
llvm::StringTableBuilder
Utility for building string tables with deduplicated suffixes.
Definition: StringTableBuilder.h:23
llvm::irsymtab::storage::Header::COFFLinkerOpts
Str COFFLinkerOpts
COFF-specific: linker directives.
Definition: IRSymtab.h:155
GlobalAlias.h
llvm::irsymtab::storage::Symbol::FB_indirect
@ FB_indirect
Definition: IRSymtab.h:109
llvm::BitcodeFileContents::StrtabForSymtab
StringRef StrtabForSymtab
Definition: BitcodeReader.h:125
llvm::Expected::takeError
Error takeError()
Take ownership of the stored error.
Definition: Error.h:599
llvm::ModuleSymbolTable
Definition: ModuleSymbolTable.h:33
Version
uint64_t Version
Definition: RawMemProfReader.cpp:25
llvm::irsymtab::storage::Symbol::FB_global
@ FB_global
Definition: IRSymtab.h:113
SmallVector.h
llvm::emitLinkerFlagsForGlobalCOFF
void emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV, const Triple &TT, Mangler &Mangler)
Definition: Mangler.cpp:211
llvm::irsymtab::storage::Symbol::ComdatIndex
Word ComdatIndex
The index into Header::Comdats, or -1 if not a comdat member.
Definition: IRSymtab.h:100
llvm::irsymtab::storage::Header::kCurrentVersion
@ kCurrentVersion
Definition: IRSymtab.h:139
llvm::irsymtab::storage::Symbol::FB_tls
@ FB_tls
Definition: IRSymtab.h:111
N
#define N
llvm::object::BasicSymbolRef::SF_Global
@ SF_Global
Definition: SymbolicFile.h:109
llvm::StringSaver::save
StringRef save(const char *S)
Definition: StringSaver.h:28
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:661
llvm::StringRef::data
const LLVM_NODISCARD char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
Definition: StringRef.h:148
llvm::Module::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:401
llvm::GlobalValue::getValueType
Type * getValueType() const
Definition: GlobalValue.h:273
Mod
Module * Mod
Definition: PassBuilderBindings.cpp:54
BitcodeReader.h
raw_ostream.h
llvm::irsymtab::storage::Symbol::Name
Str Name
The mangled symbol name.
Definition: IRSymtab.h:93
llvm::irsymtab::storage::Header::Uncommons
Range< Uncommon > Uncommons
Definition: IRSymtab.h:150
llvm::irsymtab::storage::Symbol::FB_executable
@ FB_executable
Definition: IRSymtab.h:116
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::irsymtab::storage::Symbol
Contains the information needed by linkers for symbol resolution, as well as by the LTO implementatio...
Definition: IRSymtab.h:91
llvm::MDOperand
Tracking metadata reference owned by Metadata.
Definition: Metadata.h:753
llvm::irsymtab::storage::Symbol::FB_unnamed_addr
@ FB_unnamed_addr
Definition: IRSymtab.h:115
llvm::irsymtab::storage::Symbol::FB_format_specific
@ FB_format_specific
Definition: IRSymtab.h:114
llvm::irsymtab::build
Error build(ArrayRef< Module * > Mods, SmallVector< char, 0 > &Symtab, StringTableBuilder &StrtabBuilder, BumpPtrAllocator &Alloc)
Fills in Symtab and StrtabBuilder with a valid symbol and string table for Mods.
Definition: IRSymtab.cpp:361
llvm::SmallVectorImpl::insert
iterator insert(iterator I, T &&Elt)
Definition: SmallVector.h:782
llvm::DataLayout::getTypeAllocSize
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Definition: DataLayout.h:506
llvm::Module::size
size_t size() const
Definition: Module.h:628