aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Core
diff options
context:
space:
mode:
authorJulian Büning <julian.buening@rwth-aachen.de>2019-03-20 22:01:00 +0100
committerMartinNowack <martin.nowack@gmail.com>2019-03-21 12:46:01 +0000
commit9767a37f9e8a743fa81629510346cb0a5a3a7900 (patch)
treebc49e16925582e41ee51cacc35c4f7bcafd8860f /lib/Core
parenteee440835b857a7cb68b72f4af4d22eaf19e1d76 (diff)
downloadklee-9767a37f9e8a743fa81629510346cb0a5a3a7900.tar.gz
drop support for LLVM <= 3.7
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/CMakeLists.txt11
-rw-r--r--lib/Core/Executor.cpp26
-rw-r--r--lib/Core/ExecutorUtil.cpp6
-rw-r--r--lib/Core/ExternalDispatcher.cpp42
-rw-r--r--lib/Core/Searcher.cpp7
-rw-r--r--lib/Core/StatsTracker.cpp23
6 files changed, 14 insertions, 101 deletions
diff --git a/lib/Core/CMakeLists.txt b/lib/Core/CMakeLists.txt
index 4b14df36..83a6e001 100644
--- a/lib/Core/CMakeLists.txt
+++ b/lib/Core/CMakeLists.txt
@@ -33,17 +33,12 @@ klee_add_component(kleeCore
# kleeCore.
set(LLVM_COMPONENTS
core
+ executionengine
+ mcjit
+ native
support
)
-if ("${LLVM_PACKAGE_VERSION}" VERSION_EQUAL "3.6" OR
- "${LLVM_PACKAGE_VERSION}" VERSION_GREATER "3.6")
- list(APPEND LLVM_COMPONENTS mcjit executionengine native)
-else()
- list(APPEND LLVM_COMPONENTS jit engine)
-endif()
-
-
klee_get_llvm_libs(LLVM_LIBS ${LLVM_COMPONENTS})
target_link_libraries(kleeCore PUBLIC ${LLVM_LIBS})
target_link_libraries(kleeCore PRIVATE
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 7a676cc3..d14fae21 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -56,6 +56,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
@@ -70,12 +71,6 @@
#include "llvm/Support/Process.h"
#include "llvm/Support/raw_ostream.h"
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
-#include "llvm/Support/CallSite.h"
-#else
-#include "llvm/IR/CallSite.h"
-#endif
-
#include <algorithm>
#include <cassert>
#include <cerrno>
@@ -597,11 +592,7 @@ void Executor::initializeGlobalObject(ExecutionState &state, ObjectState *os,
for (unsigned i=0, e=cds->getNumElements(); i != e; ++i)
initializeGlobalObject(state, os, cds->getElementAsConstant(i),
offset + i*elementSize);
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
} else if (!isa<UndefValue>(c) && !isa<MetadataAsValue>(c)) {
-#else
- } else if (!isa<UndefValue>(c)) {
-#endif
unsigned StoreBits = targetData->getTypeStoreSizeInBits(c->getType());
ref<ConstantExpr> C = evalConstant(c);
@@ -1560,13 +1551,8 @@ Function* Executor::getTargetFunction(Value *calledVal, ExecutionState &state) {
while (true) {
if (GlobalValue *gv = dyn_cast<GlobalValue>(c)) {
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
if (!Visited.insert(gv).second)
return 0;
-#else
- if (!Visited.insert(gv))
- return 0;
-#endif
std::string alias = state.getFnAlias(gv->getName());
if (alias != "") {
GlobalValue *old_gv = gv;
@@ -1814,12 +1800,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
std::map<ref<Expr>, BasicBlock *> expressionOrder;
// Iterate through all non-default cases and order them by expressions
-#if LLVM_VERSION_CODE > LLVM_VERSION(3, 4)
for (auto i : si->cases()) {
-#else
- for (SwitchInst::CaseIt i = si->case_begin(), e = si->case_end(); i != e;
- ++i) {
-#endif
ref<Expr> value = evalConstant(i.getCaseValue());
BasicBlock *caseSuccessor = i.getCaseSuccessor();
@@ -2402,13 +2383,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
!fpWidthToSemantics(right->getWidth()))
return terminateStateOnExecError(state, "Unsupported FRem operation");
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
bindLocal(ki, state, ConstantExpr::alloc(Res.bitcastToAPInt()));
break;
}
diff --git a/lib/Core/ExecutorUtil.cpp b/lib/Core/ExecutorUtil.cpp
index c80354e2..7b227eba 100644
--- a/lib/Core/ExecutorUtil.cpp
+++ b/lib/Core/ExecutorUtil.cpp
@@ -23,14 +23,10 @@
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
+#include "llvm/IR/GetElementPtrTypeIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
-#include "llvm/Support/GetElementPtrTypeIterator.h"
-#else
-#include "llvm/IR/GetElementPtrTypeIterator.h"
-#endif
#include "llvm/Support/raw_ostream.h"
#include <cassert>
diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp
index 28bc1898..2b537b7d 100644
--- a/lib/Core/ExternalDispatcher.cpp
+++ b/lib/Core/ExternalDispatcher.cpp
@@ -10,30 +10,19 @@
#include "ExternalDispatcher.h"
#include "klee/Config/Version.h"
+#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
-#include "llvm/ExecutionEngine/MCJIT.h"
-#else
-#include "llvm/ExecutionEngine/JIT.h"
-#endif
-
#include "llvm/ExecutionEngine/GenericValue.h"
+#include "llvm/ExecutionEngine/MCJIT.h"
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/raw_ostream.h"
-
#include "llvm/Support/TargetSelect.h"
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
-#include "llvm/Support/CallSite.h"
-#else
-#include "llvm/IR/CallSite.h"
-#endif
-
#include <csetjmp>
#include <csignal>
@@ -122,11 +111,6 @@ ExternalDispatcherImpl::ExternalDispatcherImpl(LLVMContext &ctx)
: ctx(ctx), lastErrno(0) {
std::string error;
singleDispatchModule = new Module(getFreshModuleID(), ctx);
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 6)
- // Use old JIT
- executionEngine = ExecutionEngine::createJIT(singleDispatchModule, &error);
-#else
- // Use MCJIT.
// The MCJIT JITs whole modules at a time rather than individual functions
// so we will let it manage the modules.
// Note that we don't do anything with `singleDispatchModule`. This is just
@@ -136,7 +120,6 @@ ExternalDispatcherImpl::ExternalDispatcherImpl(LLVMContext &ctx)
.setErrorStr(&error)
.setEngineKind(EngineKind::JIT)
.create();
-#endif
if (!executionEngine) {
llvm::errs() << "unable to make jit: " << error << "\n";
@@ -146,10 +129,8 @@ ExternalDispatcherImpl::ExternalDispatcherImpl(LLVMContext &ctx)
// If we have a native target, initialize it to ensure it is linked in and
// usable by the JIT.
llvm::InitializeNativeTarget();
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
llvm::InitializeNativeTargetAsmParser();
llvm::InitializeNativeTargetAsmPrinter();
-#endif
// from ExecutionEngine::create
if (executionEngine) {
@@ -197,21 +178,16 @@ bool ExternalDispatcherImpl::executeCall(Function *f, Instruction *i,
#endif
Module *dispatchModule = NULL;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
// The MCJIT generates whole modules at a time so for every call that we
// haven't made before we need to create a new Module.
dispatchModule = new Module(getFreshModuleID(), ctx);
-#else
- dispatchModule = this->singleDispatchModule;
-#endif
dispatcher = createDispatcher(f, i, dispatchModule);
dispatchers.insert(std::make_pair(i, dispatcher));
-// Force the JIT execution engine to go ahead and build the function. This
-// ensures that any errors or assertions in the compilation process will
-// trigger crashes instead of being caught as aborts in the external
-// function.
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+ // Force the JIT execution engine to go ahead and build the function. This
+ // ensures that any errors or assertions in the compilation process will
+ // trigger crashes instead of being caught as aborts in the external
+ // function.
if (dispatcher) {
// The dispatchModule is now ready so tell MCJIT to generate the code for
// it.
@@ -228,12 +204,6 @@ bool ExternalDispatcherImpl::executeCall(Function *f, Instruction *i,
// MCJIT didn't take ownership of the module so delete it.
delete dispatchModule;
}
-#else
- if (dispatcher) {
- // Old JIT works on a function at a time so compile the function.
- executionEngine->recompileAndRelinkFunction(dispatcher);
- }
-#endif
return runProtectedCall(dispatcher, args);
}
diff --git a/lib/Core/Searcher.cpp b/lib/Core/Searcher.cpp
index 47457a91..49f6e52b 100644
--- a/lib/Core/Searcher.cpp
+++ b/lib/Core/Searcher.cpp
@@ -25,17 +25,12 @@
#include "klee/Internal/Support/ModuleUtil.h"
#include "klee/Internal/System/Time.h"
#include "klee/Internal/Support/ErrorHandling.h"
+#include "llvm/IR/CallSite.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/CommandLine.h"
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
-#include "llvm/Support/CallSite.h"
-#else
-#include "llvm/IR/CallSite.h"
-#endif
-
#include <cassert>
#include <fstream>
#include <climits>
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index c0e3264d..dac18370 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -27,6 +27,8 @@
#include "UserSearcher.h"
#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/CallSite.h"
+#include "llvm/IR/CFG.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
@@ -38,14 +40,6 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/FileSystem.h"
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
-#include "llvm/Support/CallSite.h"
-#include "llvm/Support/CFG.h"
-#else
-#include "llvm/IR/CallSite.h"
-#include "llvm/IR/CFG.h"
-#endif
-
#include <fstream>
#include <unistd.h>
@@ -207,17 +201,8 @@ StatsTracker::StatsTracker(Executor &_executor, std::string _objectFilename,
if (!sys::path::is_absolute(objectFilename)) {
SmallString<128> current(objectFilename);
if(sys::fs::make_absolute(current)) {
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
Twine current_twine(current.str()); // requires a twine for this
if (!sys::fs::exists(current_twine)) {
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- bool exists = false;
- if (!sys::fs::exists(current.str(), exists)) {
-#else
- bool exists = false;
- error_code ec = sys::fs::exists(current.str(), exists);
- if (ec == errc::success && exists) {
-#endif
objectFilename = current.c_str();
}
}
@@ -643,11 +628,7 @@ 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;