#include "llvm/IR/LegacyPassManager.h" #include "llvm/IR/Module.h" #include "llvm/Support/Error.h" #include "revng/Pipeline/Context.h" #include "revng/Pipeline/Contract.h" #include "revng/Pipeline/RegisterLLVMPass.h" #include "revng/Pipeline/RegisterPipe.h" #include "revng/Pipes/CallGraphCache.h" using namespace revng::pipes; using namespace pipeline; template<> const char pipeline::YamlizableGlobal::ID = '0'; class CreateCallGraphCachePass : public llvm::ModulePass { public: static char ID; bool runOnModule(llvm::Module &Module) override { ToWrite.Name = "ASD"; return true; } CreateCallGraphCachePass(CallGraphCache &ToWrite) : llvm::ModulePass(ID), ToWrite(ToWrite) {} private: CallGraphCache &ToWrite; }; char CreateCallGraphCachePass::ID = '0'; CallGraphCache &CallGraphCache::fromContext(pipeline::Context &Ctx) { using namespace llvm; const auto &Name = CallGraphCache::GlobalName; return *cantFail(Ctx.getGlobal(Name))->get(); } const CallGraphCache & CallGraphCache::fromContext(const pipeline::Context &Ctx) { const auto &Name = CallGraphCache::GlobalName; using namespace llvm; return *cantFail(Ctx.getGlobal(Name))->get(); } class CreateCallGraphPipe { public: static constexpr auto Name = "cache-call-graph"; std::vector getContract() const { return {}; } void registerPasses(Context &Ctx, llvm::legacy::PassManager &Manager) { Manager.add(new CreateCallGraphCachePass(CallGraphCache::fromContext(Ctx))); } void print(llvm::raw_ostream &OS) const {} }; static RegisterLLVMPass X;