2017-02-22 12:32:55 +00:00
committed by Git OBS Bridge
parent e32e7e3e7c
commit 3998dbd8c4
12 changed files with 277 additions and 484 deletions

View File

@@ -5,24 +5,27 @@ Patch-mainline: no
Based on work by @ccadeptic23 and @delcypher.
Formatting fixed by @snf.
Fix compiler warning by @martijnthe.
Further fixes by @mchalupa.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
Makefile.rules | 10 +-
lib/Core/Executor.cpp | 24 +++-
lib/Core/Executor.cpp | 43 ++++++--
lib/Core/ExternalDispatcher.cpp | 34 ++++--
lib/Core/ExternalDispatcher.h | 8 +-
lib/Core/StatsTracker.cpp | 10 +-
lib/Core/StatsTracker.cpp | 11 +-
lib/Module/KModule.cpp | 27 +++--
lib/Module/ModuleUtil.cpp | 228 ++++++++++++++++++++++++++++----------
lib/Module/ModuleUtil.cpp | 225 +++++++++++++++++++++++++++-----------
lib/Module/Optimize.cpp | 17 ++-
lib/Module/RaiseAsm.cpp | 17 ++-
lib/Solver/QueryLoggingSolver.cpp | 5 +-
lib/Solver/QueryLoggingSolver.h | 3 +
lib/Support/CompressionStream.cpp | 19 +++-
test/lit.cfg | 2 +-
tools/klee/Makefile | 10 +-
tools/klee/main.cpp | 31 +++++-
14 files changed, 318 insertions(+), 108 deletions(-)
15 files changed, 341 insertions(+), 121 deletions(-)
diff --git a/Makefile.rules b/Makefile.rules
index d74b1c42b4aa..06cbbec683f2 100644
@@ -54,10 +57,63 @@ index d74b1c42b4aa..06cbbec683f2 100644
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index c369b864bc49..55a29230f36a 100644
index 58603e7ca146..80b8289d1486 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -1464,9 +1464,13 @@ Function* Executor::getTargetFunction(Value *calledVal, ExecutionState &state) {
@@ -82,6 +82,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FileSystem.h"
#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
#include "llvm/Support/CallSite.h"
@@ -93,6 +94,10 @@
#include "klee/Internal/Support/CompressionStream.h"
#endif
+#if LLVM_VERSION_CODE > LLVM_VERSION(3, 5)
+#include <system_error>
+#endif
+
#include <cassert>
#include <algorithm>
#include <iomanip>
@@ -376,12 +381,19 @@ Executor::Executor(const InterpreterOptions &opts, InterpreterHandler *ih)
optionIsSet(DebugPrintInstructions, FILE_SRC)) {
std::string debug_file_name =
interpreterHandler->getOutputFilename("instructions.txt");
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ std::error_code EC;
+#endif
std::string ErrorInfo;
+
#ifdef HAVE_ZLIB_H
if (!DebugCompressInstructions) {
#endif
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ debugInstFile = new llvm::raw_fd_ostream(debug_file_name.c_str(), EC,
+ llvm::sys::fs::OpenFlags::F_Text);
+#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
@@ -394,7 +406,12 @@ Executor::Executor(const InterpreterOptions &opts, InterpreterHandler *ih)
(debug_file_name + ".gz").c_str(), ErrorInfo);
}
#endif
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ if (EC) {
+ ErrorInfo = EC.message();
+#else
if (ErrorInfo != "") {
+#endif
klee_error("Could not open file %s : %s", debug_file_name.c_str(),
ErrorInfo.c_str());
}
@@ -1471,9 +1488,13 @@ Function* Executor::getTargetFunction(Value *calledVal, ExecutionState &state) {
while (true) {
if (GlobalValue *gv = dyn_cast<GlobalValue>(c)) {
@@ -72,7 +128,7 @@ index c369b864bc49..55a29230f36a 100644
std::string alias = state.getFnAlias(gv->getName());
if (alias != "") {
llvm::Module* currModule = kmodule->module;
@@ -1477,7 +1481,7 @@ Function* Executor::getTargetFunction(Value *calledVal, ExecutionState &state) {
@@ -1484,7 +1505,7 @@ Function* Executor::getTargetFunction(Value *calledVal, ExecutionState &state) {
old_gv->getName().str().c_str());
}
}
@@ -81,7 +137,7 @@ index c369b864bc49..55a29230f36a 100644
if (Function *f = dyn_cast<Function>(gv))
return f;
else if (GlobalAlias *ga = dyn_cast<GlobalAlias>(gv))
@@ -1639,8 +1643,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
@@ -1646,8 +1667,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(cond)) {
// Somewhat gross to create these all the time, but fine till we
// switch to an internal rep.
@@ -92,7 +148,7 @@ index c369b864bc49..55a29230f36a 100644
ConstantInt *ci = ConstantInt::get(Ty, CE->getZExtValue());
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
unsigned index = si->findCaseValue(ci).getSuccessorIndex();
@@ -1696,7 +1700,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
@@ -1703,7 +1724,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
bool result;
bool success = solver->mayBeTrue(state, match, result);
assert(success && "FIXME: Unhandled solver failure");
@@ -101,7 +157,7 @@ index c369b864bc49..55a29230f36a 100644
if (result) {
BasicBlock *caseSuccessor = it->second;
@@ -3065,8 +3069,16 @@ void Executor::callExternalFunction(ExecutionState &state,
@@ -3072,8 +3093,16 @@ void Executor::callExternalFunction(ExecutionState &state,
else
klee_warning_once(function, "%s", os.str().c_str());
}
@@ -233,21 +289,23 @@ index d8d9dc58b089..e2fb63cd12b4 100644
llvm::ExecutionEngine *executionEngine;
std::map<std::string, void*> preboundFunctions;
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index 97ed26eaaa47..5a4e3b4f58ea 100644
index dbd865248756..ded85f950fe4 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -206,12 +206,14 @@ StatsTracker::StatsTracker(Executor &_executor, std::string _objectFilename,
@@ -206,13 +206,16 @@ StatsTracker::StatsTracker(Executor &_executor, std::string _objectFilename,
if (!sys::path::is_absolute(objectFilename)) {
SmallString<128> current(objectFilename);
if(sys::fs::make_absolute(current)) {
bool exists = false;
-
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ Twine current_twine(current.str()); // requires a twine for this. so silly
+ if (!sys::fs::exists(current_twine)) {
+#elif LLVM_VERSION_CODE == LLVM_VERSION(3, 5)
+ bool exists = false;
+ if (!sys::fs::exists(current.str(), exists)) {
+#elif LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
bool exists = false;
-
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
error_code ec = sys::fs::exists(current.str(), exists);
if (ec == errc::success && exists) {
-#else
@@ -308,10 +366,10 @@ index 57346a315a1b..598c439f9da0 100644
} else {
assert(isa<Constant>(v));
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index a5394067ffea..ab2defcb3293 100644
index 2cd41c891181..537c9aba4b6f 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -212,15 +212,35 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
@@ -212,78 +212,101 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Loading modules\n");
// Load all bitcode files in to memory so we can examine their symbols
@@ -327,48 +385,39 @@ index a5394067ffea..ab2defcb3293 100644
+ AI != AE; ++AI)
+#endif
{
-
StringRef memberName;
- error_code ec = AI->getName(memberName);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+ std::error_code ec;
+ ErrorOr<StringRef> errorOr_memberName = AI->getName(); // as per
+ // http://llvm.org/docs/doxygen/html/classllvm_1_1ErrorOr.html#details
+ bool memname_success = true; // maybe a better way but this works to
+ // recreate functionality of llvm<3.6
+ if ((ec = errorOr_memberName.getError()))
+ memname_success = false;
+ else
+ ErrorOr<StringRef> errorOr_memberName = AI->getName();
+ std::error_code ec = errorOr_memberName.getError();
+ if (!ec)
+ memberName = errorOr_memberName.get();
+#else
error_code ec = AI->getName(memberName);
-
- if ( ec == errc::success )
- {
+#else
+ error_code ec = AI->getName(memberName);
+ bool memname_success = (ec == errc::success);
+#endif
+ if (memname_success) {
+ if (!ec) {
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Loading archive member " << memberName << "\n");
}
else
@@ -228,62 +248,83 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
- }
- else
- {
+ } else {
errorMessage="Archive member does not have a name!\n";
return false;
}
-
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+ ErrorOr<std::unique_ptr<llvm::object::Binary> > child = AI->getAsBinary();
+ bool getAsBin_success = true;
+ if ((ec = child.getError()))
+ getAsBin_success = false;
+ ec = child.getError();
+#else
OwningPtr<object::Binary> child;
ec = AI->getAsBinary(child);
- if (ec != object::object_error::success)
- {
+ bool getAsBin_success = (ec == object::object_error::success);
+#endif
+ if (!getAsBin_success) {
+ if (ec) {
// If we can't open as a binary object file its hopefully a bitcode file
-
- OwningPtr<MemoryBuffer> buff; // Once this is destroyed will Module still be valid??
@@ -379,45 +428,25 @@ index a5394067ffea..ab2defcb3293 100644
- SS << "Failed to get MemoryBuffer: " <<ec.message();
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ ErrorOr<MemoryBufferRef> buff = AI->getMemoryBufferRef();
+ bool getMemBuff_success = true;
+ if ((ec = buff.getError()))
+ getMemBuff_success = false;
+ ec = buff.getError();
+#elif LLVM_VERSION_CODE == LLVM_VERSION(3, 5)
+ ErrorOr<std::unique_ptr<MemoryBuffer> > errorOr_buff =
+ AI->getMemoryBuffer();
+ std::unique_ptr<MemoryBuffer> buff = nullptr;
+ bool getMemBuff_success = true;
+ if ((ec = errorOr_buff.getError()))
+ getMemBuff_success = false;
+ else
+ ec = errorOr_buff.getError();
+ if (!ec)
+ buff = std::move(errorOr_buff.get());
+#else
+ OwningPtr<MemoryBuffer> buff; // Once this is destroyed will Module still
+ // be valid??
+ bool getMemBuff_success = !(ec = AI->getMemoryBuffer(buff));
+ ec = AI->getMemoryBuffer(buff);
+#endif
+ if (!getMemBuff_success) {
+ if (ec) {
+ SS << "Failed to get MemoryBuffer: " << ec.message();
SS.flush();
return false;
}
+ if (buff) {
+ Module *Result = 0;
+// FIXME: Maybe load bitcode file lazily? Then if we need to link, materialise
+// the module
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+ bool parseFile_success = true;
+ ErrorOr<Module *> Result_error =
+ parseBitcodeFile(buff.get(), getGlobalContext());
+ if ((ec = Result_error.getError()))
+ parseFile_success = false;
+ Result = Result_error.get();
+#else
+ Result =
+ ParseBitcodeFile(buff.get(), getGlobalContext(), &errorMessage);
+ bool parseFile_success = (Result);
+#endif
-
- if (buff)
- {
- // FIXME: Maybe load bitcode file lazily? Then if we need to link, materialise the module
@@ -425,7 +454,23 @@ index a5394067ffea..ab2defcb3293 100644
-
- if(!Result)
- {
+ if (!parseFile_success) {
+ if (buff) {
+ Module *Result = 0;
+// FIXME: Maybe load bitcode file lazily? Then if we need to link, materialise
+// the module
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+ ErrorOr<Module *> Result_error =
+ parseBitcodeFile(buff.get(), getGlobalContext());
+ ec = Result_error.getError();
+ if (ec)
+ errorMessage = ec.message();
+ else
+ Result = Result_error.get();
+#else
+ Result =
+ ParseBitcodeFile(buff.get(), getGlobalContext(), &errorMessage);
+#endif
+ if (!Result) {
SS << "Loading module failed : " << errorMessage << "\n";
SS.flush();
return false;
@@ -468,7 +513,7 @@ index a5394067ffea..ab2defcb3293 100644
std::set<std::string> previouslyUndefinedSymbols;
// Walk through the modules looking for definitions of undefined symbols
@@ -315,9 +356,12 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
@@ -315,9 +338,12 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Found " << GV->getName() <<
" in " << M->getModuleIdentifier() << "\n");
@@ -484,7 +529,17 @@ index a5394067ffea..ab2defcb3293 100644
{
// Linking failed
SS << "Linking archive module with composite failed:" << errorMessage;
@@ -369,11 +413,84 @@ Module *klee::linkWithLibrary(Module *module,
@@ -358,8 +384,7 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
return true;
}
-#endif
-
+#endif // LLVM 3.3+
Module *klee::linkWithLibrary(Module *module,
const std::string &libraryName) {
@@ -369,11 +394,84 @@ Module *klee::linkWithLibrary(Module *module,
klee_error("Link with library %s failed. No such file.",
libraryName.c_str());
}
@@ -497,23 +552,23 @@ index a5394067ffea..ab2defcb3293 100644
+ klee_error("Link with library %s failed: %s", libraryName.c_str(),
+ ec.message().c_str());
+ }
+
+ sys::fs::file_magic magic =
+ sys::fs::identify_magic(Buffer.get()->getBuffer());
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ MemoryBufferRef buff = Buffer.get()->getMemBufferRef();
+#else
+#else // LLVM 3.5
+ MemoryBuffer *buff = Buffer->get();
+#endif
+ LLVMContext &Context = getGlobalContext();
+ std::string ErrorMessage;
+
+ if (magic == sys::fs::file_magic::bitcode) {
+
+ ErrorOr<Module *> Result = parseBitcodeFile(buff, Context);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ if ((ec = Buffer.getError()) || Linker::LinkModules(module, Result.get()))
+#else
+#else // LLVM 3.5
+ if ((ec = Buffer.getError()) ||
+ Linker::LinkModules(module, Result.get(), Linker::DestroySource,
+ &ErrorMessage))
@@ -527,7 +582,7 @@ index a5394067ffea..ab2defcb3293 100644
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ ErrorOr<std::unique_ptr<object::Binary> > arch =
+ object::createBinary(buff, &Context);
+#else
+#else // LLVM 3.5
+ ErrorOr<object::Binary *> arch =
+ object::createBinary(std::move(Buffer.get()), &Context);
+#endif
@@ -536,7 +591,7 @@ index a5394067ffea..ab2defcb3293 100644
+ arch.getError().message().c_str());
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ if (object::Archive *a = dyn_cast<object::Archive>(arch->get())) {
+#else
+#else // LLVM 3.5
+ if (object::Archive *a = dyn_cast<object::Archive>(arch.get())) {
+#endif
+ // Handle in helper
@@ -571,7 +626,7 @@ index a5394067ffea..ab2defcb3293 100644
}
sys::fs::file_magic magic = sys::fs::identify_magic(Buffer->getBuffer());
@@ -385,40 +502,39 @@ Module *klee::linkWithLibrary(Module *module,
@@ -385,53 +483,52 @@ Module *klee::linkWithLibrary(Module *module,
Module *Result = 0;
Result = ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage);
@@ -623,7 +678,9 @@ index a5394067ffea..ab2defcb3293 100644
}
return module;
@@ -427,11 +543,11 @@ Module *klee::linkWithLibrary(Module *module,
-#else
+#else // LLVM 3.2-
Linker linker("klee", module, false);
llvm::sys::Path libraryPath(libraryName);
bool native = false;
@@ -738,8 +795,53 @@ index 7ac783d1211c..ba185aa10863 100644
// @brief Buffer used by logBuffer
std::string BufferString;
// @brief buffer to store logs before flushing to file
diff --git a/lib/Support/CompressionStream.cpp b/lib/Support/CompressionStream.cpp
index eb208edfa395..58193c9a98a2 100644
--- a/lib/Support/CompressionStream.cpp
+++ b/lib/Support/CompressionStream.cpp
@@ -10,9 +10,11 @@
#include "klee/Config/Version.h"
#ifdef HAVE_ZLIB_H
#include "klee/Internal/Support/CompressionStream.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
+#if (LLVM_VERSION_CODE >= LLVM_VERSION(3, 3) \
+ && LLVM_VERSION_CODE <= LLVM_VERSION(3, 4))
#include "llvm/Support/system_error.h"
#else
+#include "llvm/Support/FileSystem.h"
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
@@ -25,10 +27,19 @@ compressed_fd_ostream::compressed_fd_ostream(const char *Filename,
std::string &ErrorInfo)
: llvm::raw_ostream(), pos(0) {
ErrorInfo = "";
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
// Open file in binary mode
+#if LLVM_VERSION_CODE == LLVM_VERSION(3, 4)
llvm::error_code EC =
- llvm::sys::fs::openFileForWrite(Filename, FD, llvm::sys::fs::F_Binary);
+#else
+ std::error_code EC =
+#endif
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
+ llvm::sys::fs::openFileForWrite(Filename, FD,
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+ llvm::sys::fs::F_None);
+#else
+ llvm::sys::fs::F_Binary);
+#endif
if (EC) {
ErrorInfo = EC.message();
@@ -116,4 +127,4 @@ void compressed_fd_ostream::write_file(const char *Ptr, size_t Size) {
} while (Size > 0);
}
}
-#endif
+#endif // HAVE_ZLIB_H
diff --git a/test/lit.cfg b/test/lit.cfg
index 31552882c55e..093c96df84be 100644
index 31552882c55e..6ce6dc955847 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -130,7 +130,7 @@ if int(config.llvm_version_major) == 2:
@@ -747,7 +849,7 @@ index 31552882c55e..093c96df84be 100644
# Add feature for the LLVM version in use, so it can be tested in REQUIRES and
# XFAIL checks. We also add "not-XXX" variants, for the same reason.
-known_llvm_versions = set(["2.9", "3.4", "3.5"])
+known_llvm_versions = set(["2.9", "3.4", "3.5","3.6"])
+known_llvm_versions = set(["2.9", "3.4", "3.5", "3.6"])
current_llvm_version = "%s.%s" % (config.llvm_version_major,
config.llvm_version_minor)
config.available_features.add("llvm-" + current_llvm_version)

View File

@@ -1,33 +0,0 @@
From: =?UTF-8?q?Martijn=20Th=C3=A9?= <martijn@pebble.com>
Date: Fri, 31 Jul 2015 13:42:15 +0200
Subject: Fix compiler warning
Patch-mainline: no
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
lib/Core/StatsTracker.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index 5a4e3b4f58ea..b1851bbae545 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -205,13 +205,14 @@ StatsTracker::StatsTracker(Executor &_executor, std::string _objectFilename,
if (!sys::path::is_absolute(objectFilename)) {
SmallString<128> current(objectFilename);
if(sys::fs::make_absolute(current)) {
- bool exists = false;
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
Twine current_twine(current.str()); // requires a twine for this. so silly
if (!sys::fs::exists(current_twine)) {
#elif LLVM_VERSION_CODE == LLVM_VERSION(3, 5)
+ bool exists = false;
if (!sys::fs::exists(current.str(), exists)) {
#elif LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
+ bool exists = false;
error_code ec = sys::fs::exists(current.str(), exists);
if (ec == errc::success && exists) {
#endif
--
2.11.1

View File

@@ -79,16 +79,17 @@ index 09dd715a53ae..fa29f6e3047c 100644
Instruction *argp = new BitCastInst(argI64p, PointerType::getUnqual(argTy),
"", dBB);
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index b1851bbae545..5c21b5eaeeef 100644
index ded85f950fe4..ae12708c130c 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -167,7 +167,8 @@ static bool instructionIsCoverable(Instruction *i) {
@@ -167,8 +167,9 @@ static bool instructionIsCoverable(Instruction *i) {
} else {
Instruction *prev = --it;
if (isa<CallInst>(prev) || isa<InvokeInst>(prev)) {
- Function *target = getDirectCallTarget(prev);
+ CallSite cs(prev);
+ Function *target = getDirectCallTarget(cs);
Function *target =
- getDirectCallTarget(prev, /*moduleIsFullyLinked=*/true);
+ getDirectCallTarget(cs, /*moduleIsFullyLinked=*/true);
if (target && target->doesNotReturn())
return false;
}
@@ -193,7 +194,7 @@ index 598c439f9da0..cc328b1bb974 100644
switch(SwitchType) {
case eSwitchTypeInternal: break;
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index 83e7260ce250..c2f06e484c31 100644
index 537c9aba4b6f..2aa9b8e6b0ab 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -272,14 +272,22 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er

View File

@@ -7,48 +7,48 @@ Mainly explicit casts from pointers to iterators and back.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
lib/Core/Executor.cpp | 47 +++++++++++++++++++------
lib/Core/StatsTracker.cpp | 68 ++++++++++++++++++++++++++++---------
lib/Core/Executor.cpp | 47 ++++++++++++++++++++------
lib/Core/StatsTracker.cpp | 66 +++++++++++++++++++++++++++---------
lib/Module/Checks.cpp | 34 +++++++++++--------
lib/Module/InstructionInfoTable.cpp | 15 ++++++--
lib/Module/InstructionInfoTable.cpp | 15 +++++++--
lib/Module/IntrinsicCleaner.cpp | 12 +++++--
lib/Module/KModule.cpp | 67 ++++++++++++++++++++++++++----------
lib/Module/LowerSwitch.cpp | 15 +++++++-
lib/Module/KModule.cpp | 67 +++++++++++++++++++++++++++----------
lib/Module/LowerSwitch.cpp | 15 ++++++++-
lib/Module/ModuleUtil.cpp | 65 ++++++++++++++++++++++++-----------
lib/Module/Optimize.cpp | 13 ++++++-
lib/Module/RaiseAsm.cpp | 4 +++
tools/klee/main.cpp | 32 ++++++++++++++---
11 files changed, 283 insertions(+), 89 deletions(-)
tools/klee/main.cpp | 32 +++++++++++++++---
11 files changed, 282 insertions(+), 88 deletions(-)
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 55a29230f36a..93e1ff75493b 100644
index 80b8289d1486..b3ec990dc9ae 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -530,7 +530,11 @@ void Executor::initializeGlobals(ExecutionState &state) {
@@ -554,7 +554,11 @@ void Executor::initializeGlobals(ExecutionState &state) {
// ensures that we won't conflict. we don't need to allocate a memory object
// since reading/writing via a function pointer is unsupported anyway.
for (Module::iterator i = m->begin(), ie = m->end(); i != ie; ++i) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto f = static_cast<Function *>(i);
+ Function *f = static_cast<Function *>(i);
+#else
Function *f = i;
+#endif
ref<ConstantExpr> addr(0);
// If the symbol has external weak linkage then it is implicitly
@@ -584,6 +588,11 @@ void Executor::initializeGlobals(ExecutionState &state) {
@@ -608,6 +612,11 @@ void Executor::initializeGlobals(ExecutionState &state) {
for (Module::const_global_iterator i = m->global_begin(),
e = m->global_end();
i != e; ++i) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto v = static_cast<const GlobalVariable *>(i);
+ const GlobalVariable *v = static_cast<const GlobalVariable *>(i);
+#else
+ const GlobalVariable *v = i;
+#endif
if (i->isDeclaration()) {
// FIXME: We have no general way of handling unknown external
// symbols. If we really cared about making external stuff work
@@ -614,11 +623,10 @@ void Executor::initializeGlobals(ExecutionState &state) {
@@ -638,11 +647,10 @@ void Executor::initializeGlobals(ExecutionState &state) {
klee_warning("Unable to find size for global variable: %.*s (use will result in out of bounds access)",
(int)i->getName().size(), i->getName().data());
}
@@ -63,7 +63,7 @@ index 55a29230f36a..93e1ff75493b 100644
// Program already running = object already initialized. Read
// concrete value and write it to our copy.
@@ -643,8 +651,8 @@ void Executor::initializeGlobals(ExecutionState &state) {
@@ -667,8 +675,8 @@ void Executor::initializeGlobals(ExecutionState &state) {
if (!mo)
llvm::report_fatal_error("out of memory");
ObjectState *os = bindObjectInState(state, mo, false);
@@ -74,7 +74,7 @@ index 55a29230f36a..93e1ff75493b 100644
if (!i->hasInitializer())
os->initializeToRandom();
@@ -655,8 +663,13 @@ void Executor::initializeGlobals(ExecutionState &state) {
@@ -679,8 +687,13 @@ void Executor::initializeGlobals(ExecutionState &state) {
for (Module::alias_iterator i = m->alias_begin(), ie = m->alias_end();
i != ie; ++i) {
// Map the alias to its aliasee's address. This works because we have
@@ -89,7 +89,7 @@ index 55a29230f36a..93e1ff75493b 100644
}
// once all objects are allocated, do the actual initialization
@@ -664,7 +677,12 @@ void Executor::initializeGlobals(ExecutionState &state) {
@@ -688,7 +701,12 @@ void Executor::initializeGlobals(ExecutionState &state) {
e = m->global_end();
i != e; ++i) {
if (i->hasInitializer()) {
@@ -102,7 +102,7 @@ index 55a29230f36a..93e1ff75493b 100644
const ObjectState *os = state.addressSpace.findObject(mo);
assert(os);
ObjectState *wos = state.addressSpace.getWriteable(mo, os);
@@ -2279,8 +2297,13 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
@@ -2303,8 +2321,13 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
return terminateStateOnExecError(state, "Unsupported FRem operation");
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
llvm::APFloat Res(*fpWidthToSemantics(left->getWidth()), left->getAPValue());
@@ -116,25 +116,25 @@ index 55a29230f36a..93e1ff75493b 100644
#else
llvm::APFloat Res(left->getAPValue());
Res.mod(APFloat(right->getAPValue()), APFloat::rmNearestTiesToEven);
@@ -3539,9 +3562,13 @@ void Executor::runFunctionAsMain(Function *f,
@@ -3563,9 +3586,13 @@ void Executor::runFunctionAsMain(Function *f,
arguments.push_back(ConstantExpr::alloc(argc, Expr::Int32));
if (++ai!=ae) {
- argvMO = memory->allocate((argc+1+envc+1+1) * NumPtrBytes, false, true,
- f->begin()->begin());
-
+ argvMO =
+ memory->allocate((argc + 1 + envc + 1 + 1) * NumPtrBytes, false, true,
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ static_cast<Instruction *>(f->begin()->begin()));
+ Instruction *first = static_cast<Instruction *>(f->begin()->begin());
+#else
+ f->begin()->begin());
+ Instruction *first = f->begin()->begin();
+#endif
+ argvMO = memory->allocate((argc + 1 + envc + 1 + 1) * NumPtrBytes, false,
+ true, first);
if (!argvMO)
klee_error("Could not allocate memory for function arguments");
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index 5c21b5eaeeef..31607105242c 100644
index ae12708c130c..fff266aca19b 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -162,10 +162,14 @@ static bool instructionIsCoverable(Instruction *i) {
@@ -146,20 +146,20 @@ index 5c21b5eaeeef..31607105242c 100644
return true;
} else {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto prev = static_cast<Instruction *>(--it);
+ Instruction *prev = static_cast<Instruction *>(--it);
+#else
Instruction *prev = --it;
+#endif
if (isa<CallInst>(prev) || isa<InvokeInst>(prev)) {
CallSite cs(prev);
Function *target = getDirectCallTarget(cs);
@@ -542,7 +546,12 @@ void StatsTracker::writeIStats() {
Function *target =
@@ -543,7 +547,12 @@ void StatsTracker::writeIStats() {
// Always try to write the filename before the function name, as otherwise
// KCachegrind can create two entries for the function, one with an
// unnamed file and one without.
- const InstructionInfo &ii = executor.kmodule->infos->getFunctionInfo(fnIt);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto fn = static_cast<Function *>(fnIt);
+ Function *fn = static_cast<Function *>(fnIt);
+#else
+ Function *fn = fnIt;
+#endif
@@ -167,7 +167,7 @@ index 5c21b5eaeeef..31607105242c 100644
if (ii.file != sourceFile) {
of << "fl=" << ii.file << "\n";
sourceFile = ii.file;
@@ -638,9 +647,17 @@ static std::vector<Instruction*> getSuccs(Instruction *i) {
@@ -639,9 +648,17 @@ static std::vector<Instruction*> getSuccs(Instruction *i) {
if (i==bb->getTerminator()) {
for (succ_iterator it = succ_begin(bb), ie = succ_end(bb); it != ie; ++it)
@@ -185,12 +185,12 @@ index 5c21b5eaeeef..31607105242c 100644
}
return res;
@@ -687,19 +704,23 @@ void StatsTracker::computeReachableUncovered() {
@@ -688,20 +705,24 @@ void StatsTracker::computeReachableUncovered() {
bbIt != bb_ie; ++bbIt) {
for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end();
it != ie; ++it) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto inst = static_cast<Instruction *>(it);
+ Instruction *inst = static_cast<Instruction *>(it);
+#else
+ Instruction *inst = it;
+#endif
@@ -201,10 +201,10 @@ index 5c21b5eaeeef..31607105242c 100644
// We can never call through here so assume no targets
// (which should be correct anyhow).
- callTargets.insert(std::make_pair(it,
- std::vector<Function*>()));
+ callTargets.insert(
+ std::make_pair(inst, std::vector<Function *>()));
} else if (Function *target = getDirectCallTarget(cs)) {
+ callTargets.insert(std::make_pair(inst,
std::vector<Function*>()));
} else if (Function *target = getDirectCallTarget(
cs, /*moduleIsFullyLinked=*/true)) {
- callTargets[it].push_back(target);
+ callTargets[inst].push_back(target);
} else {
@@ -216,12 +216,12 @@ index 5c21b5eaeeef..31607105242c 100644
}
}
}
@@ -718,14 +739,19 @@ void StatsTracker::computeReachableUncovered() {
@@ -720,14 +741,19 @@ void StatsTracker::computeReachableUncovered() {
std::vector<Instruction *> instructions;
for (Module::iterator fnIt = m->begin(), fn_ie = m->end();
fnIt != fn_ie; ++fnIt) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto fn = static_cast<Function *>(fnIt);
+ Function *fn = static_cast<Function *>(fnIt);
+#else
+ Function *fn = fnIt;
+#endif
@@ -239,14 +239,14 @@ index 5c21b5eaeeef..31607105242c 100644
}
// Not sure if I should bother to preorder here. XXX I should.
@@ -733,8 +759,13 @@ void StatsTracker::computeReachableUncovered() {
@@ -735,8 +761,13 @@ void StatsTracker::computeReachableUncovered() {
bbIt != bb_ie; ++bbIt) {
for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end();
it != ie; ++it) {
- instructions.push_back(it);
- unsigned id = infos.getInfo(it).id;
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto inst = static_cast<Instruction *>(it);
+ Instruction *inst = static_cast<Instruction *>(it);
+#else
+ Instruction *inst = it;
+#endif
@@ -255,14 +255,14 @@ index 5c21b5eaeeef..31607105242c 100644
sm.setIndexedValue(stats::minDistToReturn,
id,
isa<ReturnInst>(it)
@@ -815,8 +846,13 @@ void StatsTracker::computeReachableUncovered() {
@@ -817,8 +848,13 @@ void StatsTracker::computeReachableUncovered() {
bbIt != bb_ie; ++bbIt) {
for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end();
it != ie; ++it) {
- unsigned id = infos.getInfo(it).id;
- instructions.push_back(&*it);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto inst = static_cast<Instruction *>(it);
+ Instruction *inst = static_cast<Instruction *>(it);
+#else
+ Instruction *inst = it;
+#endif
@@ -324,7 +324,7 @@ index 7d9b72841753..2a1681f3a7c5 100644
diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp
index 53c64878391f..d2d312da8540 100644
index 53c64878391f..52238786f49e 100644
--- a/lib/Module/InstructionInfoTable.cpp
+++ b/lib/Module/InstructionInfoTable.cpp
@@ -134,7 +134,12 @@ InstructionInfoTable::InstructionInfoTable(Module *m)
@@ -333,7 +333,7 @@ index 53c64878391f..d2d312da8540 100644
unsigned initialLine = 0;
- for (inst_iterator it = inst_begin(fnIt), ie = inst_end(fnIt); it != ie;
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto fn = static_cast<Function *>(fnIt);
+ Function *fn = static_cast<Function *>(fnIt);
+#else
+ Function *fn = fnIt;
+#endif
@@ -396,7 +396,7 @@ index 66e9392a618d..8ec47195dd3b 100644
Value *op2 = ii->getArgOperand(1);
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index cc328b1bb974..1ceedab508b3 100644
index cc328b1bb974..75e92804c91d 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -120,12 +120,15 @@ KModule::~KModule() {
@@ -426,11 +426,11 @@ index cc328b1bb974..1ceedab508b3 100644
- CallInst::Create(getStubFunctionForCtorList(m, ctors, "klee.ctor_stub"),
- "", mainFn->begin()->begin());
+ CallInst::Create(getStubFunctionForCtorList(m, ctors, "klee.ctor_stub"),
+ "",
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ "",
+ static_cast<Instruction *>(mainFn->begin()->begin()));
+#else
+ "", mainFn->begin()->begin());
+ mainFn->begin()->begin());
+#endif
+
if (dtors) {
@@ -452,7 +452,7 @@ index cc328b1bb974..1ceedab508b3 100644
bbit != bbie; ++bbit) {
- if (&*bbit != exit) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto bb = static_cast<BasicBlock *>(bbit);
+ BasicBlock *bb = static_cast<BasicBlock *>(bbit);
+#else
+ BasicBlock *bb = bbit;
+#endif
@@ -476,7 +476,7 @@ index cc328b1bb974..1ceedab508b3 100644
- KFunction *kf = new KFunction(it, this);
-
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto fn = static_cast<Function *>(it);
+ Function *fn = static_cast<Function *>(it);
+#else
+ Function *fn = it;
+#endif
@@ -498,7 +498,7 @@ index cc328b1bb974..1ceedab508b3 100644
for (llvm::Function::iterator bbit = function->begin(),
bbie = function->end(); bbit != bbie; ++bbit) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto bb = static_cast<BasicBlock *>(bbit);
+ BasicBlock *bb = static_cast<BasicBlock *>(bbit);
+#else
BasicBlock *bb = bbit;
+#endif
@@ -525,7 +525,7 @@ index cc328b1bb974..1ceedab508b3 100644
- ki->inst = it;
- ki->dest = registerMap[it];
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto inst = static_cast<Instruction *>(it);
+ Instruction *inst = static_cast<Instruction *>(it);
+#else
+ Instruction *inst = it;
+#endif
@@ -539,7 +539,7 @@ index cc328b1bb974..1ceedab508b3 100644
ki->operands = new int[numArgs+1];
ki->operands[0] = getOperandNum(cs.getCalledValue(), registerMap, km,
diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp
index a98b84add5d7..0ad67797f21e 100644
index a98b84add5d7..7cdd5fba2bf8 100644
--- a/lib/Module/LowerSwitch.cpp
+++ b/lib/Module/LowerSwitch.cpp
@@ -44,7 +44,12 @@ bool LowerSwitchPass::runOnFunction(Function &F) {
@@ -548,7 +548,7 @@ index a98b84add5d7..0ad67797f21e 100644
for (Function::iterator I = F.begin(), E = F.end(); I != E; ) {
- BasicBlock *cur = I++; // Advance over block so we don't traverse new blocks
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto *cur = static_cast<BasicBlock *>(I);
+ BasicBlock *cur = static_cast<BasicBlock *>(I);
+#else
+ BasicBlock *cur = I;
+#endif
@@ -581,7 +581,7 @@ index a98b84add5d7..0ad67797f21e 100644
// If there is an entry in any PHI nodes for the default edge, make sure
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index c2f06e484c31..f9b84fd823f0 100644
index 2aa9b8e6b0ab..1e62498dc845 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -217,42 +217,59 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er

View File

@@ -1,174 +0,0 @@
From: =?UTF-8?q?Richard=20Trembeck=C3=BD?= <richardt@centrum.sk>
Date: Mon, 2 May 2016 01:08:53 +0200
Subject: Cleanup - removed unneccessary bools
Patch-mainline: no
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
lib/Module/ModuleUtil.cpp | 67 +++++++++++++++++------------------------------
1 file changed, 24 insertions(+), 43 deletions(-)
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index ab2defcb3293..83e7260ce250 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -223,63 +223,46 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
AI != AE; ++AI)
#endif
{
-
StringRef memberName;
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- std::error_code ec;
- ErrorOr<StringRef> errorOr_memberName = AI->getName(); // as per
- // http://llvm.org/docs/doxygen/html/classllvm_1_1ErrorOr.html#details
- bool memname_success = true; // maybe a better way but this works to
- // recreate functionality of llvm<3.6
- if ((ec = errorOr_memberName.getError()))
- memname_success = false;
- else
+ ErrorOr<StringRef> errorOr_memberName = AI->getName();
+ std::error_code ec = errorOr_memberName.getError();
+ if (!ec)
memberName = errorOr_memberName.get();
-
#else
error_code ec = AI->getName(memberName);
- bool memname_success = (ec == errc::success);
#endif
- if (memname_success) {
+ if (!ec) {
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Loading archive member " << memberName << "\n");
- }
- else
- {
+ } else {
errorMessage="Archive member does not have a name!\n";
return false;
}
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
ErrorOr<std::unique_ptr<llvm::object::Binary> > child = AI->getAsBinary();
- bool getAsBin_success = true;
- if ((ec = child.getError()))
- getAsBin_success = false;
+ ec = child.getError();
#else
OwningPtr<object::Binary> child;
ec = AI->getAsBinary(child);
- bool getAsBin_success = (ec == object::object_error::success);
#endif
- if (!getAsBin_success) {
+ if (ec) {
// If we can't open as a binary object file its hopefully a bitcode file
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
ErrorOr<MemoryBufferRef> buff = AI->getMemoryBufferRef();
- bool getMemBuff_success = true;
- if ((ec = buff.getError()))
- getMemBuff_success = false;
+ ec = buff.getError();
#elif LLVM_VERSION_CODE == LLVM_VERSION(3, 5)
ErrorOr<std::unique_ptr<MemoryBuffer> > errorOr_buff =
AI->getMemoryBuffer();
std::unique_ptr<MemoryBuffer> buff = nullptr;
- bool getMemBuff_success = true;
- if ((ec = errorOr_buff.getError()))
- getMemBuff_success = false;
- else
+ ec = errorOr_buff.getError();
+ if (!ec)
buff = std::move(errorOr_buff.get());
#else
OwningPtr<MemoryBuffer> buff; // Once this is destroyed will Module still
// be valid??
- bool getMemBuff_success = !(ec = AI->getMemoryBuffer(buff));
+ ec = AI->getMemoryBuffer(buff);
#endif
- if (!getMemBuff_success) {
+ if (ec) {
SS << "Failed to get MemoryBuffer: " << ec.message();
SS.flush();
return false;
@@ -289,19 +272,18 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
// FIXME: Maybe load bitcode file lazily? Then if we need to link, materialise
// the module
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- bool parseFile_success = true;
ErrorOr<Module *> Result_error =
parseBitcodeFile(buff.get(), getGlobalContext());
- if ((ec = Result_error.getError()))
- parseFile_success = false;
- Result = Result_error.get();
+ ec = Result_error.getError();
+ if (ec)
+ errorMessage = ec.message();
+ else
+ Result = Result_error.get();
#else
Result =
ParseBitcodeFile(buff.get(), getGlobalContext(), &errorMessage);
- bool parseFile_success = (Result);
#endif
-
- if (!parseFile_success) {
+ if (!Result) {
SS << "Loading module failed : " << errorMessage << "\n";
SS.flush();
return false;
@@ -402,8 +384,7 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
return true;
}
-#endif
-
+#endif // LLVM 3.3+
Module *klee::linkWithLibrary(Module *module,
const std::string &libraryName) {
@@ -427,7 +408,7 @@ Module *klee::linkWithLibrary(Module *module,
sys::fs::identify_magic(Buffer.get()->getBuffer());
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
MemoryBufferRef buff = Buffer.get()->getMemBufferRef();
-#else
+#else // LLVM 3.5
MemoryBuffer *buff = Buffer->get();
#endif
LLVMContext &Context = getGlobalContext();
@@ -438,7 +419,7 @@ Module *klee::linkWithLibrary(Module *module,
ErrorOr<Module *> Result = parseBitcodeFile(buff, Context);
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
if ((ec = Buffer.getError()) || Linker::LinkModules(module, Result.get()))
-#else
+#else // LLVM 3.5
if ((ec = Buffer.getError()) ||
Linker::LinkModules(module, Result.get(), Linker::DestroySource,
&ErrorMessage))
@@ -452,7 +433,7 @@ Module *klee::linkWithLibrary(Module *module,
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
ErrorOr<std::unique_ptr<object::Binary> > arch =
object::createBinary(buff, &Context);
-#else
+#else // LLVM 3.5
ErrorOr<object::Binary *> arch =
object::createBinary(std::move(Buffer.get()), &Context);
#endif
@@ -461,7 +442,7 @@ Module *klee::linkWithLibrary(Module *module,
arch.getError().message().c_str());
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
if (object::Archive *a = dyn_cast<object::Archive>(arch->get())) {
-#else
+#else // LLVM 3.5
if (object::Archive *a = dyn_cast<object::Archive>(arch.get())) {
#endif
// Handle in helper
@@ -538,7 +519,7 @@ Module *klee::linkWithLibrary(Module *module,
}
return module;
-#else
+#else // LLVM 3.2-
Linker linker("klee", module, false);
llvm::sys::Path libraryPath(libraryName);
--
2.11.1

View File

@@ -1,123 +0,0 @@
From: Marek Chalupa <mchqwerty@gmail.com>
Date: Wed, 24 Aug 2016 16:07:55 +0200
Subject: fix compilation on LLVM 3.8 after rebase to master
Patch-mainline: no
I rebased the work of rtrembecky on master and these new
changes were needed to make it compile again. Mostly
just playing with conditional includes and LLVM API
changes. All make check tests are passing :)
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
lib/Core/Executor.cpp | 18 ++++++++++++++++++
lib/Support/CompressionStream.cpp | 19 +++++++++++++++----
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 93e1ff75493b..b4d46b6823cd 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -82,6 +82,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/FileSystem.h"
#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
#include "llvm/Support/CallSite.h"
@@ -93,6 +94,10 @@
#include "klee/Internal/Support/CompressionStream.h"
#endif
+#if LLVM_VERSION_CODE > LLVM_VERSION(3, 5)
+#include <system_error>
+#endif
+
#include <cassert>
#include <algorithm>
#include <iomanip>
@@ -369,13 +374,21 @@ Executor::Executor(const InterpreterOptions &opts, InterpreterHandler *ih)
optionIsSet(DebugPrintInstructions, FILE_SRC)) {
std::string debug_file_name =
interpreterHandler->getOutputFilename("instructions.txt");
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ std::error_code EC;
+#endif
std::string ErrorInfo;
+
#ifdef HAVE_ZLIB_H
if (!DebugCompressInstructions) {
#endif
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ debugInstFile = new llvm::raw_fd_ostream(debug_file_name.c_str(), EC,
+#else
debugInstFile = new llvm::raw_fd_ostream(debug_file_name.c_str(), ErrorInfo,
+#endif
llvm::sys::fs::OpenFlags::F_Text);
#else
debugInstFile =
@@ -387,7 +400,12 @@ Executor::Executor(const InterpreterOptions &opts, InterpreterHandler *ih)
(debug_file_name + ".gz").c_str(), ErrorInfo);
}
#endif
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ if (EC) {
+ ErrorInfo = EC.message();
+#else
if (ErrorInfo != "") {
+#endif
klee_error("Could not open file %s : %s", debug_file_name.c_str(),
ErrorInfo.c_str());
}
diff --git a/lib/Support/CompressionStream.cpp b/lib/Support/CompressionStream.cpp
index eb208edfa395..a3d3b44cebf9 100644
--- a/lib/Support/CompressionStream.cpp
+++ b/lib/Support/CompressionStream.cpp
@@ -10,9 +10,11 @@
#include "klee/Config/Version.h"
#ifdef HAVE_ZLIB_H
#include "klee/Internal/Support/CompressionStream.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
+#if (LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)\
+ && LLVM_VERSION_CODE <= LLVM_VERSION(3, 4))
#include "llvm/Support/system_error.h"
#else
+#include "llvm/Support/FileSystem.h"
#include <fcntl.h>
#include <errno.h>
#include <sys/types.h>
@@ -25,10 +27,19 @@ compressed_fd_ostream::compressed_fd_ostream(const char *Filename,
std::string &ErrorInfo)
: llvm::raw_ostream(), pos(0) {
ErrorInfo = "";
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
// Open file in binary mode
+#if LLVM_VERSION_CODE == LLVM_VERSION(3, 4)
llvm::error_code EC =
- llvm::sys::fs::openFileForWrite(Filename, FD, llvm::sys::fs::F_Binary);
+#else
+ std::error_code EC =
+#endif
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
+ llvm::sys::fs::openFileForWrite(Filename, FD,
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+ llvm::sys::fs::F_None);
+#else
+ llvm::sys::fs::F_Binary);
+#endif
if (EC) {
ErrorInfo = EC.message();
@@ -116,4 +127,4 @@ void compressed_fd_ostream::write_file(const char *Ptr, size_t Size) {
} while (Size > 0);
}
}
-#endif
+#endif // HAVE_ZLIB_H
--
2.11.1

View File

@@ -1,13 +1,13 @@
<services>
<service name="tar_scm" mode="localonly">
<service name="tar_scm" mode="disabled">
<param name="url">git://github.com/klee/klee.git</param>
<param name="scm">git</param>
<param name="changesgenerate">enable</param>
<param name="versionformat">1.3.0+%cd</param>
</service>
<service name="recompress" mode="localonly">
<service name="recompress" mode="disabled">
<param name="file">klee-*.tar</param>
<param name="compression">xz</param>
</service>
<service name="set_version" mode="localonly" />
<service name="set_version" mode="disabled" />
</services>

View File

@@ -1,4 +1,4 @@
<servicedata>
<service name="tar_scm">
<param name="url">git://github.com/klee/klee.git</param>
<param name="changesrevision">3dd14b8de73b8662217dcb931b28f4e9ff823c4f</param></service></servicedata>
<param name="changesrevision">62ee2e574b9f920e6679c91da25f8941552277d9</param></service></servicedata>

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:bdc7e0810f804ae1588e5759be3fbb84d9647e87f5b237edcdd26489e8f132df
size 651168

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:841212a2355f09d4d479d54487889eaeabc3c4f2dbda90961f31ad60e2e3192c
size 646268

View File

@@ -1,3 +1,29 @@
-------------------------------------------------------------------
Wed Feb 22 10:36:55 UTC 2017 - jslaby@suse.com
- Update to version 1.3.0+20170221:
* Fix `Feature/MemoryLimit.c` test when building KLEE with ASan.
* [TravisCI] Modify TravisCI/Docker build scripts to support doing ASan/UBSan builds of KLEE.
* Fix the Autoconf/Makefile build system when building with coverage flags.
* Teach both build systems to pass the user provided CXXFLAGS and CFLAGS when using the native compiler in system tests.
* In legacy build system fix building libkleeRuntest when building with ASan.
* Increased the type size for the stop-after-n-instructions option to avoid too strict limitations
* Revert "Increased the type size for the stop-after-n-instructions option to a…"
* Silenced two "control may reach end of non-void function [-Wreturn-type]" compiler warnings, one by adding an assert, and the other by refactoring the choose() function.
* Removing unused lib/SMT directory
* Added error message when STP fails to fork.
* ReadExpr::create() was missing an opportunity to constant fold when handling constant arrays.
* Added unit tests for ReadExpr::create() to check that constant folding is correctly applied
* Added pre/post conditions as assertions
* Fixed assertion invocation: We were invoking bits64::truncateToNBits with a width greater than 64
* Refactoring code to improve readability by using UINT32/64_C macros
* Fix linker compatibility under macOS
* Increased the type size for the stop-after-n-instructions option to avoid too strict limitations (LLVM >= 3.0)
* Silenced warning: comparison of integers of different signs ('const int' and 'const unsigned long long')
* Add test case that causes an assertion failure in `klee::getDirectCallTarget(llvm::CallSite)`.
* Teach `klee::getDirectCallTarget()` to resolve weak aliases. This is controlled by a new parameter `moduleIsFullyLinked`. When true the linkage type of a weak alias is ignored. It is legal to do this when the module is fully linked because there won't be another function that could override the weak alias.
* fix metaSMT version
-------------------------------------------------------------------
Mon Feb 13 12:06:09 UTC 2017 - jslaby@suse.com

View File

@@ -17,23 +17,20 @@
%define llvm_version 3_8
%define version_unconverted 1.3.0+20170211
%define version_unconverted 1.3.0+20170221
Name: klee
Summary: LLVM Execution Engine
License: NCSA
Group: Development/Languages/Other
Version: 1.3.0+20170211
Version: 1.3.0+20170221
Release: 0
Url: http://klee.github.io/
Source0: %{name}-%{version}.tar.xz
Source1: %{name}-rpmlintrc
Patch0: 0001-Make-KLEE-compile-against-LLVM-3.5-and-3.6.patch
Patch1: 0002-Fix-compiler-warning.patch
Patch3: 0004-Cleanup-removed-unneccessary-bools.patch
Patch4: 0005-Make-KLEE-compile-against-LLVM-3.7.patch
Patch5: 0006-Make-KLEE-compile-against-LLVM-3.8.patch
Patch6: 0007-fix-compilation-on-LLVM-3.8-after-rebase-to-master.patch
Patch1: 0002-Make-KLEE-compile-against-LLVM-3.7.patch
Patch2: 0003-Make-KLEE-compile-against-LLVM-3.8.patch
BuildRequires: bison
BuildRequires: clang%{llvm_version}
BuildRequires: cmake
@@ -58,10 +55,7 @@ information on what KLEE is and what it can do, see the OSDI 2008 paper.
%setup -q
%patch0 -p1
%patch1 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch2 -p1
%build
%define __builder ninja