mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
53 lines
1.4 KiB
C++
53 lines
1.4 KiB
C++
/// \file DropRoot.cpp
|
|
/// \brief
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
#include "revng/Pipeline/AllRegistries.h"
|
|
#include "revng/Pipeline/Contract.h"
|
|
#include "revng/Pipes/Kinds.h"
|
|
#include "revng/Pipes/RootKind.h"
|
|
#include "revng/Pipes/TaggedFunctionKind.h"
|
|
|
|
class DropRootPass : public llvm::ModulePass {
|
|
public:
|
|
static char ID;
|
|
|
|
public:
|
|
DropRootPass() : ModulePass(ID) {}
|
|
|
|
bool runOnModule(llvm::Module &M) override {
|
|
using namespace llvm;
|
|
for (Function &F : FunctionTags::Root.functions(&M))
|
|
F.deleteBody();
|
|
return true;
|
|
}
|
|
|
|
void getAnalysisUsage(llvm::AnalysisUsage &AU) const override {}
|
|
};
|
|
|
|
char DropRootPass::ID = 0;
|
|
using Register = llvm::RegisterPass<DropRootPass>;
|
|
static Register X("drop-root", "Drop Root Pass", true, true);
|
|
|
|
struct DropRootPipe {
|
|
static constexpr auto Name = "drop-root";
|
|
|
|
std::vector<pipeline::ContractGroup> getContract() const {
|
|
using namespace pipeline;
|
|
using namespace ::revng::pipes;
|
|
return { ContractGroup::transformOnlyArgument(Root,
|
|
Exactness::DerivedFrom,
|
|
Kind::deadKind<&RootRank>(),
|
|
InputPreservation::Erase) };
|
|
}
|
|
|
|
void registerPasses(llvm::legacy::PassManager &Manager) {
|
|
Manager.add(new DropRootPass());
|
|
}
|
|
};
|