Skip to content

Commit

Permalink
remove LLVM < 9
Browse files Browse the repository at this point in the history
  • Loading branch information
251 authored and MartinNowack committed Jun 30, 2022
1 parent b853933 commit 6cc8ee7
Show file tree
Hide file tree
Showing 38 changed files with 23 additions and 587 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ jobs:
"LLVM 11, Doxygen",
"LLVM 10",
"LLVM 9",
"LLVM 8",
"LLVM 7",
"LLVM 6",
"ASan",
"UBSan",
"MSan",
Expand Down Expand Up @@ -70,15 +67,6 @@ jobs:
- name: "LLVM 9"
env:
LLVM_VERSION: 9
- name: "LLVM 8"
env:
LLVM_VERSION: 8
- name: "LLVM 7"
env:
LLVM_VERSION: 7
- name: "LLVM 6"
env:
LLVM_VERSION: "6.0"
# Sanitizer builds. Do unoptimized build otherwise the optimizer might remove problematic code
- name: "ASan"
env:
Expand Down
14 changes: 2 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,6 @@ else()
set(HAVE_SELINUX 0)
endif()

################################################################################
# Workarounds
################################################################################
include(${CMAKE_SOURCE_DIR}/cmake/workaround_llvm_pr39177.cmake)

################################################################################
# KLEE runtime support
################################################################################
Expand Down Expand Up @@ -612,13 +607,8 @@ if (ENABLE_KLEE_EH_CXX)
endif()
message(STATUS "Use libc++abi source path: \"${KLEE_LIBCXXABI_SRC_DIR}\"")

if (${LLVM_VERSION_MAJOR} GREATER 8 OR ${LLVM_VERSION_MAJOR} EQUAL 8)
set(SUPPORT_KLEE_EH_CXX 1) # For config.h
message(STATUS "Support for C++ Exceptions enabled")
else()
set(SUPPORT_KLEE_EH_CXX 0) # For config.h
message(STATUS "Support for C++ Exceptions (only available for LLVM >= 8.0.0) disabled")
endif()
set(SUPPORT_KLEE_EH_CXX 1) # For config.h
message(STATUS "Support for C++ Exceptions enabled")

else()
set(SUPPORT_KLEE_EH_CXX 0) # For config.h
Expand Down
133 changes: 0 additions & 133 deletions cmake/workaround_llvm_pr39177.cmake

This file was deleted.

18 changes: 0 additions & 18 deletions cmake/workaround_llvm_pr39177.ll

This file was deleted.

3 changes: 0 additions & 3 deletions include/klee/Config/config.h.cmin
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@
/* Define to the version of this package. */
#cmakedefine PACKAGE_VERSION @PACKAGE_VERSION@

/* Use Workaround for LLVM PR39177 (affecting LLVM 3.9 - 7.0.0) */
#cmakedefine USE_WORKAROUND_LLVM_PR39177 @USE_WORKAROUND_LLVM_PR39177@

/* libcxx is supported */
#cmakedefine SUPPORT_KLEE_LIBCXX @SUPPORT_KLEE_LIBCXX@

Expand Down
7 changes: 0 additions & 7 deletions include/klee/Support/Casting.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ using llvm::cast_or_null;
using llvm::dyn_cast;
using llvm::dyn_cast_or_null;
using llvm::isa;
#if LLVM_VERSION_CODE >= LLVM_VERSION(9, 0)
using llvm::isa_and_nonnull;
#else
template <typename... X, typename Y>
inline bool isa_and_nonnull(const Y &value) {
return value && isa<X...>(value);
}
#endif

} // namespace klee

Expand Down
20 changes: 5 additions & 15 deletions include/klee/Support/ModuleUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@

#include "klee/Config/Version.h"

#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0)
#include "llvm/IR/InstrTypes.h"
#else
#include "llvm/IR/CallSite.h"
#endif
#include "llvm/IR/Module.h"

