From e9774bb6d569f55f662e12e2f491d30e7cea8372 Mon Sep 17 00:00:00 2001 From: Martin Nowack Date: Mon, 30 Oct 2023 14:52:37 +0000 Subject: Use APIs of newer LLVM versions instead of unsupported ones --- lib/Core/Executor.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib/Core') diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 14951b7d..27b8804d 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -3043,7 +3043,11 @@ 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(16, 0) + auto valueRef = llvm::MutableArrayRef(value); +#else auto valueRef = makeMutableArrayRef(value); +#endif Arg.convertToInteger(valueRef, resultType, false, llvm::APFloat::rmTowardZero, &isExact); bindLocal(ki, state, ConstantExpr::alloc(value, resultType)); @@ -3061,7 +3065,11 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { uint64_t value = 0; bool isExact = true; +#if LLVM_VERSION_CODE >= LLVM_VERSION(16, 0) + auto valueRef = llvm::MutableArrayRef(value); +#else auto valueRef = makeMutableArrayRef(value); +#endif Arg.convertToInteger(valueRef, resultType, true, llvm::APFloat::rmTowardZero, &isExact); bindLocal(ki, state, ConstantExpr::alloc(value, resultType)); @@ -4947,7 +4955,12 @@ size_t Executor::getAllocationAlignment(const llvm::Value *allocSite) const { type = GO->getType(); } } else if (const AllocaInst *AI = dyn_cast(allocSite)) { +#if LLVM_VERSION_CODE <= LLVM_VERSION(10, 0) alignment = AI->getAlignment(); + +#else + alignment = AI->getAlign().value(); +#endif type = AI->getAllocatedType(); } else if (isa(allocSite) || isa(allocSite)) { // FIXME: Model the semantics of the call to use the right alignment @@ -4970,7 +4983,12 @@ size_t Executor::getAllocationAlignment(const llvm::Value *allocSite) const { assert(type != NULL); // No specified alignment. Get the alignment for the type. if (type->isSized()) { +#if LLVM_VERSION_CODE >= LLVM_VERSION(16, 0) + alignment = kmodule->targetData->getPrefTypeAlign(type).value(); +#else alignment = kmodule->targetData->getPrefTypeAlignment(type); +#endif + } else { klee_warning_once(allocSite, "Cannot determine memory alignment for " "\"%s\". Using alignment of %zu.", -- cgit 1.4.1