mirror of
https://github.com/revng/revng
synced 2026-06-21 14:07:57 +00:00
f8bd4c3bac
* Make the following private headers public:
* Lift/CPUStateAccessAnalysisPass.h
* Lift/CSVOffsets.h
* Lift/PTCDump.h
* Lift/VariableManager.h
* Move from revngSupport to revngLift:
* IRAnnotators.{h,cpp}
* SelfReferencingDbgAnnotationWriter.{h,cpp}
* Move from revngSupport to revngModel:
* FunctionTags.{h,cpp}
* ProgramCounterHandler.{h,cpp}
* Move from revngSupport to revngRecompile:
* OriginalAssemblyAnnotationWriter.{h,cpp}
55 lines
1.4 KiB
C++
55 lines
1.4 KiB
C++
//
|
|
// This file is distributed under the MIT License. See LICENSE.md for details.
|
|
//
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
#include "llvm/IR/Function.h"
|
|
#include "llvm/IR/Module.h"
|
|
|
|
#include "revng/Model/FunctionTags.h"
|
|
#include "revng/Model/LoadModelPass.h"
|
|
#include "revng/Support/IRHelpers.h"
|
|
|
|
using namespace llvm;
|
|
|
|
class RemoveLLVMAssumeCallsPass : public llvm::FunctionPass {
|
|
public:
|
|
static char ID;
|
|
|
|
public:
|
|
RemoveLLVMAssumeCallsPass() : llvm::FunctionPass(ID) {}
|
|
|
|
bool runOnFunction(llvm::Function &F) override;
|
|
|
|
void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
|
|
};
|
|
|
|
using RemoveAssumePass = RemoveLLVMAssumeCallsPass;
|
|
|
|
char RemoveAssumePass::ID = 0;
|
|
using Reg = RegisterPass<RemoveAssumePass>;
|
|
static Reg
|
|
X("remove-llvmassume-calls", "Removes calls to assume intrinsic", true, true);
|
|
|
|
void RemoveAssumePass::getAnalysisUsage(llvm::AnalysisUsage &AU) const {
|
|
}
|
|
|
|
bool RemoveAssumePass::runOnFunction(Function &F) {
|
|
|
|
// Remove calls to `llvm.assume` in isolated functions.
|
|
SmallVector<Instruction *, 8> ToErase;
|
|
for (BasicBlock &BB : F) {
|
|
for (Instruction &I : BB)
|
|
if (auto *C = dyn_cast<CallInst>(&I))
|
|
if (auto *Callee = getCallee(C);
|
|
Callee and Callee->getName() == "llvm.assume")
|
|
ToErase.push_back(C);
|
|
}
|
|
|
|
bool Changed = not ToErase.empty();
|
|
for (Instruction *I : ToErase)
|
|
eraseFromParent(I);
|
|
|
|
return Changed;
|
|
}
|