Files
revng-revng/lib/BasicAnalyses/EmptyNewPC.cpp
Alessandro Di Federico 5820908675 Remove and ban \file
2025-12-16 17:41:55 +01:00

28 lines
821 B
C++

/// A simple pass to given an empty body to the `newpc` function so that it can
/// be optimized away.
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "revng/BasicAnalyses/EmptyNewPC.h"
#include "revng/Support/IRHelperRegistry.h"
#include "revng/Support/IRHelpers.h"
using namespace llvm;
char EmptyNewPC::ID = 0;
using Register = RegisterPass<EmptyNewPC>;
static Register X("empty-newpc", "Create an empty newpc function", true, true);
bool EmptyNewPC::runOnModule(llvm::Module &M) {
LLVMContext &Context = getContext(&M);
Function *NewPCFunction = getIRHelper("newpc", M);
NewPCFunction->deleteBody();
ReturnInst::Create(Context, BasicBlock::Create(Context, "", NewPCFunction));
return false;
}