retdec
stack.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_BIN2LLVMIR_OPTIMIZATIONS_STACK_STACK_H
8 #define RETDEC_BIN2LLVMIR_OPTIMIZATIONS_STACK_STACK_H
9 
10 #include <optional>
11 #include <unordered_set>
12 
13 #include <llvm/IR/Module.h>
14 #include <llvm/Pass.h>
15 
20 
21 namespace retdec {
22 namespace bin2llvmir {
23 
24 class StackAnalysis : public llvm::ModulePass
25 {
26  public:
27  static char ID;
28  StackAnalysis();
29  virtual bool runOnModule(llvm::Module& m) override;
30  bool runOnModuleCustom(
31  llvm::Module& m,
32  Config* c,
33  Abi* abi,
34  DebugFormat* dbgf = nullptr);
35 
36  private:
37  bool run();
38  void handleInstruction(
40  llvm::Instruction* inst,
41  llvm::Value* val,
42  llvm::Type* type,
43  std::map<llvm::Value*, llvm::Value*>& val2val);
44  std::optional<int> getBaseOffset(SymbolicTree &root);
46  llvm::Function* fnc,
47  SymbolicTree& root);
49  llvm::Function* fnc,
50  SymbolicTree& root);
51 
52  private:
53  llvm::Module* _module = nullptr;
54  Config* _config = nullptr;
55  Abi* _abi = nullptr;
56  DebugFormat* _dbgf = nullptr;
57 
58  std::unordered_set<llvm::Value*> _toRemove;
59 };
60 
61 } // namespace bin2llvmir
62 } // namespace retdec
63 
64 #endif
ABI information.
Config DB provider for bin2llvmirl.
Debug format provider for bin2llvmirl.
Definition: abi.h:27
Definition: config.h:24
Definition: debugformat.h:20
Definition: reaching_definitions.h:121
Definition: stack.h:25
Abi * _abi
Definition: stack.h:55
StackAnalysis()
Definition: stack.cpp:37
bool runOnModuleCustom(llvm::Module &m, Config *c, Abi *abi, DebugFormat *dbgf=nullptr)
Definition: stack.cpp:52
std::optional< int > getBaseOffset(SymbolicTree &root)
Definition: stack.cpp:259
const retdec::common::Object * getDebugStackVariable(llvm::Function *fnc, SymbolicTree &root)
Definition: stack.cpp:293
const retdec::common::Object * getConfigStackVariable(llvm::Function *fnc, SymbolicTree &root)
Definition: stack.cpp:329
bool run()
Definition: stack.cpp:65
llvm::Module * _module
Definition: stack.h:53
virtual bool runOnModule(llvm::Module &m) override
Definition: stack.cpp:43
std::unordered_set< llvm::Value * > _toRemove
Definition: stack.h:58
static char ID
Definition: stack.h:27
void handleInstruction(ReachingDefinitionsAnalysis &RDA, llvm::Instruction *inst, llvm::Value *val, llvm::Type *type, std::map< llvm::Value *, llvm::Value * > &val2val)
Definition: stack.cpp:131
DebugFormat * _dbgf
Definition: stack.h:56
Config * _config
Definition: stack.h:54
Definition: symbolic_tree.h:43
Definition: object.h:34
The frontend-end part of the decompiler.
Definition: archive_wrapper.h:19
Construction of symbolic tree from the given node.