retdec
cond_branch_opt.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_BIN2LLVMIR_OPTIMIZATIONS_COND_BRANCH_OPT_COND_BRANCH_OPT_H
8 #define RETDEC_BIN2LLVMIR_OPTIMIZATIONS_COND_BRANCH_OPT_COND_BRANCH_OPT_H
9 
10 #include <unordered_set>
11 
12 #include <llvm/IR/Module.h>
13 #include <llvm/Pass.h>
14 
17 
18 namespace retdec {
19 namespace bin2llvmir {
20 
27 class CondBranchOpt : public llvm::ModulePass
28 {
29  public:
30  static char ID;
31  CondBranchOpt();
32  virtual bool runOnModule(llvm::Module& m) override;
33  bool runOnModuleCustom(llvm::Module& m, Config* c, Abi* abi);
34 
35  private:
36  bool run();
37  bool runOnInstruction(
39  llvm::Instruction& i);
40 
42  llvm::BranchInst* br,
43  llvm::Value* testedVal,
44  llvm::Value* subVal,
45  llvm::Instruction* binOp,
46  llvm::CmpInst::Predicate predicate);
47 
48  private:
49  llvm::Module* _module = nullptr;
50  Config* _config = nullptr;
51  Abi* _abi = nullptr;
52  std::unordered_set<llvm::Value*> _toRemove;
53 };
54 
55 } // namespace bin2llvmir
56 } // namespace retdec
57 
58 #endif
ABI information.
Config DB provider for bin2llvmirl.
Definition: abi.h:27
Definition: cond_branch_opt.h:28
llvm::Module * _module
Definition: cond_branch_opt.h:49
bool transformConditionSub(llvm::BranchInst *br, llvm::Value *testedVal, llvm::Value *subVal, llvm::Instruction *binOp, llvm::CmpInst::Predicate predicate)
Definition: cond_branch_opt.cpp:273
std::unordered_set< llvm::Value * > _toRemove
Definition: cond_branch_opt.h:52
bool runOnModuleCustom(llvm::Module &m, Config *c, Abi *abi)
Definition: cond_branch_opt.cpp:49
Config * _config
Definition: cond_branch_opt.h:50
static char ID
Definition: cond_branch_opt.h:30
CondBranchOpt()
Definition: cond_branch_opt.cpp:35
bool run()
Definition: cond_branch_opt.cpp:57
Abi * _abi
Definition: cond_branch_opt.h:51
bool runOnInstruction(ReachingDefinitionsAnalysis &RDA, llvm::Instruction &i)
Definition: cond_branch_opt.cpp:87
virtual bool runOnModule(llvm::Module &m) override
Definition: cond_branch_opt.cpp:41
Definition: config.h:24
Definition: reaching_definitions.h:121
The frontend-end part of the decompiler.
Definition: archive_wrapper.h:19