#include "llvm/Transforms/IPO/Internalize.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/GlobPattern.h"
#include "llvm/Support/LineIterator.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/IPO.h"
usingnamespacellvm;
#define DEBUG_TYPE …
STATISTIC(NumAliases, "Number of aliases internalized");
STATISTIC(NumFunctions, "Number of functions internalized");
STATISTIC(NumGlobals, "Number of global vars internalized");
static cl::opt<std::string>
APIFile("internalize-public-api-file", cl::value_desc("filename"),
cl::desc("A file containing list of symbol names to preserve"));
static cl::list<std::string>
APIList("internalize-public-api-list", cl::value_desc("list"),
cl::desc("A list of symbol names to preserve"), cl::CommaSeparated);
namespace {
class PreserveAPIList { … };
}
bool InternalizePass::shouldPreserveGV(const GlobalValue &GV) { … }
bool InternalizePass::maybeInternalize(
GlobalValue &GV, DenseMap<const Comdat *, ComdatInfo> &ComdatMap) { … }
void InternalizePass::checkComdat(
GlobalValue &GV, DenseMap<const Comdat *, ComdatInfo> &ComdatMap) { … }
bool InternalizePass::internalizeModule(Module &M) { … }
InternalizePass::InternalizePass() : … { … }
PreservedAnalyses InternalizePass::run(Module &M, ModuleAnalysisManager &AM) { … }