Jiri Slaby 2017-03-16 16:19:41 +00:00 committed by Git OBS Bridge
parent bcb81be84f
commit e862f96ab7
9 changed files with 481 additions and 1368 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,65 @@
From: Jiri Slaby <jirislaby@gmail.com>
Date: Wed, 15 Mar 2017 13:42:26 +0100
Subject: runtime: POSIX, make it compile with glibc 2.25
Patch-mainline: no
With glibc 2.25, we see:
runtime/POSIX/stubs.c:243:14: error: conflicting types for 'gnu_dev_major'
unsigned int gnu_dev_major(unsigned long long int __dev) __attribute__((weak));
^
/usr/include/sys/sysmacros.h:79:27: note: previous definition is here
__SYSMACROS_DEFINE_MAJOR (__SYSMACROS_IMPL_TEMPL)
^
Glibc 2.25 switched from ULL to dev_t for gnu_dev_major, gnu_dev_minor,
and gnu_dev_makedev. Handle by using an appropriate type according to
the glibc version.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
runtime/POSIX/stubs.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/runtime/POSIX/stubs.c b/runtime/POSIX/stubs.c
index b4f31bf7d109..bb528ad4a263 100644
--- a/runtime/POSIX/stubs.c
+++ b/runtime/POSIX/stubs.c
@@ -240,21 +240,27 @@ int strverscmp (__const char *__s1, __const char *__s2) {
return strcmp(__s1, __s2); /* XXX no doubt this is bad */
}
-unsigned int gnu_dev_major(unsigned long long int __dev) __attribute__((weak));
-unsigned int gnu_dev_major(unsigned long long int __dev) {
+#if __GLIBC_PREREQ(2, 25)
+#define gnu_dev_type dev_t
+#else
+#define gnu_dev_type unsigned long long int
+#endif
+
+unsigned int gnu_dev_major(gnu_dev_type __dev) __attribute__((weak));
+unsigned int gnu_dev_major(gnu_dev_type __dev) {
return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
}
-unsigned int gnu_dev_minor(unsigned long long int __dev) __attribute__((weak));
-unsigned int gnu_dev_minor(unsigned long long int __dev) {
+unsigned int gnu_dev_minor(gnu_dev_type __dev) __attribute__((weak));
+unsigned int gnu_dev_minor(gnu_dev_type __dev) {
return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
}
-unsigned long long int gnu_dev_makedev(unsigned int __major, unsigned int __minor) __attribute__((weak));
-unsigned long long int gnu_dev_makedev(unsigned int __major, unsigned int __minor) {
+gnu_dev_type gnu_dev_makedev(unsigned int __major, unsigned int __minor) __attribute__((weak));
+gnu_dev_type gnu_dev_makedev(unsigned int __major, unsigned int __minor) {
return ((__minor & 0xff) | ((__major & 0xfff) << 8)
- | (((unsigned long long int) (__minor & ~0xff)) << 12)
- | (((unsigned long long int) (__major & ~0xfff)) << 32));
+ | (((gnu_dev_type) (__minor & ~0xff)) << 12)
+ | (((gnu_dev_type) (__major & ~0xfff)) << 32));
}
char *canonicalize_file_name (const char *name) __attribute__((weak));
--
2.12.0

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,48 +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 ded85f950fe4..ae12708c130c 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -167,8 +167,9 @@ static bool instructionIsCoverable(Instruction *i) {
} else {
Instruction *prev = --it;
if (isa<CallInst>(prev) || isa<InvokeInst>(prev)) {
+ CallSite cs(prev);
Function *target =
- getDirectCallTarget(prev, /*moduleIsFullyLinked=*/true);
+ getDirectCallTarget(cs, /*moduleIsFullyLinked=*/true);
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,
@ -123,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);
@ -153,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 @@
@ -169,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.
@ -181,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?
@ -194,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 537c9aba4b6f..2aa9b8e6b0ab 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 @@
@ -292,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.
@ -306,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());
@ -353,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();
}
@ -381,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

@ -1,108 +1,24 @@
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
Subject: llvm: 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>
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
lib/Core/Executor.cpp | 47 ++++++++++++++++++++------
lib/Core/StatsTracker.cpp | 66 +++++++++++++++++++++++++++---------
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, 282 insertions(+), 88 deletions(-)
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 80b8289d1486..b3ec990dc9ae 100644
index 4148ca22caf3..794346e0950d 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -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)
+ 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
@@ -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)
+ 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
@@ -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());
}
-
- 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.
@@ -667,8 +675,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();
@@ -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
- // 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
@@ -688,7 +701,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);
@@ -2303,8 +2321,13 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
@@ -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());
@ -116,258 +32,27 @@ index 80b8289d1486..b3ec990dc9ae 100644
#else
llvm::APFloat Res(left->getAPValue());
Res.mod(APFloat(right->getAPValue()), APFloat::rmNearestTiesToEven);
@@ -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());
-
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ Instruction *first = static_cast<Instruction *>(f->begin()->begin());
+#else
+ 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 ae12708c130c..fff266aca19b 100644
index b93796ecdff7..fc4cb786e902 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)
+ Instruction *prev = static_cast<Instruction *>(--it);
+#else
Instruction *prev = --it;
+#endif
if (isa<CallInst>(prev) || isa<InvokeInst>(prev)) {
CallSite cs(prev);
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)
+ Function *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;
@@ -639,9 +648,17 @@ static std::vector<Instruction*> getSuccs(Instruction *i) {
if (i==bb->getTerminator()) {
@@ -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)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ res.push_back(static_cast<Instruction *>(it->begin()));
+#else
res.push_back(it->begin());
+#endif
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(++BasicBlock::iterator(i));
res.push_back(static_cast<Instruction *>(++BasicBlock::iterator(i)));
+#endif
}
return res;
@@ -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)
+ Instruction *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,
+ 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 {
- callTargets[it] =
- std::vector<Function*>(km->escapingFunctions.begin(),
- km->escapingFunctions.end());
+ callTargets[inst] = std::vector<Function *>(
+ km->escapingFunctions.begin(), km->escapingFunctions.end());
}
}
}
@@ -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)
+ Function *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.
@@ -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)
+ Instruction *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)
@@ -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)
+ Instruction *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..52238786f49e 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)
+ Function *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
index 9af6f9f40f21..1e43463e6a5c 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -79,8 +79,12 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
@@ -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);
@ -376,12 +61,9 @@ index 66e9392a618d..8ec47195dd3b 100644
+ BasicBlock::iterator i_ = i;
+#endif
// increment now since LowerIntrinsic deletion makes iterator invalid.
- ++i;
+ ++i;
++i;
if(ii) {
switch (ii->getIntrinsicID()) {
case Intrinsic::vastart:
@@ -141,8 +145,12 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
@@ -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: {
@ -395,171 +77,14 @@ index 66e9392a618d..8ec47195dd3b 100644
Value *op1 = ii->getArgOperand(0);
Value *op2 = ii->getArgOperand(1);
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index cc328b1bb974..75e92804c91d 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)
+ BasicBlock *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)
+ Function *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)
+ BasicBlock *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)
+ Instruction *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..7cdd5fba2bf8 100644
index 5cc6b991c6d1..4a5658912a0c 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)
+ BasicBlock *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,
@@ -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(getGlobalContext(), "NodeBlock");
BasicBlock *newBlock = BasicBlock::Create(F->getContext(), "NodeBlock");
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ Function::iterator FI = origBlock->getIterator();
+#else
@ -568,9 +93,9 @@ index a98b84add5d7..7cdd5fba2bf8 100644
F->getBasicBlockList().insert(++FI, newBlock);
ICmpInst *cmpInst =
@@ -104,7 +113,11 @@ void LowerSwitchPass::processSwitchInst(SwitchInst *SI) {
@@ -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(getGlobalContext(), "newDefault");
BasicBlock* newDefault = BasicBlock::Create(F->getContext(), "newDefault");
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
+ F->getBasicBlockList().insert(defaultBlock->getIterator(), newDefault);
@ -581,113 +106,62 @@ index a98b84add5d7..7cdd5fba2bf8 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 2aa9b8e6b0ab..1e62498dc845 100644
index de0130a2632c..6b50b037bc65 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
@@ -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> child = *AI;
+ ec = child.getError();
+ ErrorOr<object::Archive::Child> childErr = *AI;
+ ec = childErr.getError();
+ if (ec) {
+ errorMessage = ec.message();
+ return false;
+ }
+#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+ object::Archive::child_iterator child = AI;
+#else
+ object::Archive::child_iterator childErr = 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
+ ErrorOr<StringRef> memberNameErr = childErr->getName();
+ ec = memberNameErr.getError();
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;
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();
- ec = child.getError();
+ ErrorOr<std::unique_ptr<llvm::object::Binary> > childBin =
+ child->getAsBinary();
+ ec = childBin.getError();
+ ErrorOr<std::unique_ptr<llvm::object::Binary> > child =
+ childErr->getAsBinary();
ec = child.getError();
#else
- OwningPtr<object::Binary> child;
- ec = AI->getAsBinary(child);
+ OwningPtr<object::Binary> childBin;
+ ec = AI->getAsBinary(childBin);
#endif
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 = child->getMemoryBufferRef();
+ ErrorOr<MemoryBufferRef> buff = childErr->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
#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,
@@ -364,8 +383,10 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
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");
@ -699,40 +173,36 @@ index 2aa9b8e6b0ab..1e62498dc845 100644
archiveModules[i] = 0;
// We need to recompute the undefined symbols in the composite module
@@ -426,8 +447,12 @@ Module *klee::linkWithLibrary(Module *module,
@@ -445,7 +461,9 @@ Module *klee::linkWithLibrary(Module *module,
std::string ErrorMessage;
#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()))
if (magic == sys::fs::file_magic::bitcode) {
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
Module *Result = 0;
+#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,
#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());
}
} 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());
-#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 3eca0db6c174..e6a6c35e9ce2 100644
index 68acd2b17dda..46ab7d028224 100644
--- a/lib/Module/Optimize.cpp
+++ b/lib/Module/Optimize.cpp
@@ -126,7 +126,12 @@ static void AddStandardCompilePasses(PassManager &PM) {
@ -749,7 +219,7 @@ index 3eca0db6c174..e6a6c35e9ce2 100644
if (!DisableInline)
addPass(PM, createFunctionInliningPass()); // Inline small functions
@@ -258,8 +263,14 @@ void Optimize(Module *M, const std::string &EntryPoint) {
@@ -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.
@ -764,27 +234,11 @@ index 3eca0db6c174..e6a6c35e9ce2 100644
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
index 20b1e33a6617..4acefbf8c4de 100644
--- a/tools/klee/main.cpp
+++ b/tools/klee/main.cpp
@@ -313,7 +313,12 @@ KleeHandler::KleeHandler(int argc, char **argv)
@@ -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-");
@ -798,54 +252,7 @@ index 9265abe04820..80af2c253997 100644
// 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) {
@@ -1296,7 +1301,11 @@ int main(int argc, char **argv, char **envp) {
#else
mainModule = *mainModuleOrError;
#endif
@ -858,5 +265,5 @@ index 9265abe04820..80af2c253997 100644
ec.message().c_str());
}
--
2.11.1
2.12.0

View File

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

View File

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

View File

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

View File

@ -1,3 +1,25 @@
-------------------------------------------------------------------
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

View File

@ -17,7 +17,7 @@
%define llvm_version 3_8
%define version_unconverted 1.3.0+20170221
%define version_unconverted 1.3.0+20170307
%ifarch %{ix86} x86_64
%define with_uclibc 1
@ -29,7 +29,7 @@ Name: klee
Summary: LLVM Execution Engine
License: NCSA
Group: Development/Languages/Other
Version: 1.3.0+20170221
Version: 1.3.0+20170307
Release: 0
Url: http://klee.github.io/
Source0: %{name}-%{version}.tar.xz
@ -37,6 +37,7 @@ Source1: %{name}-rpmlintrc
Patch0: 0001-Make-KLEE-compile-against-LLVM-3.5-and-3.6.patch
Patch1: 0002-Make-KLEE-compile-against-LLVM-3.7.patch
Patch2: 0003-Make-KLEE-compile-against-LLVM-3.8.patch
Patch3: 0001-runtime-POSIX-make-it-compile-with-glibc-2.25.patch
BuildRequires: bison
BuildRequires: clang%{llvm_version}
BuildRequires: cmake
@ -65,6 +66,7 @@ information on what KLEE is and what it can do, see the OSDI 2008 paper.
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
%define __builder ninja