Accepting request 491222 from devel:tools:statica

Update to version 1.3.0+20170409

build with uclibc

OBS-URL: https://build.opensuse.org/request/show/491222
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/klee?expand=0&rev=2
This commit is contained in:
Dominique Leuenberger 2017-04-28 07:13:49 +00:00 committed by Git OBS Bridge
commit 3db80908b0
18 changed files with 2543 additions and 1841 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
From: Jiri Slaby <jirislaby@gmail.com>
Date: Fri, 17 Mar 2017 13:15:18 +0100
Subject: errno: define __errno_location
Patch-mainline: no
POSIX runtime library is built on my system with a reference to
__errno_location(). And then it is undefined when klee is run
--with-posix:
KLEE: NOTE: Using model: lib/libkleeRuntimePOSIX.bca
KLEE: output directory is "test/Runtime/POSIX/Output/Read1.c.tmp.klee-out"
KLEE: Using STP solver backend
KLEE: WARNING: undefined reference to function: __errno_location
KLEE: WARNING ONCE: calling external: __errno_location()
KLEE: ERROR: (location information missing) ASSERTION FAIL: x == -1 && errno == EFAULT
KLEE: NOTE: now ignoring this error at this location
EXITING ON ERROR:
Error: ASSERTION FAIL: x == -1 && errno == EFAULT
Stack:
#000000170 in main (argc=4, argv=24928704)
Therefore, the tests fail.
Define __errno_location as a weak symbol to return the actual int errno.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
runtime/POSIX/errno_location.c | 9 +++++++++
1 file changed, 9 insertions(+)
create mode 100644 runtime/POSIX/errno_location.c
diff --git a/runtime/POSIX/errno_location.c b/runtime/POSIX/errno_location.c
new file mode 100644
index 000000000000..58a5dab631ae
--- /dev/null
+++ b/runtime/POSIX/errno_location.c
@@ -0,0 +1,9 @@
+#include <errno.h>
+
+#undef errno
+int errno __attribute__((weak));
+
+int __attribute__((weak)) *__errno_location(void)
+{
+ return &errno;
+}
--
2.12.0

View File

@ -0,0 +1,33 @@
From: Jiri Slaby <jirislaby@gmail.com>
Date: Fri, 17 Mar 2017 13:40:30 +0100
Subject: test: disable some tests temporarily
Patch-mainline: no
They fail for some reason I cannot debug ATM, I will fix it later.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
test/Runtime/POSIX/DirSeek.c | 1 +
test/Runtime/POSIX/Ioctl.c | 1 +
2 files changed, 2 insertions(+)
--- a/test/Runtime/POSIX/DirSeek.c
+++ b/test/Runtime/POSIX/DirSeek.c
@@ -8,6 +8,7 @@
// RUN: rm -rf %t.klee-out %t.klee-out-tmp
// RUN: %gentmp %t.klee-out-tmp
// RUN: %klee --output-dir=%t.klee-out --run-in=%t.klee-out-tmp --libc=uclibc --posix-runtime --exit-on-error %t2.bc --sym-files 0 2
+// XFAIL: *
// For this test really to work as intended it needs to be run in a
// directory large enough to cause uclibc to do multiple getdents
--- a/test/Runtime/POSIX/Ioctl.c
+++ b/test/Runtime/POSIX/Ioctl.c
@@ -1,6 +1,7 @@
// RUN: %llvmgcc %s -emit-llvm -O0 -c -o %t.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee --output-dir=%t.klee-out --posix-runtime --exit-on-error %t.bc --sym-files 0 4
+// REQUIRES: undefined-symbol
#include <assert.h>
#include <fcntl.h>

File diff suppressed because it is too large Load Diff

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

