#include "llvm/Transforms/IPO/ElimAvailExtern.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/CtxProfAnalysis.h"
#include "llvm/IR/Constant.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Utils/GlobalStatus.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
usingnamespacellvm;
#define DEBUG_TYPE …
cl::opt<bool> ConvertToLocal(
"avail-extern-to-local", cl::Hidden,
cl::desc("Convert available_externally into locals, renaming them "
"to avoid link-time clashes."));
STATISTIC(NumRemovals, "Number of functions removed");
STATISTIC(NumConversions, "Number of functions converted");
STATISTIC(NumVariables, "Number of global variables removed");
void deleteFunction(Function &F) { … }
static void convertToLocalCopy(Module &M, Function &F) { … }
static bool eliminateAvailableExternally(Module &M, bool Convert) { … }
PreservedAnalyses
EliminateAvailableExternallyPass::run(Module &M, ModuleAnalysisManager &MAM) { … }