7 #include <llvm/ADT/Triple.h>
8 #include <llvm/Analysis/LoopInfo.h>
9 #include <llvm/Analysis/ScalarEvolution.h>
10 #include <llvm/Analysis/TargetLibraryInfo.h>
11 #include <llvm/IR/DataLayout.h>
12 #include <llvm/IR/LLVMContext.h>
13 #include <llvm/IR/LegacyPassManager.h>
14 #include <llvm/IR/Module.h>
15 #include <llvm/IRReader/IRReader.h>
16 #include <llvm/MC/SubtargetFeature.h>
17 #include <llvm/Pass.h>
18 #include <llvm/Support/CommandLine.h>
19 #include <llvm/Support/Debug.h>
20 #include <llvm/Support/ErrorHandling.h>
21 #include <llvm/Support/FileSystem.h>
22 #include <llvm/Support/FormattedStream.h>
23 #include <llvm/Support/Host.h>
24 #include <llvm/Support/ManagedStatic.h>
25 #include <llvm/Support/PrettyStackTrace.h>
26 #include <llvm/Support/Signals.h>
27 #include <llvm/Support/SourceMgr.h>
28 #include <llvm/Support/TargetRegistry.h>
29 #include <llvm/Support/TargetSelect.h>
30 #include <llvm/Support/ToolOutputFile.h>
31 #include <llvm/Target/TargetMachine.h>
81 #ifndef RETDEC_LLVMIR2HLL_LLVMIR2HLL_H
82 #define RETDEC_LLVMIR2HLL_LLVMIR2HLL_H
109 virtual bool runOnModule(llvm::Module &m)
override;
140 const std::string &opts)
const;
180 std::unique_ptr<llvm::ToolOutputFile>
outFile;
A base class for all alias analyses.
Factory that creates instances of classes derived from AliasAnalysis.
A base class for all evaluators.
Factory that creates instances of classes derived from ArithmExprEvaluator.
A base class of all obtainers of information about functions and function calls.
Factory that creates instances of classes derived from CallInfoObtainer.
A base class of all control-flow graph (CFG) writers.
Factory that creates instances of classes derived from CFGWriter.
A creator of call graphs (CGs) from modules.
A base class of all call graph (CG) writers.
Factory that creates instances of classes derived from CGWriter.
This class is the main chunk of code that converts an LLVM module to the specified high-level languag...
Definition: llvmir2hll.h:104
ShPtr< llvmir2hll::Semantics > semantics
The used semantics.
Definition: llvmir2hll.h:155
void createSemantics()
Creates the used semantics.
Definition: llvmir2hll.cpp:398
ShPtr< llvmir2hll::ArithmExprEvaluator > arithmExprEvaluator
The used evaluator of arithmetical expressions.
Definition: llvmir2hll.h:171
llvmir2hll::StringSet parseListOfOpts(const std::string &opts) const
Parses the given list of optimizations.
Definition: llvmir2hll.cpp:840
void convertLLVMIntrinsicFunctions()
Converts LLVM intrinsic functions to functions from the standard library.
Definition: llvmir2hll.cpp:572
std::string getTypeOfRunOptimizations() const
Returns the type of optimizations that should be run (as a string).
Definition: llvmir2hll.cpp:850
void runOptimizations()
Runs the optimizations over the resulting module.
Definition: llvmir2hll.cpp:596
virtual bool runOnModule(llvm::Module &m) override
Definition: llvmir2hll.cpp:150
void emitCFGs()
Emits a control-flow graph (CFG) for each function in the resulting module.
Definition: llvmir2hll.cpp:710
void setConfig(retdec::config::Config *c)
Definition: llvmir2hll.cpp:130
config::Config * globalConfig
The used config.
Definition: llvmir2hll.h:158
ShPtr< llvmir2hll::VarRenamer > varRenamer
The used renamer of variables.
Definition: llvmir2hll.h:177
virtual void getAnalysisUsage(llvm::AnalysisUsage &au) const override
Definition: llvmir2hll.cpp:143
ShPtr< llvmir2hll::PatternFinderRunner > instantiatePatternFinderRunner() const
Instantiates and returns a proper PatternFinderRunner.
Definition: llvmir2hll.cpp:918
void emitCG()
Emits a call graph (CG) for the resulting module.
Definition: llvmir2hll.cpp:781
bool initialize(llvm::Module &m)
Initializes all the needed private variables.
Definition: llvmir2hll.cpp:256
void removeCodeUnreachableInCFG()
Removes code from all the functions in the module that is unreachable in the CFG.
Definition: llvmir2hll.cpp:555
static char ID
Definition: llvmir2hll.h:106
void cleanup()
Cleanup.
Definition: llvmir2hll.cpp:696
void validateResultingModule()
Validates the resulting module.
Definition: llvmir2hll.cpp:633
llvmir2hll::StringVector getIdsOfPatternFindersToBeRun() const
Returns the IDs of pattern finders to be run.
Definition: llvmir2hll.cpp:861
void setOutputString(std::string *outString)
Definition: llvmir2hll.cpp:135
bool loadConfig()
Loads a config for the module.
Definition: llvmir2hll.cpp:464
void finalize()
Finalizes the run of the back-end part.
Definition: llvmir2hll.cpp:687
std::unique_ptr< llvm::raw_string_ostream > outStringStream
Output string stream.
Definition: llvmir2hll.h:183
void removeLibraryFuncs()
Removes defined functions which are from some standard library whose header file has to be included b...
Definition: llvmir2hll.cpp:533
ShPtr< llvmir2hll::Config > config
Definition: llvmir2hll.h:159
ShPtr< llvmir2hll::VarNameGen > varNameGen
The used generator of variable names.
Definition: llvmir2hll.h:174
void fixSignedUnsignedTypes()
Fixes signed and unsigned types in the resulting module.
Definition: llvmir2hll.cpp:563
void emitTargetHLLCode()
Emits the target HLL code.
Definition: llvmir2hll.cpp:669
LlvmIr2Hll(retdec::config::Config *c=nullptr)
Constructs a new decompiler.
Definition: llvmir2hll.cpp:124
void createSemanticsFromParameter()
Creates the used semantics as requested by the user.
Definition: llvmir2hll.cpp:416
ShPtr< llvmir2hll::HLLWriter > hllWriter
The used HLL writer.
Definition: llvmir2hll.h:162
llvmir2hll::PatternFinderRunner::PatternFinders instantiatePatternFinders(const llvmir2hll::StringVector &pfsIds)
Instantiates and returns the pattern finders described by their ID.
Definition: llvmir2hll.cpp:882
void renameVariables()
Renames variables in the resulting module by using the selected variable renamer.
Definition: llvmir2hll.cpp:617
void initAliasAnalysis()
Initializes the alias analysis.
Definition: llvmir2hll.cpp:588
void findPatterns()
Finds patterns in the resulting module.
Definition: llvmir2hll.cpp:654
bool convertLLVMIRToBIR()
Convert the LLVM IR module into a BIR module using the instantiated converter.
Definition: llvmir2hll.cpp:509
void convertConstantsToSymbolicNames()
Converts constants in function calls to symbolic names.
Definition: llvmir2hll.cpp:625
llvm::Module * llvmModule
The input LLVM module.
Definition: llvmir2hll.h:149
ShPtr< llvmir2hll::AliasAnalysis > aliasAnalysis
The used alias analysis.
Definition: llvmir2hll.h:165
ShPtr< llvmir2hll::Module > resModule
The resulting module in BIR.
Definition: llvmir2hll.h:152
void saveConfig()
Saves the config file.
Definition: llvmir2hll.cpp:494
void createSemanticsFromLLVMIR()
Creates the used semantics based on the data in the input LLVM IR.
Definition: llvmir2hll.cpp:443
void obtainDebugInfo()
When available, obtains debugging information.
Definition: llvmir2hll.cpp:580
std::unique_ptr< llvm::ToolOutputFile > outFile
Output file stream.
Definition: llvmir2hll.h:180
ShPtr< llvmir2hll::CallInfoObtainer > cio
The used obtainer of information about function and function calls.
Definition: llvmir2hll.h:168
std::vector< ShPtr< PatternFinder > > PatternFinders
A container storing pattern finders.
Definition: pattern_finder_runner.h:31
Runner of pattern finders for the command line interface.
A class providing an easy construction of compound semantics from several different semantics.
Decompilation configuration manipulation.
A default semantics which doesn't know anything.
A visitor for fixing the types in the IR.
A base class of all HLL writers.
Factory that creates instances of classes derived from HLLWriter.
Config in the JSON format.
Obtainer of debug information from an LLVM module.
Conversion of LLVM intrinsic functions into functions from the standard C library.
A base class for all converters of LLVM IR to BIR.
A representation of a function.
A representation of a complete module.
A library providing API for working with back-end IR.
std::vector< std::string > StringVector
Vector of strings.
Definition: types.h:87
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
std::set< std::string > StringSet
Set of strings.
Definition: types.h:51
Definition: archive_wrapper.h:19
Runner of pattern finders that performs no additional actions.
A non-recursive creator of control-flow graphs (CFGs) from functions.
A generator of variable names of the form "prefixN", where N is a number.
A manager managing optimizations.
Factory that creates instances of classes derived from PatternFinder.
A base class for all runners of pattern finders.
Factory that creates instances of classes derived from Semantics.
A base class for all validators.
Factory that creates instances of classes derived from Validator.
An analysis for obtaining information about a value.
Factory that creates instances of classes derived from VarNameGen.
A base class for all variable renamers.
Factory that creates instances of classes derived from VarRenamer.