LLVM  16.0.0git
GlobalDCE.cpp
Go to the documentation of this file.
1 //===-- GlobalDCE.cpp - DCE unreachable internal functions ----------------===//
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 // This transform is designed to eliminate unreachable internal globals from the
10 // program. It uses an aggressive algorithm, searching out globals that are
11 // known to be alive. After it finds all of the globals which are needed, it
12 // deletes whatever is left over. This allows it to delete recursive chunks of
13 // the program which are unreachable.
14 //
15 //===----------------------------------------------------------------------===//
16 
18 #include "llvm/ADT/SmallPtrSet.h"
19 #include "llvm/ADT/Statistic.h"
21 #include "llvm/IR/Instructions.h"
22 #include "llvm/IR/IntrinsicInst.h"
23 #include "llvm/IR/Module.h"
24 #include "llvm/InitializePasses.h"
25 #include "llvm/Pass.h"
27 #include "llvm/Transforms/IPO.h"
30 
31 using namespace llvm;
32 
33 #define DEBUG_TYPE "globaldce"
34 
35 static cl::opt<bool>
36  ClEnableVFE("enable-vfe", cl::Hidden, cl::init(true),
37  cl::desc("Enable virtual function elimination"));
38 
39 STATISTIC(NumAliases , "Number of global aliases removed");
40 STATISTIC(NumFunctions, "Number of functions removed");
41 STATISTIC(NumIFuncs, "Number of indirect functions removed");
42 STATISTIC(NumVariables, "Number of global variables removed");
43 STATISTIC(NumVFuncs, "Number of virtual functions removed");
44 
45 namespace {
46  class GlobalDCELegacyPass : public ModulePass {
47  public:
48  static char ID; // Pass identification, replacement for typeid
49  GlobalDCELegacyPass() : ModulePass(ID) {
51  }
52 
53  // run - Do the GlobalDCE pass on the specified module, optionally updating
54  // the specified callgraph to reflect the changes.
55  //
56  bool runOnModule(Module &M) override {
57  if (skipModule(M))
58  return false;
59 
60  // We need a minimally functional dummy module analysis manager. It needs
61  // to at least know about the possibility of proxying a function analysis
62  // manager.
63  FunctionAnalysisManager DummyFAM;
64  ModuleAnalysisManager DummyMAM;
65  DummyMAM.registerPass(
66  [&] { return FunctionAnalysisManagerModuleProxy(DummyFAM); });
67 
68  auto PA = Impl.run(M, DummyMAM);
69  return !PA.areAllPreserved();
70  }
71 
72  private:
73  GlobalDCEPass Impl;
74  };
75 }
76 
78 INITIALIZE_PASS(GlobalDCELegacyPass, "globaldce",
79  "Dead Global Elimination", false, false)
80 
81 // Public interface to the GlobalDCEPass.
83  return new GlobalDCELegacyPass();
84 }
85 
86 /// Returns true if F is effectively empty.
87 static bool isEmptyFunction(Function *F) {
88  // Skip external functions.
89  if (F->isDeclaration())
90  return false;
91  BasicBlock &Entry = F->getEntryBlock();
92  for (auto &I : Entry) {
93  if (I.isDebugOrPseudoInst())
94  continue;
95  if (auto *RI = dyn_cast<ReturnInst>(&I))
96  return !RI->getReturnValue();
97  break;
98  }
99  return false;
100 }
101 
102 /// Compute the set of GlobalValue that depends from V.
103 /// The recursion stops as soon as a GlobalValue is met.
104 void GlobalDCEPass::ComputeDependencies(Value *V,
106  if (auto *I = dyn_cast<Instruction>(V)) {
107  Function *Parent = I->getParent()->getParent();
108  Deps.insert(Parent);
109  } else if (auto *GV = dyn_cast<GlobalValue>(V)) {
110  Deps.insert(GV);
111  } else if (auto *CE = dyn_cast<Constant>(V)) {
112  // Avoid walking the whole tree of a big ConstantExprs multiple times.
113  auto Where = ConstantDependenciesCache.find(CE);
114  if (Where != ConstantDependenciesCache.end()) {
115  auto const &K = Where->second;
116  Deps.insert(K.begin(), K.end());
117  } else {
118  SmallPtrSetImpl<GlobalValue *> &LocalDeps = ConstantDependenciesCache[CE];
119  for (User *CEUser : CE->users())
120  ComputeDependencies(CEUser, LocalDeps);
121  Deps.insert(LocalDeps.begin(), LocalDeps.end());
122  }
123  }
124 }
125 
126 void GlobalDCEPass::UpdateGVDependencies(GlobalValue &GV) {
128  for (User *User : GV.users())
129  ComputeDependencies(User, Deps);
130  Deps.erase(&GV); // Remove self-reference.
131  for (GlobalValue *GVU : Deps) {
132  // If this is a dep from a vtable to a virtual function, and we have
133  // complete information about all virtual call sites which could call
134  // though this vtable, then skip it, because the call site information will
135  // be more precise.
136  if (VFESafeVTables.count(GVU) && isa<Function>(&GV)) {
137  LLVM_DEBUG(dbgs() << "Ignoring dep " << GVU->getName() << " -> "
138  << GV.getName() << "\n");
139  continue;
140  }
141  GVDependencies[GVU].insert(&GV);
142  }
143 }
144 
145 /// Mark Global value as Live
146 void GlobalDCEPass::MarkLive(GlobalValue &GV,
148  auto const Ret = AliveGlobals.insert(&GV);
149  if (!Ret.second)
150  return;
151 
152  if (Updates)
153  Updates->push_back(&GV);
154  if (Comdat *C = GV.getComdat()) {
155  for (auto &&CM : make_range(ComdatMembers.equal_range(C))) {
156  MarkLive(*CM.second, Updates); // Recursion depth is only two because only
157  // globals in the same comdat are visited.
158  }
159  }
160 }
161 
162 void GlobalDCEPass::ScanVTables(Module &M) {
164  LLVM_DEBUG(dbgs() << "Building type info -> vtable map\n");
165 
166  auto *LTOPostLinkMD =
167  cast_or_null<ConstantAsMetadata>(M.getModuleFlag("LTOPostLink"));
168  bool LTOPostLink =
169  LTOPostLinkMD &&
170  (cast<ConstantInt>(LTOPostLinkMD->getValue())->getZExtValue() != 0);
171 
172  for (GlobalVariable &GV : M.globals()) {
173  Types.clear();
174  GV.getMetadata(LLVMContext::MD_type, Types);
175  if (GV.isDeclaration() || Types.empty())
176  continue;
177 
178  // Use the typeid metadata on the vtable to build a mapping from typeids to
179  // the list of (GV, offset) pairs which are the possible vtables for that
180  // typeid.
181  for (MDNode *Type : Types) {
182  Metadata *TypeID = Type->getOperand(1).get();
183 
184  uint64_t Offset =
185  cast<ConstantInt>(
186  cast<ConstantAsMetadata>(Type->getOperand(0))->getValue())
187  ->getZExtValue();
188 
189  TypeIdMap[TypeID].insert(std::make_pair(&GV, Offset));
190  }
191 
192  // If the type corresponding to the vtable is private to this translation
193  // unit, we know that we can see all virtual functions which might use it,
194  // so VFE is safe.
195  if (auto GO = dyn_cast<GlobalObject>(&GV)) {
196  GlobalObject::VCallVisibility TypeVis = GO->getVCallVisibility();
198  (LTOPostLink &&
200  LLVM_DEBUG(dbgs() << GV.getName() << " is safe for VFE\n");
201  VFESafeVTables.insert(&GV);
202  }
203  }
204  }
205 }
206 
207 void GlobalDCEPass::ScanVTableLoad(Function *Caller, Metadata *TypeId,
208  uint64_t CallOffset) {
209  for (const auto &VTableInfo : TypeIdMap[TypeId]) {
210  GlobalVariable *VTable = VTableInfo.first;
211  uint64_t VTableOffset = VTableInfo.second;
212 
213  Constant *Ptr =
214  getPointerAtOffset(VTable->getInitializer(), VTableOffset + CallOffset,
215  *Caller->getParent(), VTable);
216  if (!Ptr) {
217  LLVM_DEBUG(dbgs() << "can't find pointer in vtable!\n");
218  VFESafeVTables.erase(VTable);
219  continue;
220  }
221 
222  auto Callee = dyn_cast<Function>(Ptr->stripPointerCasts());
223  if (!Callee) {
224  LLVM_DEBUG(dbgs() << "vtable entry is not function pointer!\n");
225  VFESafeVTables.erase(VTable);
226  continue;
227  }
228 
229  LLVM_DEBUG(dbgs() << "vfunc dep " << Caller->getName() << " -> "
230  << Callee->getName() << "\n");
231  GVDependencies[Caller].insert(Callee);
232  }
233 }
234 
235 void GlobalDCEPass::ScanTypeCheckedLoadIntrinsics(Module &M) {
236  LLVM_DEBUG(dbgs() << "Scanning type.checked.load intrinsics\n");
237  Function *TypeCheckedLoadFunc =
238  M.getFunction(Intrinsic::getName(Intrinsic::type_checked_load));
239 
240  if (!TypeCheckedLoadFunc)
241  return;
242 
243  for (auto *U : TypeCheckedLoadFunc->users()) {
244  auto CI = dyn_cast<CallInst>(U);
245  if (!CI)
246  continue;
247 
248  auto *Offset = dyn_cast<ConstantInt>(CI->getArgOperand(1));
249  Value *TypeIdValue = CI->getArgOperand(2);
250  auto *TypeId = cast<MetadataAsValue>(TypeIdValue)->getMetadata();
251 
252  if (Offset) {
253  ScanVTableLoad(CI->getFunction(), TypeId, Offset->getZExtValue());
254  } else {
255  // type.checked.load with a non-constant offset, so assume every entry in
256  // every matching vtable is used.
257  for (const auto &VTableInfo : TypeIdMap[TypeId]) {
258  VFESafeVTables.erase(VTableInfo.first);
259  }
260  }
261  }
262 }
263 
264 void GlobalDCEPass::AddVirtualFunctionDependencies(Module &M) {
265  if (!ClEnableVFE)
266  return;
267 
268  // If the Virtual Function Elim module flag is present and set to zero, then
269  // the vcall_visibility metadata was inserted for another optimization (WPD)
270  // and we may not have type checked loads on all accesses to the vtable.
271  // Don't attempt VFE in that case.
272  auto *Val = mdconst::dyn_extract_or_null<ConstantInt>(
273  M.getModuleFlag("Virtual Function Elim"));
274  if (!Val || Val->getZExtValue() == 0)
275  return;
276 
277  ScanVTables(M);
278 
279  if (VFESafeVTables.empty())
280  return;
281 
282  ScanTypeCheckedLoadIntrinsics(M);
283 
284  LLVM_DEBUG(
285  dbgs() << "VFE safe vtables:\n";
286  for (auto *VTable : VFESafeVTables)
287  dbgs() << " " << VTable->getName() << "\n";
288  );
289 }
290 
292  bool Changed = false;
293 
294  // The algorithm first computes the set L of global variables that are
295  // trivially live. Then it walks the initialization of these variables to
296  // compute the globals used to initialize them, which effectively builds a
297  // directed graph where nodes are global variables, and an edge from A to B
298  // means B is used to initialize A. Finally, it propagates the liveness
299  // information through the graph starting from the nodes in L. Nodes note
300  // marked as alive are discarded.
301 
302  // Remove empty functions from the global ctors list.
303  Changed |= optimizeGlobalCtorsList(
304  M, [](uint32_t, Function *F) { return isEmptyFunction(F); });
305 
306  // Collect the set of members for each comdat.
307  for (Function &F : M)
308  if (Comdat *C = F.getComdat())
309  ComdatMembers.insert(std::make_pair(C, &F));
310  for (GlobalVariable &GV : M.globals())
311  if (Comdat *C = GV.getComdat())
312  ComdatMembers.insert(std::make_pair(C, &GV));
313  for (GlobalAlias &GA : M.aliases())
314  if (Comdat *C = GA.getComdat())
315  ComdatMembers.insert(std::make_pair(C, &GA));
316 
317  // Add dependencies between virtual call sites and the virtual functions they
318  // might call, if we have that information.
319  AddVirtualFunctionDependencies(M);
320 
321  // Loop over the module, adding globals which are obviously necessary.
322  for (GlobalObject &GO : M.global_objects()) {
323  GO.removeDeadConstantUsers();
324  // Functions with external linkage are needed if they have a body.
325  // Externally visible & appending globals are needed, if they have an
326  // initializer.
327  if (!GO.isDeclaration())
328  if (!GO.isDiscardableIfUnused())
329  MarkLive(GO);
330 
331  UpdateGVDependencies(GO);
332  }
333 
334  // Compute direct dependencies of aliases.
335  for (GlobalAlias &GA : M.aliases()) {
336  GA.removeDeadConstantUsers();
337  // Externally visible aliases are needed.
338  if (!GA.isDiscardableIfUnused())
339  MarkLive(GA);
340 
341  UpdateGVDependencies(GA);
342  }
343 
344  // Compute direct dependencies of ifuncs.
345  for (GlobalIFunc &GIF : M.ifuncs()) {
346  GIF.removeDeadConstantUsers();
347  // Externally visible ifuncs are needed.
348  if (!GIF.isDiscardableIfUnused())
349  MarkLive(GIF);
350 
351  UpdateGVDependencies(GIF);
352  }
353 
354  // Propagate liveness from collected Global Values through the computed
355  // dependencies.
356  SmallVector<GlobalValue *, 8> NewLiveGVs{AliveGlobals.begin(),
357  AliveGlobals.end()};
358  while (!NewLiveGVs.empty()) {
359  GlobalValue *LGV = NewLiveGVs.pop_back_val();
360  for (auto *GVD : GVDependencies[LGV])
361  MarkLive(*GVD, &NewLiveGVs);
362  }
363 
364  // Now that all globals which are needed are in the AliveGlobals set, we loop
365  // through the program, deleting those which are not alive.
366  //
367 
368  // The first pass is to drop initializers of global variables which are dead.
369  std::vector<GlobalVariable *> DeadGlobalVars; // Keep track of dead globals
370  for (GlobalVariable &GV : M.globals())
371  if (!AliveGlobals.count(&GV)) {
372  DeadGlobalVars.push_back(&GV); // Keep track of dead globals
373  if (GV.hasInitializer()) {
374  Constant *Init = GV.getInitializer();
375  GV.setInitializer(nullptr);
377  Init->destroyConstant();
378  }
379  }
380 
381  // The second pass drops the bodies of functions which are dead...
382  std::vector<Function *> DeadFunctions;
383  for (Function &F : M)
384  if (!AliveGlobals.count(&F)) {
385  DeadFunctions.push_back(&F); // Keep track of dead globals
386  if (!F.isDeclaration())
387  F.deleteBody();
388  }
389 
390  // The third pass drops targets of aliases which are dead...
391  std::vector<GlobalAlias*> DeadAliases;
392  for (GlobalAlias &GA : M.aliases())
393  if (!AliveGlobals.count(&GA)) {
394  DeadAliases.push_back(&GA);
395  GA.setAliasee(nullptr);
396  }
397 
398  // The fourth pass drops targets of ifuncs which are dead...
399  std::vector<GlobalIFunc*> DeadIFuncs;
400  for (GlobalIFunc &GIF : M.ifuncs())
401  if (!AliveGlobals.count(&GIF)) {
402  DeadIFuncs.push_back(&GIF);
403  GIF.setResolver(nullptr);
404  }
405 
406  // Now that all interferences have been dropped, delete the actual objects
407  // themselves.
408  auto EraseUnusedGlobalValue = [&](GlobalValue *GV) {
410  GV->eraseFromParent();
411  Changed = true;
412  };
413 
414  NumFunctions += DeadFunctions.size();
415  for (Function *F : DeadFunctions) {
416  if (!F->use_empty()) {
417  // Virtual functions might still be referenced by one or more vtables,
418  // but if we've proven them to be unused then it's safe to replace the
419  // virtual function pointers with null, allowing us to remove the
420  // function itself.
421  ++NumVFuncs;
422 
423  // Detect vfuncs that are referenced as "relative pointers" which are used
424  // in Swift vtables, i.e. entries in the form of:
425  //
426  // i32 trunc (i64 sub (i64 ptrtoint @f, i64 ptrtoint ...)) to i32)
427  //
428  // In this case, replace the whole "sub" expression with constant 0 to
429  // avoid leaving a weird sub(0, symbol) expression behind.
431 
432  F->replaceNonMetadataUsesWith(ConstantPointerNull::get(F->getType()));
433  }
434  EraseUnusedGlobalValue(F);
435  }
436 
437  NumVariables += DeadGlobalVars.size();
438  for (GlobalVariable *GV : DeadGlobalVars)
439  EraseUnusedGlobalValue(GV);
440 
441  NumAliases += DeadAliases.size();
442  for (GlobalAlias *GA : DeadAliases)
443  EraseUnusedGlobalValue(GA);
444 
445  NumIFuncs += DeadIFuncs.size();
446  for (GlobalIFunc *GIF : DeadIFuncs)
447  EraseUnusedGlobalValue(GIF);
448 
449  // Make sure that all memory is released
450  AliveGlobals.clear();
451  ConstantDependenciesCache.clear();
452  GVDependencies.clear();
453  ComdatMembers.clear();
454  TypeIdMap.clear();
455  VFESafeVTables.clear();
456 
457  if (Changed)
458  return PreservedAnalyses::none();
459  return PreservedAnalyses::all();
460 }
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition: iterator_range.h:53
isEmptyFunction
static bool isEmptyFunction(Function *F)
Returns true if F is effectively empty.
Definition: GlobalDCE.cpp:87
llvm::SmallPtrSetImpl::erase
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false.
Definition: SmallPtrSet.h:379
llvm::AArch64PACKey::ID
ID
Definition: AArch64BaseInfo.h:818
llvm::ModulePass
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:248
IntrinsicInst.h
llvm::GlobalObject::VCallVisibilityTranslationUnit
@ VCallVisibilityTranslationUnit
Definition: GlobalObject.h:39
llvm::Function
Definition: Function.h:60
Pass.h
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1199
Statistic.h
llvm::Intrinsic::getName
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
Definition: Function.cpp:942
llvm::GlobalVariable
Definition: GlobalVariable.h:39
llvm::replaceRelativePointerUsersWithZero
void replaceRelativePointerUsersWithZero(Function *F)
Finds the same "relative pointer" pattern as described above, where the target is F,...
Definition: TypeMetadataUtils.cpp:202
llvm::GlobalAlias
Definition: GlobalAlias.h:28
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:139
llvm::PreservedAnalyses::none
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Definition: PassManager.h:155
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
Module.h
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:450
llvm::MipsISD::Ret
@ Ret
Definition: MipsISelLowering.h:119
CtorUtils.h
LLVM_DEBUG
#define LLVM_DEBUG(X)
Definition: Debug.h:101
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::BasicBlock
LLVM Basic Block Representation.
Definition: BasicBlock.h:55
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
CommandLine.h
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:24
llvm::GlobalValue::isDeclaration
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:266
llvm::User
Definition: User.h:44
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GlobalObject
Definition: GlobalObject.h:27
MAM
ModuleAnalysisManager MAM
Definition: PassBuilderBindings.cpp:61
TypeMetadataUtils.h
llvm::pdb::PDB_SymType::Caller
@ Caller
llvm::STATISTIC
STATISTIC(NumFunctions, "Total number of functions")
INITIALIZE_PASS
INITIALIZE_PASS(GlobalDCELegacyPass, "globaldce", "Dead Global Elimination", false, false) ModulePass *llvm
Definition: GlobalDCE.cpp:78
SmallPtrSet.h
llvm::Comdat
Definition: Comdat.h:33
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::isSafeToDestroyConstant
bool isSafeToDestroyConstant(const Constant *C)
It is safe to destroy a constant iff it is only used by constants itself.
Definition: GlobalStatus.cpp:43
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
TypeID
Type::TypeID TypeID
Definition: Mips16HardFloat.cpp:103
llvm::cl::opt< bool >
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::AMDGPU::Hwreg::Offset
Offset
Definition: SIDefines.h:419
uint64_t
llvm::SmallPtrSetImpl::end
iterator end() const
Definition: SmallPtrSet.h:408
llvm::ConstantPointerNull::get
static ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
Definition: Constants.cpp:1699
IPO.h
llvm::createGlobalDCEPass
ModulePass * createGlobalDCEPass()
createGlobalDCEPass - This transform is designed to eliminate unreachable internal globals (functions...
GlobalStatus.h
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:446
llvm::SmallPtrSetImpl::begin
iterator begin() const
Definition: SmallPtrSet.h:403
llvm::pdb::PDB_SymType::VTable
@ VTable
Ptr
@ Ptr
Definition: TargetLibraryInfo.cpp:60
ClEnableVFE
static cl::opt< bool > ClEnableVFE("enable-vfe", cl::Hidden, cl::init(true), cl::desc("Enable virtual function elimination"))
llvm::WinEH::EncodingType::CE
@ CE
Windows NT (Windows on ARM)
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:944
llvm::GlobalDCEPass
Pass to remove unused function declarations.
Definition: GlobalDCE.h:36
llvm::Constant::removeDeadConstantUsers
void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
Definition: Constants.cpp:702
llvm::logicalview::LVCompareKind::Types
@ Types
GlobalDCE.h
uint32_t
llvm::Value::getMetadata
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1288
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:308
llvm::Init
Definition: Record.h:282
llvm::GlobalValue::eraseFromParent
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:88
Callee
amdgpu Simplify well known AMD library false FunctionCallee Callee
Definition: AMDGPULibCalls.cpp:187
llvm::GlobalObject::VCallVisibility
VCallVisibility
Definition: GlobalObject.h:32
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition: PassManager.h:158
llvm::GlobalValue::getComdat
const Comdat * getComdat() const
Definition: Globals.cpp:176
llvm::AnalysisManager::registerPass
bool registerPass(PassBuilderT &&PassBuilder)
Register an analysis pass with the manager.
Definition: PassManager.h:836
llvm::optimizeGlobalCtorsList
bool optimizeGlobalCtorsList(Module &M, function_ref< bool(uint32_t, Function *)> ShouldRemove)
Call "ShouldRemove" for every entry in M's global_ctor list and remove the entries for which it retur...
Definition: CtorUtils.cpp:113
Instructions.h
llvm::getPointerAtOffset
Constant * getPointerAtOffset(Constant *I, uint64_t Offset, Module &M, Constant *TopLevelGlobal=nullptr)
Processes a Constant recursively looking into elements of arrays, structs and expressions to find a t...
Definition: TypeMetadataUtils.cpp:130
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:42
llvm::SmallPtrSetImpl
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:344
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:42
llvm::initializeGlobalDCELegacyPassPass
void initializeGlobalDCELegacyPassPass(PassRegistry &)
llvm::GlobalDCEPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
Definition: GlobalDCE.cpp:291
llvm::Type::TypeID
TypeID
Definitions of all of the base types for the Type system.
Definition: Type.h:54
llvm::cl::desc
Definition: CommandLine.h:412
llvm::GlobalIFunc
Definition: GlobalIFunc.h:34
InitializePasses.h
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::FunctionAnalysisManagerModuleProxy
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
Definition: PassManager.h:1014
llvm::GlobalObject::VCallVisibilityLinkageUnit
@ VCallVisibilityLinkageUnit
Definition: GlobalObject.h:37
llvm::Value::users
iterator_range< user_iterator > users()
Definition: Value.h:421
llvm::SmallPtrSetImpl::insert
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:365