diff options
author | Richard Trembecký <richardt@centrum.sk> | 2016-05-01 16:38:21 +0200 |
---|---|---|
committer | Dan Liew <delcypher@gmail.com> | 2017-05-24 14:24:47 +0100 |
commit | d3a467d8999e6e52892b13c2bc93ac829ee1b7c9 (patch) | |
tree | 99493da4b33f50eb0c27a237213c615520efbd95 /lib/Core/Executor.cpp | |
parent | 92367dec2ee00cb708454e4c33ff34d80eddb878 (diff) | |
download | klee-d3a467d8999e6e52892b13c2bc93ac829ee1b7c9.tar.gz |
llvm: make KLEE compile against LLVM 3.5 and 3.6
Based on work by @ccadeptic23 and @delcypher. Formatting fixed by @snf. Fix compiler warning by @martijnthe. Further fixes by @mchalupa. Refactored, so that changes can be reviewed -- no massive changes in whitespace and in the surrounding code. Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Diffstat (limited to 'lib/Core/Executor.cpp')
-rw-r--r-- | lib/Core/Executor.cpp | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 1930cdc3..1cdb770b 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -81,6 +81,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Process.h" #include "llvm/Support/raw_ostream.h" @@ -383,7 +384,13 @@ Executor::Executor(LLVMContext &ctx, const InterpreterOptions &opts, if (!DebugCompressInstructions) { #endif -#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) + std::error_code ec; + debugInstFile = new llvm::raw_fd_ostream(debug_file_name.c_str(), ec, + llvm::sys::fs::OpenFlags::F_Text); + if (ec) + ErrorInfo = ec.message(); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) debugInstFile = new llvm::raw_fd_ostream(debug_file_name.c_str(), ErrorInfo, llvm::sys::fs::OpenFlags::F_Text); #else @@ -1479,9 +1486,13 @@ Function* Executor::getTargetFunction(Value *calledVal, ExecutionState &state) { while (true) { if (GlobalValue *gv = dyn_cast<GlobalValue>(c)) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) + if (!Visited.insert(gv).second) + return 0; +#else if (!Visited.insert(gv)) return 0; - +#endif std::string alias = state.getFnAlias(gv->getName()); if (alias != "") { llvm::Module* currModule = kmodule->module; @@ -3080,8 +3091,16 @@ void Executor::callExternalFunction(ExecutionState &state, else klee_warning_once(function, "%s", os.str().c_str()); } - +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) + // MCJIT needs unique module, so we create quick external dispatcher for call. + // reference: + // http://blog.llvm.org/2013/07/using-mcjit-with-kaleidoscope-tutorial.html + ExternalDispatcher *e = new ExternalDispatcher(function->getContext()); + bool success = e->executeCall(function, target->inst, args); + delete e; +#else bool success = externalDispatcher->executeCall(function, target->inst, args); +#endif if (!success) { terminateStateOnError(state, "failed external call: " + function->getName(), External); |