aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Core
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/Executor.cpp55
-rw-r--r--lib/Core/ExecutorUtil.cpp4
-rw-r--r--lib/Core/GetElementPtrTypeIterator.h2
-rw-r--r--lib/Core/MemoryManager.cpp5
4 files changed, 1 insertions, 65 deletions
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index 85413a42..1f1fb18c 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -1422,21 +1422,12 @@ void Executor::stepInstruction(ExecutionState &state) {
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;
}
@@ -1936,19 +1927,8 @@ void Executor::executeCall(ExecutionState &state, KInstruction *ki, Function *f,
#if LLVM_VERSION_CODE >= LLVM_VERSION(11, 0)
MaybeAlign ma = cs.getParamAlign(k);
unsigned alignment = ma ? ma->value() : 0;
-#elif LLVM_VERSION_CODE > LLVM_VERSION(4, 0)
- unsigned alignment = cs.getParamAlignment(k);
#else
- // getParamAlignment() is buggy for LLVM <= 4, so we instead
- // get the attribute in a hacky way by parsing the textual
- // representation
- unsigned alignment = 0;
- std::string str;
- llvm::raw_string_ostream s(str);
- s << *cs.getArgument(k);
- size_t pos = str.find("align ");
- if (pos != std::string::npos)
- alignment = std::stoi(str.substr(pos + 6));
+ unsigned alignment = cs.getParamAlignment(k);
#endif
// AMD64-ABI 3.5.7p5: Step 7. Align l->overflow_arg_area upwards to a
@@ -1962,21 +1942,13 @@ void Executor::executeCall(ExecutionState &state, KInstruction *ki, Function *f,
if (!alignment)
alignment = 8;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
size = llvm::alignTo(size, alignment);
-#else
- size = llvm::RoundUpToAlignment(size, alignment);
-#endif
offsets[k] = size;
// AMD64-ABI 3.5.7p5: Step 9. Set l->overflow_arg_area to:
// l->overflow_arg_area + sizeof(type)
// Step 10. Align l->overflow_arg_area upwards to an 8 byte boundary.
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
size += llvm::alignTo(argWidth, WordSize) / 8;
-#else
- size += llvm::RoundUpToAlignment(argWidth, WordSize) / 8;
-#endif
}
}
@@ -2161,11 +2133,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
#endif
// XXX need to check other param attrs ?
-#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
bool isSExt = cs.hasRetAttr(llvm::Attribute::SExt);
-#else
- bool isSExt = cs.paramHasAttr(0, llvm::Attribute::SExt);
-#endif
if (isSExt) {
result = SExtExpr::create(result, to);
} else {
@@ -2299,11 +2267,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
// switch to an internal rep.
llvm::IntegerType *Ty = cast<IntegerType>(si->getCondition()->getType());
ConstantInt *ci = ConstantInt::get(Ty, CE->getZExtValue());
-#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
unsigned index = si->findCaseValue(ci)->getSuccessorIndex();
-#else
- unsigned index = si->findCaseValue(ci).getSuccessorIndex();
-#endif
transferToBasicBlock(si->getSuccessor(index), si->getParent(), state);
} else {
// Handle possible different branch targets
@@ -2470,11 +2434,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
if (from != to) {
// XXX need to check other param attrs ?
-#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
bool isSExt = cs.paramHasAttr(i, llvm::Attribute::SExt);
-#else
- bool isSExt = cs.paramHasAttr(i+1, llvm::Attribute::SExt);
-#endif
if (isSExt) {
arguments[i] = SExtExpr::create(arguments[i], to);
} else {
@@ -2975,11 +2935,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
llvm::APFloat Arg(*fpWidthToSemantics(arg->getWidth()), arg->getAPValue());
uint64_t value = 0;
bool isExact = true;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
auto valueRef = makeMutableArrayRef(value);
-#else
- uint64_t *valueRef = &value;
-#endif
Arg.convertToInteger(valueRef, resultType, false,
llvm::APFloat::rmTowardZero, &isExact);
bindLocal(ki, state, ConstantExpr::alloc(value, resultType));
@@ -2997,11 +2953,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
uint64_t value = 0;
bool isExact = true;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
auto valueRef = makeMutableArrayRef(value);
-#else
- uint64_t *valueRef = &value;
-#endif
Arg.convertToInteger(valueRef, resultType, true,
llvm::APFloat::rmTowardZero, &isExact);
bindLocal(ki, state, ConstantExpr::alloc(value, resultType));
@@ -3397,17 +3349,12 @@ 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()));
-#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0)
} else if (isa<ArrayType>(*ii)) {
computeOffsetsSeqTy<ArrayType>(kgepi, constantOffset, index, ii);
} else if (isa<VectorType>(*ii)) {
computeOffsetsSeqTy<VectorType>(kgepi, constantOffset, index, ii);
} else if (isa<PointerType>(*ii)) {
computeOffsetsSeqTy<PointerType>(kgepi, constantOffset, index, ii);
-#else
- } else if (isa<SequentialType>(*ii)) {
- computeOffsetsSeqTy<SequentialType>(kgepi, constantOffset, index, ii);
-#endif
} else
assert("invalid type" && 0);
index++;
diff --git a/lib/Core/ExecutorUtil.cpp b/lib/Core/ExecutorUtil.cpp
index 84226a64..1050ba23 100644
--- a/lib/Core/ExecutorUtil.cpp
+++ b/lib/Core/ExecutorUtil.cpp
@@ -214,11 +214,7 @@ namespace klee {
continue;
// Handle a struct index, which adds its field offset to the pointer.
-#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0)
if (auto STy = ii.getStructTypeOrNull()) {
-#else
- if (StructType *STy = dyn_cast<StructType>(*ii)) {
-#endif
unsigned ElementIdx = indexOp->getZExtValue();
const StructLayout *SL = kmodule->targetData->getStructLayout(STy);
base = base->Add(
diff --git a/lib/Core/GetElementPtrTypeIterator.h b/lib/Core/GetElementPtrTypeIterator.h
index 87de667d..89606a0a 100644
--- a/lib/Core/GetElementPtrTypeIterator.h
+++ b/lib/Core/GetElementPtrTypeIterator.h
@@ -88,10 +88,8 @@ class generic_gep_type_iterator
if (llvm::CompositeType *CT = dyn_cast<llvm::CompositeType>(CurTy)) {
CurTy = CT->getTypeAtIndex(getOperand());
#endif
-#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0)
} else if (auto ptr = dyn_cast<llvm::PointerType>(CurTy)) {
CurTy = ptr->getElementType();
-#endif
} else {
CurTy = 0;
}
diff --git a/lib/Core/MemoryManager.cpp b/lib/Core/MemoryManager.cpp
index e3fffd9b..f15c0db9 100644
--- a/lib/Core/MemoryManager.cpp
+++ b/lib/Core/MemoryManager.cpp
@@ -116,12 +116,7 @@ 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