LLVM  6.0.0svn
ThinLTOBitcodeWriter.cpp
Go to the documentation of this file.
1 //===- ThinLTOBitcodeWriter.cpp - Bitcode writing pass for ThinLTO --------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
16 #include "llvm/IR/Constants.h"
17 #include "llvm/IR/DebugInfo.h"
18 #include "llvm/IR/Intrinsics.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/IR/PassManager.h"
21 #include "llvm/Pass.h"
25 #include "llvm/Transforms/IPO.h"
29 using namespace llvm;
30 
31 namespace {
32 
33 // Promote each local-linkage entity defined by ExportM and used by ImportM by
34 // changing visibility and appending the given ModuleId.
35 void promoteInternals(Module &ExportM, Module &ImportM, StringRef ModuleId,
36  SetVector<GlobalValue *> &PromoteExtra) {
38  for (auto &ExportGV : ExportM.global_values()) {
39  if (!ExportGV.hasLocalLinkage())
40  continue;
41 
42  auto Name = ExportGV.getName();
43  GlobalValue *ImportGV = ImportM.getNamedValue(Name);
44  if ((!ImportGV || ImportGV->use_empty()) && !PromoteExtra.count(&ExportGV))
45  continue;
46 
47  std::string NewName = (Name + ModuleId).str();
48 
49  if (const auto *C = ExportGV.getComdat())
50  if (C->getName() == Name)
51  RenamedComdats.try_emplace(C, ExportM.getOrInsertComdat(NewName));
52 
53  ExportGV.setName(NewName);
54  ExportGV.setLinkage(GlobalValue::ExternalLinkage);
55  ExportGV.setVisibility(GlobalValue::HiddenVisibility);
56 
57  if (ImportGV) {
58  ImportGV->setName(NewName);
60  }
61  }
62 
63  if (!RenamedComdats.empty())
64  for (auto &GO : ExportM.global_objects())
65  if (auto *C = GO.getComdat()) {
66  auto Replacement = RenamedComdats.find(C);
67  if (Replacement != RenamedComdats.end())
68  GO.setComdat(Replacement->second);
69  }
70 }
71 
72 // Promote all internal (i.e. distinct) type ids used by the module by replacing
73 // them with external type ids formed using the module id.
74 //
75 // Note that this needs to be done before we clone the module because each clone
76 // will receive its own set of distinct metadata nodes.
77 void promoteTypeIds(Module &M, StringRef ModuleId) {
79  auto ExternalizeTypeId = [&](CallInst *CI, unsigned ArgNo) {
80  Metadata *MD =
81  cast<MetadataAsValue>(CI->getArgOperand(ArgNo))->getMetadata();
82 
83  if (isa<MDNode>(MD) && cast<MDNode>(MD)->isDistinct()) {
84  Metadata *&GlobalMD = LocalToGlobal[MD];
85  if (!GlobalMD) {
86  std::string NewName =
87  (to_string(LocalToGlobal.size()) + ModuleId).str();
88  GlobalMD = MDString::get(M.getContext(), NewName);
89  }
90 
91  CI->setArgOperand(ArgNo,
92  MetadataAsValue::get(M.getContext(), GlobalMD));
93  }
94  };
95 
96  if (Function *TypeTestFunc =
97  M.getFunction(Intrinsic::getName(Intrinsic::type_test))) {
98  for (const Use &U : TypeTestFunc->uses()) {
99  auto CI = cast<CallInst>(U.getUser());
100  ExternalizeTypeId(CI, 1);
101  }
102  }
103 
104  if (Function *TypeCheckedLoadFunc =
105  M.getFunction(Intrinsic::getName(Intrinsic::type_checked_load))) {
106  for (const Use &U : TypeCheckedLoadFunc->uses()) {
107  auto CI = cast<CallInst>(U.getUser());
108  ExternalizeTypeId(CI, 2);
109  }
110  }
111 
112  for (GlobalObject &GO : M.global_objects()) {
114  GO.getMetadata(LLVMContext::MD_type, MDs);
115 
116  GO.eraseMetadata(LLVMContext::MD_type);
117  for (auto MD : MDs) {
118  auto I = LocalToGlobal.find(MD->getOperand(1));
119  if (I == LocalToGlobal.end()) {
120  GO.addMetadata(LLVMContext::MD_type, *MD);
121  continue;
122  }
123  GO.addMetadata(
125  *MDNode::get(M.getContext(),
126  ArrayRef<Metadata *>{MD->getOperand(0), I->second}));
127  }
128  }
129 }
130 
131 // Drop unused globals, and drop type information from function declarations.
132 // FIXME: If we made functions typeless then there would be no need to do this.
133 void simplifyExternals(Module &M) {
134  FunctionType *EmptyFT =
136 
137  for (auto I = M.begin(), E = M.end(); I != E;) {
138  Function &F = *I++;
139  if (F.isDeclaration() && F.use_empty()) {
140  F.eraseFromParent();
141  continue;
142  }
143 
144  if (!F.isDeclaration() || F.getFunctionType() == EmptyFT ||
145  // Changing the type of an intrinsic may invalidate the IR.
146  F.getName().startswith("llvm."))
147  continue;
148 
149  Function *NewF =
151  NewF->setVisibility(F.getVisibility());
152  NewF->takeName(&F);
154  F.eraseFromParent();
155  }
156 
157  for (auto I = M.global_begin(), E = M.global_end(); I != E;) {
158  GlobalVariable &GV = *I++;
159  if (GV.isDeclaration() && GV.use_empty()) {
160  GV.eraseFromParent();
161  continue;
162  }
163  }
164 }
165 
166 void filterModule(
167  Module *M, function_ref<bool(const GlobalValue *)> ShouldKeepDefinition) {
168  for (Module::alias_iterator I = M->alias_begin(), E = M->alias_end();
169  I != E;) {
170  GlobalAlias *GA = &*I++;
171  if (ShouldKeepDefinition(GA))
172  continue;
173 
174  GlobalObject *GO;
175  if (GA->getValueType()->isFunctionTy())
176  GO = Function::Create(cast<FunctionType>(GA->getValueType()),
178  else
179  GO = new GlobalVariable(
180  *M, GA->getValueType(), false, GlobalValue::ExternalLinkage,
181  nullptr, "", nullptr,
182  GA->getThreadLocalMode(), GA->getType()->getAddressSpace());
183  GO->takeName(GA);
184  GA->replaceAllUsesWith(GO);
185  GA->eraseFromParent();
186  }
187 
188  for (Function &F : *M) {
189  if (ShouldKeepDefinition(&F))
190  continue;
191 
192  F.deleteBody();
193  F.setComdat(nullptr);
194  F.clearMetadata();
195  }
196 
197  for (GlobalVariable &GV : M->globals()) {
198  if (ShouldKeepDefinition(&GV))
199  continue;
200 
201  GV.setInitializer(nullptr);
203  GV.setComdat(nullptr);
204  GV.clearMetadata();
205  }
206 }
207 
208 void forEachVirtualFunction(Constant *C, function_ref<void(Function *)> Fn) {
209  if (auto *F = dyn_cast<Function>(C))
210  return Fn(F);
211  if (isa<GlobalValue>(C))
212  return;
213  for (Value *Op : C->operands())
214  forEachVirtualFunction(cast<Constant>(Op), Fn);
215 }
216 
217 // If it's possible to split M into regular and thin LTO parts, do so and write
218 // a multi-module bitcode file with the two parts to OS. Otherwise, write only a
219 // regular LTO bitcode file to OS.
220 void splitAndWriteThinLTOBitcode(
221  raw_ostream &OS, raw_ostream *ThinLinkOS,
222  function_ref<AAResults &(Function &)> AARGetter, Module &M) {
223  std::string ModuleId = getUniqueModuleId(&M);
224  if (ModuleId.empty()) {
225  // We couldn't generate a module ID for this module, just write it out as a
226  // regular LTO module.
227  WriteBitcodeToFile(&M, OS);
228  if (ThinLinkOS)
229  // We don't have a ThinLTO part, but still write the module to the
230  // ThinLinkOS if requested so that the expected output file is produced.
231  WriteBitcodeToFile(&M, *ThinLinkOS);
232  return;
233  }
234 
235  promoteTypeIds(M, ModuleId);
236 
237  // Returns whether a global has attached type metadata. Such globals may
238  // participate in CFI or whole-program devirtualization, so they need to
239  // appear in the merged module instead of the thin LTO module.
240  auto HasTypeMetadata = [&](const GlobalObject *GO) {
243  return !MDs.empty();
244  };
245 
246  // Collect the set of virtual functions that are eligible for virtual constant
247  // propagation. Each eligible function must not access memory, must return
248  // an integer of width <=64 bits, must take at least one argument, must not
249  // use its first argument (assumed to be "this") and all arguments other than
250  // the first one must be of <=64 bit integer type.
251  //
252  // Note that we test whether this copy of the function is readnone, rather
253  // than testing function attributes, which must hold for any copy of the
254  // function, even a less optimized version substituted at link time. This is
255  // sound because the virtual constant propagation optimizations effectively
256  // inline all implementations of the virtual function into each call site,
257  // rather than using function attributes to perform local optimization.
258  std::set<const Function *> EligibleVirtualFns;
259  // If any member of a comdat lives in MergedM, put all members of that
260  // comdat in MergedM to keep the comdat together.
261  DenseSet<const Comdat *> MergedMComdats;
262  for (GlobalVariable &GV : M.globals())
263  if (HasTypeMetadata(&GV)) {
264  if (const auto *C = GV.getComdat())
265  MergedMComdats.insert(C);
266  forEachVirtualFunction(GV.getInitializer(), [&](Function *F) {
267  auto *RT = dyn_cast<IntegerType>(F->getReturnType());
268  if (!RT || RT->getBitWidth() > 64 || F->arg_empty() ||
269  !F->arg_begin()->use_empty())
270  return;
271  for (auto &Arg : make_range(std::next(F->arg_begin()), F->arg_end())) {
272  auto *ArgT = dyn_cast<IntegerType>(Arg.getType());
273  if (!ArgT || ArgT->getBitWidth() > 64)
274  return;
275  }
276  if (!F->isDeclaration() &&
277  computeFunctionBodyMemoryAccess(*F, AARGetter(*F)) == MAK_ReadNone)
278  EligibleVirtualFns.insert(F);
279  });
280  }
281 
282  ValueToValueMapTy VMap;
283  std::unique_ptr<Module> MergedM(
284  CloneModule(&M, VMap, [&](const GlobalValue *GV) -> bool {
285  if (const auto *C = GV->getComdat())
286  if (MergedMComdats.count(C))
287  return true;
288  if (auto *F = dyn_cast<Function>(GV))
289  return EligibleVirtualFns.count(F);
290  if (auto *GVar = dyn_cast_or_null<GlobalVariable>(GV->getBaseObject()))
291  return HasTypeMetadata(GVar);
292  return false;
293  }));
294  StripDebugInfo(*MergedM);
295 
296  for (Function &F : *MergedM)
297  if (!F.isDeclaration()) {
298  // Reset the linkage of all functions eligible for virtual constant
299  // propagation. The canonical definitions live in the thin LTO module so
300  // that they can be imported.
302  F.setComdat(nullptr);
303  }
304 
305  SetVector<GlobalValue *> CfiFunctions;
306  for (auto &F : M)
307  if ((!F.hasLocalLinkage() || F.hasAddressTaken()) && HasTypeMetadata(&F))
308  CfiFunctions.insert(&F);
309 
310  // Remove all globals with type metadata, globals with comdats that live in
311  // MergedM, and aliases pointing to such globals from the thin LTO module.
312  filterModule(&M, [&](const GlobalValue *GV) {
313  if (auto *GVar = dyn_cast_or_null<GlobalVariable>(GV->getBaseObject()))
314  if (HasTypeMetadata(GVar))
315  return false;
316  if (const auto *C = GV->getComdat())
317  if (MergedMComdats.count(C))
318  return false;
319  return true;
320  });
321 
322  promoteInternals(*MergedM, M, ModuleId, CfiFunctions);
323  promoteInternals(M, *MergedM, ModuleId, CfiFunctions);
324 
325  SmallVector<MDNode *, 8> CfiFunctionMDs;
326  for (auto V : CfiFunctions) {
327  Function &F = *cast<Function>(V);
330 
331  auto &Ctx = MergedM->getContext();
333  Elts.push_back(MDString::get(Ctx, F.getName()));
334  CfiFunctionLinkage Linkage;
335  if (!F.isDeclarationForLinker())
336  Linkage = CFL_Definition;
337  else if (F.isWeakForLinker())
338  Linkage = CFL_WeakDeclaration;
339  else
340  Linkage = CFL_Declaration;
342  llvm::ConstantInt::get(Type::getInt8Ty(Ctx), Linkage)));
343  for (auto Type : Types)
344  Elts.push_back(Type);
345  CfiFunctionMDs.push_back(MDTuple::get(Ctx, Elts));
346  }
347 
348  if(!CfiFunctionMDs.empty()) {
349  NamedMDNode *NMD = MergedM->getOrInsertNamedMetadata("cfi.functions");
350  for (auto MD : CfiFunctionMDs)
351  NMD->addOperand(MD);
352  }
353 
354  simplifyExternals(*MergedM);
355 
356  // FIXME: Try to re-use BSI and PFI from the original module here.
357  ProfileSummaryInfo PSI(M);
358  ModuleSummaryIndex Index = buildModuleSummaryIndex(M, nullptr, &PSI);
359 
360  // Mark the merged module as requiring full LTO. We still want an index for
361  // it though, so that it can participate in summary-based dead stripping.
362  MergedM->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
363  ModuleSummaryIndex MergedMIndex =
364  buildModuleSummaryIndex(*MergedM, nullptr, &PSI);
365 
366  SmallVector<char, 0> Buffer;
367 
368  BitcodeWriter W(Buffer);
369  // Save the module hash produced for the full bitcode, which will
370  // be used in the backends, and use that in the minimized bitcode
371  // produced for the full link.
372  ModuleHash ModHash = {{0}};
373  W.writeModule(&M, /*ShouldPreserveUseListOrder=*/false, &Index,
374  /*GenerateHash=*/true, &ModHash);
375  W.writeModule(MergedM.get(), /*ShouldPreserveUseListOrder=*/false,
376  &MergedMIndex);
377  W.writeSymtab();
378  W.writeStrtab();
379  OS << Buffer;
380 
381  // If a minimized bitcode module was requested for the thin link, only
382  // the information that is needed by thin link will be written in the
383  // given OS (the merged module will be written as usual).
384  if (ThinLinkOS) {
385  Buffer.clear();
386  BitcodeWriter W2(Buffer);
387  StripDebugInfo(M);
388  W2.writeThinLinkBitcode(&M, Index, ModHash);
389  W2.writeModule(MergedM.get(), /*ShouldPreserveUseListOrder=*/false,
390  &MergedMIndex);
391  W2.writeSymtab();
392  W2.writeStrtab();
393  *ThinLinkOS << Buffer;
394  }
395 }
396 
397 // Returns whether this module needs to be split because it uses type metadata.
398 bool requiresSplit(Module &M) {
400  for (auto &GO : M.global_objects()) {
402  if (!MDs.empty())
403  return true;
404  }
405 
406  return false;
407 }
408 
409 void writeThinLTOBitcode(raw_ostream &OS, raw_ostream *ThinLinkOS,
410  function_ref<AAResults &(Function &)> AARGetter,
411  Module &M, const ModuleSummaryIndex *Index) {
412  // See if this module has any type metadata. If so, we need to split it.
413  if (requiresSplit(M))
414  return splitAndWriteThinLTOBitcode(OS, ThinLinkOS, AARGetter, M);
415 
416  // Otherwise we can just write it out as a regular module.
417 
418  // Save the module hash produced for the full bitcode, which will
419  // be used in the backends, and use that in the minimized bitcode
420  // produced for the full link.
421  ModuleHash ModHash = {{0}};
422  WriteBitcodeToFile(&M, OS, /*ShouldPreserveUseListOrder=*/false, Index,
423  /*GenerateHash=*/true, &ModHash);
424  // If a minimized bitcode module was requested for the thin link, only
425  // the information that is needed by thin link will be written in the
426  // given OS.
427  if (ThinLinkOS && Index)
428  WriteThinLinkBitcodeToFile(&M, *ThinLinkOS, *Index, ModHash);
429 }
430 
431 class WriteThinLTOBitcode : public ModulePass {
432  raw_ostream &OS; // raw_ostream to print on
433  // The output stream on which to emit a minimized module for use
434  // just in the thin link, if requested.
435  raw_ostream *ThinLinkOS;
436 
437 public:
438  static char ID; // Pass identification, replacement for typeid
439  WriteThinLTOBitcode() : ModulePass(ID), OS(dbgs()), ThinLinkOS(nullptr) {
441  }
442 
443  explicit WriteThinLTOBitcode(raw_ostream &o, raw_ostream *ThinLinkOS)
444  : ModulePass(ID), OS(o), ThinLinkOS(ThinLinkOS) {
446  }
447 
448  StringRef getPassName() const override { return "ThinLTO Bitcode Writer"; }
449 
450  bool runOnModule(Module &M) override {
451  const ModuleSummaryIndex *Index =
452  &(getAnalysis<ModuleSummaryIndexWrapperPass>().getIndex());
453  writeThinLTOBitcode(OS, ThinLinkOS, LegacyAARGetter(*this), M, Index);
454  return true;
455  }
456  void getAnalysisUsage(AnalysisUsage &AU) const override {
457  AU.setPreservesAll();
461  }
462 };
463 } // anonymous namespace
464 
465 char WriteThinLTOBitcode::ID = 0;
466 INITIALIZE_PASS_BEGIN(WriteThinLTOBitcode, "write-thinlto-bitcode",
467  "Write ThinLTO Bitcode", false, true)
471 INITIALIZE_PASS_END(WriteThinLTOBitcode, "write-thinlto-bitcode",
472  "Write ThinLTO Bitcode", false, true)
473 
475  raw_ostream *ThinLinkOS) {
476  return new WriteThinLTOBitcode(Str, ThinLinkOS);
477 }
478 
482  AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
483  writeThinLTOBitcode(OS, ThinLinkOS,
484  [&FAM](Function &F) -> AAResults & {
485  return FAM.getResult<AAManager>(F);
486  },
488  return PreservedAnalyses::all();
489 }
void setVisibility(VisibilityTypes V)
Definition: GlobalValue.h:231
bool isDeclarationForLinker() const
Definition: GlobalValue.h:514
uint64_t CallInst * C
ModulePass * createWriteThinLTOBitcodePass(raw_ostream &Str, raw_ostream *ThinLinkOS=nullptr)
Write ThinLTO-ready bitcode to Str.
ThreadLocalMode getThreadLocalMode() const
Definition: GlobalValue.h:246
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Definition: Metadata.h:1131
iterator_range< use_iterator > uses()
Definition: Value.h:356
bool hasLocalLinkage() const
Definition: GlobalValue.h:427
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition: PassManager.h:687
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:446
This is the interface to build a ModuleSummaryIndex for a module.
Implements a dense probed hash-table based set.
Definition: DenseSet.h:221
Available for inspection, not emission.
Definition: GlobalValue.h:50
Analysis providing profile information.
void addOperand(MDNode *M)
Definition: Metadata.cpp:1079
This class represents a function call, abstracting a target machine&#39;s calling convention.
write thinlto bitcode
An immutable pass that tracks lazily created AssumptionCache objects.
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:89
CfiFunctionLinkage
The type of CFI jumptable needed for a function.
Externally visible function.
Definition: GlobalValue.h:49
arg_iterator arg_end()
Definition: Function.h:612
F(f)
MemoryAccessKind computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR)
Returns the memory access properties of this copy of the function.
Analysis pass to provide the ModuleSummaryIndex object.
ModuleSummaryIndex buildModuleSummaryIndex(const Module &M, std::function< BlockFrequencyInfo *(const Function &F)> GetBFICallback, ProfileSummaryInfo *PSI)
Direct function to compute a ModuleSummaryIndex from a given module.
void eraseFromParent()
eraseFromParent - This method unlinks &#39;this&#39; from the containing module and deletes it...
Definition: Globals.cpp:433
iterator_range< global_object_iterator > global_objects()
Definition: Module.h:636
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
Definition: PassSupport.h:51
A tuple of MDNodes.
Definition: Metadata.h:1323
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Definition: Function.cpp:591
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Definition: Globals.cpp:340
LLVMContext & getContext() const
Get the global data context.
Definition: Module.h:237
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
This class is a functor to be used in legacy module or SCC passes for computing AA results for a func...
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1431
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:286
global_iterator global_begin()
Definition: Module.h:555
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Definition: StringRef.h:267
Class to represent function types.
Definition: DerivedTypes.h:103
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
bool insert(const value_type &X)
Insert a new element into the SetVector.
Definition: SetVector.h:142
bool arg_empty() const
Definition: Function.h:631
LLVMContext & getContext() const
Definition: Metadata.h:922
void setComdat(Comdat *C)
Definition: GlobalObject.h:103
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
Definition: DebugInfo.cpp:332
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
Definition: Module.cpp:112
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:430
void takeName(Value *V)
Transfer the name from V to this value.
Definition: Value.cpp:292
Class to hold module path string table and global value map, and encapsulate methods for operating on...
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:408
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
Definition: SetVector.h:211
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
Definition: GlobalValue.h:361
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:106
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Definition: Constants.cpp:1678
void WriteBitcodeToFile(const Module *M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false, ModuleHash *ModHash=nullptr)
Write the specified module to the specified raw output stream.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
Definition: Metadata.h:1164
Type * getReturnType() const
Returns the type of the ret val.
Definition: Function.h:150
Emits an error if two values disagree, otherwise the resulting value is that of the operands...
Definition: Module.h:114
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:153
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:225
alias_iterator alias_end()
Definition: Module.h:596
write thinlto Write ThinLTO Bitcode
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
void deleteBody()
deleteBody - This method deletes the body of the function, and converts the linkage to external...
Definition: Function.h:541
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
Definition: Constant.h:42
This file contains the declarations for the subclasses of Constant, which represent the different fla...
A manager for alias analyses.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
void eraseFromParent()
eraseFromParent - This method unlinks &#39;this&#39; from the containing module and deletes it...
Definition: Globals.cpp:336
Represent the analysis usage information of a pass.
static Type * getVoidTy(LLVMContext &C)
Definition: Type.cpp:161
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Definition: Type.cpp:297
op_range operands()
Definition: User.h:222
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:495
arg_iterator arg_begin()
Definition: Function.h:603
Class to represent integer types.
Definition: DerivedTypes.h:40
std::unique_ptr< Module > CloneModule(const Module *M)
Return an exact copy of the specified module.
Definition: CloneModule.cpp:36
std::string getUniqueModuleId(Module *M)
Produce a unique identifier for this module by taking the MD5 sum of the names of the module&#39;s strong...
static void write(bool isBE, void *P, T V)
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
Definition: Module.cpp:467
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:159
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
global_iterator global_end()
Definition: Module.h:557
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Iterator for intrusive lists based on ilist_node.
void initializeWriteThinLTOBitcodePass(PassRegistry &)
void WriteThinLinkBitcodeToFile(const Module *M, raw_ostream &Out, const ModuleSummaryIndex &Index, const ModuleHash &ModHash)
Write the specified thin link bitcode file (i.e., the minimized bitcode file) to the given raw output...
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:864
Module.h This file contains the declarations for the Module class.
alias_iterator alias_begin()
Definition: Module.h:594
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
Definition: Constants.cpp:560
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:436
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:132
Function * getFunction(StringRef Name) const
Look up the specified function in the module symbol table.
Definition: Module.cpp:172
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:145
const Comdat * getComdat() const
Definition: Globals.cpp:166
void setPreservesAll()
Set by analyses that do not transform their input at all.
amdgpu Simplify well known AMD library false Value Value * Arg
const Comdat * getComdat() const
Definition: GlobalObject.h:101
Basic Alias true
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:212
iterator end()
Definition: Module.h:574
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:61
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:220
#define I(x, y, z)
Definition: MD5.cpp:58
void setArgOperand(unsigned i, Value *v)
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:225
iterator begin()
Definition: Module.h:572
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
Type * getValueType() const
Definition: GlobalValue.h:267
void eraseFromParent()
eraseFromParent - This method unlinks &#39;this&#39; from the containing module and deletes it...
Definition: Function.cpp:202
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
Definition: DenseSet.h:91
Provides passes for computing function attributes based on interprocedural analyses.
const std::string to_string(const T &Value)
Definition: ScopedPrinter.h:62
const GlobalObject * getBaseObject() const
Definition: Globals.cpp:256
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:201
bool hasAddressTaken(const User **=nullptr) const
hasAddressTaken - returns true if there are any uses of this function other than direct calls or invo...
Definition: Function.cpp:1213
LLVM Value Representation.
Definition: Value.h:73
A vector that has set insertion semantics.
Definition: SetVector.h:41
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
iterator_range< global_iterator > globals()
Definition: Module.h:561
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
This is the interface for LLVM&#39;s primary stateless and local alias analysis.
A container for analyses that lazily runs them and caches their results.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
Definition: Function.h:136
This header defines various interfaces for pass management in LLVM.
INITIALIZE_PASS_BEGIN(WriteThinLTOBitcode, "write-thinlto-bitcode", "Write ThinLTO Bitcode", false, true) INITIALIZE_PASS_END(WriteThinLTOBitcode
iterator_range< global_value_iterator > global_values()
Definition: Module.h:662
Root of the metadata hierarchy.
Definition: Metadata.h:58
static IntegerType * getInt8Ty(LLVMContext &C)
Definition: Type.cpp:174
bool use_empty() const
Definition: Value.h:328
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:265
Legacy wrapper pass to provide the ModuleSummaryIndex object.
An analysis over an "outer" IR unit that provides access to an analysis manager over an "inner" IR un...
Definition: PassManager.h:946