#include "llvm/IR/LegacyPassManager.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/CallGraphSCCPass.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/AbstractCallSite.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/CallingConv.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/OptBisect.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
#include "gtest/gtest.h"
usingnamespacellvm;
namespace llvm {
void initializeModuleNDMPass(PassRegistry&);
void initializeFPassPass(PassRegistry&);
void initializeCGPassPass(PassRegistry&);
void initializeLPassPass(PassRegistry&);
namespace {
struct ModuleNDNM: public ModulePass { … };
char ModuleNDNM::ID= …;
char ModuleNDNM::run= …;
struct ModuleNDM : public ModulePass { … };
char ModuleNDM::ID= …;
char ModuleNDM::run= …;
struct ModuleNDM2 : public ModulePass { … };
char ModuleNDM2::ID= …;
char ModuleNDM2::run= …;
struct ModuleDNM : public ModulePass { … };
char ModuleDNM::ID= …;
char ModuleDNM::run= …;
template<typename P>
struct PassTestBase : public P { … };
template<typename P> char PassTestBase<P>::ID;
template<typename P> int PassTestBase<P>::runc;
template<typename P> bool PassTestBase<P>::initialized;
template<typename P> bool PassTestBase<P>::finalized;
template<typename T, typename P>
struct PassTest : public PassTestBase<P> { … };
struct CGPass : public PassTest<CallGraph, CallGraphSCCPass> { … };
struct FPass : public PassTest<Module, FunctionPass> { … };
struct LPass : public PassTestBase<LoopPass> { … };
int LPass::initcount= …;
int LPass::fincount= …;
struct OnTheFlyTest: public ModulePass { … };
char OnTheFlyTest::ID= …;
TEST(PassManager, RunOnce) { … }
TEST(PassManager, ReRun) { … }
Module *makeLLVMModule(LLVMContext &Context);
template<typename T>
void MemoryTestHelper(int run) { … }
template<typename T>
void MemoryTestHelper(int run, int N) { … }
TEST(PassManager, Memory) { … }
TEST(PassManager, MemoryOnTheFly) { … }
struct CustomOptPassGate : public OptPassGate { … };
struct ModuleOpt: public ModulePass { … };
char ModuleOpt::ID= …;
TEST(PassManager, CustomOptPassGate) { … }
Module *makeLLVMModule(LLVMContext &Context) { … }
struct CallbackCallsModifierPass : public CGPass { … };
TEST(PassManager, CallbackCallsModifier0) { … }
}
}
INITIALIZE_PASS(…)
INITIALIZE_PASS_BEGIN(CGPass, "cgp","cgp", false, false)
INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass)
INITIALIZE_PASS_END(CGPass, "cgp","cgp", false, false)
INITIALIZE_PASS(…)
INITIALIZE_PASS_BEGIN(LPass, "lp","lp", false, false)
INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
INITIALIZE_PASS_END(LPass, "lp","lp", false, false)