25 #define DEBUG_TYPE "elim-avail-extern"
27 STATISTIC(NumFunctions,
"Number of functions removed");
28 STATISTIC(NumVariables,
"Number of global variables removed");
35 if (!GV.hasAvailableExternallyLinkage())
37 if (GV.hasInitializer()) {
39 GV.setInitializer(
nullptr);
43 GV.removeDeadConstantUsers();
51 if (!
F.hasAvailableExternallyLinkage())
53 if (!
F.isDeclaration())
56 F.removeDeadConstantUsers();
72 struct EliminateAvailableExternallyLegacyPass :
public ModulePass {
74 EliminateAvailableExternallyLegacyPass() :
ModulePass(
ID) {
82 bool runOnModule(
Module &M) {
92 "Eliminate Available Externally Globals",
false,
false)
95 return new EliminateAvailableExternallyLegacyPass();
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
STATISTIC(NumFunctions,"Total number of functions")
A Module instance is used to store all the information related to an LLVM module. ...
Externally visible function.
ModulePass * createEliminateAvailableExternallyPass()
This transform is designed to eliminate available external globals (functions or global variables) ...
PreservedAnalyses run(Module &M, ModuleAnalysisManager &)
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static bool eliminateAvailableExternally(Module &M)
A set of analyses that are preserved following a run of a transformation pass.
void initializeEliminateAvailableExternallyLegacyPassPass(PassRegistry &)
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isSafeToDestroyConstant(const Constant *C)
It is safe to destroy a constant iff it is only used by constants itself.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
INITIALIZE_PASS(EliminateAvailableExternallyLegacyPass,"elim-avail-extern","Eliminate Available Externally Globals", false, false) ModulePass *llvm
Module.h This file contains the declarations for the Module class.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
void destroyConstant()
Called if some element of this constant is no longer valid.
iterator_range< global_iterator > globals()
A container for analyses that lazily runs them and caches their results.