@ -1,37 +1,21 @@
From: =?UTF-8?q?Richard=20Trembeck=C3=BD?= <richardt@centrum.sk>
Date: Thu, 28 Apr 2016 18:27:24 +0200
Subject: Make KLEE compile against LLVM 3.7
Subject: llvm: make KLEE compile against LLVM 3.7
Patch-mainline: no
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
include/klee/CommandLine.h | 3 +-
include/klee/Internal/Support/FloatEvaluation.h | 7 +++++
lib/Core/ExternalDispatcher.cpp | 15 ++++++----
lib/Core/StatsTracker.cpp | 3 +-
lib/Module/InstructionInfoTable.cpp | 8 ++++-
lib/Module/IntrinsicCleaner.cpp | 14 +++++++++
lib/Module/KModule.cpp | 13 ++++++++-
lib/Module/ModuleUtil.cpp | 24 +++++++++++++--
lib/Module/Optimize.cpp | 39 +++++++++++++++++--------
lib/Module/RaiseAsm.cpp | 6 ++--
tools/klee/main.cpp | 9 +++++-
11 files changed, 113 insertions(+), 28 deletions(-)
include/klee/Internal/Support/FloatEvaluation.h | 7 +++++++
lib/Core/ExternalDispatcher.cpp | 4 ++++
lib/Module/InstructionInfoTable.cpp | 8 +++++++-
lib/Module/IntrinsicCleaner.cpp | 14 ++++++++++++++
lib/Module/KModule.cpp | 13 ++++++++++++-
lib/Module/ModuleUtil.cpp | 22 +++++++++++++++++++---
lib/Module/Optimize.cpp | 21 +++++++++++++++++++--
lib/Module/RaiseAsm.cpp | 5 ++++-
tools/klee/main.cpp | 6 +++++-
9 files changed, 91 insertions(+), 9 deletions(-)
diff --git a/include/klee/CommandLine.h b/include/klee/CommandLine.h
index 95aa51e041e2..cc186db711fc 100644
--- a/include/klee/CommandLine.h
+++ b/include/klee/CommandLine.h
@@ -70,8 +70,7 @@ extern llvm::cl::opt<klee::MetaSMTBackendType> MetaSMTBackend;
//A bit of ugliness so we can use cl::list<> like cl::bits<>, see queryLoggingOptions
template <typename T>
-static bool optionIsSet(llvm::cl::list<T> list, T option)
-{
+static bool optionIsSet(llvm::cl::list<T> &list, T option) {
return std::find(list.begin(), list.end(), option) != list.end();
}
diff --git a/include/klee/Internal/Support/FloatEvaluation.h b/include/klee/Internal/Support/FloatEvaluation.h
index 6d9092f2ea37..436e0dc8152f 100644
--- a/include/klee/Internal/Support/FloatEvaluation.h
@ -53,47 +37,23 @@ index 6d9092f2ea37..436e0dc8152f 100644
}
}
diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp
index 09dd715a53ae..fa29f6e3047c 100644
index 9701d35add85..d49373f84e64 100644
--- a/lib/Core/ExternalDispatcher.cpp
+++ b/lib/Core/ExternalDispatcher.cpp
@@ -253,11 +253,16 @@ Function *ExternalDispatcher::createDispatcher(Function *target, Instruction *in
// functions.
@@ -257,7 +257,11 @@ Function *ExternalDispatcher::createDispatcher(Function *target, Instruction *in
LLVM_TYPE_Q Type *argTy = (i < FTy->getNumParams() ? FTy->getParamType(i) :
(*ai)->getType());
- Instruction *argI64p =
- GetElementPtrInst::Create(argI64s,
- ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
- idx),
- "", dBB);
+ Instruction *argI64p =
Instruction *argI64p =
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+ GetElementPtrInst::Create(
+ nullptr, argI64s,
+ GetElementPtrInst::Create(nullptr, argI64s,
+#else
+ GetElementPtrInst::Create(
+ argI64s,
GetElementPtrInst::Create(argI64s,
+#endif
+ ConstantInt::get(Type::getInt32Ty(getGlobalContext()), idx), "",
+ dBB);
ConstantInt::get(Type::getInt32Ty(ctx), idx),
"", dBB);
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
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -167,7 +167,8 @@ 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);
if (target && target->doesNotReturn())
return false;
}
diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp
index 7e9a9e268b40..53c64878391f 100644
index adf054423f13..625c4a297ead 100644
--- a/lib/Module/InstructionInfoTable.cpp
+++ b/lib/Module/InstructionInfoTable.cpp
@@ -87,7 +87,7 @@ static void buildInstructionToLineMap(Module *m,
@ -122,28 +82,28 @@ index 7e9a9e268b40..53c64878391f 100644
}
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index 54582e6954cf..66e9392a618d 100644
index 3f7644af3d37..9af6f9f40f21 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -109,11 +109,25 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
@@ -110,11 +110,25 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
Value *pSrc = CastInst::CreatePointerCast(src, i64p, "vacopy.cast.src", ii);
Value *val = new LoadInst(pSrc, std::string(), ii); new StoreInst(val, pDst, ii);
Value *off = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), 1);
Value *off = ConstantInt::get(Type::getInt64Ty(ctx), 1);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+ pDst =
+ GetElementPtrInst::Create(nullptr, pDst, off, std::string(), ii);
+ pSrc =
+ GetElementPtrInst::Create(nullptr, pSrc, off, std::string(), ii);
+ pDst = GetElementPtrInst::Create(nullptr, pDst, off, std::string(),
+ ii);
+ pSrc = GetElementPtrInst::Create(nullptr, pSrc, off, std::string(),
+ ii);
+#else
pDst = GetElementPtrInst::Create(pDst, off, std::string(), ii);
pSrc = GetElementPtrInst::Create(pSrc, off, std::string(), ii);
+#endif
val = new LoadInst(pSrc, std::string(), ii); new StoreInst(val, pDst, ii);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+ pDst =
+ GetElementPtrInst::Create(nullptr, pDst, off, std::string(), ii);
+ pSrc =
+ GetElementPtrInst::Create(nullptr, pSrc, off, std::string(), ii);
+ pDst = GetElementPtrInst::Create(nullptr, pDst, off, std::string(),
+ ii);
+ pSrc = GetElementPtrInst::Create(nullptr, pSrc, off, std::string(),
+ ii);
+#else
pDst = GetElementPtrInst::Create(pDst, off, std::string(), ii);
pSrc = GetElementPtrInst::Create(pSrc, off, std::string(), ii);
@ -152,7 +112,7 @@ index 54582e6954cf..66e9392a618d 100644
}
ii->removeFromParent();
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index 598c439f9da0..cc328b1bb974 100644
index 45dc34bfec46..4fac18739aba 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -46,8 +46,11 @@
@ -168,7 +128,7 @@ index 598c439f9da0..cc328b1bb974 100644
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/raw_os_ostream.h"
@@ -301,7 +304,11 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
@@ -305,7 +308,11 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
// invariant transformations that we will end up doing later so that
// optimize is seeing what is as close as possible to the final
// module.
@ -180,7 +140,7 @@ index 598c439f9da0..cc328b1bb974 100644
pm.add(new RaiseAsmPass());
if (opts.CheckDivZero) pm.add(new DivCheckPass());
if (opts.CheckOvershift) pm.add(new OvershiftCheckPass());
@@ -369,7 +376,11 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
@@ -373,7 +380,11 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
// linked in something with intrinsics but any external calls are
// going to be unresolved. We really need to handle the intrinsics
// directly I think?
@ -193,65 +153,60 @@ 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 c7f1c6d9d4a7..de0130a2632c 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
// FIXME: Maybe load bitcode file lazily? Then if we need to link, materialise
// the module
@@ -274,13 +274,21 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
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 *> resultErr = parseBitcodeFile(buff.get(),
- composite->getContext());
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+ ErrorOr<std::unique_ptr<Module> > Result_error =
+ ErrorOr<std::unique_ptr<Module> > resultErr =
+#else
ErrorOr<Module *> Result_error =
+ ErrorOr<Module *> resultErr =
+#endif
parseBitcodeFile(buff.get(), getGlobalContext());
ec = Result_error.getError();
+ parseBitcodeFile(buff.get(), composite->getContext());
ec = resultErr.getError();
if (ec)
errorMessage = ec.message();
else
- Result = Result_error.get();
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+ Result = Result_error->release();
#else
+ Result = Result_error.get();
+ Result = resultErr->release();
+#else
Result = resultErr.get();
+#endif
+#else // LLVM 3.3, 3.4
Result =
ParseBitcodeFile(buff.get(), getGlobalContext(), &errorMessage);
#endif
@@ -416,8 +424,15 @@ Module *klee::linkWithLibrary(Module *module,
#else
Result = ParseBitcodeFile(buff.get(), composite->getContext(),
&errorMessage);
@@ -439,7 +447,12 @@ Module *klee::linkWithLibrary(Module *module,
if (magic == sys::fs::file_magic::bitcode) {
Module *Result = 0;
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- ErrorOr<Module *> ResultErr = parseBitcodeFile(Buffer, Context);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+ ErrorOr<std::unique_ptr<Module> > Result = parseBitcodeFile(buff, Context);
+
+ if ((ec = Buffer.getError()) || Linker::LinkModules(module, Result->get()))
+ klee_error("Link with library %s failed: %s", libraryName.c_str(),
+ ec.message().c_str());
+#else // LLVM 3.5, 3.6
ErrorOr<Module *> Result = parseBitcodeFile(buff, Context);
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#if LLVM_VERSION_CODE == LLVM_VERSION(3, 6)
if ((ec = Buffer.getError()) || Linker::LinkModules(module, Result.get()))
#else // LLVM 3.5
if ((ec = Buffer.getError()) ||
@@ -426,8 +441,11 @@ Module *klee::linkWithLibrary(Module *module,
#endif
klee_error("Link with library %s failed: %s", libraryName.c_str(),
ec.message().c_str());
-
+ ErrorOr<std::unique_ptr<Module> > ResultErr =
+#else
+ ErrorOr<Module *> ResultErr =
+#endif
+ parseBitcodeFile(Buffer, Context);
if ((ec = ResultErr.getError())) {
ErrorMessage = ec.message();
#else
@@ -464,7 +477,10 @@ Module *klee::linkWithLibrary(Module *module,
ErrorMessage.c_str());
}
+// unique_ptr owns the Module, we don't have to delete it
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 7)
delete Result.get();
+#endif
delete Result;
+#endif
} else if (magic == sys::fs::file_magic::archive) {
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp
index 8cd592069523..3eca0db6c174 100644
index c0f3f34ca8e8..68acd2b17dda 100644
--- a/lib/Module/Optimize.cpp
+++ b/lib/Module/Optimize.cpp
@@ -16,7 +16,11 @@
@ -291,7 +246,7 @@ index 8cd592069523..3eca0db6c174 100644
PM.add(createVerifierPass()); // Verify that input is correct
#if LLVM_VERSION_CODE < LLVM_VERSION(3, 0)
@@ -166,27 +177,31 @@ static void AddStandardCompilePasses(PassManager &PM) {
@@ -166,14 +177,20 @@ static void AddStandardCompilePasses(PassManager &PM) {
void Optimize(Module *M, const std::string &EntryPoint) {
// Instantiate the pass manager to organize the passes.
@ -305,44 +260,22 @@ index 8cd592069523..3eca0db6c174 100644
if (VerifyEach)
Passes.add(createVerifierPass());
// Add an appropriate DataLayout instance for this module...
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+ // Add an appropriate TargetData instance for this module...
+ addPass(Passes, new TargetData(M));
+#elif LLVM_VERSION_CODE <= LLVM_VERSION(3, 4)
// Add an appropriate DataLayout instance for this module...
- DataLayoutPass *dlpass = new DataLayoutPass();
- dlpass->doInitialization(*M);
- addPass(Passes, dlpass);
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+ addPass(Passes, new DataLayout(M));
+#elif LLVM_VERSION_CODE == LLVM_VERSION(3, 5)
// Add an appropriate DataLayout instance for this module...
addPass(Passes, new DataLayoutPass(M));
-#elif LLVM_VERSION_CODE > LLVM_VERSION(3, 1)
+#elif LLVM_VERSION_CODE == LLVM_VERSION(3, 6)
// Add an appropriate DataLayout instance for this module...
- addPass(Passes, new DataLayout(M));
-#else
- // Add an appropriate TargetData instance for this module...
- addPass(Passes, new TargetData(M));
-#endif
+ DataLayoutPass *dlpass = new DataLayoutPass();
+ dlpass->doInitialization(*M);
+ addPass(Passes, dlpass);
+#endif // LLVM 3.7+ doesn't have DataLayoutPass anymore.
// DWD - Run the opt standard pass list as well.
AddStandardCompilePasses(Passes);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+ // LLVM 3.7+ doesn't have DataLayoutPass anymore.
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
DataLayoutPass *dlpass = new DataLayoutPass();
dlpass->doInitialization(*M);
addPass(Passes, dlpass);
diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp
index bde9fba93c3a..a2972ce7ee9b 100644
index 5fc54ef17743..29576ad10e9e 100644
--- a/lib/Module/RaiseAsm.cpp
+++ b/lib/Module/RaiseAsm.cpp
@@ -103,8 +103,10 @@ bool RaiseAsmPass::runOnModule(Module &M) {
@@ -103,7 +103,10 @@ bool RaiseAsmPass::runOnModule(Module &M) {
klee_warning("Warning: unable to select native target: %s", Err.c_str());
TLI = 0;
} else {
-
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+ TM = NativeTarget->createTargetMachine(HostTriple, "", "", TargetOptions());
@ -352,21 +285,18 @@ index bde9fba93c3a..a2972ce7ee9b 100644
TLI = TM->getSubtargetImpl()->getTargetLowering();
#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index 3747d69db0ed..9265abe04820 100644
index 90d54e064dd3..20b1e33a6617 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -59,6 +59,10 @@
#include "llvm/Support/system_error.h"
#endif
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
@@ -46,6 +46,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#endif
+
#include <dirent.h>
#include <signal.h>
#include <unistd.h>
@@ -1292,8 +1296,11 @@ int main(int argc, char **argv, char **envp) {
#include "llvm/Support/raw_ostream.h"
#if LLVM_VERSION_CODE < LLVM_VERSION(3, 0)
@@ -1290,8 +1291,11 @@ int main(int argc, char **argv, char **envp) {
// from the std::unique_ptr
Buffer->release();
}
@ -380,5 +310,5 @@ index 3747d69db0ed..9265abe04820 100644
klee_error("error loading program '%s': %s", InputFile.c_str(),
ec.message().c_str());
--
2.11.1
2.12.0

View File

@ -0,0 +1,269 @@
From: =?UTF-8?q?Richard=20Trembeck=C3=BD?= <richardt@centrum.sk>
Date: Wed, 4 May 2016 15:21:45 +0200
Subject: llvm: make KLEE compile against LLVM 3.8
Patch-mainline: no
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
lib/Core/Executor.cpp | 5 +++++
lib/Core/StatsTracker.cpp | 4 ++++
lib/Module/IntrinsicCleaner.cpp | 10 +++++++++-
lib/Module/LowerSwitch.cpp | 8 ++++++++
lib/Module/ModuleUtil.cpp | 38 ++++++++++++++++++++++++++++++--------
lib/Module/Optimize.cpp | 13 ++++++++++++-
tools/klee/main.cpp | 11 ++++++++++-
7 files changed, 78 insertions(+), 11 deletions(-)
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 4148ca22caf3..794346e0950d 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -2301,8 +2301,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());
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ Res.mod(
+ APFloat(*fpWidthToSemantics(right->getWidth()), right->getAPValue()));
+#else
Res.mod(APFloat(*fpWidthToSemantics(right->getWidth()),right->getAPValue()),
APFloat::rmNearestTiesToEven);
+#endif
#else
llvm::APFloat Res(left->getAPValue());
Res.mod(APFloat(right->getAPValue()), APFloat::rmNearestTiesToEven);
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index b93796ecdff7..fc4cb786e902 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -641,7 +641,11 @@ static std::vector<Instruction*> getSuccs(Instruction *i) {
for (succ_iterator it = succ_begin(bb), ie = succ_end(bb); it != ie; ++it)
res.push_back(static_cast<Instruction *>(it->begin()));
} else {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ res.push_back(static_cast<Instruction *>(++(i->getIterator())));
+#else
res.push_back(static_cast<Instruction *>(++BasicBlock::iterator(i)));
+#endif
}
return res;
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index 9af6f9f40f21..1e43463e6a5c 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -80,6 +80,10 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
for (BasicBlock::iterator i = b.begin(), ie = b.end();
(i != ie) && (block_split == false);) {
IntrinsicInst *ii = dyn_cast<IntrinsicInst>(&*i);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ // create a copy of iterator to pass to IRBuilder ctor later
+ BasicBlock::iterator i_ = i;
+#endif
// increment now since LowerIntrinsic deletion makes iterator invalid.
++i;
if(ii) {
@@ -142,8 +146,12 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
case Intrinsic::uadd_with_overflow:
case Intrinsic::usub_with_overflow:
case Intrinsic::umul_with_overflow: {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ // ctor needs the iterator, but we already increased our one
+ IRBuilder<> builder(ii->getParent(), i_);
+#else
IRBuilder<> builder(ii->getParent(), ii);
-
+#endif
Value *op1 = ii->getArgOperand(0);
Value *op2 = ii->getArgOperand(1);
diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp
index 5cc6b991c6d1..4a5658912a0c 100644
--- a/lib/Module/LowerSwitch.cpp
+++ b/lib/Module/LowerSwitch.cpp
@@ -68,7 +68,11 @@ void LowerSwitchPass::switchConvert(CaseItr begin, CaseItr end,
// iterate through all the cases, creating a new BasicBlock for each
for (CaseItr it = begin; it < end; ++it) {
BasicBlock *newBlock = BasicBlock::Create(F->getContext(), "NodeBlock");
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ Function::iterator FI = origBlock->getIterator();
+#else
Function::iterator FI = origBlock;
+#endif
F->getBasicBlockList().insert(++FI, newBlock);
ICmpInst *cmpInst =
@@ -105,7 +109,11 @@ void LowerSwitchPass::processSwitchInst(SwitchInst *SI) {
// if-then statements go to this and the PHI nodes are happy.
BasicBlock* newDefault = BasicBlock::Create(F->getContext(), "newDefault");
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ F->getBasicBlockList().insert(defaultBlock->getIterator(), newDefault);
+#else
F->getBasicBlockList().insert(defaultBlock, newDefault);
+#endif
BranchInst::Create(defaultBlock, newDefault);
// 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 de0130a2632c..6b50b037bc65 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -223,8 +223,19 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
StringRef memberName;
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- ErrorOr<StringRef> memberNameErr = AI->getName();
- std::error_code ec = memberNameErr.getError();
+ std::error_code ec;
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ ErrorOr<object::Archive::Child> childErr = *AI;
+ ec = childErr.getError();
+ if (ec) {
+ errorMessage = ec.message();
+ return false;
+ }
+#else
+ object::Archive::child_iterator childErr = AI;
+#endif
+ ErrorOr<StringRef> memberNameErr = childErr->getName();
+ ec = memberNameErr.getError();
if (!ec) {
memberName = memberNameErr.get();
#else
@@ -242,7 +253,8 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
}
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- ErrorOr<std::unique_ptr<llvm::object::Binary> > child = AI->getAsBinary();
+ ErrorOr<std::unique_ptr<llvm::object::Binary> > child =
+ childErr->getAsBinary();
ec = child.getError();
#else
OwningPtr<object::Binary> child;
@@ -251,7 +263,7 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
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();
+ ErrorOr<MemoryBufferRef> buff = childErr->getMemoryBufferRef();
ec = buff.getError();
#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
ErrorOr<std::unique_ptr<MemoryBuffer> > buffErr = AI->getMemoryBuffer();
@@ -359,7 +371,9 @@ 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");
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ if (Linker::linkModules(*composite, std::unique_ptr<Module>(M)))
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
if (Linker::LinkModules(composite, M))
#else
if (Linker::LinkModules(composite, M, Linker::DestroySource, &errorMessage))
@@ -376,8 +390,10 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
// Link succeed, now clean up
modulesLoadedOnPass++;
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Linking succeeded.\n");
-
+// M was owned by linkModules function
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
delete M;
+#endif
archiveModules[i] = 0;
// We need to recompute the undefined symbols in the composite module
@@ -445,7 +461,9 @@ Module *klee::linkWithLibrary(Module *module,
std::string ErrorMessage;
if (magic == sys::fs::file_magic::bitcode) {
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
Module *Result = 0;
+#endif
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
ErrorOr<std::unique_ptr<Module> > ResultErr =
@@ -463,11 +481,15 @@ Module *klee::linkWithLibrary(Module *module,
ErrorMessage.c_str());
}
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) && \
+ LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
Result = ResultErr.get();
#endif
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ if (Linker::linkModules(*module, std::move(ResultErr.get()))) {
+ ErrorMessage = "linking error";
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
if (Linker::LinkModules(module, Result)) {
ErrorMessage = "linking error";
#else
diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp
index 68acd2b17dda..46ab7d028224 100644
--- a/lib/Module/Optimize.cpp
+++ b/lib/Module/Optimize.cpp
@@ -126,7 +126,12 @@ static void AddStandardCompilePasses(PassManager &PM) {
addPass(PM, createCFGSimplificationPass()); // Clean up after IPCP & DAE
addPass(PM, createPruneEHPass()); // Remove dead EH info
- addPass(PM, createFunctionAttrsPass()); // Deduce function attrs
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ addPass(PM, createPostOrderFunctionAttrsPass());
+ addPass(PM, createReversePostOrderFunctionAttrsPass());
+#else
+ addPass(PM, createFunctionAttrsPass()); // Deduce function attrs
+#endif
if (!DisableInline)
addPass(PM, createFunctionInliningPass()); // Inline small functions
@@ -257,8 +262,14 @@ void Optimize(Module *M, const std::string &EntryPoint) {
addPass(Passes, createScalarReplAggregatesPass()); // Break up allocas
// Run a few AA driven optimizations here and now, to cleanup the code.
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ addPass(Passes, createPostOrderFunctionAttrsPass());
+ addPass(Passes, createReversePostOrderFunctionAttrsPass());
+ // addPass(Passes, createGlobalsAAWrapperPass());
+#else
addPass(Passes, createFunctionAttrsPass()); // Add nocapture
addPass(Passes, createGlobalsModRefPass()); // IP alias analysis
+#endif
addPass(Passes, createLICMPass()); // Hoist loop invariants
addPass(Passes, createGVNPass()); // Remove redundancies
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index 20b1e33a6617..4acefbf8c4de 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -310,7 +310,12 @@ KleeHandler::KleeHandler(int argc, char **argv)
for (; i <= INT_MAX; ++i) {
SmallString<128> d(directory);
llvm::sys::path::append(d, "klee-out-");
- raw_svector_ostream ds(d); ds << i; ds.flush();
+ raw_svector_ostream ds(d);
+ ds << i;
+// SmallString is always up-to-date, no need to flush. See Support/raw_ostream.h
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
+ ds.flush();
+#endif
// create directory and try to link klee-last
if (mkdir(d.c_str(), 0775) == 0) {
@@ -1296,7 +1301,11 @@ int main(int argc, char **argv, char **envp) {
#else
mainModule = *mainModuleOrError;
#endif
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ if (auto ec = mainModule->materializeAll()) {
+#else
if (auto ec = mainModule->materializeAllPermanently()) {
+#endif
klee_error("error loading program '%s': %s", InputFile.c_str(),
ec.message().c_str());
}
--
2.12.0

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,862 +0,0 @@
From: =?UTF-8?q?Richard=20Trembeck=C3=BD?= <richardt@centrum.sk>
Date: Wed, 4 May 2016 15:21:45 +0200
Subject: Make KLEE compile against LLVM 3.8
Patch-mainline: no
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/Module/Checks.cpp | 34 +++++++++++--------
lib/Module/InstructionInfoTable.cpp | 15 ++++++--
lib/Module/IntrinsicCleaner.cpp | 12 +++++--
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(-)
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 55a29230f36a..93e1ff75493b 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -530,7 +530,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);
+#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) {
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);
+#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) {
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());
}
-
- MemoryObject *mo = memory->allocate(size, false, true, i);
+ MemoryObject *mo = memory->allocate(size, false, true, v);
ObjectState *os = bindObjectInState(state, mo, false);
- globalObjects.insert(std::make_pair(i, mo));
- globalAddresses.insert(std::make_pair(i, mo->getBaseExpr()));
+ globalObjects.insert(std::make_pair(v, mo));
+ globalAddresses.insert(std::make_pair(v, mo->getBaseExpr()));
// Program already running = object already initialized. Read
// concrete value and write it to our copy.
@@ -643,8 +651,8 @@ void Executor::initializeGlobals(ExecutionState &state) {
if (!mo)
llvm::report_fatal_error("out of memory");
ObjectState *os = bindObjectInState(state, mo, false);
- globalObjects.insert(std::make_pair(i, mo));
- globalAddresses.insert(std::make_pair(i, mo->getBaseExpr()));
+ globalObjects.insert(std::make_pair(v, mo));
+ globalAddresses.insert(std::make_pair(v, mo->getBaseExpr()));
if (!i->hasInitializer())
os->initializeToRandom();
@@ -655,8 +663,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
- // addresses for everything, even undefined functions.
+ // addresses for everything, even undefined functions.
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ globalAddresses.insert(std::make_pair(static_cast<GlobalAlias *>(i),
+ evalConstant(i->getAliasee())));
+#else
globalAddresses.insert(std::make_pair(i, evalConstant(i->getAliasee())));
+#endif
}
// once all objects are allocated, do the actual initialization
@@ -664,7 +677,12 @@ void Executor::initializeGlobals(ExecutionState &state) {
e = m->global_end();
i != e; ++i) {
if (i->hasInitializer()) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ MemoryObject *mo =
+ globalObjects.find(static_cast<const GlobalVariable *>(i))->second;
+#else
MemoryObject *mo = globalObjects.find(i)->second;
+#endif
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) {
return terminateStateOnExecError(state, "Unsupported FRem operation");
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
llvm::APFloat Res(*fpWidthToSemantics(left->getWidth()), left->getAPValue());
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ Res.mod(
+ APFloat(*fpWidthToSemantics(right->getWidth()), right->getAPValue()));
+#else
Res.mod(APFloat(*fpWidthToSemantics(right->getWidth()),right->getAPValue()),
APFloat::rmNearestTiesToEven);
+#endif
#else
llvm::APFloat Res(left->getAPValue());
Res.mod(APFloat(right->getAPValue()), APFloat::rmNearestTiesToEven);
@@ -3539,9 +3562,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()));
+#else
+ f->begin()->begin());
+#endif
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
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -162,10 +162,14 @@ static bool instructionIsCoverable(Instruction *i) {
if (i->getOpcode() == Instruction::Unreachable) {
BasicBlock *bb = i->getParent();
BasicBlock::iterator it(i);
- if (it==bb->begin()) {
+ if (it == bb->begin()) {
return true;
} else {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto 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() {
// 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);
+#else
+ Function *fn = fnIt;
+#endif
+ const InstructionInfo &ii = executor.kmodule->infos->getFunctionInfo(fn);
if (ii.file != sourceFile) {
of << "fl=" << ii.file << "\n";
sourceFile = ii.file;
@@ -638,9 +647,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)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ res.push_back(static_cast<Instruction *>(it->begin()));
+#else
res.push_back(it->begin());
+#endif
} else {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ res.push_back(static_cast<Instruction *>(++(i->getIterator())));
+#else
res.push_back(++BasicBlock::iterator(i));
+#endif
}
return res;
@@ -687,19 +704,23 @@ 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);
+#else
+ Instruction *inst = it;
+#endif
if (isa<CallInst>(it) || isa<InvokeInst>(it)) {
- CallSite cs(it);
+ CallSite cs(inst);
if (isa<InlineAsm>(cs.getCalledValue())) {
// 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[it].push_back(target);
+ callTargets[inst].push_back(target);
} else {
- callTargets[it] =
- std::vector<Function*>(km->escapingFunctions.begin(),
- km->escapingFunctions.end());
+ callTargets[inst] = std::vector<Function *>(
+ km->escapingFunctions.begin(), km->escapingFunctions.end());
}
}
}
@@ -718,14 +739,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);
+#else
+ Function *fn = fnIt;
+#endif
if (fnIt->isDeclaration()) {
if (fnIt->doesNotReturn()) {
- functionShortestPath[fnIt] = 0;
+ functionShortestPath[fn] = 0;
} else {
- functionShortestPath[fnIt] = 1; // whatever
+ functionShortestPath[fn] = 1; // whatever
}
} else {
- functionShortestPath[fnIt] = 0;
+ functionShortestPath[fn] = 0;
}
// Not sure if I should bother to preorder here. XXX I should.
@@ -733,8 +759,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);
+#else
+ Instruction *inst = it;
+#endif
+ instructions.push_back(inst);
+ unsigned id = infos.getInfo(inst).id;
sm.setIndexedValue(stats::minDistToReturn,
id,
isa<ReturnInst>(it)
@@ -815,8 +846,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);
+#else
+ Instruction *inst = it;
+#endif
+ unsigned id = infos.getInfo(inst).id;
+ instructions.push_back(inst);
sm.setIndexedValue(stats::minDistToUncovered,
id,
sm.getIndexedValue(stats::uncoveredInstructions, id));
diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp
index 7d9b72841753..2a1681f3a7c5 100644
--- a/lib/Module/Checks.cpp
+++ b/lib/Module/Checks.cpp
@@ -64,14 +64,17 @@ bool DivCheckPass::runOnModule(Module &M) {
Instruction::BinaryOps opcode = binOp->getOpcode();
if (opcode == Instruction::SDiv || opcode == Instruction::UDiv ||
opcode == Instruction::SRem || opcode == Instruction::URem) {
-
- CastInst *denominator =
- CastInst::CreateIntegerCast(i->getOperand(1),
- Type::getInt64Ty(getGlobalContext()),
- false, /* sign doesn't matter */
- "int_cast_to_i64",
- i);
-
+
+ CastInst *denominator = CastInst::CreateIntegerCast(
+ i->getOperand(1), Type::getInt64Ty(getGlobalContext()),
+ false, /* sign doesn't matter */
+ "int_cast_to_i64",
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ static_cast<Instruction *>(i));
+#else
+ i);
+#endif
+
// Lazily bind the function to avoid always importing it.
if (!divZeroCheckFunction) {
Constant *fc = M.getOrInsertFunction("klee_div_zero_check",
@@ -121,12 +124,15 @@ bool OvershiftCheckPass::runOnModule(Module &M) {
ConstantInt *bitWidthC = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),bitWidth,false);
args.push_back(bitWidthC);
- CastInst *shift =
- CastInst::CreateIntegerCast(i->getOperand(1),
- Type::getInt64Ty(getGlobalContext()),
- false, /* sign doesn't matter */
- "int_cast_to_i64",
- i);
+ CastInst *shift = CastInst::CreateIntegerCast(
+ i->getOperand(1), Type::getInt64Ty(getGlobalContext()),
+ false, /* sign doesn't matter */
+ "int_cast_to_i64",
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ static_cast<Instruction *>(i));
+#else
+ i);
+#endif
args.push_back(shift);
diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp
index 53c64878391f..d2d312da8540 100644
--- a/lib/Module/InstructionInfoTable.cpp
+++ b/lib/Module/InstructionInfoTable.cpp
@@ -134,7 +134,12 @@ InstructionInfoTable::InstructionInfoTable(Module *m)
// if any.
const std::string *initialFile = &dummyString;
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);
+#else
+ Function *fn = fnIt;
+#endif
+ for (inst_iterator it = inst_begin(fn), ie = inst_end(fn); it != ie;
++it) {
if (getInstructionDebugInfo(&*it, initialFile, initialLine))
break;
@@ -142,8 +147,8 @@ InstructionInfoTable::InstructionInfoTable(Module *m)
const std::string *file = initialFile;
unsigned line = initialLine;
- for (inst_iterator it = inst_begin(fnIt), ie = inst_end(fnIt); it != ie;
- ++it) {
+ for (inst_iterator it = inst_begin(fn), ie = inst_end(fn); it != ie;
+ ++it) {
Instruction *instr = &*it;
unsigned assemblyLine = lineTable[instr];
@@ -199,6 +204,10 @@ InstructionInfoTable::getFunctionInfo(const Function *f) const {
// and construct a test case for it if it does, though.
return dummyInfo;
} else {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ return getInfo(static_cast<const Instruction *>(f->begin()->begin()));
+#else
return getInfo(f->begin()->begin());
+#endif
}
}
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index 66e9392a618d..8ec47195dd3b 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -79,8 +79,12 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
for (BasicBlock::iterator i = b.begin(), ie = b.end();
(i != ie) && (block_split == false);) {
IntrinsicInst *ii = dyn_cast<IntrinsicInst>(&*i);
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ // create a copy of iterator to pass to IRBuilder ctor later
+ BasicBlock::iterator i_ = i;
+#endif
// increment now since LowerIntrinsic deletion makes iterator invalid.
- ++i;
+ ++i;
if(ii) {
switch (ii->getIntrinsicID()) {
case Intrinsic::vastart:
@@ -141,8 +145,12 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
case Intrinsic::uadd_with_overflow:
case Intrinsic::usub_with_overflow:
case Intrinsic::umul_with_overflow: {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ // ctor needs the iterator, but we already increased our one
+ IRBuilder<> builder(ii->getParent(), i_);
+#else
IRBuilder<> builder(ii->getParent(), ii);
-
+#endif
Value *op1 = ii->getArgOperand(0);
Value *op2 = ii->getArgOperand(1);
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index cc328b1bb974..1ceedab508b3 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -120,12 +120,15 @@ KModule::~KModule() {
delete[] constantTable;
delete infos;
- for (std::vector<KFunction*>::iterator it = functions.begin(),
- ie = functions.end(); it != ie; ++it)
+ for (std::vector<KFunction *>::iterator it = functions.begin(),
+ ie = functions.end();
+ it != ie; ++it)
delete *it;
- for (std::map<llvm::Constant*, KConstant*>::iterator it=constantMap.begin(),
- itE=constantMap.end(); it!=itE;++it)
+ for (std::map<llvm::Constant *, KConstant *>::iterator
+ it = constantMap.begin(),
+ itE = constantMap.end();
+ it != itE; ++it)
delete it->second;
delete targetData;
@@ -197,8 +200,14 @@ static void injectStaticConstructorsAndDestructors(Module *m) {
klee_error("Could not find main() function.");
if (ctors)
- 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());
+#endif
+
if (dtors) {
Function *dtorStub = getStubFunctionForCtorList(m, dtors, "klee.dtor_stub");
for (Function::iterator it = mainFn->begin(), ie = mainFn->end();
@@ -278,22 +287,27 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
result = PHINode::Create(f->getReturnType(), 0, "retval", exit);
#else
- result = PHINode::Create(f->getReturnType(), "retval", exit);
+ result = PHINode::Create(f->getReturnType(), "retval", exit);
#endif
CallInst::Create(mergeFn, "", exit);
ReturnInst::Create(getGlobalContext(), result, exit);
llvm::errs() << "KLEE: adding klee_merge at exit of: " << name << "\n";
- for (llvm::Function::iterator bbit = f->begin(), bbie = f->end();
+ for (llvm::Function::iterator bbit = f->begin(), bbie = f->end();
bbit != bbie; ++bbit) {
- if (&*bbit != exit) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto bb = static_cast<BasicBlock *>(bbit);
+#else
+ BasicBlock *bb = bbit;
+#endif
+ if (bb != exit) {
Instruction *i = bbit->getTerminator();
if (i->getOpcode()==Instruction::Ret) {
if (result) {
- result->addIncoming(i->getOperand(0), bbit);
+ result->addIncoming(i->getOperand(0), bb);
}
i->eraseFromParent();
- BranchInst::Create(exit, bbit);
+ BranchInst::Create(exit, bb);
}
}
}
@@ -458,15 +472,20 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
if (it->isDeclaration())
continue;
- KFunction *kf = new KFunction(it, this);
-
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto fn = static_cast<Function *>(it);
+#else
+ Function *fn = it;
+#endif
+ KFunction *kf = new KFunction(fn, this);
+
for (unsigned i=0; i<kf->numInstructions; ++i) {
KInstruction *ki = kf->instructions[i];
ki->info = &infos->getInfo(ki->inst);
}
functions.push_back(kf);
- functionMap.insert(std::make_pair(it, kf));
+ functionMap.insert(std::make_pair(fn, kf));
}
/* Compute various interesting properties */
@@ -547,7 +566,11 @@ KFunction::KFunction(llvm::Function *_function,
trackCoverage(true) {
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);
+#else
BasicBlock *bb = bbit;
+#endif
basicBlockEntry[bb] = numInstructions;
numInstructions += bb->size();
}
@@ -562,7 +585,11 @@ KFunction::KFunction(llvm::Function *_function,
bbie = function->end(); bbit != bbie; ++bbit) {
for (llvm::BasicBlock::iterator it = bbit->begin(), ie = bbit->end();
it != ie; ++it)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ registerMap[static_cast<Instruction *>(it)] = rnum++;
+#else
registerMap[it] = rnum++;
+#endif
}
numRegisters = rnum;
@@ -581,12 +608,16 @@ KFunction::KFunction(llvm::Function *_function,
default:
ki = new KInstruction(); break;
}
-
- ki->inst = it;
- ki->dest = registerMap[it];
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto inst = static_cast<Instruction *>(it);
+#else
+ Instruction *inst = it;
+#endif
+ ki->inst = inst;
+ ki->dest = registerMap[inst];
if (isa<CallInst>(it) || isa<InvokeInst>(it)) {
- CallSite cs(it);
+ CallSite cs(inst);
unsigned numArgs = cs.arg_size();
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
--- a/lib/Module/LowerSwitch.cpp
+++ b/lib/Module/LowerSwitch.cpp
@@ -44,7 +44,12 @@ bool LowerSwitchPass::runOnFunction(Function &F) {
bool changed = false;
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);
+#else
+ BasicBlock *cur = I;
+#endif
+ I++; // Advance over block so we don't traverse new blocks
if (SwitchInst *SI = dyn_cast<SwitchInst>(cur->getTerminator())) {
changed = true;
@@ -67,7 +72,11 @@ void LowerSwitchPass::switchConvert(CaseItr begin, CaseItr end,
// iterate through all the cases, creating a new BasicBlock for each
for (CaseItr it = begin; it < end; ++it) {
BasicBlock *newBlock = BasicBlock::Create(getGlobalContext(), "NodeBlock");
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ Function::iterator FI = origBlock->getIterator();
+#else
Function::iterator FI = origBlock;
+#endif
F->getBasicBlockList().insert(++FI, newBlock);
ICmpInst *cmpInst =
@@ -104,7 +113,11 @@ void LowerSwitchPass::processSwitchInst(SwitchInst *SI) {
// if-then statements go to this and the PHI nodes are happy.
BasicBlock* newDefault = BasicBlock::Create(getGlobalContext(), "newDefault");
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ F->getBasicBlockList().insert(defaultBlock->getIterator(), newDefault);
+#else
F->getBasicBlockList().insert(defaultBlock, newDefault);
+#endif
BranchInst::Create(defaultBlock, newDefault);
// 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
--- 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
AE = archive->child_end();
AI != AE; ++AI)
#else
-
for (object::Archive::child_iterator AI = archive->begin_children(),
AE = archive->end_children();
AI != AE; ++AI)
#endif
{
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+ std::error_code ec;
+#else
+ error_code ec;
+#endif
StringRef memberName;
+
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ ErrorOr<object::Archive::Child> child = *AI;
+ ec = child.getError();
+ if (ec) {
+ errorMessage = ec.message();
+ return false;
+ }
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+ object::Archive::child_iterator child = AI;
+#endif
+
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- ErrorOr<StringRef> errorOr_memberName = AI->getName();
- std::error_code ec = errorOr_memberName.getError();
+ ErrorOr<StringRef> errorOr_memberName = child->getName();
+ ec = errorOr_memberName.getError();
if (!ec)
memberName = errorOr_memberName.get();
-#else
- error_code ec = AI->getName(memberName);
+#else // LLVM 3.3, 3.4
+ ec = AI->getName(memberName);
#endif
if (!ec) {
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Loading archive member " << memberName << "\n");
} else {
- errorMessage="Archive member does not have a name!\n";
+ errorMessage = "Archive member does not have a name!";
return false;
}
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- ErrorOr<std::unique_ptr<llvm::object::Binary> > child = AI->getAsBinary();
- ec = child.getError();
+ ErrorOr<std::unique_ptr<llvm::object::Binary> > childBin =
+ child->getAsBinary();
+ ec = childBin.getError();
#else
- OwningPtr<object::Binary> child;
- ec = AI->getAsBinary(child);
+ OwningPtr<object::Binary> childBin;
+ ec = AI->getAsBinary(childBin);
#endif
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();
+ ErrorOr<MemoryBufferRef> buff = child->getMemoryBufferRef();
ec = buff.getError();
#elif LLVM_VERSION_CODE == LLVM_VERSION(3, 5)
ErrorOr<std::unique_ptr<MemoryBuffer> > errorOr_buff =
- AI->getMemoryBuffer();
+ child->getMemoryBuffer();
std::unique_ptr<MemoryBuffer> buff = nullptr;
ec = errorOr_buff.getError();
if (!ec)
@@ -292,7 +309,7 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
ParseBitcodeFile(buff.get(), getGlobalContext(), &errorMessage);
#endif
if (!Result) {
- SS << "Loading module failed : " << errorMessage << "\n";
+ SS << "Loading module failed : " << errorMessage;
SS.flush();
return false;
}
@@ -301,8 +318,8 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
errorMessage = "Buffer was NULL!";
return false;
}
- } else if (child.get()->isObject()) {
- SS << "Object file " << child.get()->getFileName().data()
+ } else if (childBin.get()->isObject()) {
+ SS << "Object file " << childBin.get()->getFileName().data()
<< " in archive is not supported";
SS.flush();
return false;
@@ -346,7 +363,9 @@ 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");
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ if (Linker::linkModules(*composite, std::unique_ptr<Module>(M)))
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
if (Linker::LinkModules(composite, M))
#else
if (Linker::LinkModules(composite, M, Linker::DestroySource,
@@ -364,8 +383,10 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
// Link succeed, now clean up
modulesLoadedOnPass++;
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Linking succeeded.\n");
-
+// M was owned by linkModules function
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
delete M;
+#endif
archiveModules[i] = 0;
// We need to recompute the undefined symbols in the composite module
@@ -426,8 +447,12 @@ Module *klee::linkWithLibrary(Module *module,
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
ErrorOr<std::unique_ptr<Module> > Result = parseBitcodeFile(buff, Context);
-
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ if ((ec = Buffer.getError()) ||
+ Linker::linkModules(*module, std::move(Result.get())))
+#else
if ((ec = Buffer.getError()) || Linker::LinkModules(module, Result->get()))
+#endif
klee_error("Link with library %s failed: %s", libraryName.c_str(),
ec.message().c_str());
#else // LLVM 3.5, 3.6
@@ -487,7 +512,7 @@ Module *klee::linkWithLibrary(Module *module,
#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
error_code ec;
OwningPtr<MemoryBuffer> Buffer;
- if (ec = MemoryBuffer::getFile(libraryName, Buffer)) {
+ if ((ec = MemoryBuffer::getFile(libraryName, Buffer))) {
klee_error("Link with library %s failed: %s", libraryName.c_str(),
ec.message().c_str());
}
@@ -510,7 +535,7 @@ Module *klee::linkWithLibrary(Module *module,
} else if (magic == sys::fs::file_magic::archive) {
OwningPtr<object::Binary> arch;
- if (ec = object::createBinary(Buffer.take(), arch))
+ if ((ec = object::createBinary(Buffer.take(), arch)))
klee_error("Link with library %s failed: %s", libraryName.c_str(),
ec.message().c_str());
diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp
index 3eca0db6c174..e6a6c35e9ce2 100644
--- a/lib/Module/Optimize.cpp
+++ b/lib/Module/Optimize.cpp
@@ -126,7 +126,12 @@ static void AddStandardCompilePasses(PassManager &PM) {
addPass(PM, createCFGSimplificationPass()); // Clean up after IPCP & DAE
addPass(PM, createPruneEHPass()); // Remove dead EH info
- addPass(PM, createFunctionAttrsPass()); // Deduce function attrs
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ addPass(PM, createPostOrderFunctionAttrsPass());
+ addPass(PM, createReversePostOrderFunctionAttrsPass());
+#else
+ addPass(PM, createFunctionAttrsPass()); // Deduce function attrs
+#endif
if (!DisableInline)
addPass(PM, createFunctionInliningPass()); // Inline small functions
@@ -258,8 +263,14 @@ void Optimize(Module *M, const std::string &EntryPoint) {
addPass(Passes, createScalarReplAggregatesPass()); // Break up allocas
// Run a few AA driven optimizations here and now, to cleanup the code.
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ addPass(Passes, createPostOrderFunctionAttrsPass());
+ addPass(Passes, createReversePostOrderFunctionAttrsPass());
+ // addPass(Passes, createGlobalsAAWrapperPass());
+#else
addPass(Passes, createFunctionAttrsPass()); // Add nocapture
addPass(Passes, createGlobalsModRefPass()); // IP alias analysis
+#endif
addPass(Passes, createLICMPass()); // Hoist loop invariants
addPass(Passes, createGVNPass()); // Remove redundancies
diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp
index a2972ce7ee9b..c820736f5d66 100644
--- a/lib/Module/RaiseAsm.cpp
+++ b/lib/Module/RaiseAsm.cpp
@@ -126,7 +126,11 @@ bool RaiseAsmPass::runOnModule(Module &M) {
for (Module::iterator fi = M.begin(), fe = M.end(); fi != fe; ++fi) {
for (Function::iterator bi = fi->begin(), be = fi->end(); bi != be; ++bi) {
for (BasicBlock::iterator ii = bi->begin(), ie = bi->end(); ii != ie;) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto i = static_cast<Instruction *>(ii);
+#else
Instruction *i = ii;
+#endif
++ii;
changed |= runOnInstruction(M, i);
}
diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp
index 9265abe04820..80af2c253997 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -313,7 +313,12 @@ KleeHandler::KleeHandler(int argc, char **argv)
for (; i <= INT_MAX; ++i) {
SmallString<128> d(directory);
llvm::sys::path::append(d, "klee-out-");
- raw_svector_ostream ds(d); ds << i; ds.flush();
+ raw_svector_ostream ds(d);
+ ds << i;
+// SmallString is always up-to-date, no need to flush. See Support/raw_ostream.h
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
+ ds.flush();
+#endif
// create directory and try to link klee-last
if (mkdir(d.c_str(), 0775) == 0) {
@@ -690,11 +695,17 @@ static int initEnv(Module *mainModule) {
if (mainFn->arg_size() < 2) {
klee_error("Cannot handle ""--posix-runtime"" when main() has less than two arguments.\n");
}
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto firstInst = static_cast<Instruction *>(mainFn->begin()->begin());
- Instruction* firstInst = mainFn->begin()->begin();
+ auto oldArgc = static_cast<Argument *>(mainFn->arg_begin());
+ auto oldArgv = static_cast<Argument *>(++mainFn->arg_begin());
+#else
+ Instruction *firstInst = mainFn->begin()->begin();
- Value* oldArgc = mainFn->arg_begin();
- Value* oldArgv = ++mainFn->arg_begin();
+ Value *oldArgc = mainFn->arg_begin();
+ Value *oldArgv = ++mainFn->arg_begin();
+#endif
AllocaInst* argcPtr =
new AllocaInst(oldArgc->getType(), "argcPtr", firstInst);
@@ -1099,7 +1110,11 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule, StringRef libDir)
// naming conflict.
for (Module::iterator fi = mainModule->begin(), fe = mainModule->end();
fi != fe; ++fi) {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ auto f = static_cast<Function *>(fi);
+#else
Function *f = fi;
+#endif
const std::string &name = f->getName();
if (name[0]=='\01') {
unsigned size = name.size();
@@ -1158,8 +1173,13 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule, StringRef libDir)
std::vector<llvm::Value*> args;
args.push_back(llvm::ConstantExpr::getBitCast(userMainFn,
ft->getParamType(0)));
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ args.push_back(static_cast<Argument *>(stub->arg_begin())); // argc
+ args.push_back(static_cast<Argument *>(++stub->arg_begin())); // argv
+#else
args.push_back(stub->arg_begin()); // argc
args.push_back(++stub->arg_begin()); // argv
+#endif
args.push_back(Constant::getNullValue(ft->getParamType(3))); // app_init
args.push_back(Constant::getNullValue(ft->getParamType(4))); // app_fini
args.push_back(Constant::getNullValue(ft->getParamType(5))); // rtld_fini
@@ -1301,7 +1321,11 @@ int main(int argc, char **argv, char **envp) {
#else
mainModule = *mainModuleOrError;
#endif
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ if (auto ec = mainModule->materializeAll()) {
+#else
if (auto ec = mainModule->materializeAllPermanently()) {
+#endif
klee_error("error loading program '%s': %s", InputFile.c_str(),
ec.message().c_str());
}
--
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">28872c1a0cb8a8f6b835af67719b9cd9aba66d3f</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:3742053b828c281cddc02058e5f5e346d6fe5c990a9602e5a0ad8679c17010d9
size 648972

View File

@ -1,2 +1,3 @@
addFilter("shlib-policy-name-error.*libkleeRuntest1_0")
addFilter("binaryinfo-readelf-failed.*bca")
addFilter("devel-file-in-non-devel-package")

View File

@ -1,3 +1,112 @@
-------------------------------------------------------------------
Wed Apr 26 09:18:55 UTC 2017 - jslaby@suse.com
- Update to version 1.3.0+20170409:
* [TravisCI] Check if `METASMT_VERSION` is set and abort if it is not set. Also exit if any of the commands in `.travis/metaSMT.sh` fail.
* [TravisCI] Try to unbreak the metaSMT build.
* [TravisCI] Try unbreaking the TravisCI metaSMT build. Copying across the `cmake` directory breaks KLEE's CMake build.
* [CMake] Try to fix bug reported by #633.
* [CMake] Fix #631
* [CMake] When supported pass `USES_TERMINAL` argument to `ExternalProject_Add_Step()` so that when using Ninja the output of the bitcode build system is shown immediately.
* [CMake] Add the `clean_runtime` top level target to provide an easy way to clean the runtime build.
* [Docker] Unbreak build.
* [TravisCI] Make handling of `TRAVIS_OS_NAME` more robust by not assuming that its value not being `linux` implies `osx`.
* test: lit, add geq/lt-llvm- configs
* [NFC] Reindent `test/lit.cfg` and add vim mode line to use right indentation and syntax highlighting.
* [travis] fix a git submodule failure of metaSMT
* [CMake] Don't redownload FileCheck.cpp if it exists
* Removed unused variable 'fake_object' in MemoryObject
-------------------------------------------------------------------
Tue Mar 28 13:43:30 UTC 2017 - jslaby@suse.com
- Update to version 1.3.0+20170328:
* runtime: POSIX, make it compile with glibc 2.25
* [Lit] Add system information (linux/darwim) to LIT configuration. Added 'not-*' features that exist if target operating system does not match a list of know operating systems.
* Fix test case for OSX: only weak aliases are supported on darwin Rewritten tests by replacing 'XFAIL: darwin' with 'REQUIRES: not-darwin'
* test: fix 'not' build
* test: POSIX, stop FD_Fail to fail
* runtime: POSIX, check path prior dereference
* [travis] use a proper version of metaSMT via environment variable METASMT_VERSION
* [travis] build metaSMT without C++11
* remove special handling of metaSMT_CXXFLAGS (unnecessary now as we use a fixed version of metaSMT with this flag being properly set)
* [WIP] Fix bug where stats would not be updated on early exit caused by finding a bug with the `-exit-on-error` option enabled.
* Replace `llvm:errs()` with `klee_error()` as suggested by @andreamattavelli
* Add test case to check that on early exits stats are flushed
* Add `AssignmentValidatingSolver`. It's purpose is to check any computed assignments against the corresponding `Query` object and check the assignment evaluates correctly.
* [CMake] Unbreak build due to not adding AssignmentValidatingSolver.cpp to list of source files.
* [Travis-CI] Refactored Z3 in its own script
* [Travis-CI] Added support for macOS build
- enable checking of the result (%check section), only on x86_64
- add some patches
* 0001-errno-define-__errno_location.patch
* 0001-test-DirSeek-make-it-XFAIL-temporarily.patch
* 0001-test-add-versions-of-some-tests-for-LLVM-3.8.patch
- renamed patches
* 0005-Make-KLEE-compile-against-LLVM-3.7.patch
-> 0002-Make-KLEE-compile-against-LLVM-3.7.patch
* 0006-Make-KLEE-compile-against-LLVM-3.8.patch
-> 0003-Make-KLEE-compile-against-LLVM-3.8.patch
- deleted patches (they are upstream)
* 0001-runtime-POSIX-make-it-compile-with-glibc-2.25.patch
* 0002-Fix-compiler-warning.patch
* 0004-Cleanup-removed-unneccessary-bools.patch
* 0007-fix-compilation-on-LLVM-3.8-after-rebase-to-master.patch
-------------------------------------------------------------------
Wed Mar 15 12:57:25 UTC 2017 - jslaby@suse.com
- add 0001-runtime-POSIX-make-it-compile-with-glibc-2.25.patch
- Update to version 1.3.0+20170307:
* klee: remove use of deprecated 'register'
* Makefile: change -std-compile-opts to -O3
* CommandLine: do not copy list in optionIsSet
* Teach KLEE to respect the requested memory alignment of globals and stack variables when possible.
* llvm: stop using global context
* Module: simplify is_object checks
* convert iterators using static_cast
* Core: MCJIT functions need unique names
* Added new option --warnings-only-to-file which causes warnings to be written to warnings.txt only. Disabled by default.
* Updated test cases that check warning messages.
* Core: explicitly create CallSite from Instruction
* fix for PathOS.id
* Using klee_message instead of llvm:errs
* Moved printFileLine() to be part of KInstruction
* test: POSIX/DirSeek, cleanup
* test: ConstantExpr, fix bogus test
-------------------------------------------------------------------
Thu Mar 2 14:11:06 UTC 2017 - jslaby@suse.com
- enable uclibc & POSIX runtime
- add some %doc files
-------------------------------------------------------------------
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

@ -15,33 +15,44 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define llvm_version 3_8
%define llvm_version_major 3
%define llvm_version_minor 8
%define llvm_version %{llvm_version_major}_%{llvm_version_minor}
%define version_unconverted 1.3.0+20170211
%define version_unconverted 1.3.0+20170409
%ifarch %{ix86} x86_64
%define with_uclibc 1
%else
%define with_uclibc 0
%endif
Name: klee
Summary: LLVM Execution Engine
License: NCSA
Group: Development/Languages/Other
Version: 1.3.0+20170211
Version: 1.3.0+20170409
Release: 0
Url: http://klee.github.io/
Source0: %{name}-%{version}.tar.xz
Source1: %{name}-rpmlintrc
Source2: https://raw.githubusercontent.com/llvm-mirror/llvm/release_%{llvm_version_major}%{llvm_version_minor}/utils/not/not.cpp
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
BuildRequires: bison
Patch1: 0002-Make-KLEE-compile-against-LLVM-3.7.patch
Patch2: 0003-Make-KLEE-compile-against-LLVM-3.8.patch
Patch3: 0001-test-add-versions-of-some-tests-for-LLVM-3.8.patch
Patch4: 0001-errno-define-__errno_location.patch
Patch5: 0001-test-DirSeek-make-it-XFAIL-temporarily.patch
BuildRequires: clang%{llvm_version}
BuildRequires: cmake
BuildRequires: flex
BuildRequires: gperftools-devel
%if %{with_uclibc}
BuildRequires: klee-uclibc-devel-static
%endif
BuildRequires: libacl-devel
BuildRequires: libcap-devel
BuildRequires: libselinux-devel
BuildRequires: lit
BuildRequires: llvm%{llvm_version}-devel
BuildRequires: ninja
BuildRequires: python-base
@ -58,10 +69,12 @@ information on what KLEE is and what it can do, see the OSDI 2008 paper.
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
mkdir -p build/test/
cp %{SOURCE2} build/test/
%build
%define __builder ninja
@ -74,12 +87,23 @@ information on what KLEE is and what it can do, see the OSDI 2008 paper.
-DENABLE_SOLVER_STP=ON \
-DENABLE_TCMALLOC=ON \
-DENABLE_UNIT_TESTS=OFF \
-DENABLE_SYSTEM_TESTS=OFF \
-DENABLE_SYSTEM_TESTS=ON \
-DCMAKE_C_FLAGS="%optflags" \
-DCMAKE_CXX_FLAGS="%optflags" \
%if %{with_uclibc}
-DENABLE_POSIX_RUNTIME=ON \
-DENABLE_KLEE_UCLIBC=ON \
-DKLEE_UCLIBC_PATH=%{_libdir}/klee-uclibc/ \
%endif
-DBUILD_SHARED_LIBS:BOOL=OFF
%make_jobs
%check
%ifarch x86_64
cd build
ninja check
%endif
%install
%cmake_install
@ -89,6 +113,7 @@ information on what KLEE is and what it can do, see the OSDI 2008 paper.
%files
%defattr(-,root,root)
%doc LICENSE.TXT NEWS README.md TODO.txt
%{_bindir}/gen-random-bout
%{_bindir}/kleaver
%{_bindir}/klee
@ -99,6 +124,11 @@ information on what KLEE is and what it can do, see the OSDI 2008 paper.
%{_libdir}/libkleeRuntest.so*
%dir %{_libdir}/klee/
%dir %{_libdir}/klee/runtime/
%{_libdir}/klee/runtime/klee*.bc
%{_libdir}/klee/runtime/klee-libc.bc
%{_libdir}/klee/runtime/kleeRuntimeIntrinsic.bc
%if %{with_uclibc}
%{_libdir}/klee/runtime/klee-uclibc.bca
%{_libdir}/klee/runtime/libkleeRuntimePOSIX.bca
%endif
%changelog

64
not.cpp Normal file
View File

@ -0,0 +1,64 @@
//===- not.cpp - The 'not' testing tool -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
// Usage:
// not cmd
// Will return true if cmd doesn't crash and returns false.
// not --crash cmd
// Will return true if cmd crashes (e.g. for testing crash reporting).
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
int main(int argc, const char **argv) {
bool ExpectCrash = false;
++argv;
--argc;
if (argc > 0 && StringRef(argv[0]) == "--crash") {
++argv;
--argc;
ExpectCrash = true;
}
if (argc == 0)
return 1;
auto Program = sys::findProgramByName(argv[0]);
if (!Program) {
errs() << "Error: Unable to find `" << argv[0]
<< "' in PATH: " << Program.getError().message() << "\n";
return 1;
}
std::string ErrMsg;
int Result = sys::ExecuteAndWait(*Program, argv, nullptr, nullptr, 0, 0,
&ErrMsg);
#ifdef _WIN32
// Handle abort() in msvcrt -- It has exit code as 3. abort(), aka
// unreachable, should be recognized as a crash. However, some binaries use
// exit code 3 on non-crash failure paths, so only do this if we expect a
// crash.
if (ExpectCrash && Result == 3)
Result = -3;
#endif
if (Result < 0) {
errs() << "Error: " << ErrMsg << "\n";
if (ExpectCrash)
return 0;
return 1;
}
if (ExpectCrash)
return 1;
return Result == 0;
}