From 325c6cdcab632a6824be8ca9a926f4c4573adbdb Mon Sep 17 00:00:00 2001 From: Daniel Schemmel Date: Thu, 1 Feb 2024 14:51:37 +0000 Subject: drop llvm 9 and 10 --- .github/workflows/build.yaml | 8 -- lib/Core/Executor.cpp | 32 ------ lib/Core/GetElementPtrTypeIterator.h | 10 -- lib/Core/MemoryManager.cpp | 14 --- lib/Module/IntrinsicCleaner.cpp | 4 - lib/Module/Optimize.cpp | 2 +- lib/Module/OptimizeLegacy.cpp | 4 - runtime/Sanitizer/ubsan/ubsan_checks.inc | 10 -- runtime/Sanitizer/ubsan/ubsan_handlers.cpp | 28 ----- scripts/build/p-clang-linux-ubuntu-22.04.inc | 4 - scripts/build/patches/llvm90.patch | 114 --------------------- ...ow-applying_nonzero_offset_to_nonnull_pointer.c | 4 +- ...applying_nonzero_offset_to_nonnull_pointer_10.c | 24 ----- ...rflow-applying_nonzero_offset_to_null_pointer.c | 2 - ...overflow-applying_zero_offset_to_null_pointer.c | 2 - test/Runtime/FreeStanding/memcpy_chk_err.c | 4 +- test/VectorInstructions/oob-llvm-lt11.c | 44 -------- test/VectorInstructions/oob-read-llvm-geq11.c | 46 --------- test/VectorInstructions/oob-read.c | 45 ++++++++ test/VectorInstructions/oob-write-llvm-geq11.c | 51 --------- test/VectorInstructions/oob-write.c | 49 +++++++++ test/lit.cfg | 2 +- 22 files changed, 98 insertions(+), 405 deletions(-) delete mode 100644 scripts/build/patches/llvm90.patch delete mode 100644 test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_nonnull_pointer_10.c delete mode 100644 test/VectorInstructions/oob-llvm-lt11.c delete mode 100644 test/VectorInstructions/oob-read-llvm-geq11.c create mode 100644 test/VectorInstructions/oob-read.c delete mode 100644 test/VectorInstructions/oob-write-llvm-geq11.c create mode 100644 test/VectorInstructions/oob-write.c diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index a329a02c..fcd21892 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -42,8 +42,6 @@ jobs: "LLVM 13", "LLVM 12", "LLVM 11, Doxygen", - "LLVM 10", - "LLVM 9", "ASan", "UBSan", "MSan", @@ -74,12 +72,6 @@ jobs: env: LLVM_VERSION: 11 ENABLE_DOXYGEN: 1 - - name: "LLVM 10" - env: - LLVM_VERSION: 10 - - name: "LLVM 9" - env: - LLVM_VERSION: 9 # Sanitizer builds. Do unoptimized build otherwise the optimizer # might remove problematic code - name: "ASan" diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 78b3dd35..d70a2c4e 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -77,11 +77,7 @@ #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(10, 0) #include "llvm/Support/TypeSize.h" -#else -typedef unsigned TypeSize; -#endif #include "llvm/Support/raw_ostream.h" #include @@ -1990,12 +1986,8 @@ void Executor::executeCall(ExecutionState &state, KInstruction *ki, Function *f, argWidth = arguments[k]->getWidth(); } -#if LLVM_VERSION_CODE >= LLVM_VERSION(11, 0) MaybeAlign ma = cb.getParamAlign(k); unsigned alignment = ma ? ma->value() : 0; -#else - unsigned alignment = cb.getParamAlignment(k); -#endif if (WordSize == Expr::Int32 && !alignment) alignment = 4; @@ -3245,11 +3237,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { return; } uint64_t iIdx = cIdx->getZExtValue(); -#if LLVM_VERSION_MAJOR >= 11 const auto *vt = cast(iei->getType()); -#else - const llvm::VectorType *vt = iei->getType(); -#endif unsigned EltBits = getWidthForLLVMType(vt->getElementType()); if (iIdx >= vt->getNumElements()) { @@ -3287,11 +3275,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { return; } uint64_t iIdx = cIdx->getZExtValue(); -#if LLVM_VERSION_MAJOR >= 11 const auto *vt = cast(eei->getVectorOperandType()); -#else - const llvm::VectorType *vt = eei->getVectorOperandType(); -#endif unsigned EltBits = getWidthForLLVMType(vt->getElementType()); if (iIdx >= vt->getNumElements()) { @@ -3502,10 +3486,6 @@ void Executor::bindInstructionConstants(KInstruction *KI) { #endif } else if (InsertValueInst *ivi = dyn_cast(KI->inst)) { KGEPInstruction *kgepi = static_cast(KI); -#if LLVM_VERSION_CODE <= LLVM_VERSION(10, 0) - computeOffsets(kgepi, iv_type_begin(ivi), iv_type_end(ivi)); - assert(kgepi->indices.empty() && "InsertValue constant offset expected"); -#else llvm::Value *agg = ivi->getAggregateOperand(); llvm::Type *current_type = agg->getType(); std::uint64_t offset = 0; @@ -3526,14 +3506,8 @@ void Executor::bindInstructionConstants(KInstruction *KI) { current_type = GetElementPtrInst::getTypeAtIndex(current_type, index); } kgepi->offset = offset; -#endif } else if (ExtractValueInst *evi = dyn_cast(KI->inst)) { KGEPInstruction *kgepi = static_cast(KI); -#if LLVM_VERSION_CODE <= LLVM_VERSION(10, 0) - computeOffsets(kgepi, ev_type_begin(evi), ev_type_end(evi)); - assert(kgepi->indices.empty() && "ExtractValue constant offset expected"); -#else - llvm::Value *agg = evi->getAggregateOperand(); llvm::Type *current_type = agg->getType(); uint64_t offset = 0; @@ -3554,7 +3528,6 @@ void Executor::bindInstructionConstants(KInstruction *KI) { current_type = GetElementPtrInst::getTypeAtIndex(current_type, index); } kgepi->offset = offset; -#endif } } @@ -4955,12 +4928,7 @@ 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 diff --git a/lib/Core/GetElementPtrTypeIterator.h b/lib/Core/GetElementPtrTypeIterator.h index 4e0314cb..e4ca8dc9 100644 --- a/lib/Core/GetElementPtrTypeIterator.h +++ b/lib/Core/GetElementPtrTypeIterator.h @@ -71,12 +71,7 @@ public: llvm::Type *operator*() const { return CurTy; } llvm::Type *getIndexedType() const { -#if LLVM_VERSION_CODE >= LLVM_VERSION(11, 0) return llvm::GetElementPtrInst::getTypeAtIndex(CurTy, getOperand()); -#else - llvm::CompositeType *CT = cast(CurTy); - return CT->getTypeAtIndex(getOperand()); -#endif } // This is a non-standard operator->. It allows you to call methods on the @@ -86,14 +81,9 @@ public: llvm::Value *getOperand() const { return asValue(*OpIt); } generic_gep_type_iterator& operator++() { // Preincrement -#if LLVM_VERSION_CODE >= LLVM_VERSION(11, 0) if (isa(CurTy) || isa(CurTy) || isa(CurTy)) { CurTy = llvm::GetElementPtrInst::getTypeAtIndex(CurTy, getOperand()); -#else - if (llvm::CompositeType *CT = dyn_cast(CurTy)) { - CurTy = CT->getTypeAtIndex(getOperand()); -#endif } else if (CurTy->isPointerTy()) { CurTy = CurTy->getPointerElementType(); } else { diff --git a/lib/Core/MemoryManager.cpp b/lib/Core/MemoryManager.cpp index 3b0f5064..9d291578 100644 --- a/lib/Core/MemoryManager.cpp +++ b/lib/Core/MemoryManager.cpp @@ -22,11 +22,7 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/GlobalVariable.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/MathExtras.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(10, 0) #include "llvm/Support/Alignment.h" -#else -#include "llvm/Support/MathExtras.h" -#endif DISABLE_WARNING_POP #include @@ -187,28 +183,18 @@ MemoryManager::MemoryManager(ArrayCache *_arrayCache) stackFactory, nullptr); // check invariants -#if LLVM_VERSION_CODE >= LLVM_VERSION(10, 0) llvm::Align pageAlignment(pageSize); -#endif for (auto &requestedSegment : requestedSegments) { auto &segment1 = std::get<0>(requestedSegment); auto &start1 = std::get<1>(requestedSegment); auto &size1 = std::get<2>(requestedSegment); // check for page alignment // NOTE: sizes are assumed to be page aligned due to multiplication -#if LLVM_VERSION_CODE >= LLVM_VERSION(10, 0) if (start1 != 0 && !llvm::isAligned(pageAlignment, start1)) { klee_error("Deterministic allocator: Requested start address for %s " "is not page aligned (page size: %" PRIu64 " B)", segment1.c_str(), pageAlignment.value()); } -#else - if (start1 != 0 && llvm::OffsetToAlignment(start1, pageSize) != 0) { - klee_error("Deterministic allocator: Requested start address for %s " - "is not page aligned (page size: %zu B)", - segment1.c_str(), pageSize); - } -#endif // check for overlap of segments std::uintptr_t end1 = start1 + size1; diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp index af77ed70..8d507754 100644 --- a/lib/Module/IntrinsicCleaner.cpp +++ b/lib/Module/IntrinsicCleaner.cpp @@ -25,9 +25,7 @@ DISABLE_WARNING_DEPRECATED_DECLARATIONS #include "llvm/IR/Instruction.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(10, 0) #include "llvm/IR/IntrinsicsX86.h" -#endif #include "llvm/IR/Module.h" #include "llvm/IR/Type.h" #include "llvm/Pass.h" @@ -391,9 +389,7 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { case Intrinsic::readcyclecounter: case Intrinsic::returnaddress: case Intrinsic::round: -#if LLVM_VERSION_CODE >= LLVM_VERSION(11, 0) case Intrinsic::roundeven: -#endif case Intrinsic::sin: case Intrinsic::sqrt: case Intrinsic::stackrestore: diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp index 9475512b..654279f4 100644 --- a/lib/Module/Optimize.cpp +++ b/lib/Module/Optimize.cpp @@ -25,4 +25,4 @@ void klee::optimiseAndPrepare(bool OptimiseKLEECall, bool Optimize, llvm::ArrayRef preservedFunctions, llvm::Module *module) { assert(0); -} \ No newline at end of file +} diff --git a/lib/Module/OptimizeLegacy.cpp b/lib/Module/OptimizeLegacy.cpp index e8d2f499..ee2b7ba4 100644 --- a/lib/Module/OptimizeLegacy.cpp +++ b/lib/Module/OptimizeLegacy.cpp @@ -89,11 +89,7 @@ static void AddStandardCompilePasses(legacy::PassManager &PM) { addPass(PM, createPromoteMemoryToRegisterPass()); // Kill useless allocas addPass(PM, createGlobalOptimizerPass()); // Optimize out global vars addPass(PM, createGlobalDCEPass()); // Remove unused fns and globs -#if LLVM_VERSION_CODE >= LLVM_VERSION(11, 0) addPass(PM, createSCCPPass()); // Constant prop with SCCP -#else - addPass(PM, createIPConstantPropagationPass()); // IP Constant Propagation -#endif addPass(PM, createDeadArgEliminationPass()); // Dead argument elimination addPass(PM, createInstructionCombiningPass()); // Clean up after IPCP & DAE addPass(PM, createCFGSimplificationPass()); // Clean up after IPCP & DAE diff --git a/runtime/Sanitizer/ubsan/ubsan_checks.inc b/runtime/Sanitizer/ubsan/ubsan_checks.inc index 35c64f41..4edc0992 100644 --- a/runtime/Sanitizer/ubsan/ubsan_checks.inc +++ b/runtime/Sanitizer/ubsan/ubsan_checks.inc @@ -26,17 +26,13 @@ UBSAN_CHECK(GenericUB, "undefined-behavior", "undefined") UBSAN_CHECK(NullPointerUse, "null-pointer-use", "null") -#if LLVM_VERSION_MAJOR >= 11 UBSAN_CHECK(NullPointerUseWithNullability, "null-pointer-use", "nullability-assign") -#endif -#if LLVM_VERSION_MAJOR >= 10 UBSAN_CHECK(NullptrWithOffset, "nullptr-with-offset", "pointer-overflow") UBSAN_CHECK(NullptrWithNonZeroOffset, "nullptr-with-nonzero-offset", "pointer-overflow") UBSAN_CHECK(NullptrAfterNonZeroOffset, "nullptr-after-nonzero-offset", "pointer-overflow") -#endif UBSAN_CHECK(PointerOverflow, "pointer-overflow", "pointer-overflow") UBSAN_CHECK(MisalignedPointerUse, "misaligned-pointer-use", "alignment") UBSAN_CHECK(AlignmentAssumption, "alignment-assumption", "alignment") @@ -49,9 +45,7 @@ UBSAN_CHECK(IntegerDivideByZero, "integer-divide-by-zero", "integer-divide-by-zero") UBSAN_CHECK(FloatDivideByZero, "float-divide-by-zero", "float-divide-by-zero") UBSAN_CHECK(InvalidBuiltin, "invalid-builtin-use", "invalid-builtin-use") -#if LLVM_VERSION_MAJOR >= 11 UBSAN_CHECK(InvalidObjCCast, "invalid-objc-cast", "invalid-objc-cast") -#endif UBSAN_CHECK(ImplicitUnsignedIntegerTruncation, "implicit-unsigned-integer-truncation", "implicit-unsigned-integer-truncation") @@ -76,14 +70,10 @@ UBSAN_CHECK(InvalidEnumLoad, "invalid-enum-load", "enum") UBSAN_CHECK(FunctionTypeMismatch, "function-type-mismatch", "function") UBSAN_CHECK(InvalidNullReturn, "invalid-null-return", "returns-nonnull-attribute") -#if LLVM_VERSION_MAJOR >= 11 UBSAN_CHECK(InvalidNullReturnWithNullability, "invalid-null-return", "nullability-return") -#endif UBSAN_CHECK(InvalidNullArgument, "invalid-null-argument", "nonnull-attribute") -#if LLVM_VERSION_MAJOR >= 11 UBSAN_CHECK(InvalidNullArgumentWithNullability, "invalid-null-argument", "nullability-arg") -#endif UBSAN_CHECK(DynamicTypeMismatch, "dynamic-type-mismatch", "vptr") UBSAN_CHECK(CFIBadType, "cfi-bad-type", "cfi") diff --git a/runtime/Sanitizer/ubsan/ubsan_handlers.cpp b/runtime/Sanitizer/ubsan/ubsan_handlers.cpp index 0213836b..c1f94beb 100644 --- a/runtime/Sanitizer/ubsan/ubsan_handlers.cpp +++ b/runtime/Sanitizer/ubsan/ubsan_handlers.cpp @@ -45,14 +45,10 @@ static const char *get_suffix(ErrorType ET) { // It should never happen in KLEE runtime. return "exec.err"; case ErrorType::NullPointerUse: -#if LLVM_VERSION_MAJOR >= 11 case ErrorType::NullPointerUseWithNullability: -#endif -#if LLVM_VERSION_MAJOR >= 10 case ErrorType::NullptrWithOffset: case ErrorType::NullptrWithNonZeroOffset: case ErrorType::NullptrAfterNonZeroOffset: -#endif case ErrorType::PointerOverflow: case ErrorType::MisalignedPointerUse: case ErrorType::AlignmentAssumption: @@ -69,12 +65,10 @@ static const char *get_suffix(ErrorType ET) { return "div.err"; case ErrorType::InvalidBuiltin: return "invalid_builtin_use.err"; -#if LLVM_VERSION_MAJOR >= 11 case ErrorType::InvalidObjCCast: // Option `fsanitize=objc-cast` is not supported due to the requirement for // Darwin system. return "exec.err"; -#endif case ErrorType::ImplicitUnsignedIntegerTruncation: case ErrorType::ImplicitSignedIntegerTruncation: return "implicit_truncation.err"; @@ -101,13 +95,9 @@ static const char *get_suffix(ErrorType ET) { // This check is unsupported return "exec.err"; case ErrorType::InvalidNullReturn: -#if LLVM_VERSION_MAJOR >= 11 case ErrorType::InvalidNullReturnWithNullability: -#endif case ErrorType::InvalidNullArgument: -#if LLVM_VERSION_MAJOR >= 11 case ErrorType::InvalidNullArgumentWithNullability: -#endif return "nullable_attribute.err"; case ErrorType::DynamicTypeMismatch: case ErrorType::CFIBadType: @@ -122,7 +112,6 @@ __attribute__((noreturn)) static void report_error_type(ErrorType ET) { report_error(ConvertTypeToString(ET), get_suffix(ET)); } -#if LLVM_VERSION_MAJOR >= 11 /// Situations in which we might emit a check for the suitability of a /// pointer or glvalue. Needs to be kept in sync with CodeGenFunction.h in /// clang. @@ -161,20 +150,15 @@ enum TypeCheckKind { /// null or an object within its lifetime. TCK_DynamicOperation }; -#endif static void handleTypeMismatchImpl(TypeMismatchData *Data, ValueHandle Pointer) { uptr Alignment = (uptr)1 << Data->LogAlignment; ErrorType ET; if (!Pointer) -#if LLVM_VERSION_MAJOR >= 11 ET = (Data->TypeCheckKind == TCK_NonnullAssign) ? ErrorType::NullPointerUseWithNullability : ErrorType::NullPointerUse; -#else - ET = ErrorType::NullPointerUse; -#endif else if (Pointer & (Alignment - 1)) ET = ErrorType::MisalignedPointerUse; else @@ -440,12 +424,8 @@ extern "C" void __ubsan_handle_invalid_builtin_abort(InvalidBuiltinData *Data) { static void handleNonNullReturn(NonNullReturnData * /*Data*/, SourceLocation * /*LocPtr*/, bool IsAttr) { -#if LLVM_VERSION_MAJOR >= 11 ErrorType ET = IsAttr ? ErrorType::InvalidNullReturn : ErrorType::InvalidNullReturnWithNullability; -#else - ErrorType ET = ErrorType::InvalidNullReturn; -#endif report_error_type(ET); } @@ -471,12 +451,8 @@ __ubsan_handle_nullability_return_v1_abort(NonNullReturnData *Data, } static void handleNonNullArg(NonNullArgData * /*Data*/, bool IsAttr) { -#if LLVM_VERSION_MAJOR >= 11 ErrorType ET = IsAttr ? ErrorType::InvalidNullArgument : ErrorType::InvalidNullArgumentWithNullability; -#else - ErrorType ET = ErrorType::InvalidNullArgument; -#endif report_error_type(ET); } @@ -499,7 +475,6 @@ extern "C" void __ubsan_handle_nullability_arg_abort(NonNullArgData *Data) { static void handlePointerOverflowImpl(PointerOverflowData * /*Data*/, ValueHandle Base, ValueHandle Result) { -#if LLVM_VERSION_MAJOR >= 10 ErrorType ET; if (Base == 0 && Result == 0) ET = ErrorType::NullptrWithOffset; @@ -509,9 +484,6 @@ static void handlePointerOverflowImpl(PointerOverflowData * /*Data*/, ET = ErrorType::NullptrAfterNonZeroOffset; else ET = ErrorType::PointerOverflow; -#else - ErrorType ET = ErrorType::PointerOverflow; -#endif report_error_type(ET); } diff --git a/scripts/build/p-clang-linux-ubuntu-22.04.inc b/scripts/build/p-clang-linux-ubuntu-22.04.inc index dc125bd5..8220b1f8 100644 --- a/scripts/build/p-clang-linux-ubuntu-22.04.inc +++ b/scripts/build/p-clang-linux-ubuntu-22.04.inc @@ -1,8 +1,4 @@ get_docker_config_id_clang() { - if [[ "${LLVM_VERSION_SHORT}" -ge "11" ]]; then echo "" return 0; - else - return 1; - fi } diff --git a/scripts/build/patches/llvm90.patch b/scripts/build/patches/llvm90.patch deleted file mode 100644 index 3ff0dc29..00000000 --- a/scripts/build/patches/llvm90.patch +++ /dev/null @@ -1,114 +0,0 @@ -diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc -index 490a04b21..42e43a044 100644 ---- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc -+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_ioctl.inc -@@ -366,15 +366,6 @@ static void ioctl_table_fill() { - - #if SANITIZER_LINUX && !SANITIZER_ANDROID - // _(SIOCDEVPLIP, WRITE, struct_ifreq_sz); // the same as EQL_ENSLAVE -- _(CYGETDEFTHRESH, WRITE, sizeof(int)); -- _(CYGETDEFTIMEOUT, WRITE, sizeof(int)); -- _(CYGETMON, WRITE, struct_cyclades_monitor_sz); -- _(CYGETTHRESH, WRITE, sizeof(int)); -- _(CYGETTIMEOUT, WRITE, sizeof(int)); -- _(CYSETDEFTHRESH, NONE, 0); -- _(CYSETDEFTIMEOUT, NONE, 0); -- _(CYSETTHRESH, NONE, 0); -- _(CYSETTIMEOUT, NONE, 0); - _(EQL_EMANCIPATE, WRITE, struct_ifreq_sz); - _(EQL_ENSLAVE, WRITE, struct_ifreq_sz); - _(EQL_GETMASTRCFG, WRITE, struct_ifreq_sz); -diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc -index b7fa6e8f7..fa981e129 100644 ---- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc -+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cc -@@ -126,7 +126,6 @@ typedef struct user_fpregs elf_fpregset_t; - # include - #endif - #include --#include - #include - #include - #include -@@ -437,7 +436,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); - - #if SANITIZER_LINUX && !SANITIZER_ANDROID - unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct); -- unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor); - #if EV_VERSION > (0x010000) - unsigned struct_input_keymap_entry_sz = sizeof(struct input_keymap_entry); - #else -@@ -803,15 +801,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr); - #endif // SANITIZER_LINUX - - #if SANITIZER_LINUX && !SANITIZER_ANDROID -- unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH; -- unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT; -- unsigned IOCTL_CYGETMON = CYGETMON; -- unsigned IOCTL_CYGETTHRESH = CYGETTHRESH; -- unsigned IOCTL_CYGETTIMEOUT = CYGETTIMEOUT; -- unsigned IOCTL_CYSETDEFTHRESH = CYSETDEFTHRESH; -- unsigned IOCTL_CYSETDEFTIMEOUT = CYSETDEFTIMEOUT; -- unsigned IOCTL_CYSETTHRESH = CYSETTHRESH; -- unsigned IOCTL_CYSETTIMEOUT = CYSETTIMEOUT; - unsigned IOCTL_EQL_EMANCIPATE = EQL_EMANCIPATE; - unsigned IOCTL_EQL_ENSLAVE = EQL_ENSLAVE; - unsigned IOCTL_EQL_GETMASTRCFG = EQL_GETMASTRCFG; -@@ -1126,8 +1115,9 @@ CHECK_SIZE_AND_OFFSET(ipc_perm, uid); - CHECK_SIZE_AND_OFFSET(ipc_perm, gid); - CHECK_SIZE_AND_OFFSET(ipc_perm, cuid); - CHECK_SIZE_AND_OFFSET(ipc_perm, cgid); --#if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21) --/* On aarch64 glibc 2.20 and earlier provided incorrect mode field. */ -+#if !SANITIZER_LINUX || __GLIBC_PREREQ (2, 31) -+/* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit -+ on many architectures. */ - CHECK_SIZE_AND_OFFSET(ipc_perm, mode); - #endif - -diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h -index f1a4fd7d3..029a209fc 100644 ---- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h -+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h -@@ -203,26 +203,13 @@ namespace __sanitizer { - u64 __unused1; - u64 __unused2; - #elif defined(__sparc__) --#if defined(__arch64__) - unsigned mode; -- unsigned short __pad1; --#else -- unsigned short __pad1; -- unsigned short mode; - unsigned short __pad2; --#endif - unsigned short __seq; - unsigned long long __unused1; - unsigned long long __unused2; --#elif defined(__mips__) || defined(__aarch64__) || defined(__s390x__) -- unsigned int mode; -- unsigned short __seq; -- unsigned short __pad1; -- unsigned long __unused1; -- unsigned long __unused2; - #else -- unsigned short mode; -- unsigned short __pad1; -+ unsigned int mode; - unsigned short __seq; - unsigned short __pad2; - #if defined(__x86_64__) && !defined(_LP64) -diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt -index 901f55c99..7cb78afe5 100644 ---- a/llvm/tools/llvm-shlib/CMakeLists.txt -+++ b/llvm/tools/llvm-shlib/CMakeLists.txt -@@ -44,7 +44,9 @@ if(LLVM_BUILD_LLVM_DYLIB) - endif() - add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${INSTALL_WITH_TOOLCHAIN} ${SOURCES}) - -+ if(LIB_NAMES) - list(REMOVE_DUPLICATES LIB_NAMES) -+ endif() - if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU) - OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") - OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "GNU") diff --git a/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_nonnull_pointer.c b/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_nonnull_pointer.c index ce1a8fea..6109fcd7 100644 --- a/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_nonnull_pointer.c +++ b/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_nonnull_pointer.c @@ -1,5 +1,3 @@ -// REQUIRES: lt-llvm-10.0 - // RUN: %clang %s -fsanitize=pointer-overflow -emit-llvm -g %O0opt -c -o %t.bc // RUN: rm -rf %t.klee-out // RUN: %klee --output-dir=%t.klee-out --emit-all-errors --ubsan-runtime %t.bc 2>&1 | FileCheck %s @@ -18,7 +16,7 @@ int main() { char *ptr = (char *)address; - // CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:{{[0-9]+}}: pointer-overflow + // CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:{{[0-9]+}}: nullptr-after-nonzero-offset result = ptr + 1; return 0; } diff --git a/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_nonnull_pointer_10.c b/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_nonnull_pointer_10.c deleted file mode 100644 index 7a6b5153..00000000 --- a/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_nonnull_pointer_10.c +++ /dev/null @@ -1,24 +0,0 @@ -// REQUIRES: geq-llvm-10.0 - -// RUN: %clang %s -fsanitize=pointer-overflow -emit-llvm -g %O0opt -c -o %t.bc -// RUN: rm -rf %t.klee-out -// RUN: %klee --output-dir=%t.klee-out --emit-all-errors --ubsan-runtime %t.bc 2>&1 | FileCheck %s -// RUN: ls %t.klee-out/ | grep .ktest | wc -l | grep 2 -// RUN: ls %t.klee-out/ | grep .ptr.err | wc -l | grep 1 - -#include "klee/klee.h" -#include - -int main() { - size_t address; - volatile char *result; - - klee_make_symbolic(&address, sizeof(address), "address"); - klee_assume(address != 0); - - char *ptr = (char *)address; - - // CHECK: KLEE: ERROR: {{.*}}runtime/Sanitizer/ubsan/ubsan_handlers.cpp:{{[0-9]+}}: nullptr-after-nonzero-offset - result = ptr + 1; - return 0; -} diff --git a/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_null_pointer.c b/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_null_pointer.c index 5fb711b6..f4f09745 100644 --- a/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_null_pointer.c +++ b/test/Feature/ubsan/ubsan_pointer_overflow-applying_nonzero_offset_to_null_pointer.c @@ -1,5 +1,3 @@ -// REQUIRES: geq-llvm-10.0 - // RUN: %clang %s -fsanitize=pointer-overflow -emit-llvm -g %O0opt -c -o %t.bc // RUN: rm -rf %t.klee-out // RUN: %klee --output-dir=%t.klee-out --emit-all-errors --ubsan-runtime %t.bc 2>&1 | FileCheck %s diff --git a/test/Feature/ubsan/ubsan_pointer_overflow-applying_zero_offset_to_null_pointer.c b/test/Feature/ubsan/ubsan_pointer_overflow-applying_zero_offset_to_null_pointer.c index c65954e3..627dc801 100644 --- a/test/Feature/ubsan/ubsan_pointer_overflow-applying_zero_offset_to_null_pointer.c +++ b/test/Feature/ubsan/ubsan_pointer_overflow-applying_zero_offset_to_null_pointer.c @@ -1,5 +1,3 @@ -// REQUIRES: geq-llvm-10.0 - // RUN: %clang %s -fsanitize=pointer-overflow -emit-llvm -g %O0opt -c -o %t.bc // RUN: rm -rf %t.klee-out // RUN: %klee --output-dir=%t.klee-out --emit-all-errors --ubsan-runtime %t.bc 2>&1 | FileCheck %s diff --git a/test/Runtime/FreeStanding/memcpy_chk_err.c b/test/Runtime/FreeStanding/memcpy_chk_err.c index 490d3f1d..997499ec 100644 --- a/test/Runtime/FreeStanding/memcpy_chk_err.c +++ b/test/Runtime/FreeStanding/memcpy_chk_err.c @@ -1,9 +1,7 @@ // This test checks that __memcpy_chk find the kind of errors it was // designed to find -// It requires clang >= 10 and not FreeBSD, otherwise a direct call to -// memcpy is emitted instead of to __memcpy_chk -// REQUIRES: geq-llvm-10.0 +// On FreeBSD, a direct call to memcpy is emitted instead of to __memcpy_chk // REQUIRES: not-freebsd // RUN: %clang %s -emit-llvm -O2 -g -c -D_FORTIFY_SOURCE=1 -o %t2.bc diff --git a/test/VectorInstructions/oob-llvm-lt11.c b/test/VectorInstructions/oob-llvm-lt11.c deleted file mode 100644 index 9d80ef7d..00000000 --- a/test/VectorInstructions/oob-llvm-lt11.c +++ /dev/null @@ -1,44 +0,0 @@ -// REQUIRES: lt-llvm-11.0 -// RUN: %clang %s -emit-llvm %O0opt -g -c -o %t1.bc -// RUN: rm -rf %t.klee-out -// NOTE: Have to pass `--optimize=false` to avoid vector operations being -// constant folded away. -// RUN: %klee --output-dir=%t.klee-out --optimize=false %t1.bc > %t.stdout.log 2> %t.stderr.log -// RUN: FileCheck -input-file=%t.stderr.log %s - -#include "klee/klee.h" - -#include -#include -#include - -typedef uint32_t v4ui __attribute__((vector_size(16))); -int main() { - v4ui f = {1, 2, 3, 4}; - int k = klee_range(0, 10, "k"); - - if (k == 0) { - // CHECK-DAG: [[@LINE+1]]: Out of bounds write when inserting element - f[4] = 255; // Out of bounds write - } - - if (k == 1) { - // CHECK-DAG: [[@LINE+1]]: Out of bounds read when extracting element - printf("f[4] = %u\n", f[5]); // Out of bounds - } - - if (k > 6) { - // Performing read should be ExtractElement instruction. - // For now this is an expected limitation. - // CHECK-DAG: [[@LINE+1]]: ExtractElement, support for symbolic index not implemented - uint32_t readValue = f[k]; - } - else { - // Performing write should be InsertElement instructions. - // For now this is an expected limitation. - // CHECK-DAG: [[@LINE+1]]: InsertElement, support for symbolic index not implemented - f[k] = 255; - } - - return 0; -} diff --git a/test/VectorInstructions/oob-read-llvm-geq11.c b/test/VectorInstructions/oob-read-llvm-geq11.c deleted file mode 100644 index 309e05b1..00000000 --- a/test/VectorInstructions/oob-read-llvm-geq11.c +++ /dev/null @@ -1,46 +0,0 @@ -// REQUIRES: geq-llvm-11.0 -// XFAIL: geq-llvm-11.0 - -/* The scalarizer pass in LLVM 11 was changed to generate, for a - read f[k], with k symbolic and f a 4-element vector: - if k == 0 => f[0] - elif k == 1 => f[1] - elif k == 2 => f[2] - elif k == 3 => f[3] - else ==> undef - - Therefore, even though an OOB access might exist at the source code - level, no such OOB accesses exist anymore at the LLVM IR level. - - And since undef is currently treated in KLEE as 0, an overflowing - access is always translated as f[0], which may lead to future - problems being missed. - - This test is marked as XFAIL as a reminder that we need to fix this - behaviour, most likely by having undef return a new symbolic variable. -*/ - -// RUN: %clang %s -emit-llvm %O0opt -g -c -o %t1.bc -// RUN: rm -rf %t.klee-out -// NOTE: Have to pass `--optimize=false` to avoid vector operations being -// constant folded away. -// RUN: %klee --output-dir=%t.klee-out --optimize=false --exit-on-error %t1.bc 2>%t.log -// RUN: FileCheck -input-file=%t.stderr.log %s - -#include "klee/klee.h" - -#include -#include -#include - -typedef uint32_t v4ui __attribute__((vector_size(16))); -int main() { - v4ui f = {1, 2, 3, 4}; - int k = klee_range(4, 10, "k"); - - uint32_t v = f[k]; // Symbolic out-of-bounds read - v = f[v]; // This should trigger an error, but currently this returns f[0] = 1 - assert(v != 1); - - return 0; -} diff --git a/test/VectorInstructions/oob-read.c b/test/VectorInstructions/oob-read.c new file mode 100644 index 00000000..2584b3a0 --- /dev/null +++ b/test/VectorInstructions/oob-read.c @@ -0,0 +1,45 @@ +// XFAIL: * + +/* The scalarizer pass in LLVM 11 was changed to generate, for a + read f[k], with k symbolic and f a 4-element vector: + if k == 0 => f[0] + elif k == 1 => f[1] + elif k == 2 => f[2] + elif k == 3 => f[3] + else ==> undef + + Therefore, even though an OOB access might exist at the source code + level, no such OOB accesses exist anymore at the LLVM IR level. + + And since undef is currently treated in KLEE as 0, an overflowing + access is always translated as f[0], which may lead to future + problems being missed. + + This test is marked as XFAIL as a reminder that we need to fix this + behaviour, most likely by having undef return a new symbolic variable. +*/ + +// RUN: %clang %s -emit-llvm %O0opt -g -c -o %t1.bc +// RUN: rm -rf %t.klee-out +// NOTE: Have to pass `--optimize=false` to avoid vector operations being +// constant folded away. +// RUN: %klee --output-dir=%t.klee-out --optimize=false --exit-on-error %t1.bc 2>%t.log +// RUN: FileCheck -input-file=%t.stderr.log %s + +#include "klee/klee.h" + +#include +#include +#include + +typedef uint32_t v4ui __attribute__((vector_size(16))); +int main() { + v4ui f = {1, 2, 3, 4}; + int k = klee_range(4, 10, "k"); + + uint32_t v = f[k]; // Symbolic out-of-bounds read + v = f[v]; // This should trigger an error, but currently this returns f[0] = 1 + assert(v != 1); + + return 0; +} diff --git a/test/VectorInstructions/oob-write-llvm-geq11.c b/test/VectorInstructions/oob-write-llvm-geq11.c deleted file mode 100644 index 5c3e691c..00000000 --- a/test/VectorInstructions/oob-write-llvm-geq11.c +++ /dev/null @@ -1,51 +0,0 @@ -// REQUIRES: geq-llvm-11.0 - -/* The scalarizer pass in LLVM 11 was changed to generate, for a - write of the form f[k] = v, with f a 4-element vector: - if k == 0 => f[0] = v - if k == 1 => f[1] = v - if k == 2 => f[2] = v - if k == 3 => f[3] = v - - Therefore, even though an OOB write access might exist at the source - code level (e.g., f[5] = v), no such OOB accesses exist anymore at - the LLVM IR level. - - So unlike in the LLVM < 11 test, here we test that the contents of - the vector is unmodified after the OOB write. -*/ - -// RUN: %clang %s -emit-llvm %O0opt -g -c -o %t1.bc -// RUN: rm -rf %t.klee-out -// NOTE: Have to pass `--optimize=false` to avoid vector operations being -// constant folded away. -// RUN: %klee --output-dir=%t.klee-out --optimize=false --exit-on-error %t1.bc - -#include "klee/klee.h" - -#include -#include -#include - -typedef uint32_t v4ui __attribute__((vector_size(16))); -int main() { - v4ui f = {1, 2, 3, 4}; - int k = klee_range(0, 10, "k"); - - if (k < 4) { - f[5] = 3; // Concrete out-of-bounds write - assert(f[0] == 1); - assert(f[1] == 2); - assert(f[2] == 3); - assert(f[3] == 4); - } - else { - f[k] = 255; // Symbolic out-of-bounds write - assert(f[0] == 1); - assert(f[1] == 2); - assert(f[2] == 3); - assert(f[3] == 4); - } - - return 0; -} diff --git a/test/VectorInstructions/oob-write.c b/test/VectorInstructions/oob-write.c new file mode 100644 index 00000000..6906dc62 --- /dev/null +++ b/test/VectorInstructions/oob-write.c @@ -0,0 +1,49 @@ +/* The scalarizer pass in LLVM 11 was changed to generate, for a + write of the form f[k] = v, with f a 4-element vector: + if k == 0 => f[0] = v + if k == 1 => f[1] = v + if k == 2 => f[2] = v + if k == 3 => f[3] = v + + Therefore, even though an OOB write access might exist at the source + code level (e.g., f[5] = v), no such OOB accesses exist anymore at + the LLVM IR level. + + So unlike in the LLVM < 11 test, here we test that the contents of + the vector is unmodified after the OOB write. +*/ + +// RUN: %clang %s -emit-llvm %O0opt -g -c -o %t1.bc +// RUN: rm -rf %t.klee-out +// NOTE: Have to pass `--optimize=false` to avoid vector operations being +// constant folded away. +// RUN: %klee --output-dir=%t.klee-out --optimize=false --exit-on-error %t1.bc + +#include "klee/klee.h" + +#include +#include +#include + +typedef uint32_t v4ui __attribute__((vector_size(16))); +int main() { + v4ui f = {1, 2, 3, 4}; + int k = klee_range(0, 10, "k"); + + if (k < 4) { + f[5] = 3; // Concrete out-of-bounds write + assert(f[0] == 1); + assert(f[1] == 2); + assert(f[2] == 3); + assert(f[3] == 4); + } + else { + f[k] = 255; // Symbolic out-of-bounds write + assert(f[0] == 1); + assert(f[1] == 2); + assert(f[2] == 3); + assert(f[3] == 4); + } + + return 0; +} diff --git a/test/lit.cfg b/test/lit.cfg index 489c272d..773c249d 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -170,7 +170,7 @@ config.substitutions.append( # 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. -known_llvm_versions = { "9.0", "10.0", "11.0", "11.1", "12.0", "13.0", "14.0", "15.0", "16.0", "17.0" } +known_llvm_versions = { "11.0", "11.1", "12.0", "13.0", "14.0", "15.0", "16.0", "17.0" } current_llvm_version_tuple = (int(config.llvm_version_major), int(config.llvm_version_minor)) current_llvm_version = "%s.%s" % current_llvm_version_tuple -- cgit 1.4.1