diff options
Diffstat (limited to 'include/klee/Internal/Module/KModule.h')
-rw-r--r-- | include/klee/Internal/Module/KModule.h | 55 |
1 files changed, 40 insertions, 15 deletions
diff --git a/include/klee/Internal/Module/KModule.h b/include/klee/Internal/Module/KModule.h index e8ded725..478e24d7 100644 --- a/include/klee/Internal/Module/KModule.h +++ b/include/klee/Internal/Module/KModule.h @@ -13,7 +13,10 @@ #include "klee/Config/Version.h" #include "klee/Interpreter.h" +#include "llvm/ADT/ArrayRef.h" + #include <map> +#include <memory> #include <set> #include <vector> @@ -50,12 +53,11 @@ namespace klee { /// "coverable" for statistics and search heuristics. bool trackCoverage; - private: - KFunction(const KFunction&); - KFunction &operator=(const KFunction&); - public: explicit KFunction(llvm::Function*, KModule *); + KFunction(const KFunction &) = delete; + KFunction &operator=(const KFunction &) = delete; + ~KFunction(); unsigned getArgRegister(unsigned index) { return index; } @@ -80,24 +82,24 @@ namespace klee { class KModule { public: - llvm::Module *module; - llvm::DataLayout *targetData; + std::unique_ptr<llvm::Module> module; + std::unique_ptr<llvm::DataLayout> targetData; // Our shadow versions of LLVM structures. - std::vector<KFunction*> functions; + std::vector<std::unique_ptr<KFunction>> functions; std::map<llvm::Function*, KFunction*> functionMap; // Functions which escape (may be called indirectly) // XXX change to KFunction std::set<llvm::Function*> escapingFunctions; - InstructionInfoTable *infos; + std::unique_ptr<InstructionInfoTable> infos; std::vector<llvm::Constant*> constants; - std::map<const llvm::Constant*, KConstant*> constantMap; + std::map<const llvm::Constant *, std::unique_ptr<KConstant>> constantMap; KConstant* getKConstant(const llvm::Constant *c); - Cell *constantTable; + std::unique_ptr<Cell[]> constantTable; // Functions which are part of KLEE runtime std::set<const llvm::Function*> internalFunctions; @@ -107,14 +109,37 @@ namespace klee { void addInternalFunction(const char* functionName); public: - KModule(llvm::Module *_module); - ~KModule(); + KModule() = default; - /// Initialize local data structures. + /// Optimise and prepare module such that KLEE can execute it // + void optimiseAndPrepare(const Interpreter::ModuleOptions &opts, + llvm::ArrayRef<const char *>); + + /// Manifest the generated module (e.g. assembly.ll, output.bc) and + /// prepares KModule + /// + /// @param ih + /// @param forceSourceOutput true if assembly.ll should be created + /// // FIXME: ihandler should not be here - void prepare(const Interpreter::ModuleOptions &opts, - InterpreterHandler *ihandler); + void manifest(InterpreterHandler *ih, bool forceSourceOutput); + + /// Link the provided modules together as one KLEE module. + /// + /// If the entry point is empty, all modules are linked together. + /// If the entry point is not empty, all modules are linked which resolve + /// the dependencies of the module containing entryPoint + /// + /// @param modules list of modules to be linked together + /// @param entryPoint name of the function which acts as the program's entry + /// point + /// @return true if at least one module has been linked in, false if nothing + /// changed + bool link(std::vector<std::unique_ptr<llvm::Module>> &modules, + const std::string &entryPoint); + + void instrument(const Interpreter::ModuleOptions &opts); /// Return an id for the given constant, creating a new one if necessary. unsigned getConstantID(llvm::Constant *c, KInstruction* ki); |