25 #define DEBUG_TYPE "elim-avail-extern"
27 STATISTIC(NumFunctions,
"Number of functions removed");
28 STATISTIC(NumVariables,
"Number of global variables removed");
31 struct EliminateAvailableExternally :
public ModulePass {
41 bool runOnModule(
Module &M)
override;
47 "Eliminate Available Externally Globals",
false,
false)
50 return new EliminateAvailableExternally();
53 bool EliminateAvailableExternally::runOnModule(
Module &M) {
59 if (!
I->hasAvailableExternallyLinkage())
61 if (
I->hasInitializer()) {
63 I->setInitializer(
nullptr);
67 I->removeDeadConstantUsers();
74 if (!
I->hasAvailableExternallyLinkage())
76 if (!
I->isDeclaration())
79 I->removeDeadConstantUsers();
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. ...
void initializeEliminateAvailableExternallyPass(PassRegistry &)
Externally visible function.
ModulePass * createEliminateAvailableExternallyPass()
This transform is designed to eliminate available external globals (functions or global variables) ...
global_iterator global_begin()
INITIALIZE_PASS(EliminateAvailableExternally,"elim-avail-extern","Eliminate Available Externally Globals", false, false) ModulePass *llvm
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.
global_iterator global_end()
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.