LLVM 24.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 "IPOOptions.h"
19#include "llvm/ADT/DenseSet.h"
21#include "llvm/ADT/Statistic.h"
25#include "llvm/IR/Module.h"
27#include "llvm/Pass.h"
28#include "llvm/Transforms/IPO.h"
31
32using namespace llvm;
33
34#define DEBUG_TYPE "globaldce"
35
36namespace {
37class GlobalDCELegacyPass : public ModulePass {
38public:
39 static char ID; // Pass identification, replacement for typeid
40 GlobalDCELegacyPass() : ModulePass(ID) {}
41 bool runOnModule(Module &M) override {
42 if (skipModule(M))
43 return false;
44 // Note: GlobalDCEPass does not use any analyses, so we're safe to call the
45 // new-pm style pass with a default-initialized analysis manager here
47 auto PA = Impl.run(M, MAM);
48 return !PA.areAllPreserved();
49 }
50
51private:
52 GlobalDCEPass Impl;
53};
54} // namespace
55
56char GlobalDCELegacyPass::ID = 0;
57INITIALIZE_PASS(GlobalDCELegacyPass, "globaldce", "Dead Global Elimination",
58 false, false)
59
60// Public interface to the GlobalDCEPass.
61ModulePass *llvm::createGlobalDCEPass() { return new GlobalDCELegacyPass(); }
62
63STATISTIC(NumAliases , "Number of global aliases removed");
64STATISTIC(NumFunctions, "Number of functions removed");
65STATISTIC(NumIFuncs, "Number of indirect functions removed");
66STATISTIC(NumVariables, "Number of global variables removed");
67STATISTIC(NumVFuncs, "Number of virtual functions removed");
68
69/// Returns true if F is effectively empty.
70static bool isEmptyFunction(Function *F) {
71 // Skip external functions.
72 if (F->isDeclaration())
73 return false;
74 BasicBlock &Entry = F->getEntryBlock();
75 for (auto &I : Entry) {
77 continue;
78 if (auto *RI = dyn_cast<ReturnInst>(&I))
79 return !RI->getReturnValue();
80 break;
81 }
82 return false;
83}
84
85/// Compute the set of GlobalValue that depends from V.
86/// The recursion stops as soon as a GlobalValue is met.
87void GlobalDCEPass::ComputeDependencies(Value *V,
89 if (auto *I = dyn_cast<Instruction>(V)) {
90 Function *Parent = I->getParent()->getParent();
91 Deps.insert(Parent);
92 } else if (auto *GV = dyn_cast<GlobalValue>(V)) {
93 Deps.insert(GV);
94 } else if (auto *CE = dyn_cast<Constant>(V)) {
95 // Avoid walking the whole tree of a big ConstantExprs multiple times.
96 auto Where = ConstantDependenciesCache.find(CE);
97 if (Where == ConstantDependenciesCache.end()) {
98 // Compute into a local set first: the recursion can insert into the
99 // cache, which would invalidate references into it.
100 SmallPtrSet<GlobalValue *, 8> LocalDeps;
101 for (User *CEUser : CE->users())
102 ComputeDependencies(CEUser, LocalDeps);
103 Where =
104 ConstantDependenciesCache.try_emplace(CE, std::move(LocalDeps)).first;
105 }
106 Deps.insert_range(Where->second);
107 }
108}
109
110void GlobalDCEPass::UpdateGVDependencies(GlobalValue &GV) {
111 SmallPtrSet<GlobalValue *, 8> Deps;
112 for (User *User : GV.users())
113 ComputeDependencies(User, Deps);
114 Deps.erase(&GV); // Remove self-reference.
115 for (GlobalValue *GVU : Deps) {
116 // If this is a dep from a vtable to a virtual function, and we have
117 // complete information about all virtual call sites which could call
118 // though this vtable, then skip it, because the call site information will
119 // be more precise.
120 if (VFESafeVTables.count(GVU) && isa<Function>(&GV)) {
121 LLVM_DEBUG(dbgs() << "Ignoring dep " << GVU->getName() << " -> "
122 << GV.getName() << "\n");
123 continue;
124 }
125 GVDependencies[GVU].insert(&GV);
126 }
127}
128
129/// Mark Global value as Live
130void GlobalDCEPass::MarkLive(GlobalValue &GV,
132 auto const Ret = AliveGlobals.insert(&GV);
133 if (!Ret.second)
134 return;
135
136 if (Updates)
137 Updates->push_back(&GV);
138 if (Comdat *C = GV.getComdat()) {
139 for (auto &&CM : make_range(ComdatMembers.equal_range(C))) {
140 MarkLive(*CM.second, Updates); // Recursion depth is only two because only
141 // globals in the same comdat are visited.
142 }
143 }
144}
145
146void GlobalDCEPass::ScanVTables(Module &M) {
148 LLVM_DEBUG(dbgs() << "Building type info -> vtable map\n");
149
150 for (GlobalVariable &GV : M.globals()) {
151 Types.clear();
152 GV.getMetadata(LLVMContext::MD_type, Types);
153 if (GV.isDeclaration() || Types.empty())
154 continue;
155
156 // Use the typeid metadata on the vtable to build a mapping from typeids to
157 // the list of (GV, offset) pairs which are the possible vtables for that
158 // typeid.
159 for (MDNode *Type : Types) {
160 Metadata *TypeID = Type->getOperand(1).get();
161
164 cast<ConstantAsMetadata>(Type->getOperand(0))->getValue())
165 ->getZExtValue();
166
167 TypeIdMap[TypeID].insert(std::make_pair(&GV, Offset));
168 }
169
170 // If the type corresponding to the vtable is private to this translation
171 // unit, we know that we can see all virtual functions which might use it,
172 // so VFE is safe.
173 GlobalObject::VCallVisibility TypeVis = GV.getVCallVisibility();
175 (InLTOPostLink &&
177 LLVM_DEBUG(dbgs() << GV.getName() << " is safe for VFE\n");
178 VFESafeVTables.insert(&GV);
179 }
180 }
181}
182
183void GlobalDCEPass::ScanVTableLoad(Function *Caller, Metadata *TypeId,
184 uint64_t CallOffset) {
185 Module &M = *Caller->getParent();
186
187 for (const auto &[VTable, VTableOffset] : TypeIdMap[TypeId]) {
188 uint64_t SlotOffset = VTableOffset + CallOffset;
189
190 Constant *Ptr =
191 getPointerAtOffset(VTable->getInitializer(), SlotOffset, M, VTable);
192 if (!Ptr) {
193 // A slot that is NULL does not reference a function, so there is nothing
194 // to keep alive. We can still perform VFE on this vtable.
195 if (!isNullVTableSlot(VTable, SlotOffset, M)) {
196 LLVM_DEBUG(dbgs() << "can't find pointer in vtable!\n");
197 VFESafeVTables.erase(VTable);
198 }
199 continue;
200 }
201
203 if (!Callee) {
204 if (!isNullVTableSlot(VTable, SlotOffset, M)) {
205 LLVM_DEBUG(dbgs() << "vtable entry is not function pointer!\n");
206 VFESafeVTables.erase(VTable);
207 }
208 continue;
209 }
210
211 LLVM_DEBUG(dbgs() << "vfunc dep " << Caller->getName() << " -> "
212 << Callee->getName() << "\n");
213 VFuncDependencies[Caller].insert({VTable, Callee});
214 }
215}
216
217void GlobalDCEPass::ScanTypeCheckedLoadIntrinsics(Module &M) {
218 LLVM_DEBUG(dbgs() << "Scanning type.checked.load intrinsics\n");
219 Function *TypeCheckedLoadFunc =
220 Intrinsic::getDeclarationIfExists(&M, Intrinsic::type_checked_load);
221 Function *TypeCheckedLoadRelativeFunc = Intrinsic::getDeclarationIfExists(
222 &M, Intrinsic::type_checked_load_relative);
223
224 // Keep track of which (function, type id, offset) triples we've already
225 // scanned, to prevent repeated work.
226 DenseSet<std::tuple<Function *, Metadata *, uint64_t>> ScannedLoads;
227
228 auto scan = [&](Function *CheckedLoadFunc) {
229 if (!CheckedLoadFunc)
230 return;
231
232 for (auto *U : CheckedLoadFunc->users()) {
233 auto CI = dyn_cast<CallInst>(U);
234 if (!CI)
235 continue;
236
237 auto *Offset = dyn_cast<ConstantInt>(CI->getArgOperand(1));
238 Value *TypeIdValue = CI->getArgOperand(2);
239 auto *TypeId = cast<MetadataAsValue>(TypeIdValue)->getMetadata();
240
241 if (Offset) {
242 if (ScannedLoads
243 .insert({CI->getFunction(), TypeId, Offset->getZExtValue()})
244 .second)
245 ScanVTableLoad(CI->getFunction(), TypeId, Offset->getZExtValue());
246 } else {
247 // type.checked.load with a non-constant offset, so assume every entry
248 // in every matching vtable is used.
249 for (const auto &VTableInfo : TypeIdMap[TypeId]) {
250 VFESafeVTables.erase(VTableInfo.first);
251 }
252 }
253 }
254 };
255
256 scan(TypeCheckedLoadFunc);
257 scan(TypeCheckedLoadRelativeFunc);
258}
259
260void GlobalDCEPass::AddVirtualFunctionDependencies(Module &M) {
261 if (!getIPOOptions(M).enable_vfe)
262 return;
263
264 // If the Virtual Function Elim module flag is present and set to zero, then
265 // the vcall_visibility metadata was inserted for another optimization (WPD)
266 // and we may not have type checked loads on all accesses to the vtable.
267 // Don't attempt VFE in that case.
269 M.getModuleFlag("Virtual Function Elim"));
270 if (!Val || Val->isZero())
271 return;
272
273 ScanVTables(M);
274
275 if (VFESafeVTables.empty())
276 return;
277
278 ScanTypeCheckedLoadIntrinsics(M);
279
281 dbgs() << "VFE safe vtables:\n";
282 for (auto *VTable : VFESafeVTables)
283 dbgs() << " " << VTable->getName() << "\n";
284 );
285}
286
288 bool Changed = false;
289
290 // Only the analyses of the deleted functions need to be cleared.
291 FunctionAnalysisManager *FAM = nullptr;
292 if (MAM.isPassRegistered<FunctionAnalysisManagerModuleProxy>()) {
293 if (auto *FAMProxy =
294 MAM.getCachedResult<FunctionAnalysisManagerModuleProxy>(M))
295 FAM = &FAMProxy->getManager();
296 }
297
298 // The algorithm first computes the set L of global variables that are
299 // trivially live.
300 //
301 // Then it walks the initialization of these variables to compute the globals
302 // used to initialize them, which effectively builds a directed graph where
303 // nodes are global variables, and an edge from A to B means B is used to
304 // initialize A.
305 //
306 // Finally, it propagates the liveness information through the graph starting
307 // from the nodes in L. A virtual call only keeps a virtual function alive
308 // when its vtable is also live.
309 //
310 // Nodes not marked as alive are discarded.
311
312 // Remove empty functions from the global ctors list.
314 M, [](uint32_t, Function *F) { return isEmptyFunction(F); });
315
316 // Collect the set of members for each comdat.
317 for (Function &F : M)
318 if (Comdat *C = F.getComdat())
319 ComdatMembers.insert(std::make_pair(C, &F));
320 for (GlobalVariable &GV : M.globals())
321 if (Comdat *C = GV.getComdat())
322 ComdatMembers.insert(std::make_pair(C, &GV));
323 for (GlobalAlias &GA : M.aliases())
324 if (Comdat *C = GA.getComdat())
325 ComdatMembers.insert(std::make_pair(C, &GA));
326
327 // Add dependencies between virtual call sites and the virtual functions they
328 // might call, if we have that information.
329 AddVirtualFunctionDependencies(M);
330
331 // Loop over the module, adding globals which are obviously necessary.
332 for (GlobalObject &GO : M.global_objects()) {
333 GO.removeDeadConstantUsers();
334 // Functions with external linkage are needed if they have a body.
335 // Externally visible & appending globals are needed, if they have an
336 // initializer.
337 if (!GO.isDeclaration())
338 if (!GO.isDiscardableIfUnused())
339 MarkLive(GO);
340
341 UpdateGVDependencies(GO);
342 }
343
344 // Compute direct dependencies of aliases.
345 for (GlobalAlias &GA : M.aliases()) {
346 GA.removeDeadConstantUsers();
347 // Externally visible aliases are needed.
348 if (!GA.isDiscardableIfUnused())
349 MarkLive(GA);
350
351 UpdateGVDependencies(GA);
352 }
353
354 // Compute direct dependencies of ifuncs.
355 for (GlobalIFunc &GIF : M.ifuncs()) {
356 GIF.removeDeadConstantUsers();
357 // Externally visible ifuncs are needed.
358 if (!GIF.isDiscardableIfUnused())
359 MarkLive(GIF);
360
361 UpdateGVDependencies(GIF);
362 }
363
364 // Propagate liveness from collected Global Values through the computed
365 // dependencies.
366 SmallVector<GlobalValue *, 8> NewLiveGVs{AliveGlobals.begin(),
367 AliveGlobals.end()};
368 while (!NewLiveGVs.empty()) {
369 GlobalValue *LGV = NewLiveGVs.pop_back_val();
370 for (auto *GVD : GVDependencies[LGV])
371 MarkLive(*GVD, &NewLiveGVs);
372
373 // A virtual call keeps a virtual function alive only if the vtable it is
374 // loaded from is alive too. If the vtable is not live, defer the function:
375 // the vtable may become live later.
376 if (auto *F = dyn_cast<Function>(LGV)) {
377 if (auto It = VFuncDependencies.find(F); It != VFuncDependencies.end()) {
378 for (auto [VTable, VFunc] : It->second) {
379 if (AliveGlobals.contains(VTable))
380 MarkLive(*VFunc, &NewLiveGVs);
381 else
382 PendingVFuncs[VTable].push_back(VFunc);
383 }
384 }
385 }
386
387 // If LGV is a vtable that became alive later, mark its deferred functions
388 // live.
389 if (auto *VT = dyn_cast<GlobalVariable>(LGV)) {
390 if (auto It = PendingVFuncs.find(VT); It != PendingVFuncs.end()) {
391 for (auto *VFunc : It->second)
392 MarkLive(*VFunc, &NewLiveGVs);
393 }
394 }
395 }
396
397 // Now that all globals which are needed are in the AliveGlobals set, we loop
398 // through the program, deleting those which are not alive.
399 //
400
401 // The first pass is to drop initializers of global variables which are dead.
402 std::vector<GlobalVariable *> DeadGlobalVars; // Keep track of dead globals
403 for (GlobalVariable &GV : M.globals())
404 if (!AliveGlobals.count(&GV)) {
405 DeadGlobalVars.push_back(&GV); // Keep track of dead globals
406 if (GV.hasInitializer()) {
407 Constant *Init = GV.getInitializer();
408 GV.setInitializer(nullptr);
410 Init->destroyConstant();
411 }
412 }
413
414 // The second pass drops the bodies of functions which are dead...
415 std::vector<Function *> DeadFunctions;
416 for (Function &F : M)
417 if (!AliveGlobals.count(&F)) {
418 DeadFunctions.push_back(&F); // Keep track of dead globals
419 if (FAM)
420 FAM->clear(F, F.getName());
421 if (!F.isDeclaration())
422 F.deleteBody();
423 }
424
425 // The third pass drops targets of aliases which are dead...
426 std::vector<GlobalAlias*> DeadAliases;
427 for (GlobalAlias &GA : M.aliases())
428 if (!AliveGlobals.count(&GA)) {
429 DeadAliases.push_back(&GA);
430 GA.setAliasee(nullptr);
431 }
432
433 // The fourth pass drops targets of ifuncs which are dead...
434 std::vector<GlobalIFunc*> DeadIFuncs;
435 for (GlobalIFunc &GIF : M.ifuncs())
436 if (!AliveGlobals.count(&GIF)) {
437 DeadIFuncs.push_back(&GIF);
438 GIF.setResolver(nullptr);
439 }
440
441 // Now that all interferences have been dropped, delete the actual objects
442 // themselves.
443 auto EraseUnusedGlobalValue = [&](GlobalValue *GV) {
445 GV->eraseFromParent();
446 Changed = true;
447 };
448
449 NumFunctions += DeadFunctions.size();
450 for (Function *F : DeadFunctions) {
451 if (!F->use_empty()) {
452 // Virtual functions might still be referenced by one or more vtables,
453 // but if we've proven them to be unused then it's safe to replace the
454 // virtual function pointers with null, allowing us to remove the
455 // function itself.
456 ++NumVFuncs;
457
458 // Detect vfuncs that are referenced as "relative pointers" which are used
459 // in Swift vtables, i.e. entries in the form of:
460 //
461 // i32 trunc (i64 sub (i64 ptrtoint @f, i64 ptrtoint ...)) to i32)
462 //
463 // In this case, replace the whole "sub" expression with constant 0 to
464 // avoid leaving a weird sub(0, symbol) expression behind.
466
467 F->replaceNonMetadataUsesWith(ConstantPointerNull::get(F->getType()));
468 }
469 EraseUnusedGlobalValue(F);
470 }
471
472 NumVariables += DeadGlobalVars.size();
473 for (GlobalVariable *GV : DeadGlobalVars)
474 EraseUnusedGlobalValue(GV);
475
476 NumAliases += DeadAliases.size();
477 for (GlobalAlias *GA : DeadAliases)
478 EraseUnusedGlobalValue(GA);
479
480 NumIFuncs += DeadIFuncs.size();
481 for (GlobalIFunc *GIF : DeadIFuncs)
482 EraseUnusedGlobalValue(GIF);
483
484 // Make sure that all memory is released
485 AliveGlobals.clear();
486 ConstantDependenciesCache.clear();
487 GVDependencies.clear();
488 VFuncDependencies.clear();
489 PendingVFuncs.clear();
490 ComdatMembers.clear();
491 TypeIdMap.clear();
492 VFESafeVTables.clear();
493
494 if (!Changed)
495 return PreservedAnalyses::all();
496
500 return PA;
501}
502
504 raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) {
505 static_cast<PassInfoMixin<GlobalDCEPass> *>(this)->printPipeline(
506 OS, MapClassName2PassName);
507 if (InLTOPostLink)
508 OS << "<vfe-linkage-unit-visibility>";
509}
uint64_t uint64_t
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
dxil translate DXIL Translate Metadata
This file defines the DenseSet and SmallDenseSet classes.
static bool isEmptyFunction(Function *F)
Returns true if F is effectively empty.
Definition GlobalDCE.cpp:70
Module.h This file contains the declarations for the Module class.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
Type::TypeID TypeID
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
This file defines the SmallPtrSet class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Definition Statistic.h:170
#define LLVM_DEBUG(...)
Definition Debug.h:119
This templated class represents "all analyses that operate over <aparticular IR unit>" (e....
Definition Analysis.h:50
LLVM Basic Block Representation.
Definition BasicBlock.h:61
static LLVM_ABI ConstantPointerNull * get(PointerType *T)
Static factory methods - Return objects of the specified value.
This is an important base class in LLVM.
Definition Constant.h:44
const Constant * stripPointerCasts() const
Definition Constant.h:243
LLVM_ABI void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
Pass to remove unused function declarations.
Definition GlobalDCE.h:39
LLVM_ABI void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
LLVM_ABI bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition Globals.cpp:408
LLVM_ABI const Comdat * getComdat() const
Definition Globals.cpp:274
LLVM_ABI void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
Definition Globals.cpp:158
Root of the metadata hierarchy.
Definition Metadata.h:65
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition Pass.h:253
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
PreservedAnalyses & preserve()
Mark an analysis as preserved.
Definition Analysis.h:132
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
bool erase(PtrType Ptr)
Remove pointer from the set.
void insert_range(Range &&R)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
LLVM Value Representation.
Definition Value.h:75
iterator_range< user_iterator > users()
Definition Value.h:428
LLVM_ABI MDNode * getMetadata(StringRef Kind) const LLVM_READONLY
Get the current metadata attachments for the given kind, if any.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Definition Value.cpp:314
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
LLVM_ABI Function * getDeclarationIfExists(const Module *M, ID id)
Look up the Function declaration of the intrinsic id in the Module M and return it if it exists.
@ CE
Windows NT (Windows on ARM)
Definition MCAsmInfo.h:51
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract_or_null(Y &&MD)
Extract a Value from Metadata, if any, allowing null.
Definition Metadata.h:721
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
LLVM_ABI ModulePass * createGlobalDCEPass()
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
const IPOOptions & getIPOOptions(const LLVMContext &C)
Definition IPOOptions.h:44
LLVM_ABI bool isSafeToDestroyConstant(const Constant *C)
It is safe to destroy a constant iff it is only used by constants itself.
LLVM_ABI 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...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
LLVM_ABI bool isNullVTableSlot(GlobalVariable *GV, uint64_t Offset, Module &M)
Returns true if the vtable slot at Offset in GV is a NULL function pointer.
LLVM_ABI void replaceRelativePointerUsersWithZero(Constant *C)
Finds the same "relative pointer" pattern as described above, where the target is C,...
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
LLVM_ABI 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...