#include <memory>
Expand Down Expand Up @@ -44,17 +40,11 @@ linkModules(std::vector<std::unique_ptr<llvm::Module>> &modules,
/// calls, although complicated constant expressions might be
/// another possibility).
///
/// If `moduleIsFullyLinked` is set to true it will be assumed that the
/// module containing the `llvm::CallSite` (`llvm::CallBase` on LLVM 8+)
/// is fully linked. This assumption allows resolution of functions
/// that are marked as overridable.
llvm::Function *getDirectCallTarget(
#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0)
const llvm::CallBase &cb,
#else
const llvm::CallSite &cs,
#endif
bool moduleIsFullyLinked);
/// If `moduleIsFullyLinked` is set to true it will be assumed that the module
/// containing the `llvm::CallBase` is fully linked. This assumption allows
/// resolution of functions that are marked as overridable.
llvm::Function *getDirectCallTarget(const llvm::CallBase &cb,
bool moduleIsFullyLinked);

/// Return true iff the given Function value is used in something
/// other than a direct call (or a constant expression that
Expand Down
38 changes: 0 additions & 38 deletions lib/Core/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/BasicBlock.h"
#if LLVM_VERSION_CODE < LLVM_VERSION(8, 0)
#include "llvm/IR/CallSite.h"
#endif
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
Expand Down Expand Up @@ -1782,7 +1779,6 @@ void Executor::executeCall(ExecutionState &state, KInstruction *ki, Function *f,
}
#endif

#if LLVM_VERSION_CODE >= LLVM_VERSION(7, 0)
case Intrinsic::fshr:
case Intrinsic::fshl: {
ref<Expr> op1 = eval(ki, 1, state).value;
Expand All @@ -1807,7 +1803,6 @@ void Executor::executeCall(ExecutionState &state, KInstruction *ki, Function *f,
}
break;
}
#endif

// va_arg is handled by caller and intrinsic lowering, see comment for
// ExecutionState::varargs
Expand Down Expand Up @@ -1928,21 +1923,10 @@ void Executor::executeCall(ExecutionState &state, KInstruction *ki, Function *f,
uint64_t offsets[callingArgs]; // offsets of variadic arguments
uint64_t argWidth; // width of current variadic argument

#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0)
const CallBase &cs = cast<CallBase>(*i);
#else
const CallSite cs(i);
#endif
for (unsigned k = funcArgs; k < callingArgs; k++) {
if (cs.isByValArgument(k)) {
#if LLVM_VERSION_CODE >= LLVM_VERSION(9, 0)
Type *t = cs.getParamByValType(k);
#else
auto arg = cs.getArgOperand(k);
Type *t = arg->getType();
assert(t->isPointerTy());
t = t->getPointerElementType();
#endif
argWidth = kmodule->targetData->getTypeSizeInBits(t);
} else {
argWidth = arguments[k]->getWidth();
Expand Down Expand Up @@ -2152,13 +2136,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
Expr::Width to = getWidthForLLVMType(t);

if (from != to) {
#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0)
const CallBase &cs = cast<CallBase>(*caller);
#else
const CallSite cs(isa<InvokeInst>(caller)
? CallSite(cast<InvokeInst>(caller))
: CallSite(cast<CallInst>(caller)));
#endif

// XXX need to check other param attrs ?
bool isSExt = cs.hasRetAttr(llvm::Attribute::SExt);
Expand Down Expand Up @@ -2416,14 +2394,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
if (isa<DbgInfoIntrinsic>(i))
break;

#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0)
const CallBase &cs = cast<CallBase>(*i);
Value *fp = cs.getCalledOperand();
#else
const CallSite cs(i);
Value *fp = cs.getCalledValue();
#endif

unsigned numArgs = cs.arg_size();
Function *f = getTargetFunction(fp, state);

Expand Down Expand Up @@ -2830,8 +2802,6 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
}

// Floating point instructions

#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0)
case Instruction::FNeg: {
ref<ConstantExpr> arg =
toConstant(state, eval(ki, 0, state).value, "floating point");
Expand All @@ -2843,7 +2813,6 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
bindLocal(ki, state, ConstantExpr::alloc(Res.bitcastToAPInt()));
break;
}
#endif

case Instruction::FAdd: {
ref<ConstantExpr> left = toConstant(state, eval(ki, 0, state).value,
Expand Down Expand Up @@ -4643,14 +4612,7 @@ size_t Executor::getAllocationAlignment(const llvm::Value *allocSite) const {
type = AI->getAllocatedType();
} else if (isa<InvokeInst>(allocSite) || isa<CallInst>(allocSite)) {
// FIXME: Model the semantics of the call to use the right alignment
#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0)
const CallBase &cs = cast<CallBase>(*allocSite);
#else
llvm::Value *allocSiteNonConst = const_cast<llvm::Value *>(allocSite);
const CallSite cs(isa<InvokeInst>(allocSiteNonConst)
? CallSite(cast<InvokeInst>(allocSiteNonConst))
: CallSite(cast<CallInst>(allocSiteNonConst)));
#endif
llvm::Function *fn =
klee::getDirectCallTarget(cs, /*moduleIsFullyLinked=*/true);
if (fn)
Expand Down
Loading

0 comments on commit 6cc8ee7

Please sign in to comment.