mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
ba49937a69
A simple pass that removes the calls to `newpc` marker.
30 lines
791 B
C++
30 lines
791 B
C++
/// \file RemoveNewPCCalls.cpp
|
|
/// \brief Remove calls to newpc in a function.
|
|
|
|
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "revng/BasicAnalyses/RemoveNewPCCalls.h"
|
|
#include "revng/Support/IRHelpers.h"
|
|
|
|
llvm::PreservedAnalyses
|
|
RemoveNewPCCallsPass::run(llvm::Function &F,
|
|
llvm::FunctionAnalysisManager &FAM) {
|
|
llvm::SmallVector<llvm::Instruction *, 16> ToErase;
|
|
for (auto &BB : F) {
|
|
for (auto &I : BB)
|
|
if (isCallTo(&I, "newpc"))
|
|
ToErase.push_back(&I);
|
|
}
|
|
|
|
bool Changed = not ToErase.empty();
|
|
for (auto *I : ToErase)
|
|
I->eraseFromParent();
|
|
|
|
return (Changed ? llvm::PreservedAnalyses::none() :
|
|
llvm::PreservedAnalyses::all());
|
|
}
|