llvm/llvm/unittests/IR/LegacyPassManagerTest.cpp

//===- llvm/unittest/IR/LegacyPassManager.cpp - Legacy PassManager tests --===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This unit test exercises the legacy pass manager infrastructure. We use the
// old names as well to ensure that the source-level compatibility is preserved
// where possible.
//
//===----------------------------------------------------------------------===//

#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 {
    // ND = no deps
    // NM = no modifications
    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) {}

    // Skips or runs optional passes.
    struct CustomOptPassGate : public OptPassGate {};

    // Optional module pass.
    struct ModuleOpt: public ModulePass {};
    char ModuleOpt::ID=;

    TEST(PassManager, CustomOptPassGate) {}

    Module *makeLLVMModule(LLVMContext &Context) {}

    // Test for call graph SCC pass that replaces all callback call instructions
    // with clones and updates CallGraph by calling CallGraph::replaceCallEdge()
    // method. Test is expected to complete successfully after running pass on
    // all SCCs in the test module.
    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)