Hello community, here is the log from the commit of package klee for openSUSE:Factory checked in at 2017-06-12 15:32:07 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/klee (Old) and /work/SRC/openSUSE:Factory/.klee.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "klee" Mon Jun 12 15:32:07 2017 rev:3 rq:502372 version:1.3.0+20170607 Changes: -------- --- /work/SRC/openSUSE:Factory/klee/klee.changes 2017-04-28 09:13:52.941183343 +0200 +++ /work/SRC/openSUSE:Factory/.klee.new/klee.changes 2017-06-12 15:32:17.733513096 +0200 @@ -1,0 +2,56 @@ +Thu Jun 08 08:48:58 UTC 2017 - [email protected] + +- Build against LLVM 4 +- Update to version 1.3.0+20170607: + * Fix test failure on systems with libstdc++ corresponding to gcc7. + * llvm: rename ExitOnError to OptExitOnError + * Prevent test failure when realloc fails in test/Feature/Realloc.c +- added patches: + 0001-llvm-don-t-use-clEnumValEnd-for-LLVM-4.0.patch + 0002-llvm-get-rid-of-static_casts-from-iterators.patch + 0003-Core-TimingSolver-use-WallTimer.patch + 0004-llvm-make-KLEE-compile-against-LLVM-3.7.patch + 0005-llvm-make-KLEE-compile-against-LLVM-3.8.patch + 0006-llvm-make-KLEE-compile-against-LLVM-3.9.patch + 0007-test-add-versions-of-some-tests-for-LLVM-3.8.patch + 0008-travis-CI-add-LLVM-3.8-build-tests.patch + 0009-llvm40-handle-different-header-names.patch + 0010-llvm-APFloat-members-are-functions-in-LLVM-4.0.patch + 0011-llvm40-errorOr-and-similar.patch + 0012-llvm-use-chrono-helpers-from-LLVM-4.0.patch + 0013-llvm-PointerType-is-not-SequentialType-in-LLVM-4.patch +- removed patches (renamed to the above): + 0001-test-add-versions-of-some-tests-for-LLVM-3.8.patch + 0002-Make-KLEE-compile-against-LLVM-3.7.patch + 0003-Make-KLEE-compile-against-LLVM-3.8.patch + +------------------------------------------------------------------- +Mon Jun 05 07:45:51 UTC 2017 - [email protected] + +- Update to version 1.3.0+20170602: + * use METASMT_REQUIRE_RTTI flag to decide whether we need RTTI + * [travis] add environment variable METASMT_BOOST_VERSION to control the boost version used by metaSMT and test it with the combination LLVM-2.9 + metaSMT + * [CMake] change WARNING to FATAL_ERROR when building with a non-RTTI LLVM version and a metaSMT version that requires RTTI + * [TravisCI] Try to unbreak the build against upstream STP. + * Remove redundant KLEE prefix while logging + * llvm: make KLEE compile against LLVM 3.5 and 3.6 + * travis CI: add LLVM 3.5 and 3.6 tests + * Rearchitect ExternalDispatcher + * gitignore build + * [Z3] Support another solver failure reason that Z3 might give. I'm going to guess it means timeout but I'm not 100% sure about this. + * [Z3] Add assertions in Z3 builder to catch underflow with bad widths. + * [Z3] Move the `dump()` methods of the Z3NodeHandle<> specializations into `Z3Builder.cpp` so they can be called from in gdb. + * Refactor file opening code out of `main.cpp` and into `klee_open_output_file()` function so that it can be used by the Z3Solver. + * [Z3] Add the `-debug-z3-dump-queries=<path>` command line option. This is useful for getting access to the constraints being stored in the Z3 solver in the SMT-LIBv2.5 format. + * [Z3] Add option to manually validate Z3 models. + * [Z3] Implement API logging. + * [Z3] In `getConstraintLog()` use a separate builder from that of the solver. This is to avoid tampering with the cache of the builder the solver is using. + * [Z3] Switch from `Z3_mk_simple_solver()` to `Z3_mk_solver()`. + * [Z3] Add `-debug-z3-verbosity=<N>` option which behaves like Z3's `-v:<N>` option. This lets us see what Z3 is doing execution (e.g. which tactic is being applied) which is very useful for debugging. + * [Z3] Remove unused include. + * replace handleMetaSMT() with klee::createMetaSMTSolver() and move it into MetaSMTSolver.cpp so that the backend headers only need to be included once there + * hide backend solver declarations from public include +- remove 0001-Make-KLEE-compile-against-LLVM-3.5-and-3.6.patch + It is upstream already. + +------------------------------------------------------------------- Old: ---- 0001-Make-KLEE-compile-against-LLVM-3.5-and-3.6.patch 0001-test-add-versions-of-some-tests-for-LLVM-3.8.patch 0002-Make-KLEE-compile-against-LLVM-3.7.patch 0003-Make-KLEE-compile-against-LLVM-3.8.patch klee-1.3.0+20170409.tar.xz New: ---- 0001-llvm-don-t-use-clEnumValEnd-for-LLVM-4.0.patch 0002-llvm-get-rid-of-static_casts-from-iterators.patch 0003-Core-TimingSolver-use-WallTimer.patch 0004-llvm-make-KLEE-compile-against-LLVM-3.7.patch 0005-llvm-make-KLEE-compile-against-LLVM-3.8.patch 0006-llvm-make-KLEE-compile-against-LLVM-3.9.patch 0007-test-add-versions-of-some-tests-for-LLVM-3.8.patch 0008-travis-CI-add-LLVM-3.8-build-tests.patch 0009-llvm40-handle-different-header-names.patch 0010-llvm-APFloat-members-are-functions-in-LLVM-4.0.patch 0011-llvm40-errorOr-and-similar.patch 0012-llvm-use-chrono-helpers-from-LLVM-4.0.patch 0013-llvm-PointerType-is-not-SequentialType-in-LLVM-4.patch FileCheck.cpp klee-1.3.0+20170607.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ klee.spec ++++++ --- /var/tmp/diff_new_pack.Y5J6ge/_old 2017-06-12 15:32:19.273295928 +0200 +++ /var/tmp/diff_new_pack.Y5J6ge/_new 2017-06-12 15:32:19.273295928 +0200 @@ -15,11 +15,11 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # -%define llvm_version_major 3 -%define llvm_version_minor 8 -%define llvm_version %{llvm_version_major}_%{llvm_version_minor} +%define llvm_version_major 4 +%define llvm_version_minor 0 +%define llvm_version %{llvm_version_major} -%define version_unconverted 1.3.0+20170409 +%define version_unconverted 1.3.0+20170607 %ifarch %{ix86} x86_64 %define with_uclibc 1 @@ -31,23 +31,34 @@ Summary: LLVM Execution Engine License: NCSA Group: Development/Languages/Other -Version: 1.3.0+20170409 +Version: 1.3.0+20170607 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-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 +Source3: https://raw.githubusercontent.com/llvm-mirror/llvm/release_%{llvm_version_major}%{llvm_version_minor}/utils/FileCheck/FileCheck.cpp +Patch0: 0001-errno-define-__errno_location.patch +Patch1: 0001-test-DirSeek-make-it-XFAIL-temporarily.patch +Patch2: 0001-llvm-don-t-use-clEnumValEnd-for-LLVM-4.0.patch +Patch3: 0002-llvm-get-rid-of-static_casts-from-iterators.patch +Patch4: 0003-Core-TimingSolver-use-WallTimer.patch +Patch5: 0004-llvm-make-KLEE-compile-against-LLVM-3.7.patch +Patch6: 0005-llvm-make-KLEE-compile-against-LLVM-3.8.patch +Patch7: 0006-llvm-make-KLEE-compile-against-LLVM-3.9.patch +Patch8: 0007-test-add-versions-of-some-tests-for-LLVM-3.8.patch +Patch9: 0008-travis-CI-add-LLVM-3.8-build-tests.patch +Patch10: 0009-llvm40-handle-different-header-names.patch +Patch11: 0010-llvm-APFloat-members-are-functions-in-LLVM-4.0.patch +Patch12: 0011-llvm40-errorOr-and-similar.patch +Patch13: 0012-llvm-use-chrono-helpers-from-LLVM-4.0.patch +Patch14: 0013-llvm-PointerType-is-not-SequentialType-in-LLVM-4.patch + BuildRequires: clang%{llvm_version} BuildRequires: cmake BuildRequires: gperftools-devel %if %{with_uclibc} -BuildRequires: klee-uclibc-devel-static +BuildRequires: klee-uclibc-devel-static(llvm%{llvm_version}) %endif BuildRequires: libacl-devel BuildRequires: libcap-devel @@ -73,8 +84,18 @@ %patch3 -p1 %patch4 -p1 %patch5 -p1 +%patch6 -p1 +%patch7 -p1 +%patch8 -p1 +%patch9 -p1 +%patch10 -p1 +%patch11 -p1 +%patch12 -p1 +%patch13 -p1 +%patch14 -p1 mkdir -p build/test/ cp %{SOURCE2} build/test/ +cp %{SOURCE3} build/test/ %build %define __builder ninja ++++++ 0001-errno-define-__errno_location.patch ++++++ --- /var/tmp/diff_new_pack.Y5J6ge/_old 2017-06-12 15:32:19.293293108 +0200 +++ /var/tmp/diff_new_pack.Y5J6ge/_new 2017-06-12 15:32:19.293293108 +0200 @@ -24,13 +24,10 @@ Signed-off-by: Jiri Slaby <[email protected]> --- - runtime/POSIX/errno_location.c | 9 +++++++++ + 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 @@ @@ -43,6 +40,3 @@ +{ + return &errno; +} --- -2.12.0 - ++++++ 0001-llvm-don-t-use-clEnumValEnd-for-LLVM-4.0.patch ++++++ From: Jiri Slaby <[email protected]> Date: Wed, 7 Jun 2017 13:32:53 +0200 Subject: llvm: don't use clEnumValEnd for LLVM 4.0 Patch-mainline: no It became unnecessary when defining options and mainly undefined. So introduce KLEE_LLVM_CL_VAL_END as suggested by @delcypher. Signed-off-by: Jiri Slaby <[email protected]> --- include/klee/Config/Version.h | 6 ++++++ lib/Basic/CmdLineOptions.cpp | 18 +++++++++--------- lib/Core/Executor.cpp | 8 ++++---- lib/Core/UserSearcher.cpp | 4 ++-- lib/Expr/ExprSMTLIBPrinter.cpp | 8 ++++---- lib/Module/KModule.cpp | 4 ++-- tools/kleaver/main.cpp | 8 ++++---- tools/klee/main.cpp | 4 ++-- 8 files changed, 33 insertions(+), 27 deletions(-) diff --git a/include/klee/Config/Version.h b/include/klee/Config/Version.h index ea2af9615f98..c1fdbb97d53d 100644 --- a/include/klee/Config/Version.h +++ b/include/klee/Config/Version.h @@ -21,4 +21,10 @@ # define LLVM_TYPE_Q const #endif +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) +# define KLEE_LLVM_CL_VAL_END +#else +# define KLEE_LLVM_CL_VAL_END , clEnumValEnd +#endif + #endif diff --git a/lib/Basic/CmdLineOptions.cpp b/lib/Basic/CmdLineOptions.cpp index 82cb01b20f73..54087c216438 100644 --- a/lib/Basic/CmdLineOptions.cpp +++ b/lib/Basic/CmdLineOptions.cpp @@ -13,6 +13,7 @@ */ #include "klee/CommandLine.h" +#include "klee/Config/Version.h" namespace klee { @@ -76,9 +77,8 @@ llvm::cl::list<QueryLoggingSolverType> queryLoggingOptions( clEnumValN(ALL_KQUERY,"all:kquery","All queries in .kquery (KQuery) format"), clEnumValN(ALL_SMTLIB,"all:smt2","All queries in .smt2 (SMT-LIBv2) format"), clEnumValN(SOLVER_KQUERY,"solver:kquery","All queries reaching the solver in .kquery (KQuery) format"), - clEnumValN(SOLVER_SMTLIB,"solver:smt2","All queries reaching the solver in .smt2 (SMT-LIBv2) format"), - clEnumValEnd - ), + clEnumValN(SOLVER_SMTLIB,"solver:smt2","All queries reaching the solver in .smt2 (SMT-LIBv2) format") + KLEE_LLVM_CL_VAL_END), llvm::cl::CommaSeparated ); @@ -106,8 +106,8 @@ llvm::cl::opt<klee::MetaSMTBackendType> MetaSMTBackend( clEnumValN(METASMT_BACKEND_STP, "stp", "Use metaSMT with STP"), clEnumValN(METASMT_BACKEND_Z3, "z3", "Use metaSMT with Z3"), clEnumValN(METASMT_BACKEND_BOOLECTOR, "btor", - "Use metaSMT with Boolector"), - clEnumValEnd), + "Use metaSMT with Boolector") + KLEE_LLVM_CL_VAL_END), llvm::cl::init(METASMT_DEFAULT_BACKEND)); #undef METASMT_DEFAULT_BACKEND @@ -140,8 +140,8 @@ llvm::cl::opt<CoreSolverType> CoreSolverToUse( llvm::cl::values(clEnumValN(STP_SOLVER, "stp", "stp" STP_IS_DEFAULT_STR), clEnumValN(METASMT_SOLVER, "metasmt", "metaSMT" METASMT_IS_DEFAULT_STR), clEnumValN(DUMMY_SOLVER, "dummy", "Dummy solver"), - clEnumValN(Z3_SOLVER, "z3", "Z3" Z3_IS_DEFAULT_STR), - clEnumValEnd), + clEnumValN(Z3_SOLVER, "z3", "Z3" Z3_IS_DEFAULT_STR) + KLEE_LLVM_CL_VAL_END), llvm::cl::init(DEFAULT_CORE_SOLVER)); llvm::cl::opt<CoreSolverType> DebugCrossCheckCoreSolverWith( @@ -153,8 +153,8 @@ llvm::cl::opt<CoreSolverType> DebugCrossCheckCoreSolverWith( clEnumValN(DUMMY_SOLVER, "dummy", "Dummy solver"), clEnumValN(Z3_SOLVER, "z3", "Z3"), clEnumValN(NO_SOLVER, "none", - "Do not cross check (default)"), - clEnumValEnd), + "Do not cross check (default)") + KLEE_LLVM_CL_VAL_END), llvm::cl::init(NO_SOLVER)); } #undef STP_IS_DEFAULT_STR diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index d71d767d7e04..49e326f7e64c 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -156,8 +156,8 @@ namespace { "inst_id]"), clEnumValN(FILE_COMPACT, "compact:file", "Log all instructions to file instructions.txt in format " - "[inst_id]"), - clEnumValEnd), + "[inst_id]") + KLEE_LLVM_CL_VAL_END), llvm::cl::CommaSeparated); #ifdef HAVE_ZLIB_H cl::opt<bool> DebugCompressInstructions( @@ -288,8 +288,8 @@ namespace { clEnumValN(Executor::ReadOnly, "ReadOnly", "Write to read-only memory"), clEnumValN(Executor::ReportError, "ReportError", "klee_report_error called"), clEnumValN(Executor::User, "User", "Wrong klee_* functions invocation"), - clEnumValN(Executor::Unhandled, "Unhandled", "Unhandled instruction hit"), - clEnumValEnd), + clEnumValN(Executor::Unhandled, "Unhandled", "Unhandled instruction hit") + KLEE_LLVM_CL_VAL_END), cl::ZeroOrMore); #if LLVM_VERSION_CODE < LLVM_VERSION(3, 0) diff --git a/lib/Core/UserSearcher.cpp b/lib/Core/UserSearcher.cpp index 725836e8bb75..2bbbe74785a3 100644 --- a/lib/Core/UserSearcher.cpp +++ b/lib/Core/UserSearcher.cpp @@ -30,8 +30,8 @@ namespace { clEnumValN(Searcher::NURS_Depth, "nurs:depth", "use NURS with 2^depth"), clEnumValN(Searcher::NURS_ICnt, "nurs:icnt", "use NURS with Instr-Count"), clEnumValN(Searcher::NURS_CPICnt, "nurs:cpicnt", "use NURS with CallPath-Instr-Count"), - clEnumValN(Searcher::NURS_QC, "nurs:qc", "use NURS with Query-Cost"), - clEnumValEnd)); + clEnumValN(Searcher::NURS_QC, "nurs:qc", "use NURS with Query-Cost") + KLEE_LLVM_CL_VAL_END)); cl::opt<bool> UseIterativeDeepeningTimeSearch("use-iterative-deepening-time-search", diff --git a/lib/Expr/ExprSMTLIBPrinter.cpp b/lib/Expr/ExprSMTLIBPrinter.cpp index e8e9a253181c..192e3461caf9 100644 --- a/lib/Expr/ExprSMTLIBPrinter.cpp +++ b/lib/Expr/ExprSMTLIBPrinter.cpp @@ -25,8 +25,8 @@ argConstantDisplayMode( clEnumValN(klee::ExprSMTLIBPrinter::HEX, "hex", "Use Hexadecimal form (e.g. #x2D)"), clEnumValN(klee::ExprSMTLIBPrinter::DECIMAL, "dec", - "Use decimal form (e.g. (_ bv45 8) )"), - clEnumValEnd), + "Use decimal form (e.g. (_ bv45 8) )") + KLEE_LLVM_CL_VAL_END), llvm::cl::init(klee::ExprSMTLIBPrinter::DECIMAL)); llvm::cl::opt<bool> humanReadableSMTLIB( @@ -44,8 +44,8 @@ llvm::cl::opt<klee::ExprSMTLIBPrinter::AbbreviationMode> abbreviationMode( clEnumValN(klee::ExprSMTLIBPrinter::ABBR_LET, "let", "Abbreviate with let"), clEnumValN(klee::ExprSMTLIBPrinter::ABBR_NAMED, "named", - "Abbreviate with :named annotations"), - clEnumValEnd), + "Abbreviate with :named annotations") + KLEE_LLVM_CL_VAL_END), llvm::cl::init(klee::ExprSMTLIBPrinter::ABBR_LET)); } diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index 45dc34bfec46..6438707ab346 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -92,8 +92,8 @@ namespace { clEnumValN(eSwitchTypeLLVM, "llvm", "lower using LLVM"), clEnumValN(eSwitchTypeInternal, "internal", - "execute switch internally"), - clEnumValEnd), + "execute switch internally") + KLEE_LLVM_CL_VAL_END), cl::init(eSwitchTypeInternal)); cl::opt<bool> diff --git a/tools/kleaver/main.cpp b/tools/kleaver/main.cpp index 3fde0abf16bf..b8b32e31264a 100644 --- a/tools/kleaver/main.cpp +++ b/tools/kleaver/main.cpp @@ -68,8 +68,8 @@ namespace { clEnumValN(PrintAST, "print-ast", "Print parsed AST nodes from the input file."), clEnumValN(Evaluate, "evaluate", - "Print parsed AST nodes from the input file."), - clEnumValEnd)); + "Print parsed AST nodes from the input file.") + KLEE_LLVM_CL_VAL_END)); enum BuilderKinds { @@ -88,8 +88,8 @@ namespace { clEnumValN(ConstantFoldingBuilder, "constant-folding", "Fold constant expressions."), clEnumValN(SimplifyingBuilder, "simplify", - "Fold constants and simplify expressions."), - clEnumValEnd)); + "Fold constants and simplify expressions.") + KLEE_LLVM_CL_VAL_END)); llvm::cl::opt<std::string> directoryToWriteQueryLogs("query-log-dir",llvm::cl::desc("The folder to write query logs to. Defaults is current working directory."), diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index b74789fa1bea..94798dad3181 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -145,8 +145,8 @@ namespace { cl::desc("Choose libc version (none by default)."), cl::values(clEnumValN(NoLibc, "none", "Don't link in a libc"), clEnumValN(KleeLibc, "klee", "Link in klee libc"), - clEnumValN(UcLibc, "uclibc", "Link in uclibc (adapted for klee)"), - clEnumValEnd), + clEnumValN(UcLibc, "uclibc", "Link in uclibc (adapted for klee)") + KLEE_LLVM_CL_VAL_END), cl::init(NoLibc)); -- 2.13.1 ++++++ 0002-llvm-get-rid-of-static_casts-from-iterators.patch ++++++ From: Jiri Slaby <[email protected]> Date: Wed, 7 Jun 2017 14:30:54 +0200 Subject: llvm: get rid of static_casts from iterators Patch-mainline: no In commit b7a6aec4eeb4 (convert iterators using static_cast), I switched all implicit casts to static_cast. It turned out that llvm 4.0 banned casting via static_cast. See e.g. 1e2bc42eb988 in the llvm repo what they do. So similarly to the above commit, change all the casts of iterators to "&*" which is what they do in LLVM. Signed-off-by: Jiri Slaby <[email protected]> --- lib/Core/Executor.cpp | 11 +++++------ lib/Core/StatsTracker.cpp | 21 ++++++++++----------- lib/Module/Checks.cpp | 4 ++-- lib/Module/InstructionInfoTable.cpp | 4 ++-- lib/Module/KModule.cpp | 12 ++++++------ lib/Module/LowerSwitch.cpp | 2 +- lib/Module/RaiseAsm.cpp | 2 +- tools/klee/main.cpp | 12 ++++++------ 8 files changed, 33 insertions(+), 35 deletions(-) diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 49e326f7e64c..2c0fc0d1290c 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -546,7 +546,7 @@ 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) { - Function *f = static_cast<Function *>(i); + Function *f = &*i; ref<ConstantExpr> addr(0); // If the symbol has external weak linkage then it is implicitly @@ -600,7 +600,7 @@ void Executor::initializeGlobals(ExecutionState &state) { for (Module::const_global_iterator i = m->global_begin(), e = m->global_end(); i != e; ++i) { - const GlobalVariable *v = static_cast<const GlobalVariable *>(i); + const GlobalVariable *v = &*i; size_t globalObjectAlignment = getAllocationAlignment(v); if (i->isDeclaration()) { // FIXME: We have no general way of handling unknown external @@ -678,8 +678,7 @@ void Executor::initializeGlobals(ExecutionState &state) { i != ie; ++i) { // Map the alias to its aliasee's address. This works because we have // addresses for everything, even undefined functions. - globalAddresses.insert(std::make_pair(static_cast<GlobalAlias *>(i), - evalConstant(i->getAliasee()))); + globalAddresses.insert(std::make_pair(&*i, evalConstant(i->getAliasee()))); } // once all objects are allocated, do the actual initialization @@ -687,7 +686,7 @@ void Executor::initializeGlobals(ExecutionState &state) { e = m->global_end(); i != e; ++i) { if (i->hasInitializer()) { - const GlobalVariable *v = static_cast<const GlobalVariable *>(i); + const GlobalVariable *v = &*i; MemoryObject *mo = globalObjects.find(v)->second; const ObjectState *os = state.addressSpace.findObject(mo); assert(os); @@ -3554,7 +3553,7 @@ void Executor::runFunctionAsMain(Function *f, if (ai!=ae) { arguments.push_back(ConstantExpr::alloc(argc, Expr::Int32)); if (++ai!=ae) { - Instruction *first = static_cast<Instruction *>(f->begin()->begin()); + Instruction *first = &*f->begin()->begin(); argvMO = memory->allocate((argc + 1 + envc + 1 + 1) * NumPtrBytes, /*isLocal=*/false, /*isGlobal=*/true, diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index b93796ecdff7..86de9586bd3f 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -165,7 +165,7 @@ static bool instructionIsCoverable(Instruction *i) { if (it==bb->begin()) { return true; } else { - Instruction *prev = static_cast<Instruction *>(--it); + Instruction *prev = &*(--it); if (isa<CallInst>(prev) || isa<InvokeInst>(prev)) { Function *target = getDirectCallTarget(CallSite(prev), /*moduleIsFullyLinked=*/true); @@ -542,7 +542,7 @@ 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. - Function *fn = static_cast<Function *>(fnIt); + Function *fn = &*fnIt; const InstructionInfo &ii = executor.kmodule->infos->getFunctionInfo(fn); if (ii.file != sourceFile) { of << "fl=" << ii.file << "\n"; @@ -639,9 +639,9 @@ 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) - res.push_back(static_cast<Instruction *>(it->begin())); + res.push_back(&*it->begin()); } else { - res.push_back(static_cast<Instruction *>(++BasicBlock::iterator(i))); + res.push_back(&*(++BasicBlock::iterator(i))); } return res; @@ -688,7 +688,7 @@ void StatsTracker::computeReachableUncovered() { bbIt != bb_ie; ++bbIt) { for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end(); it != ie; ++it) { - Instruction *inst = static_cast<Instruction *>(it); + Instruction *inst = &*it; if (isa<CallInst>(inst) || isa<InvokeInst>(inst)) { CallSite cs(inst); if (isa<InlineAsm>(cs.getCalledValue())) { @@ -721,7 +721,7 @@ void StatsTracker::computeReachableUncovered() { std::vector<Instruction *> instructions; for (Module::iterator fnIt = m->begin(), fn_ie = m->end(); fnIt != fn_ie; ++fnIt) { - Function *fn = static_cast<Function *>(fnIt); + Function *fn = &*fnIt; if (fnIt->isDeclaration()) { if (fnIt->doesNotReturn()) { functionShortestPath[fn] = 0; @@ -737,7 +737,7 @@ void StatsTracker::computeReachableUncovered() { bbIt != bb_ie; ++bbIt) { for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end(); it != ie; ++it) { - Instruction *inst = static_cast<Instruction *>(it); + Instruction *inst = &*it; instructions.push_back(inst); unsigned id = infos.getInfo(inst).id; sm.setIndexedValue(stats::minDistToReturn, @@ -796,14 +796,13 @@ void StatsTracker::computeReachableUncovered() { // functionShortestPath, or it will remain 0 (erroneously indicating // that no return instructions are reachable) Function *f = inst->getParent()->getParent(); - if (best != cur - || (inst == static_cast<Instruction *>(f->begin()->begin()) + if (best != cur || (inst == &*f->begin()->begin() && functionShortestPath[f] != best)) { sm.setIndexedValue(stats::minDistToReturn, id, best); changed = true; // Update shortest path if this is the entry point. - if (inst == static_cast<Instruction *>(f->begin()->begin())) + if (inst == &*f->begin()->begin()) functionShortestPath[f] = best; } } @@ -820,7 +819,7 @@ void StatsTracker::computeReachableUncovered() { bbIt != bb_ie; ++bbIt) { for (BasicBlock::iterator it = bbIt->begin(), ie = bbIt->end(); it != ie; ++it) { - Instruction *inst = static_cast<Instruction *>(it); + Instruction *inst = &*it; unsigned id = infos.getInfo(inst).id; instructions.push_back(inst); sm.setIndexedValue(stats::minDistToUncovered, diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp index 48a4eb940f8b..eb0f189b1fd1 100644 --- a/lib/Module/Checks.cpp +++ b/lib/Module/Checks.cpp @@ -71,7 +71,7 @@ bool DivCheckPass::runOnModule(Module &M) { Type::getInt64Ty(ctx), false, /* sign doesn't matter */ "int_cast_to_i64", - static_cast<Instruction *>(i)); + &*i); // Lazily bind the function to avoid always importing it. if (!divZeroCheckFunction) { @@ -129,7 +129,7 @@ bool OvershiftCheckPass::runOnModule(Module &M) { Type::getInt64Ty(ctx), false, /* sign doesn't matter */ "int_cast_to_i64", - static_cast<Instruction *>(i)); + &*i); args.push_back(shift); diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp index adf054423f13..8e58c19b0bb2 100644 --- a/lib/Module/InstructionInfoTable.cpp +++ b/lib/Module/InstructionInfoTable.cpp @@ -120,7 +120,7 @@ InstructionInfoTable::InstructionInfoTable(Module *m) for (Module::iterator fnIt = m->begin(), fn_ie = m->end(); fnIt != fn_ie; ++fnIt) { - Function *fn = static_cast<Function *>(fnIt); + Function *fn = &*fnIt; // We want to ensure that as all instructions have source information, if // available. Clang sometimes will not write out debug information on the @@ -193,6 +193,6 @@ InstructionInfoTable::getFunctionInfo(const Function *f) const { // and construct a test case for it if it does, though. return dummyInfo; } else { - return getInfo(static_cast<const Instruction *>(f->begin()->begin())); + return getInfo(&*f->begin()->begin()); } } diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index 6438707ab346..bb74a71579c0 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -196,7 +196,7 @@ static void injectStaticConstructorsAndDestructors(Module *m) { if (ctors) CallInst::Create(getStubFunctionForCtorList(m, ctors, "klee.ctor_stub"), - "", static_cast<Instruction *>(mainFn->begin()->begin())); + "", &*mainFn->begin()->begin()); if (dtors) { Function *dtorStub = getStubFunctionForCtorList(m, dtors, "klee.dtor_stub"); for (Function::iterator it = mainFn->begin(), ie = mainFn->end(); @@ -286,7 +286,7 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, llvm::errs() << "KLEE: adding klee_merge at exit of: " << name << "\n"; for (llvm::Function::iterator bbit = f->begin(), bbie = f->end(); bbit != bbie; ++bbit) { - BasicBlock *bb = static_cast<BasicBlock *>(bbit); + BasicBlock *bb = &*bbit; if (bb != exit) { Instruction *i = bbit->getTerminator(); if (i->getOpcode()==Instruction::Ret) { @@ -451,7 +451,7 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, if (it->isDeclaration()) continue; - Function *fn = static_cast<Function *>(it); + Function *fn = &*it; KFunction *kf = new KFunction(fn, this); for (unsigned i=0; i<kf->numInstructions; ++i) { @@ -542,7 +542,7 @@ KFunction::KFunction(llvm::Function *_function, trackCoverage(true) { for (llvm::Function::iterator bbit = function->begin(), bbie = function->end(); bbit != bbie; ++bbit) { - BasicBlock *bb = static_cast<BasicBlock *>(bbit); + BasicBlock *bb = &*bbit; basicBlockEntry[bb] = numInstructions; numInstructions += bb->size(); } @@ -557,7 +557,7 @@ KFunction::KFunction(llvm::Function *_function, bbie = function->end(); bbit != bbie; ++bbit) { for (llvm::BasicBlock::iterator it = bbit->begin(), ie = bbit->end(); it != ie; ++it) - registerMap[static_cast<Instruction *>(it)] = rnum++; + registerMap[&*it] = rnum++; } numRegisters = rnum; @@ -577,7 +577,7 @@ KFunction::KFunction(llvm::Function *_function, ki = new KInstruction(); break; } - Instruction *inst = static_cast<Instruction *>(it); + Instruction *inst = &*it; ki->inst = inst; ki->dest = registerMap[inst]; diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp index 5cc6b991c6d1..b20c21ab34e4 100644 --- a/lib/Module/LowerSwitch.cpp +++ b/lib/Module/LowerSwitch.cpp @@ -44,7 +44,7 @@ bool LowerSwitchPass::runOnFunction(Function &F) { bool changed = false; for (Function::iterator I = F.begin(), E = F.end(); I != E; ) { - BasicBlock *cur = static_cast<BasicBlock *>(I); + BasicBlock *cur = &*I; I++; // Advance over block so we don't traverse new blocks if (SwitchInst *SI = dyn_cast<SwitchInst>(cur->getTerminator())) { diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index 5fc54ef17743..113dcc621ae2 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -124,7 +124,7 @@ 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;) { - Instruction *i = static_cast<Instruction *>(ii); + Instruction *i = &*ii; ++ii; changed |= runOnInstruction(M, i); } diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index 94798dad3181..e5b8fa6c1b96 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -670,10 +670,10 @@ static int initEnv(Module *mainModule) { klee_error("Cannot handle ""--posix-runtime"" when main() has less than two arguments.\n"); } - Instruction *firstInst = static_cast<Instruction *>(mainFn->begin()->begin()); + Instruction *firstInst = &*mainFn->begin()->begin(); - Value *oldArgc = static_cast<Argument *>(mainFn->arg_begin()); - Value *oldArgv = static_cast<Argument *>(++mainFn->arg_begin()); + Value *oldArgc = &*mainFn->arg_begin(); + Value *oldArgv = &*(++mainFn->arg_begin()); AllocaInst* argcPtr = new AllocaInst(oldArgc->getType(), "argcPtr", firstInst); @@ -1080,7 +1080,7 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule, StringRef libDir) // naming conflict. for (Module::iterator fi = mainModule->begin(), fe = mainModule->end(); fi != fe; ++fi) { - Function *f = static_cast<Function *>(fi); + Function *f = &*fi; const std::string &name = f->getName(); if (name[0]=='\01') { unsigned size = name.size(); @@ -1139,8 +1139,8 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule, StringRef libDir) std::vector<llvm::Value*> args; args.push_back(llvm::ConstantExpr::getBitCast(userMainFn, ft->getParamType(0))); - args.push_back(static_cast<Argument *>(stub->arg_begin())); // argc - args.push_back(static_cast<Argument *>(++stub->arg_begin())); // argv + args.push_back(&*stub->arg_begin()); // argc + args.push_back(&*(++stub->arg_begin())); // argv 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 -- 2.13.1 ++++++ 0003-Core-TimingSolver-use-WallTimer.patch ++++++ From: Jiri Slaby <[email protected]> Date: Wed, 7 Jun 2017 16:50:27 +0200 Subject: Core: TimingSolver, use WallTimer Patch-mainline: no Do not opencode what we already have in WallTimer. This simplifies the code a lot and makes transition to LLVM 4.0 a lot easier. We also introduce a helper to update the times. Signed-off-by: Jiri Slaby <[email protected]> --- lib/Core/TimingSolver.cpp | 38 +++++++++++++++----------------------- lib/Core/TimingSolver.h | 3 +++ 2 files changed, 18 insertions(+), 23 deletions(-) diff --git a/lib/Core/TimingSolver.cpp b/lib/Core/TimingSolver.cpp index b70bcbefcddc..77451111b676 100644 --- a/lib/Core/TimingSolver.cpp +++ b/lib/Core/TimingSolver.cpp @@ -13,17 +13,21 @@ #include "klee/ExecutionState.h" #include "klee/Solver.h" #include "klee/Statistics.h" -#include "klee/Internal/System/Time.h" +#include "klee/Internal/Support/Timer.h" #include "CoreStats.h" -#include "llvm/Support/TimeValue.h" - using namespace klee; using namespace llvm; /***/ +void TimingSolver::updateTimes(const ExecutionState& state, uint64_t usec) +{ + stats::solverTime += usec; + state.queryCost += usec / 1e6; +} + bool TimingSolver::evaluate(const ExecutionState& state, ref<Expr> expr, Solver::Validity &result) { // Fast path, to avoid timer and OS overhead. @@ -32,17 +36,14 @@ bool TimingSolver::evaluate(const ExecutionState& state, ref<Expr> expr, return true; } - sys::TimeValue now = util::getWallTimeVal(); + WallTimer timer; if (simplifyExprs) expr = state.constraints.simplifyExpr(expr); bool success = solver->evaluate(Query(state.constraints, expr), result); - sys::TimeValue delta = util::getWallTimeVal(); - delta -= now; - stats::solverTime += delta.usec(); - state.queryCost += delta.usec()/1000000.; + updateTimes(state, timer.check()); return success; } @@ -55,17 +56,14 @@ bool TimingSolver::mustBeTrue(const ExecutionState& state, ref<Expr> expr, return true; } - sys::TimeValue now = util::getWallTimeVal(); + WallTimer timer; if (simplifyExprs) expr = state.constraints.simplifyExpr(expr); bool success = solver->mustBeTrue(Query(state.constraints, expr), result); - sys::TimeValue delta = util::getWallTimeVal(); - delta -= now; - stats::solverTime += delta.usec(); - state.queryCost += delta.usec()/1000000.; + updateTimes(state, timer.check()); return success; } @@ -101,17 +99,14 @@ bool TimingSolver::getValue(const ExecutionState& state, ref<Expr> expr, return true; } - sys::TimeValue now = util::getWallTimeVal(); + WallTimer timer; if (simplifyExprs) expr = state.constraints.simplifyExpr(expr); bool success = solver->getValue(Query(state.constraints, expr), result); - sys::TimeValue delta = util::getWallTimeVal(); - delta -= now; - stats::solverTime += delta.usec(); - state.queryCost += delta.usec()/1000000.; + updateTimes(state, timer.check()); return success; } @@ -125,16 +120,13 @@ TimingSolver::getInitialValues(const ExecutionState& state, if (objects.empty()) return true; - sys::TimeValue now = util::getWallTimeVal(); + WallTimer timer; bool success = solver->getInitialValues(Query(state.constraints, ConstantExpr::alloc(0, Expr::Bool)), objects, result); - sys::TimeValue delta = util::getWallTimeVal(); - delta -= now; - stats::solverTime += delta.usec(); - state.queryCost += delta.usec()/1000000.; + updateTimes(state, timer.check()); return success; } diff --git a/lib/Core/TimingSolver.h b/lib/Core/TimingSolver.h index c98dd881b841..c1c229b08fc0 100644 --- a/lib/Core/TimingSolver.h +++ b/lib/Core/TimingSolver.h @@ -26,6 +26,9 @@ namespace klee { Solver *solver; bool simplifyExprs; + private: + void updateTimes(const ExecutionState& state, uint64_t usec); + public: /// TimingSolver - Construct a new timing solver. /// -- 2.13.1 ++++++ 0004-llvm-make-KLEE-compile-against-LLVM-3.7.patch ++++++ From: =?UTF-8?q?Richard=20Trembeck=C3=BD?= <[email protected]> Date: Thu, 28 Apr 2016 18:27:24 +0200 Subject: llvm: make KLEE compile against LLVM 3.7 Patch-mainline: no Signed-off-by: Jiri Slaby <[email protected]> --- include/klee/Internal/Support/FloatEvaluation.h | 7 +++++++ lib/Core/ExternalDispatcher.cpp | 3 +++ 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, 90 insertions(+), 9 deletions(-) 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 +++ b/include/klee/Internal/Support/FloatEvaluation.h @@ -132,8 +132,15 @@ inline uint64_t mod(uint64_t l, uint64_t r, unsigned inWidth) { // determine if l represents NaN inline bool isNaN(uint64_t l, unsigned inWidth) { switch( inWidth ) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) + case FLT_BITS: + return std::isnan(UInt64AsFloat(l)); + case DBL_BITS: + return std::isnan(UInt64AsDouble(l)); +#else case FLT_BITS: return llvm::IsNAN( UInt64AsFloat(l) ); case DBL_BITS: return llvm::IsNAN( UInt64AsDouble(l) ); +#endif default: llvm::report_fatal_error("unsupported floating point width"); } } diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp index df0dd9a9a12f..380c97e62db8 100644 --- a/lib/Core/ExternalDispatcher.cpp +++ b/lib/Core/ExternalDispatcher.cpp @@ -331,6 +331,9 @@ Function *ExternalDispatcherImpl::createDispatcher(Function *target, LLVM_TYPE_Q Type *argTy = (i < FTy->getNumParams() ? FTy->getParamType(i) : (*ai)->getType()); Instruction *argI64p = GetElementPtrInst::Create( +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) + nullptr, +#endif argI64s, ConstantInt::get(Type::getInt32Ty(ctx), idx), "", dBB); Instruction *argp = diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp index 8e58c19b0bb2..44addc762daa 100644 --- a/lib/Module/InstructionInfoTable.cpp +++ b/lib/Module/InstructionInfoTable.cpp @@ -87,7 +87,7 @@ static void buildInstructionToLineMap(Module *m, } } -static std::string getDSPIPath(DILocation Loc) { +static std::string getDSPIPath(const DILocation &Loc) { std::string dir = Loc.getDirectory(); std::string file = Loc.getFilename(); if (dir.empty() || file[0] == '/') { @@ -103,9 +103,15 @@ bool InstructionInfoTable::getInstructionDebugInfo(const llvm::Instruction *I, const std::string *&File, unsigned &Line) { if (MDNode *N = I->getMetadata("dbg")) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) + DILocation *Loc = cast<DILocation>(N); + File = internString(getDSPIPath(*Loc)); + Line = Loc->getLine(); +#else DILocation Loc(N); File = internString(getDSPIPath(Loc)); Line = Loc.getLineNumber(); +#endif return true; } diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp index 3f7644af3d37..9af6f9f40f21 100644 --- a/lib/Module/IntrinsicCleaner.cpp +++ b/lib/Module/IntrinsicCleaner.cpp @@ -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(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); +#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); +#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); } ii->removeFromParent(); diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index bb74a71579c0..b31b7fd5a56d 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -46,8 +46,11 @@ #else #include "llvm/IR/CallSite.h" #endif - +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) +#include "llvm/IR/LegacyPassManager.h" +#else #include "llvm/PassManager.h" +#endif #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_os_ostream.h" @@ -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. +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) + legacy::PassManager pm; +#else PassManager pm; +#endif pm.add(new RaiseAsmPass()); if (opts.CheckDivZero) pm.add(new DivCheckPass()); if (opts.CheckOvershift) pm.add(new OvershiftCheckPass()); @@ -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? +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) + legacy::PassManager pm3; +#else PassManager pm3; +#endif pm3.add(createCFGSimplificationPass()); switch(SwitchType) { case eSwitchTypeInternal: break; diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index c7f1c6d9d4a7..de0130a2632c 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -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> > resultErr = +#else + ErrorOr<Module *> resultErr = +#endif + parseBitcodeFile(buff.get(), composite->getContext()); ec = resultErr.getError(); if (ec) errorMessage = ec.message(); else +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) + Result = resultErr->release(); +#else Result = resultErr.get(); +#endif #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> > 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; +#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 c0f3f34ca8e8..68acd2b17dda 100644 --- a/lib/Module/Optimize.cpp +++ b/lib/Module/Optimize.cpp @@ -16,7 +16,11 @@ //===----------------------------------------------------------------------===// #include "klee/Config/Version.h" +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) +#include "llvm/IR/LegacyPassManager.h" +#else #include "llvm/PassManager.h" +#endif #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Support/CommandLine.h" @@ -80,7 +84,11 @@ static cl::alias A1("S", cl::desc("Alias for --strip-debug"), // A utility function that adds a pass to the pass manager but will also add // a verifier pass after if we're supposed to verify. +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) +static inline void addPass(legacy::PassManager &PM, Pass *P) { +#else static inline void addPass(PassManager &PM, Pass *P) { +#endif // Add the pass to the pass manager... PM.add(P); @@ -91,8 +99,11 @@ static inline void addPass(PassManager &PM, Pass *P) { namespace llvm { - +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) +static void AddStandardCompilePasses(legacy::PassManager &PM) { +#else static void AddStandardCompilePasses(PassManager &PM) { +#endif PM.add(createVerifierPass()); // Verify that input is correct #if LLVM_VERSION_CODE < LLVM_VERSION(3, 0) @@ -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. +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) + legacy::PassManager Passes; +#else PassManager Passes; +#endif // If we're verifying, start off with a verification pass. 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, 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 113dcc621ae2..668ce4853cca 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -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()); + TLI = TM->getSubtargetImpl(*(M.begin()))->getTargetLowering(); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) TM = NativeTarget->createTargetMachine(HostTriple, "", "", TargetOptions()); 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 e5b8fa6c1b96..dd78d5410e28 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -47,6 +47,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" #if LLVM_VERSION_CODE < LLVM_VERSION(3, 0) @@ -1278,8 +1279,11 @@ int main(int argc, char **argv, char **envp) { // from the std::unique_ptr Buffer->release(); } - +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) + mainModule = mainModuleOrError->release(); +#else mainModule = *mainModuleOrError; +#endif if (auto ec = mainModule->materializeAllPermanently()) { klee_error("error loading program '%s': %s", InputFile.c_str(), ec.message().c_str()); -- 2.13.1 ++++++ 0005-llvm-make-KLEE-compile-against-LLVM-3.8.patch ++++++ From: =?UTF-8?q?Richard=20Trembeck=C3=BD?= <[email protected]> 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 <[email protected]> --- 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 2c0fc0d1290c..70354edc37ea 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -2300,8 +2300,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 86de9586bd3f..798318ae8992 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(&*it->begin()); } else { +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8) + res.push_back(&*(++(i->getIterator()))); +#else res.push_back(&*(++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 b20c21ab34e4..147b5acb6d25 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 dd78d5410e28..78ea1a6eb569 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -311,7 +311,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) { @@ -1284,7 +1289,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.13.1 ++++++ 0006-llvm-make-KLEE-compile-against-LLVM-3.9.patch ++++++ From: Jiri Slaby <[email protected]> Date: Wed, 22 Feb 2017 15:57:55 +0100 Subject: llvm: make KLEE compile against LLVM 3.9 Patch-mainline: no Signed-off-by: Jiri Slaby <[email protected]> --- lib/Core/Executor.cpp | 16 ++++++++++++++++ lib/Core/MemoryManager.cpp | 5 ++++- lib/Module/ModuleUtil.cpp | 33 ++++++++++++++++++++++++++++++--- lib/Module/Optimize.cpp | 29 ++++++++++++++++++++++++++++- lib/Module/RaiseAsm.cpp | 11 +++++++++-- tools/kleaver/main.cpp | 4 ++++ tools/klee/main.cpp | 4 ++++ 7 files changed, 95 insertions(+), 7 deletions(-) diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 70354edc37ea..841734573abc 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -1399,10 +1399,18 @@ void Executor::executeCall(ExecutionState &state, // // Alignment requirements for scalar types is the same as their size if (argWidth > Expr::Int64) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + size = llvm::alignTo(size, 16); +#else size = llvm::RoundUpToAlignment(size, 16); +#endif requires16ByteAlignment = true; } +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + size += llvm::alignTo(argWidth, WordSize) / 8; +#else size += llvm::RoundUpToAlignment(argWidth, WordSize) / 8; +#endif } } @@ -1435,10 +1443,18 @@ void Executor::executeCall(ExecutionState &state, Expr::Width argWidth = arguments[i]->getWidth(); if (argWidth > Expr::Int64) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + offset = llvm::alignTo(offset, 16); +#else offset = llvm::RoundUpToAlignment(offset, 16); +#endif } os->write(offset, arguments[i]); +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + offset += llvm::alignTo(argWidth, WordSize) / 8; +#else offset += llvm::RoundUpToAlignment(argWidth, WordSize) / 8; +#endif } } } diff --git a/lib/Core/MemoryManager.cpp b/lib/Core/MemoryManager.cpp index 24e2ed97581f..f40e8bc9deb8 100644 --- a/lib/Core/MemoryManager.cpp +++ b/lib/Core/MemoryManager.cpp @@ -111,9 +111,12 @@ MemoryObject *MemoryManager::allocate(uint64_t size, bool isLocal, uint64_t address = 0; if (DeterministicAllocation) { - +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + address = llvm::alignTo((uint64_t)nextFreeSlot + alignment - 1, alignment); +#else address = llvm::RoundUpToAlignment((uint64_t)nextFreeSlot + alignment - 1, alignment); +#endif // Handle the case of 0-sized allocations as 1-byte allocations. // This way, we make sure we have this allocation between its own red zones diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index 6b50b037bc65..14d48b026d14 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -212,7 +212,11 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Loading modules\n"); // Load all bitcode files in to memory so we can examine their symbols -#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + Error Err; + for (object::Archive::child_iterator AI = archive->child_begin(Err), + AE = archive->child_end(); AI != AE; ++AI) +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) for (object::Archive::child_iterator AI = archive->child_begin(), AE = archive->child_end(); AI != AE; ++AI) #else @@ -252,7 +256,14 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er return false; } -#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + Expected<std::unique_ptr<llvm::object::Binary> > child = + childErr->getAsBinary(); + if (!child) { + ec = errorToErrorCode(child.takeError()); + consumeError(child.takeError()); + } +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) ErrorOr<std::unique_ptr<llvm::object::Binary> > child = childErr->getAsBinary(); ec = child.getError(); @@ -335,6 +346,13 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er } } +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + if (Err) { + SS << "Cannot iterate over archive"; + SS.flush(); + return false; + } +#endif KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Loaded " << archiveModules.size() << " modules\n"); @@ -505,7 +523,12 @@ Module *klee::linkWithLibrary(Module *module, #endif } else if (magic == sys::fs::file_magic::archive) { -#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + Expected<std::unique_ptr<object::Binary> > arch = + object::createBinary(Buffer, &Context); + if (!arch) + ec = errorToErrorCode(arch.takeError()); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) ErrorOr<std::unique_ptr<object::Binary> > arch = object::createBinary(Buffer, &Context); ec = arch.getError(); @@ -575,7 +598,11 @@ Function *klee::getDirectCallTarget(CallSite cs, bool moduleIsFullyLinked) { if (Function *f = dyn_cast<Function>(v)) { return f; } else if (llvm::GlobalAlias *ga = dyn_cast<GlobalAlias>(v)) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + if (moduleIsFullyLinked || !(ga->isInterposable())) { +#else if (moduleIsFullyLinked || !(ga->mayBeOverridden())) { +#endif v = ga->getAliasee(); } else { v = NULL; diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp index 46ab7d028224..745d89f70027 100644 --- a/lib/Module/Optimize.cpp +++ b/lib/Module/Optimize.cpp @@ -16,6 +16,9 @@ //===----------------------------------------------------------------------===// #include "klee/Config/Version.h" +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) +#include "llvm/Transforms/IPO/FunctionAttrs.h" +#endif #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) #include "llvm/IR/LegacyPassManager.h" #else @@ -47,6 +50,9 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) +#include "llvm/Transforms/Scalar/GVN.h" +#endif #include "llvm/Support/PluginLoader.h" using namespace llvm; @@ -127,7 +133,11 @@ static void AddStandardCompilePasses(PassManager &PM) { addPass(PM, createPruneEHPass()); // Remove dead EH info #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + addPass(PM, createPostOrderFunctionAttrsLegacyPass()); +#else addPass(PM, createPostOrderFunctionAttrsPass()); +#endif addPass(PM, createReversePostOrderFunctionAttrsPass()); #else addPass(PM, createFunctionAttrsPass()); // Deduce function attrs @@ -143,7 +153,11 @@ static void AddStandardCompilePasses(PassManager &PM) { addPass(PM, createInstructionCombiningPass()); // Cleanup for scalarrepl. addPass(PM, createJumpThreadingPass()); // Thread jumps. addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + addPass(PM, createSROAPass()); // Break up aggregate allocas +#else addPass(PM, createScalarReplAggregatesPass()); // Break up aggregate allocas +#endif addPass(PM, createInstructionCombiningPass()); // Combine silly seq's addPass(PM, createTailCallEliminationPass()); // Eliminate tail calls @@ -215,7 +229,12 @@ void Optimize(Module *M, const std::string &EntryPoint) { // for a main function. If main is defined, mark all other functions // internal. if (!DisableInternalize) { -#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + auto PreserveEP = [=](const GlobalValue &GV) { + return GV.getName().equals(EntryPoint); + }; + ModulePass *pass = createInternalizePass(PreserveEP); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 2) ModulePass *pass = createInternalizePass( std::vector<const char *>(1, EntryPoint.c_str())); #else @@ -259,11 +278,19 @@ void Optimize(Module *M, const std::string &EntryPoint) { // The IPO passes may leave cruft around. Clean up after them. addPass(Passes, createInstructionCombiningPass()); addPass(Passes, createJumpThreadingPass()); // Thread jumps. +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + addPass(Passes, createSROAPass()); // Break up allocas +#else addPass(Passes, createScalarReplAggregatesPass()); // Break up allocas +#endif // Run a few AA driven optimizations here and now, to cleanup the code. #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + addPass(Passes, createPostOrderFunctionAttrsLegacyPass()); +#else addPass(Passes, createPostOrderFunctionAttrsPass()); +#endif addPass(Passes, createReversePostOrderFunctionAttrsPass()); // addPass(Passes, createGlobalsAAWrapperPass()); #else diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index 668ce4853cca..08e78748d30c 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -75,7 +75,10 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) { triple.getOS() == llvm::Triple::Darwin)) { if (ia->getAsmString() == "" && ia->hasSideEffects()) { -#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + IRBuilder<> Builder(I); + Builder.CreateFence(llvm::AtomicOrdering::SequentiallyConsistent); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 3) IRBuilder<> Builder(I); Builder.CreateFence(llvm::SequentiallyConsistent); #endif @@ -103,7 +106,11 @@ 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, 7) +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + TM = NativeTarget->createTargetMachine(HostTriple, "", "", TargetOptions(), + None); + TLI = TM->getSubtargetImpl(*(M.begin()))->getTargetLowering(); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) TM = NativeTarget->createTargetMachine(HostTriple, "", "", TargetOptions()); TLI = TM->getSubtargetImpl(*(M.begin()))->getTargetLowering(); #elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) diff --git a/tools/kleaver/main.cpp b/tools/kleaver/main.cpp index b8b32e31264a..800cece95e9c 100644 --- a/tools/kleaver/main.cpp +++ b/tools/kleaver/main.cpp @@ -400,7 +400,11 @@ static bool printInputAsSMTLIBv2(const char *Filename, int main(int argc, char **argv) { bool success = true; +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + llvm::sys::PrintStackTraceOnErrorSignal(argv[0]); +#else llvm::sys::PrintStackTraceOnErrorSignal(); +#endif llvm::cl::SetVersionPrinter(klee::printVersion); llvm::cl::ParseCommandLineOptions(argc, argv); diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index 78ea1a6eb569..eac69ada30e0 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -1170,7 +1170,11 @@ int main(int argc, char **argv, char **envp) { llvm::InitializeNativeTarget(); parseArguments(argc, argv); +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) + sys::PrintStackTraceOnErrorSignal(argv[0]); +#else sys::PrintStackTraceOnErrorSignal(); +#endif if (Watchdog) { if (MaxTime==0) { -- 2.13.1 ++++++ 0001-test-add-versions-of-some-tests-for-LLVM-3.8.patch -> 0007-test-add-versions-of-some-tests-for-LLVM-3.8.patch ++++++ --- /work/SRC/openSUSE:Factory/klee/0001-test-add-versions-of-some-tests-for-LLVM-3.8.patch 2017-04-28 09:13:52.629227334 +0200 +++ /work/SRC/openSUSE:Factory/.klee.new/0007-test-add-versions-of-some-tests-for-LLVM-3.8.patch 2017-06-12 15:32:13.218149931 +0200 @@ -56,21 +56,21 @@ create mode 100644 test/regression/2007-08-16-invalid-constant-value.llvm38.c diff --git a/test/Concrete/BoolReadWrite.ll b/test/Concrete/BoolReadWrite.ll -index f818ecafacd5..eb618d2726b7 100644 +index f818ecafacd5..f2d76227c545 100644 --- a/test/Concrete/BoolReadWrite.ll +++ b/test/Concrete/BoolReadWrite.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s declare void @print_i1(i1) diff --git a/test/Concrete/BoolReadWrite.llvm38.ll b/test/Concrete/BoolReadWrite.llvm38.ll new file mode 100644 -index 000000000000..c68696d1a4c1 +index 000000000000..d2c6c88aff32 --- /dev/null +++ b/test/Concrete/BoolReadWrite.llvm38.ll @@ -0,0 +1,16 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s + +declare void @print_i1(i1) @@ -87,21 +87,21 @@ + ret i32 0 +} diff --git a/test/Concrete/ConstantExpr.ll b/test/Concrete/ConstantExpr.ll -index d00c59a637e9..d5a97919634b 100644 +index d00c59a637e9..84cf1ad0f517 100644 --- a/test/Concrete/ConstantExpr.ll +++ b/test/Concrete/ConstantExpr.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s ; Most of the test below use the *address* of gInt as part of their computation, diff --git a/test/Concrete/ConstantExpr.llvm38.ll b/test/Concrete/ConstantExpr.llvm38.ll new file mode 100644 -index 000000000000..f02e59ffe49a +index 000000000000..dc9dce931ba8 --- /dev/null +++ b/test/Concrete/ConstantExpr.llvm38.ll @@ -0,0 +1,165 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s + +; Most of the test below use the *address* of gInt as part of their computation, @@ -267,21 +267,21 @@ +declare void @print_i32(i32) +declare void @print_i64(i64) diff --git a/test/Concrete/FloatingPointOps.ll b/test/Concrete/FloatingPointOps.ll -index 5dd6d2feb41e..20c99db798b1 100644 +index 5dd6d2feb41e..12d8cd241d2f 100644 --- a/test/Concrete/FloatingPointOps.ll +++ b/test/Concrete/FloatingPointOps.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s ; casting error messages diff --git a/test/Concrete/FloatingPointOps.llvm38.ll b/test/Concrete/FloatingPointOps.llvm38.ll new file mode 100644 -index 000000000000..44fa9f2a9ac1 +index 000000000000..3dbbb49aef4b --- /dev/null +++ b/test/Concrete/FloatingPointOps.llvm38.ll @@ -0,0 +1,680 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s + +; casting error messages @@ -962,21 +962,21 @@ + ret i32 0 +} diff --git a/test/Concrete/GlobalInitializers.ll b/test/Concrete/GlobalInitializers.ll -index e3657dad19e5..4399da750475 100755 +index e3657dad19e5..b883ad40d940 100755 --- a/test/Concrete/GlobalInitializers.ll +++ b/test/Concrete/GlobalInitializers.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s declare void @print_i32(i32) diff --git a/test/Concrete/GlobalInitializers.llvm38.ll b/test/Concrete/GlobalInitializers.llvm38.ll new file mode 100755 -index 000000000000..604e999183f3 +index 000000000000..98f5b6787f80 --- /dev/null +++ b/test/Concrete/GlobalInitializers.llvm38.ll @@ -0,0 +1,48 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s + +declare void @print_i32(i32) @@ -1025,21 +1025,21 @@ + ret i32 0 +} diff --git a/test/Concrete/SimpleStoreAndLoad.ll b/test/Concrete/SimpleStoreAndLoad.ll -index 1edad0386916..1046c5d81bd3 100644 +index 1edad0386916..6e8542f8f5fd 100644 --- a/test/Concrete/SimpleStoreAndLoad.ll +++ b/test/Concrete/SimpleStoreAndLoad.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s declare void @print_i32(i32) diff --git a/test/Concrete/SimpleStoreAndLoad.llvm38.ll b/test/Concrete/SimpleStoreAndLoad.llvm38.ll new file mode 100644 -index 000000000000..b8944ee9b939 +index 000000000000..1a36c674c36d --- /dev/null +++ b/test/Concrete/SimpleStoreAndLoad.llvm38.ll @@ -0,0 +1,20 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: %S/ConcreteTest.py --klee='%klee' --lli=%lli %s + +declare void @print_i32(i32) @@ -1060,21 +1060,21 @@ + ret i32 0 +} diff --git a/test/Feature/BitcastAlias.ll b/test/Feature/BitcastAlias.ll -index e0e3653feebc..0232903eb74a 100644 +index e0e3653feebc..f29e739c9e75 100644 --- a/test/Feature/BitcastAlias.ll +++ b/test/Feature/BitcastAlias.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: llvm-as %s -f -o %t1.bc ; RUN: rm -rf %t.klee-out ; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 diff --git a/test/Feature/BitcastAlias.llvm38.ll b/test/Feature/BitcastAlias.llvm38.ll new file mode 100644 -index 000000000000..cecf68cc1f39 +index 000000000000..ff7009b7711b --- /dev/null +++ b/test/Feature/BitcastAlias.llvm38.ll @@ -0,0 +1,35 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: llvm-as %s -f -o %t1.bc +; RUN: rm -rf %t.klee-out +; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 @@ -1110,21 +1110,21 @@ + ret i32 0 +} diff --git a/test/Feature/BitcastAliasMD2U.ll b/test/Feature/BitcastAliasMD2U.ll -index 24eabaa57c8c..ade6ba8a65db 100644 +index 24eabaa57c8c..322012882f01 100644 --- a/test/Feature/BitcastAliasMD2U.ll +++ b/test/Feature/BitcastAliasMD2U.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: llvm-as %s -f -o %t1.bc ; RUN: rm -rf %t.klee-out ; RUN: %klee --output-dir=%t.klee-out -disable-opt -search=nurs:md2u %t1.bc > %t2 diff --git a/test/Feature/BitcastAliasMD2U.llvm38.ll b/test/Feature/BitcastAliasMD2U.llvm38.ll new file mode 100644 -index 000000000000..aa7c5dec500f +index 000000000000..f4e41293c347 --- /dev/null +++ b/test/Feature/BitcastAliasMD2U.llvm38.ll @@ -0,0 +1,35 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: llvm-as %s -f -o %t1.bc +; RUN: rm -rf %t.klee-out +; RUN: %klee --output-dir=%t.klee-out -disable-opt -search=nurs:md2u %t1.bc > %t2 @@ -1160,21 +1160,21 @@ + ret i32 0 +} diff --git a/test/Feature/ConstantStruct.ll b/test/Feature/ConstantStruct.ll -index 4fe6b5d0e041..dfb304185d88 100644 +index 4fe6b5d0e041..cb7ce2541bad 100644 --- a/test/Feature/ConstantStruct.ll +++ b/test/Feature/ConstantStruct.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: llvm-as %s -f -o %t1.bc ; RUN: rm -rf %t.klee-out ; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 diff --git a/test/Feature/ConstantStruct.llvm38.ll b/test/Feature/ConstantStruct.llvm38.ll new file mode 100644 -index 000000000000..2d468c13fae2 +index 000000000000..b0e6ea835e1e --- /dev/null +++ b/test/Feature/ConstantStruct.llvm38.ll @@ -0,0 +1,34 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: llvm-as %s -f -o %t1.bc +; RUN: rm -rf %t.klee-out +; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 @@ -1209,21 +1209,21 @@ + ret i32 0 +} diff --git a/test/Feature/GetElementPtr.ll b/test/Feature/GetElementPtr.ll -index da94441c685e..7a3b4cd53b7c 100644 +index da94441c685e..cf3cc20d6dc2 100644 --- a/test/Feature/GetElementPtr.ll +++ b/test/Feature/GetElementPtr.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: llvm-as %s -f -o %t1.bc ; RUN: rm -rf %t.klee-out ; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 diff --git a/test/Feature/GetElementPtr.llvm38.ll b/test/Feature/GetElementPtr.llvm38.ll new file mode 100644 -index 000000000000..e063247918f3 +index 000000000000..72c71f2b14d0 --- /dev/null +++ b/test/Feature/GetElementPtr.llvm38.ll @@ -0,0 +1,30 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: llvm-as %s -f -o %t1.bc +; RUN: rm -rf %t.klee-out +; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 @@ -1254,21 +1254,21 @@ + ret i32 0 +} diff --git a/test/Feature/InsertExtractValue.ll b/test/Feature/InsertExtractValue.ll -index 83e8f851ccea..55839bb18d28 100644 +index 83e8f851ccea..a52222e2232a 100644 --- a/test/Feature/InsertExtractValue.ll +++ b/test/Feature/InsertExtractValue.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: llvm-as %s -f -o %t1.bc ; RUN: rm -rf %t.klee-out ; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 diff --git a/test/Feature/InsertExtractValue.llvm38.ll b/test/Feature/InsertExtractValue.llvm38.ll new file mode 100644 -index 000000000000..ca04c46745ae +index 000000000000..2b80b9385cb5 --- /dev/null +++ b/test/Feature/InsertExtractValue.llvm38.ll @@ -0,0 +1,34 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: llvm-as %s -f -o %t1.bc +; RUN: rm -rf %t.klee-out +; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 @@ -1303,21 +1303,21 @@ + ret i32 0 +} diff --git a/test/Feature/Overflow.ll b/test/Feature/Overflow.ll -index 35dfbd10fe02..9632e1e02d1c 100644 +index 35dfbd10fe02..08ece1189a54 100644 --- a/test/Feature/Overflow.ll +++ b/test/Feature/Overflow.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: llvm-as %s -f -o %t1.bc ; RUN: rm -rf %t.klee-out ; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 diff --git a/test/Feature/Overflow.llvm38.ll b/test/Feature/Overflow.llvm38.ll new file mode 100644 -index 000000000000..f7fcf71b7f11 +index 000000000000..c84aeb26bc23 --- /dev/null +++ b/test/Feature/Overflow.llvm38.ll @@ -0,0 +1,45 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: llvm-as %s -f -o %t1.bc +; RUN: rm -rf %t.klee-out +; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 @@ -1363,21 +1363,21 @@ + ret i32 0 +} diff --git a/test/Feature/OverflowMul.ll b/test/Feature/OverflowMul.ll -index 7026aa74bfbe..513cefd68277 100644 +index 7026aa74bfbe..422672e37f51 100644 --- a/test/Feature/OverflowMul.ll +++ b/test/Feature/OverflowMul.ll @@ -1,3 +1,4 @@ -+; REQUIRES: not-llvm-3.8 ++; REQUIRES: lt-llvm-3.8 ; RUN: llvm-as %s -f -o %t1.bc ; RUN: rm -rf %t.klee-out ; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 diff --git a/test/Feature/OverflowMul.llvm38.ll b/test/Feature/OverflowMul.llvm38.ll new file mode 100644 -index 000000000000..8ad119bd6893 +index 000000000000..84f5242e9e92 --- /dev/null +++ b/test/Feature/OverflowMul.llvm38.ll @@ -0,0 +1,45 @@ -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: llvm-as %s -f -o %t1.bc +; RUN: rm -rf %t.klee-out +; RUN: %klee --output-dir=%t.klee-out -disable-opt %t1.bc > %t2 @@ -1500,7 +1500,7 @@ + ret i32 %res +} diff --git a/test/Intrinsics/objectsize.ll b/test/Intrinsics/objectsize.ll -index 8b75ce8feda5..255c7156017d 100644 +index 8b75ce8feda5..08dd81460a6e 100644 --- a/test/Intrinsics/objectsize.ll +++ b/test/Intrinsics/objectsize.ll @@ -1,7 +1,7 @@ @@ -1508,20 +1508,20 @@ ; so this LLVM IR fails to verify for that version. ; -; REQUIRES: not-llvm-2.9 -+; REQUIRES: not-llvm-2.9, not-llvm-3.8 ++; REQUIRES: not-llvm-2.9, lt-llvm-3.8 ; RUN: %llvmas %s -o=%t.bc ; RUN: rm -rf %t.klee-out ; RUN: %klee -exit-on-error --output-dir=%t.klee-out -disable-opt %t.bc diff --git a/test/Intrinsics/objectsize.llvm38.ll b/test/Intrinsics/objectsize.llvm38.ll new file mode 100644 -index 000000000000..af193daf0fd1 +index 000000000000..d3f733ef6758 --- /dev/null +++ b/test/Intrinsics/objectsize.llvm38.ll @@ -0,0 +1,36 @@ +; Unfortunately LLVM 2.9 has a different suffix for the ``llvm.objectsize`` instrinsic +; so this LLVM IR fails to verify for that version. +; -+; REQUIRES: llvm-3.8 ++; REQUIRES: geq-llvm-3.8 +; RUN: %llvmas %s -o=%t.bc +; RUN: rm -rf %t.klee-out +; RUN: %klee -exit-on-error --output-dir=%t.klee-out -disable-opt %t.bc @@ -1555,10 +1555,10 @@ + +declare void @abort() noreturn nounwind diff --git a/test/lit.cfg b/test/lit.cfg -index 6ce6dc955847..90cd4aceb6f9 100644 +index 9c557a78cc8f..6922cbce3313 100644 --- a/test/lit.cfg +++ b/test/lit.cfg -@@ -130,7 +130,7 @@ if int(config.llvm_version_major) == 2: +@@ -158,7 +158,7 @@ if int(config.llvm_version_major) == 2: # Add feature for the LLVM version in use, so it can be tested in REQUIRES and # XFAIL checks. We also add "not-XXX" variants, for the same reason. @@ -1568,21 +1568,21 @@ config.llvm_version_minor) config.available_features.add("llvm-" + current_llvm_version) diff --git a/test/regression/2007-08-16-invalid-constant-value.c b/test/regression/2007-08-16-invalid-constant-value.c -index e0b304f40b01..d65be6af4929 100644 +index e0b304f40b01..2b428f643ec5 100644 --- a/test/regression/2007-08-16-invalid-constant-value.c +++ b/test/regression/2007-08-16-invalid-constant-value.c @@ -1,3 +1,4 @@ -+// REQUIRES: not-llvm-3.8 ++// REQUIRES: lt-llvm-3.8 // RUN: rm -f %t4.out %t4.err %t4.log // RUN: %llvmgcc %s -emit-llvm -O2 -c -o %t1.bc // RUN: llvm-as -f %p/../Feature/_utils._ll -o %t2.bc diff --git a/test/regression/2007-08-16-invalid-constant-value.llvm38.c b/test/regression/2007-08-16-invalid-constant-value.llvm38.c new file mode 100644 -index 000000000000..907749e3cf83 +index 000000000000..71daeac5b523 --- /dev/null +++ b/test/regression/2007-08-16-invalid-constant-value.llvm38.c @@ -0,0 +1,33 @@ -+// REQUIRES: llvm-3.8 ++// REQUIRES: geq-llvm-3.8 +// RUN: rm -f %t4.out %t4.err %t4.log +// RUN: %llvmgcc %s -emit-llvm -O2 -c -o %t1.bc +// RUN: llvm-as -f %p/../Feature/_utils.llvm38._ll -o %t2.bc @@ -1616,5 +1616,5 @@ + return 0; +} -- -2.12.0 +2.13.1 ++++++ 0008-travis-CI-add-LLVM-3.8-build-tests.patch ++++++ From: Jiri Slaby <[email protected]> Date: Thu, 23 Feb 2017 15:27:56 +0100 Subject: travis CI: add LLVM 3.8 build tests Patch-mainline: no 3.9 does not seem to be in deb repos yet. 3.7 is not in debian repos either (already). Legacy build system is not supported since 3.8. Signed-off-by: Jiri Slaby <[email protected]> --- .travis.yml | 4 +++- .travis/install-llvm-and-runtime-compiler.sh | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9a337952b17c..7c6b93c497ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ env: ########################################################################### # Check a subset of the matrix of: - # LLVM : {2.9, 3.4, 3.5, 3.6} + # LLVM : {2.9, 3.4, 3.5, 3.6, 3.8, 3.9} # SOLVERS : {Z3, STP, STP:Z3, metaSMT} # STP_VERSION : {2.1.2, master} # METASMT_VERSION : {v4.rc1} @@ -41,6 +41,8 @@ env: # TODO: Add Doxygen build # Check KLEE CMake build in a few configurations +# This should be 3.9, but debian does not seem to have llvm 3.9 yet. + - LLVM_VERSION=3.8 SOLVERS=STP:Z3 STP_VERSION=2.1.2 KLEE_UCLIBC=klee_uclibc_v1.0.0 DISABLE_ASSERTIONS=0 ENABLE_OPTIMIZED=1 COVERAGE=0 USE_TCMALLOC=1 USE_CMAKE=1 - LLVM_VERSION=3.6 SOLVERS=STP:Z3 STP_VERSION=2.1.2 KLEE_UCLIBC=klee_uclibc_v1.0.0 DISABLE_ASSERTIONS=0 ENABLE_OPTIMIZED=1 COVERAGE=0 USE_TCMALLOC=1 USE_CMAKE=1 - LLVM_VERSION=3.5 SOLVERS=STP:Z3 STP_VERSION=2.1.2 KLEE_UCLIBC=klee_uclibc_v1.0.0 DISABLE_ASSERTIONS=0 ENABLE_OPTIMIZED=1 COVERAGE=0 USE_TCMALLOC=1 USE_CMAKE=1 diff --git a/.travis/install-llvm-and-runtime-compiler.sh b/.travis/install-llvm-and-runtime-compiler.sh index 8e8e98633aac..c5993a7b2e84 100755 --- a/.travis/install-llvm-and-runtime-compiler.sh +++ b/.travis/install-llvm-and-runtime-compiler.sh @@ -5,7 +5,10 @@ if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y llvm-${LLVM_VERSION} llvm-${LLVM_VERSION}-dev if [ "${LLVM_VERSION}" != "2.9" ]; then - sudo apt-get install -y llvm-${LLVM_VERSION}-tools clang-${LLVM_VERSION} + sudo apt-get install -y clang-${LLVM_VERSION} + if [ "${LLVM_VERSION}" != "3.8" -a "${LLVM_VERSION}" != "3.9" ]; then + sudo apt-get install -y llvm-${LLVM_VERSION}-tools + fi sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 20 sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION} 20 else -- 2.13.1 ++++++ 0009-llvm40-handle-different-header-names.patch ++++++ From: Jiri Slaby <[email protected]> Date: Wed, 7 Jun 2017 14:57:45 +0200 Subject: llvm40: handle different header names Patch-mainline: no LLVM 4.0 renamed and split some headers. Take this into account in includes. Signed-off-by: Jiri Slaby <[email protected]> --- lib/Module/KModule.cpp | 4 ++++ lib/Module/ModuleUtil.cpp | 6 ++++++ tools/klee/main.cpp | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index b31b7fd5a56d..a47e0a43615a 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -21,7 +21,11 @@ #include "klee/Internal/Support/Debug.h" #include "klee/Internal/Support/ModuleUtil.h" +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) +#include "llvm/Bitcode/BitcodeWriter.h" +#else #include "llvm/Bitcode/ReaderWriter.h" +#endif #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3) #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index 14d48b026d14..6bdea479ee06 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -19,7 +19,11 @@ #endif #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3) +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) +#include <llvm/Bitcode/BitcodeReader.h> +#else #include "llvm/Bitcode/ReaderWriter.h" +#endif #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" @@ -31,7 +35,9 @@ #include "llvm/Support/FileSystem.h" #include "llvm/IR/ValueSymbolTable.h" #include "llvm/Support/SourceMgr.h" +#if LLVM_VERSION_CODE < LLVM_VERSION(4, 0) #include "llvm/Support/DataStream.h" +#endif #else #include "llvm/Function.h" #include "llvm/Instructions.h" diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index eac69ada30e0..eccc79776bb5 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -43,13 +43,18 @@ #endif #include "llvm/Support/Errno.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) +#include <llvm/Bitcode/BitcodeReader.h> +#else +#include <llvm/Bitcode/ReaderWriter.h> +#endif + #if LLVM_VERSION_CODE < LLVM_VERSION(3, 0) #include "llvm/Target/TargetSelect.h" #else -- 2.13.1 ++++++ 0010-llvm-APFloat-members-are-functions-in-LLVM-4.0.patch ++++++ From: Jiri Slaby <[email protected]> Date: Wed, 7 Jun 2017 14:54:32 +0200 Subject: llvm: APFloat members are functions in LLVM 4.0 Patch-mainline: no Signed-off-by: Jiri Slaby <[email protected]> --- lib/Core/Executor.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 841734573abc..4a0239dace49 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -1542,12 +1542,21 @@ static bool isDebugIntrinsic(const Function *f, KModule *KM) { static inline const llvm::fltSemantics * fpWidthToSemantics(unsigned width) { switch(width) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + case Expr::Int32: + return &llvm::APFloat::IEEEsingle(); + case Expr::Int64: + return &llvm::APFloat::IEEEdouble(); + case Expr::Fl80: + return &llvm::APFloat::x87DoubleExtended(); +#else case Expr::Int32: return &llvm::APFloat::IEEEsingle; case Expr::Int64: return &llvm::APFloat::IEEEdouble; case Expr::Fl80: return &llvm::APFloat::x87DoubleExtended; +#endif default: return 0; } -- 2.13.1 ++++++ 0011-llvm40-errorOr-and-similar.patch ++++++ From: Jiri Slaby <[email protected]> Date: Wed, 7 Jun 2017 14:58:29 +0200 Subject: llvm40: errorOr and similar Patch-mainline: no Signed-off-by: Jiri Slaby <[email protected]> --- lib/Module/ModuleUtil.cpp | 31 ++++++++++++++++++++++++++----- tools/klee/main.cpp | 19 +++++++++++++++---- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index 6bdea479ee06..a807ff79e95e 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -219,7 +219,7 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Loading modules\n"); // Load all bitcode files in to memory so we can examine their symbols #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9) - Error Err; + Error Err = Error::success(); for (object::Archive::child_iterator AI = archive->child_begin(Err), AE = archive->child_end(); AI != AE; ++AI) #elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) @@ -244,8 +244,14 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er #else object::Archive::child_iterator childErr = AI; #endif +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + Expected<StringRef> memberNameErr = childErr->getName(); + ec = memberNameErr ? std::error_code() : + errorToErrorCode(memberNameErr.takeError()); +#else ErrorOr<StringRef> memberNameErr = childErr->getName(); ec = memberNameErr.getError(); +#endif if (!ec) { memberName = memberNameErr.get(); #else @@ -279,7 +285,10 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er #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) +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + Expected<MemoryBufferRef> buff = childErr->getMemoryBufferRef(); + ec = buff ? std::error_code() : errorToErrorCode(buff.takeError()); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) ErrorOr<MemoryBufferRef> buff = childErr->getMemoryBufferRef(); ec = buff.getError(); #elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) @@ -303,13 +312,20 @@ 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) -#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + Expected<std::unique_ptr<Module> > resultErr = + parseBitcodeFile(buff.get(), composite->getContext()); + ec = resultErr ? std::error_code() : + errorToErrorCode(resultErr.takeError()); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) ErrorOr<std::unique_ptr<Module> > resultErr = + parseBitcodeFile(buff.get(), composite->getContext()); + ec = resultErr.getError(); #else ErrorOr<Module *> resultErr = -#endif parseBitcodeFile(buff.get(), composite->getContext()); ec = resultErr.getError(); +#endif if (ec) errorMessage = ec.message(); else @@ -488,7 +504,12 @@ Module *klee::linkWithLibrary(Module *module, #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(4, 0) + Expected<std::unique_ptr<Module> > ResultErr = + parseBitcodeFile(Buffer, Context); + if (!ResultErr) { + ErrorMessage = errorToErrorCode(ResultErr.takeError()).message(); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5) #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7) ErrorOr<std::unique_ptr<Module> > ResultErr = #else diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index eccc79776bb5..098f9308d130 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -1278,15 +1278,23 @@ int main(int argc, char **argv, char **envp) { klee_error("error loading program '%s': %s", InputFile.c_str(), Buffer.getError().message().c_str()); -#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) + std::error_code ec; +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + Expected<std::unique_ptr<Module>> mainModuleOrError = + getOwningLazyBitcodeModule(std::move(Buffer.get()), ctx); + ec = mainModuleOrError ? std::error_code() : + errorToErrorCode(mainModuleOrError.takeError()); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) auto mainModuleOrError = getLazyBitcodeModule(std::move(Buffer.get()), ctx); + ec = mainModuleOrError.getError(); #else auto mainModuleOrError = getLazyBitcodeModule(Buffer->get(), ctx); + ec = mainModuleOrError.getError(); #endif - if (!mainModuleOrError) { + if (ec) { klee_error("error loading program '%s': %s", InputFile.c_str(), - mainModuleOrError.getError().message().c_str()); + ec.message().c_str()); } else { // The module has taken ownership of the MemoryBuffer so release it @@ -1298,7 +1306,10 @@ int main(int argc, char **argv, char **envp) { #else mainModule = *mainModuleOrError; #endif -#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8) +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + if (llvm::Error err = mainModule->materializeAll()) { + std::error_code ec = errorToErrorCode(std::move(err)); +#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 8) if (auto ec = mainModule->materializeAll()) { #else if (auto ec = mainModule->materializeAllPermanently()) { -- 2.13.1 ++++++ 0012-llvm-use-chrono-helpers-from-LLVM-4.0.patch ++++++ From: Jiri Slaby <[email protected]> Date: Wed, 7 Jun 2017 13:36:28 +0200 Subject: llvm: use chrono helpers from LLVM 4.0 Patch-mainline: no LLVM 4.0 removes the old time interface and starts using the C++11's chrono. So swiych to that in klee for LLVM 4.0 too. Signed-off-by: Jiri Slaby <[email protected]> --- include/klee/Internal/Support/Timer.h | 8 ++++++++ include/klee/Internal/System/Time.h | 11 +++++++++++ lib/Core/StatsTracker.cpp | 24 ++++++++++++++++++++++++ lib/Support/Time.cpp | 32 ++++++++++++++++++++++++++++++++ lib/Support/Timer.cpp | 16 ++++++++++++++++ 5 files changed, 91 insertions(+) diff --git a/include/klee/Internal/Support/Timer.h b/include/klee/Internal/Support/Timer.h index a422abd027f3..d80ccb31f647 100644 --- a/include/klee/Internal/Support/Timer.h +++ b/include/klee/Internal/Support/Timer.h @@ -12,9 +12,17 @@ #include <stdint.h> +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) +#include <llvm/Support/Chrono.h> +#endif + namespace klee { class WallTimer { +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + llvm::sys::TimePoint<> start; +#else uint64_t startMicroseconds; +#endif public: WallTimer(); diff --git a/include/klee/Internal/System/Time.h b/include/klee/Internal/System/Time.h index 14d235364401..feeeed8affa2 100644 --- a/include/klee/Internal/System/Time.h +++ b/include/klee/Internal/System/Time.h @@ -10,7 +10,13 @@ #ifndef KLEE_UTIL_TIME_H #define KLEE_UTIL_TIME_H +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) +#include <chrono> + +#include <llvm/Support/Chrono.h> +#else #include <llvm/Support/TimeValue.h> +#endif namespace klee { namespace util { @@ -22,7 +28,12 @@ namespace klee { double getWallTime(); /// Wall time as TimeValue object. +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + double durationToDouble(std::chrono::nanoseconds dur); + llvm::sys::TimePoint<> getWallTimeVal(); +#else llvm::sys::TimeValue getWallTimeVal(); +#endif } } diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index 798318ae8992..abfc6bf823be 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -294,6 +294,29 @@ void StatsTracker::done() { void StatsTracker::stepInstruction(ExecutionState &es) { if (OutputIStats) { if (TrackInstructionTime) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + static sys::TimePoint<> lastNowTime; + static std::chrono::nanoseconds lastUserTime(0); + + if (lastUserTime.count() == 0) { + std::chrono::nanoseconds sys; + sys::Process::GetTimeUsage(lastNowTime, lastUserTime, sys); + } else { + sys::TimePoint<> now; + std::chrono::nanoseconds user, sys; + + sys::Process::GetTimeUsage(now, user, sys); + + std::chrono::microseconds delta = + std::chrono::duration_cast<std::chrono::microseconds>(user - lastUserTime); + std::chrono::microseconds deltaNow = + std::chrono::duration_cast<std::chrono::microseconds>(now - lastNowTime); + stats::instructionTime += delta.count(); + stats::instructionRealTime += deltaNow.count(); + lastUserTime = user; + lastNowTime = now; + } +#else static sys::TimeValue lastNowTime(0,0),lastUserTime(0,0); if (lastUserTime.seconds()==0 && lastUserTime.nanoseconds()==0) { @@ -309,6 +332,7 @@ void StatsTracker::stepInstruction(ExecutionState &es) { lastUserTime = user; lastNowTime = now; } +#endif } Instruction *inst = es.pc->inst; diff --git a/lib/Support/Time.cpp b/lib/Support/Time.cpp index be5eaf186958..c931c058ffd0 100644 --- a/lib/Support/Time.cpp +++ b/lib/Support/Time.cpp @@ -10,12 +10,43 @@ #include "klee/Config/Version.h" #include "klee/Internal/System/Time.h" +#include <chrono> + +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) +#include <llvm/Support/Chrono.h> +#else #include "llvm/Support/TimeValue.h" +#endif + #include "llvm/Support/Process.h" using namespace llvm; using namespace klee; +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) +double util::durationToDouble(std::chrono::nanoseconds dur) +{ + return dur.count() / 1e9; +} + +double util::getUserTime() { + sys::TimePoint<> now; + std::chrono::nanoseconds user, sys; + + sys::Process::GetTimeUsage(now, user, sys); + + return durationToDouble(user); +} + +double util::getWallTime() { + return durationToDouble(getWallTimeVal().time_since_epoch()); +} + +sys::TimePoint<> util::getWallTimeVal() { + return std::chrono::system_clock::now(); +} + +#else double util::getUserTime() { sys::TimeValue now(0,0),user(0,0),sys(0,0); sys::Process::GetTimeUsage(now,user,sys); @@ -30,3 +61,4 @@ double util::getWallTime() { sys::TimeValue util::getWallTimeVal() { return sys::TimeValue::now(); } +#endif diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index da96981079ae..a223b39ada57 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -15,6 +15,20 @@ using namespace klee; using namespace llvm; +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + +WallTimer::WallTimer() { + start = util::getWallTimeVal(); +} + +uint64_t WallTimer::check() { + sys::TimePoint<> now = util::getWallTimeVal(); + return std::chrono::duration_cast<std::chrono::microseconds>(now - + start).count(); +} + +#else + WallTimer::WallTimer() { startMicroseconds = util::getWallTimeVal().usec(); } @@ -22,3 +36,5 @@ WallTimer::WallTimer() { uint64_t WallTimer::check() { return util::getWallTimeVal().usec() - startMicroseconds; } + +#endif -- 2.13.1 ++++++ 0013-llvm-PointerType-is-not-SequentialType-in-LLVM-4.patch ++++++ From: Jiri Slaby <[email protected]> Date: Thu, 8 Jun 2017 13:25:56 +0200 Subject: llvm: PointerType is not SequentialType in LLVM 4 Patch-mainline: no So handle the type specially whenever needed. Signed-off-by: Jiri Slaby <[email protected]> --- include/klee/util/GetElementPtrTypeIterator.h | 5 +++++ lib/Core/Executor.cpp | 22 +++++++++++++++++++--- lib/Core/ExecutorUtil.cpp | 17 ++++++++++++++--- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/include/klee/util/GetElementPtrTypeIterator.h b/include/klee/util/GetElementPtrTypeIterator.h index 2d145cd67f14..b551d772eaac 100644 --- a/include/klee/util/GetElementPtrTypeIterator.h +++ b/include/klee/util/GetElementPtrTypeIterator.h @@ -93,6 +93,11 @@ namespace klee { if (LLVM_TYPE_Q llvm::CompositeType *CT = dyn_cast<llvm::CompositeType>(CurTy)) { CurTy = CT->getTypeAtIndex(getOperand()); +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + } else if (LLVM_TYPE_Q llvm::PointerType *ptr = + dyn_cast<llvm::PointerType>(CurTy)) { + CurTy = ptr->getElementType(); +#endif } else { CurTy = 0; } diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 4a0239dace49..fd5cb5e4e751 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -2648,8 +2648,7 @@ void Executor::computeOffsets(KGEPInstruction *kgepi, TypeIt ib, TypeIt ie) { uint64_t addend = sl->getElementOffset((unsigned) ci->getZExtValue()); constantOffset = constantOffset->Add(ConstantExpr::alloc(addend, Context::get().getPointerWidth())); - } else { - const SequentialType *set = cast<SequentialType>(*ii); + } else if (const SequentialType *set = dyn_cast<SequentialType>(*ii)) { uint64_t elementSize = kmodule->targetData->getTypeStoreSize(set->getElementType()); Value *operand = ii.getOperand(); @@ -2663,7 +2662,24 @@ void Executor::computeOffsets(KGEPInstruction *kgepi, TypeIt ib, TypeIt ie) { } else { kgepi->indices.push_back(std::make_pair(index, elementSize)); } - } +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + } else if (const PointerType *ptr = dyn_cast<PointerType>(*ii)) { + uint64_t elementSize = + kmodule->targetData->getTypeStoreSize(ptr->getElementType()); + Value *operand = ii.getOperand(); + if (Constant *c = dyn_cast<Constant>(operand)) { + ref<ConstantExpr> index = + evalConstant(c)->SExt(Context::get().getPointerWidth()); + ref<ConstantExpr> addend = + index->Mul(ConstantExpr::alloc(elementSize, + Context::get().getPointerWidth())); + constantOffset = constantOffset->Add(addend); + } else { + kgepi->indices.push_back(std::make_pair(index, elementSize)); + } +#endif + } else + assert("invalid type" && 0); index++; } kgepi->offset = constantOffset->getZExtValue(); diff --git a/lib/Core/ExecutorUtil.cpp b/lib/Core/ExecutorUtil.cpp index b91b5deec173..a63b891bf925 100644 --- a/lib/Core/ExecutorUtil.cpp +++ b/lib/Core/ExecutorUtil.cpp @@ -102,8 +102,7 @@ namespace klee { addend = ConstantExpr::alloc(sl->getElementOffset((unsigned) ci->getZExtValue()), Context::get().getPointerWidth()); - } else { - const SequentialType *set = cast<SequentialType>(*ii); + } else if (const SequentialType *set = dyn_cast<SequentialType>(*ii)) { ref<ConstantExpr> index = evalConstant(cast<Constant>(ii.getOperand())); unsigned elementSize = @@ -112,7 +111,19 @@ namespace klee { index = index->ZExt(Context::get().getPointerWidth()); addend = index->Mul(ConstantExpr::alloc(elementSize, Context::get().getPointerWidth())); - } +#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0) + } else if (const PointerType *ptr = dyn_cast<PointerType>(*ii)) { + ref<ConstantExpr> index = + evalConstant(cast<Constant>(ii.getOperand())); + unsigned elementSize = + kmodule->targetData->getTypeStoreSize(ptr->getElementType()); + + index = index->ZExt(Context::get().getPointerWidth()); + addend = index->Mul(ConstantExpr::alloc(elementSize, + Context::get().getPointerWidth())); +#endif + } else + assert("invalid type" && 0); base = base->Add(addend); } -- 2.13.1 ++++++ FileCheck.cpp ++++++ ++++ 1397 lines (skipped) ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.Y5J6ge/_old 2017-06-12 15:32:19.477267161 +0200 +++ /var/tmp/diff_new_pack.Y5J6ge/_new 2017-06-12 15:32:19.477267161 +0200 @@ -1,4 +1,4 @@ <servicedata> <service name="tar_scm"> <param name="url">git://github.com/klee/klee.git</param> - <param name="changesrevision">28872c1a0cb8a8f6b835af67719b9cd9aba66d3f</param></service></servicedata> \ No newline at end of file + <param name="changesrevision">1310855836fb7e931371647f4464801c277b0f7c</param></service></servicedata> \ No newline at end of file ++++++ klee-1.3.0+20170409.tar.xz -> klee-1.3.0+20170607.tar.xz ++++++ ++++ 2185 lines of diff (skipped) ++++++ not.cpp ++++++ --- /var/tmp/diff_new_pack.Y5J6ge/_old 2017-06-12 15:32:20.117176909 +0200 +++ /var/tmp/diff_new_pack.Y5J6ge/_new 2017-06-12 15:32:20.121176345 +0200 @@ -12,7 +12,6 @@ // 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;
