28#define DEBUG_TYPE "elim-avail-extern"
30STATISTIC(NumFunctions,
"Number of functions removed");
31STATISTIC(NumVariables,
"Number of global variables removed");
38 if (!GV.hasAvailableExternallyLinkage())
40 if (GV.hasInitializer()) {
42 GV.setInitializer(
nullptr);
44 Init->destroyConstant();
46 GV.removeDeadConstantUsers();
54 if (!
F.hasAvailableExternallyLinkage())
56 if (!
F.isDeclaration())
59 F.removeDeadConstantUsers();
static bool eliminateAvailableExternally(Module &M)
Module.h This file contains the declarations for the Module class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
A container for analyses that lazily runs them and caches their results.
This is an important base class in LLVM.
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
@ ExternalLinkage
Externally visible function.
A Module instance is used to store all the information related to an LLVM module.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
This is an optimization pass for GlobalISel generic memory operations.
bool isSafeToDestroyConstant(const Constant *C)
It is safe to destroy a constant iff it is only used by constants itself.