about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/build.yaml17
-rw-r--r--cmake/workaround_llvm_pr39177.cmake3
-rw-r--r--runtime/CMakeLists.txt6
-rw-r--r--scripts/build/p-libcxx.inc8
-rw-r--r--scripts/build/p-llvm.inc25
-rw-r--r--scripts/build/patches/libcxx38.patch11
-rw-r--r--scripts/build/patches/libcxx39.patch11
-rw-r--r--scripts/build/patches/libcxx40.patch11
-rw-r--r--scripts/build/patches/llvm38.patch127
-rw-r--r--scripts/build/patches/llvm39.patch76
-rw-r--r--scripts/build/patches/llvm40.patch100
-rw-r--r--scripts/build/patches/llvm50.patch24
-rw-r--r--test/CMakeLists.txt12
-rw-r--r--test/Concrete/CMakeLists.txt7
-rw-r--r--test/lit.cfg3
-rw-r--r--test/lit.site.cfg.in4
-rw-r--r--test/regression/2018-10-30-llvm-pr39177.ll1
-rw-r--r--unittests/TestMain.cpp8
18 files changed, 14 insertions, 440 deletions
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 64b77f38..efd72c48 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -44,10 +44,6 @@ jobs:
                 "LLVM 8",
                 "LLVM 7",
                 "LLVM 6",
-                "LLVM 5",
-                "LLVM 4",
-                "LLVM 3.9",
-                "LLVM 3.8",
                 "ASan",
                 "UBSan",
                 "MSan",
@@ -84,19 +80,6 @@ jobs:
           - name: "LLVM 6"
             env:
               LLVM_VERSION: 6
-          - name: "LLVM 5"
-            env:
-              LLVM_VERSION: 5
-          - name: "LLVM 4"
-            env:
-              LLVM_VERSION: 4
-          - name: "LLVM 3.9"
-            env:
-              LLVM_VERSION: 3.9
-          - name: "LLVM 3.8"
-            env:
-              LLVM_VERSION: 3.8
-              USE_LIBCXX: 0
           # Sanitizer builds. Do unoptimized build otherwise the optimizer might remove problematic code
           - name: "ASan"
             env:
diff --git a/cmake/workaround_llvm_pr39177.cmake b/cmake/workaround_llvm_pr39177.cmake
index 317cac7e..9e0ac8bd 100644
--- a/cmake/workaround_llvm_pr39177.cmake
+++ b/cmake/workaround_llvm_pr39177.cmake
@@ -43,8 +43,7 @@
 # [MODIFIED] lib/Module/Passes.h
 
 # Detect whether LLVM version is affected by PR39177
-if ((${LLVM_VERSION_MAJOR} GREATER 3 OR (${LLVM_VERSION_MAJOR} EQUAL 3 AND ${LLVM_VERSION_MINOR} EQUAL 9)) # LLVM >= 3.9
-   AND (${LLVM_VERSION_MAJOR} LESS 7 OR (${LLVM_VERSION_MAJOR} EQUAL 7 AND ${LLVM_VERSION_MINOR} EQUAL 0 AND ${LLVM_VERSION_PATCH} EQUAL 0))) # LLVM <= 7.0.0
+if (${LLVM_VERSION_MAJOR} LESS 7 OR (${LLVM_VERSION_MAJOR} EQUAL 7 AND ${LLVM_VERSION_MINOR} EQUAL 0 AND ${LLVM_VERSION_PATCH} EQUAL 0)) # LLVM <= 7.0.0
   set(DISABLE_WORKAROUND_LLVM_PR39177_DEFAULT OFF)
 else()
   set(DISABLE_WORKAROUND_LLVM_PR39177_DEFAULT ON)
diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt
index 6ee6f830..5747672c 100644
--- a/runtime/CMakeLists.txt
+++ b/runtime/CMakeLists.txt
@@ -79,12 +79,10 @@ set(COMMON_CC_FLAGS
         -D__STDC_CONSTANT_MACROS
         -Wall
         -Wwrite-strings
+        -Xclang
+        -disable-O0-optnone
         )
 
-if (${LLVM_VERSION_MAJOR} GREATER 4)
-    list(APPEND COMMON_CC_FLAGS "-Xclang" "-disable-O0-optnone")
-endif ()
-
 foreach (_suffix ${LIB_BC_SUFFIX})
     list(APPEND "LIB_BC_FLAGS_${_suffix}" ${COMMON_CC_FLAGS})
 endforeach ()
diff --git a/scripts/build/p-libcxx.inc b/scripts/build/p-libcxx.inc
index ec0d902b..d88699ba 100644
--- a/scripts/build/p-libcxx.inc
+++ b/scripts/build/p-libcxx.inc
@@ -10,11 +10,7 @@ download_libcxx() {
   [[ -f "${LIBCXX_SRC}/.src_checked_out" ]] && return 0
 
   local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
-
-  local version=""
-  [[ "${LLVM_VERSION_MAJOR}" -le 3 ]] && version="release/${LLVM_VERSION}.x"
-  [[ "${LLVM_VERSION_MAJOR}" -ge 4 ]] && version="release/${LLVM_VERSION_MAJOR}.x"
-
+  local version="release/${LLVM_VERSION_MAJOR}.x"
 
   git clone --single-branch --branch "${version}" --depth 1 "https://github.com/llvm/llvm-project.git" "${LIBCXX_SRC}"
 
@@ -85,7 +81,7 @@ install_libcxx() {
     fi
 
     local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
-    [[ "${LLVM_VERSION_MAJOR}" -ge 6 ]] && libraries+=("${LIBCXX_INSTALL}"/lib/lib*.a)
+    libraries+=("${LIBCXX_INSTALL}"/lib/lib*.a)
 
 
     for p in "${libraries[@]}" ; do
diff --git a/scripts/build/p-llvm.inc b/scripts/build/p-llvm.inc
index a97b8676..e335ad73 100644
--- a/scripts/build/p-llvm.inc
+++ b/scripts/build/p-llvm.inc
@@ -97,17 +97,7 @@ download_llvm() {
   local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
 
   branch_name="release/${LLVM_VERSION_MAJOR}.x"
-  if [[ "${LLVM_VERSION_MAJOR}" -le 3 ]]; then
-    branch_name="release/${LLVM_VERSION}.x"
-  fi
   git_clone_or_update "https://github.com/llvm/llvm-project.git" "${LLVM_SRC_BASE}" "${branch_name}" || exit 1
-  if [[ "${LLVM_VERSION_MAJOR}" -lt 4 ]]; then
-    # Use symlinks for older versions whose build systems do not support the monorepo directory layout
-    ln -s "${LLVM_SRC_BASE}/clang" "${LLVM_SRC_BASE}/llvm/tools/"
-    ln -s "${LLVM_SRC_BASE}/compiler-rt" "${LLVM_SRC_BASE}/llvm/projects/"
-    ln -s "${LLVM_SRC_BASE}/libcxx" "${LLVM_SRC_BASE}/llvm/projects/"
-    ln -s "${LLVM_SRC_BASE}/libcxxabi" "${LLVM_SRC_BASE}/llvm/projects/"
-  fi
 
   # Apply existing patches if needed
   if [ -f "${DIR}/patches/llvm${LLVM_VERSION_SHORT}.patch" ]; then
@@ -190,11 +180,7 @@ build_llvm() {
   )
 
   # Select components to build
-  if [[ ${LLVM_VERSION_SHORT} -ge 60 ]]; then
-    CONFIG+=("-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;libcxx;libcxxabi")
-  else
-    CONFIG+=("-DLLVM_ENABLE_PROJECTS=clang;compiler-rt")
-  fi
+  CONFIG+=("-DLLVM_ENABLE_PROJECTS=clang;compiler-rt;libcxx;libcxxabi")
 
   # cmake build
   if [[ "${enable_optimized}" == "1" && "${enable_debug}" != "1" ]]; then
@@ -279,13 +265,8 @@ install_llvm() {
       install-clang install-llvm-config install-llvm-objdump
       install-llvm-link install-llvm-ar install-llvm-nm install-llvm-dis
       install-clang-headers install-llvm-as
-      install-llvm-symbolizer install-LLVMSupport install-lli not FileCheck )
-  
-    if [[ ${LLVM_VERSION_SHORT} -eq 38 ]]; then
-      LLVM_PACKAGES=("${LLVM_PACKAGES[@]}" installhdrs)
-    else
-      LLVM_PACKAGES=("${LLVM_PACKAGES[@]}" install-llvm-headers)
-    fi
+      install-llvm-symbolizer install-LLVMSupport install-lli not FileCheck
+      install-llvm-headers )
   
     ninja "${LLVM_PACKAGES[@]}"
 
diff --git a/scripts/build/patches/libcxx38.patch b/scripts/build/patches/libcxx38.patch
deleted file mode 100644
index 382db544..00000000
--- a/scripts/build/patches/libcxx38.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/libcxx/include/__locale
-+++ b/libcxx/include/__locale
-@@ -34,7 +34,7 @@
- # include <support/solaris/xlocale.h>
- #elif defined(_NEWLIB_VERSION)
- # include <support/newlib/xlocale.h>
--#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
-+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
-     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
- # include <xlocale.h>
- #elif defined(_LIBCPP_HAS_MUSL_LIBC)
diff --git a/scripts/build/patches/libcxx39.patch b/scripts/build/patches/libcxx39.patch
deleted file mode 100644
index 382db544..00000000
--- a/scripts/build/patches/libcxx39.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/libcxx/include/__locale
-+++ b/libcxx/include/__locale
-@@ -34,7 +34,7 @@
- # include <support/solaris/xlocale.h>
- #elif defined(_NEWLIB_VERSION)
- # include <support/newlib/xlocale.h>
--#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
-+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
-     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
- # include <xlocale.h>
- #elif defined(_LIBCPP_HAS_MUSL_LIBC)
diff --git a/scripts/build/patches/libcxx40.patch b/scripts/build/patches/libcxx40.patch
deleted file mode 100644
index 382db544..00000000
--- a/scripts/build/patches/libcxx40.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/libcxx/include/__locale
-+++ b/libcxx/include/__locale
-@@ -34,7 +34,7 @@
- # include <support/solaris/xlocale.h>
- #elif defined(_NEWLIB_VERSION)
- # include <support/newlib/xlocale.h>
--#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
-+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
-     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
- # include <xlocale.h>
- #elif defined(_LIBCPP_HAS_MUSL_LIBC)
diff --git a/scripts/build/patches/llvm38.patch b/scripts/build/patches/llvm38.patch
deleted file mode 100644
index f2de69b0..00000000
--- a/scripts/build/patches/llvm38.patch
+++ /dev/null
@@ -1,127 +0,0 @@
-diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
-index 99c7b8e6..f9a57b25 100644
---- a/clang/lib/Driver/ToolChains.cpp
-+++ b/clang/lib/Driver/ToolChains.cpp
-@@ -1241,20 +1241,31 @@ Generic_GCC::GCCVersion Linux::GCCVersion::Parse(StringRef VersionText) {
-   if (First.first.getAsInteger(10, GoodVersion.Major) || GoodVersion.Major < 0)
-     return BadVersion;
-   GoodVersion.MajorStr = First.first.str();
--  if (Second.first.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
-+  if (First.second.empty())
-+    return GoodVersion;
-+  StringRef MinorStr = Second.first;
-+  if (Second.second.empty()) {
-+    if (size_t EndNumber = MinorStr.find_first_not_of("0123456789")) {
-+      GoodVersion.PatchSuffix = MinorStr.substr(EndNumber);
-+      MinorStr = MinorStr.slice(0, EndNumber);
-+    }
-+  }
-+  if (MinorStr.getAsInteger(10, GoodVersion.Minor) || GoodVersion.Minor < 0)
-     return BadVersion;
--  GoodVersion.MinorStr = Second.first.str();
-+  GoodVersion.MinorStr = MinorStr.str();
-
-   // First look for a number prefix and parse that if present. Otherwise just
-   // stash the entire patch string in the suffix, and leave the number
-   // unspecified. This covers versions strings such as:
-+  //   5        (handled above)
-   //   4.4
-+  //   4.4-patched
-   //   4.4.0
-   //   4.4.x
-   //   4.4.2-rc4
-   //   4.4.x-patched
-   // And retains any patch number it finds.
--  StringRef PatchText = GoodVersion.PatchSuffix = Second.second.str();
-+  StringRef PatchText = Second.second.str();
-   if (!PatchText.empty()) {
-     if (size_t EndNumber = PatchText.find_first_not_of("0123456789")) {
-       // Try to parse the number and any suffix.
-diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
-index 70799663..b9ca8b9d 100644
---- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
-+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
-@@ -565,8 +565,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) {
- }
- #endif
-
--uptr internal_sigaltstack(const struct sigaltstack *ss,
--                         struct sigaltstack *oss) {
-+uptr internal_sigaltstack(const void *ss, void *oss) {
-   return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
- }
-
-diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
-index 77bfbd15..5572793e 100644
---- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
-+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
-@@ -21,7 +21,6 @@
- #include "sanitizer_platform_limits_posix.h"
-
- struct link_map;  // Opaque type returned by dlopen().
--struct sigaltstack;
-
- namespace __sanitizer {
- // Dirent structure for getdents(). Note that this structure is different from
-@@ -30,8 +29,7 @@ struct linux_dirent;
-
- // Syscall wrappers.
- uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
--uptr internal_sigaltstack(const struct sigaltstack* ss,
--                          struct sigaltstack* oss);
-+uptr internal_sigaltstack(const void* ss, void* oss);
- uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
-     __sanitizer_sigset_t *oldset);
- void internal_sigfillset(__sanitizer_sigset_t *set);
-diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
-index d1e2f6ac..2df7be58 100644
---- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
-+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
-@@ -272,7 +272,7 @@ static int TracerThread(void* argument) {
-
-   // Alternate stack for signal handling.
-   InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize);
--  struct sigaltstack handler_stack;
-+  stack_t handler_stack;
-   internal_memset(&handler_stack, 0, sizeof(handler_stack));
-   handler_stack.ss_sp = handler_stack_memory.data();
-   handler_stack.ss_size = kHandlerStackSize;
-diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
-index 66025611..98a5b135 100644
---- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
-+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
-@@ -311,7 +311,7 @@ bool IsGlobalVar(uptr addr) {
- int ExtractResolvFDs(void *state, int *fds, int nfd) {
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
-   int cnt = 0;
--  __res_state *statp = (__res_state*)state;
-+  struct __res_state *statp = (struct __res_state*)state;
-   for (int i = 0; i < MAXNS && cnt < nfd; i++) {
-     if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
-       fds[cnt++] = statp->_u._ext.nssocks[i];
-diff --git a/libcxx/include/__locale b/libcxx/include/__locale
-index 7bc701dd..ae0372fe 100644
---- a/libcxx/include/__locale
-+++ b/libcxx/include/__locale
-@@ -34,7 +34,7 @@
- # include <support/solaris/xlocale.h>
- #elif defined(_NEWLIB_VERSION)
- # include <support/newlib/xlocale.h>
--#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
-+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
-     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
- # include <xlocale.h>
- #elif defined(_LIBCPP_HAS_MUSL_LIBC)
-diff --git a/llvm/include/llvm/IR/ValueMap.h b/llvm/include/llvm/IR/ValueMap.h
-index ad518ac0..d928f6a2 100644
---- a/llvm/include/llvm/IR/ValueMap.h
-+++ b/llvm/include/llvm/IR/ValueMap.h
-@@ -99,7 +99,7 @@ public:
-   explicit ValueMap(const ExtraData &Data, unsigned NumInitBuckets = 64)
-       : Map(NumInitBuckets), Data(Data) {}
-
--  bool hasMD() const { return MDMap; }
-+  bool hasMD() const { return static_cast<bool>(MDMap); }
-   MDMapT &MD() {
-     if (!MDMap)
-       MDMap.reset(new MDMapT);
\ No newline at end of file
diff --git a/scripts/build/patches/llvm39.patch b/scripts/build/patches/llvm39.patch
deleted file mode 100644
index da2be4cd..00000000
--- a/scripts/build/patches/llvm39.patch
+++ /dev/null
@@ -1,76 +0,0 @@
---- a/compiler-rt/lib/esan/esan_sideline_linux.cpp
-+++ b/compiler-rt/lib/esan/esan_sideline_linux.cpp
-@@ -70,7 +70,7 @@ int SidelineThread::runSideline(void *Arg) {
-
-   // Set up a signal handler on an alternate stack for safety.
-   InternalScopedBuffer<char> StackMap(SigAltStackSize);
--  struct sigaltstack SigAltStack;
-+  stack_t SigAltStack;
-   SigAltStack.ss_sp = StackMap.data();
-   SigAltStack.ss_size = SigAltStackSize;
-   SigAltStack.ss_flags = 0;
---- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
-+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
-@@ -607,8 +607,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) {
- }
- #endif
-
--uptr internal_sigaltstack(const struct sigaltstack *ss,
--                         struct sigaltstack *oss) {
-+uptr internal_sigaltstack(const void *ss, void *oss) {
-   return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
- }
-
---- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
-+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
-@@ -21,7 +21,6 @@
- #include "sanitizer_platform_limits_posix.h"
-
- struct link_map;  // Opaque type returned by dlopen().
--struct sigaltstack;
-
- namespace __sanitizer {
- // Dirent structure for getdents(). Note that this structure is different from
-@@ -30,8 +29,7 @@ struct linux_dirent;
-
- // Syscall wrappers.
- uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
--uptr internal_sigaltstack(const struct sigaltstack* ss,
--                          struct sigaltstack* oss);
-+uptr internal_sigaltstack(const void* ss, void* oss);
- uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
-     __sanitizer_sigset_t *oldset);
-
---- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
-+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
-@@ -273,7 +273,7 @@ static int TracerThread(void* argument) {
-
-   // Alternate stack for signal handling.
-   InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize);
--  struct sigaltstack handler_stack;
-+  stack_t handler_stack;
-   internal_memset(&handler_stack, 0, sizeof(handler_stack));
-   handler_stack.ss_sp = handler_stack_memory.data();
-   handler_stack.ss_size = kHandlerStackSize;
---- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
-+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
-@@ -282,7 +282,7 @@ void InitializePlatform() {
- int ExtractResolvFDs(void *state, int *fds, int nfd) {
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
-   int cnt = 0;
--  __res_state *statp = (__res_state*)state;
-+  struct __res_state *statp = (struct __res_state*)state;
-   for (int i = 0; i < MAXNS && cnt < nfd; i++) {
-     if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
-       fds[cnt++] = statp->_u._ext.nssocks[i];
---- a/libcxx/include/__locale
-+++ b/libcxx/include/__locale
-@@ -34,7 +34,7 @@
- # include <support/solaris/xlocale.h>
- #elif defined(_NEWLIB_VERSION)
- # include <support/newlib/xlocale.h>
--#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
-+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
-     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
- # include <xlocale.h>
- #elif defined(_LIBCPP_HAS_MUSL_LIBC)
\ No newline at end of file
diff --git a/scripts/build/patches/llvm40.patch b/scripts/build/patches/llvm40.patch
deleted file mode 100644
index 4a101487..00000000
--- a/scripts/build/patches/llvm40.patch
+++ /dev/null
@@ -1,100 +0,0 @@
---- a/compiler-rt/lib/esan/esan_sideline_linux.cpp
-+++ b/compiler-rt/lib/esan/esan_sideline_linux.cpp
-@@ -70,7 +70,7 @@ int SidelineThread::runSideline(void *Arg) {
-
-   // Set up a signal handler on an alternate stack for safety.
-   InternalScopedBuffer<char> StackMap(SigAltStackSize);
--  struct sigaltstack SigAltStack;
-+  stack_t SigAltStack;
-   SigAltStack.ss_sp = StackMap.data();
-   SigAltStack.ss_size = SigAltStackSize;
-   SigAltStack.ss_flags = 0;
---- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
-+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc
-@@ -607,8 +607,7 @@ uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5) {
- }
- #endif
-
--uptr internal_sigaltstack(const struct sigaltstack *ss,
--                         struct sigaltstack *oss) {
-+uptr internal_sigaltstack(const void *ss, void *oss) {
-   return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
- }
-
---- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
-+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.h
-@@ -21,7 +21,6 @@
- #include "sanitizer_platform_limits_posix.h"
-
- struct link_map;  // Opaque type returned by dlopen().
--struct sigaltstack;
-
- namespace __sanitizer {
- // Dirent structure for getdents(). Note that this structure is different from
-@@ -30,8 +29,7 @@ struct linux_dirent;
-
- // Syscall wrappers.
- uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
--uptr internal_sigaltstack(const struct sigaltstack* ss,
--                          struct sigaltstack* oss);
-+uptr internal_sigaltstack(const void* ss, void* oss);
- uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
-     __sanitizer_sigset_t *oldset);
-
---- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
-+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
-@@ -275,7 +275,7 @@ static int TracerThread(void* argument) {
-
-   // Alternate stack for signal handling.
-   InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize);
--  struct sigaltstack handler_stack;
-+  stack_t handler_stack;
-   internal_memset(&handler_stack, 0, sizeof(handler_stack));
-   handler_stack.ss_sp = handler_stack_memory.data();
-   handler_stack.ss_size = kHandlerStackSize;
---- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
-+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cc
-@@ -289,7 +289,7 @@ void InitializePlatform() {
- int ExtractResolvFDs(void *state, int *fds, int nfd) {
- #if SANITIZER_LINUX && !SANITIZER_ANDROID
-   int cnt = 0;
--  __res_state *statp = (__res_state*)state;
-+  struct __res_state *statp = (struct __res_state*)state;
-   for (int i = 0; i < MAXNS && cnt < nfd; i++) {
-     if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
-       fds[cnt++] = statp->_u._ext.nssocks[i];
---- a/libcxx/include/__locale
-+++ b/libcxx/include/__locale
-@@ -34,7 +34,7 @@
- # include <support/solaris/xlocale.h>
- #elif defined(_NEWLIB_VERSION)
- # include <support/newlib/xlocale.h>
--#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
-+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
-     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
- # include <xlocale.h>
- #elif defined(_LIBCPP_HAS_MUSL_LIBC)
---- a/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
-+++ b/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
-@@ -687,7 +687,7 @@ private:
-
-   uint32_t getTrampolineSize() const { return RemoteTrampolineSize; }
-
--  Expected<std::vector<char>> readMem(char *Dst, JITTargetAddress Src,
-+  Expected<std::vector<unsigned char>> readMem(char *Dst, JITTargetAddress Src,
-                                       uint64_t Size) {
-     // Check for an 'out-of-band' error, e.g. from an MM destructor.
-     if (ExistingError)
---- a/llvm/tools/llvm-shlib/CMakeLists.txt
-+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
-@@ -35,8 +35,9 @@ if(LLVM_DYLIB_EXPORTED_SYMBOL_FILE)
- endif()
-
- add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${SOURCES})
--
-+if(LIB_NAMES)
- list(REMOVE_DUPLICATES LIB_NAMES)
-+endif()
- if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" OR MINGW) # FIXME: It should be "GNU ld for elf"
-   # GNU ld doesn't resolve symbols in the version script.
-   set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
diff --git a/scripts/build/patches/llvm50.patch b/scripts/build/patches/llvm50.patch
deleted file mode 100644
index d6ce652b..00000000
--- a/scripts/build/patches/llvm50.patch
+++ /dev/null
@@ -1,24 +0,0 @@
---- a/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
-+++ b/llvm/include/llvm/ExecutionEngine/Orc/OrcRemoteTargetClient.h
-@@ -713,7 +713,7 @@ private:
-
-   uint32_t getTrampolineSize() const { return RemoteTrampolineSize; }
-
--  Expected<std::vector<char>> readMem(char *Dst, JITTargetAddress Src,
-+  Expected<std::vector<unsigned char>> readMem(char *Dst, JITTargetAddress Src,
-                                       uint64_t Size) {
-     // Check for an 'out-of-band' error, e.g. from an MM destructor.
-     if (ExistingError)
---- a/llvm/tools/llvm-shlib/CMakeLists.txt
-+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
-@@ -36,7 +36,10 @@ endif()
-
- add_llvm_library(LLVM SHARED DISABLE_LLVM_LINK_LLVM_DYLIB SONAME ${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 "DragonFly")) # FIXME: It should be "GNU ld for elf"
-   configure_file(
-   ${CMAKE_CURRENT_SOURCE_DIR}/simple_version_script.map.in
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 2a968333..a62347c1 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -75,11 +75,7 @@ endif()
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${KLEE_TOOLS_DIR}/testtools)
 
 if (DOWNLOAD_FILECHECK_SOURCE)
-  if (${LLVM_VERSION_MAJOR} GREATER 3)
-    set(FILECHECK_SRC_URL "https://raw.githubusercontent.com/llvm/llvm-project/release/${LLVM_VERSION_MAJOR}.x/llvm/utils/FileCheck/FileCheck.cpp")
-  else()
-    set(FILECHECK_SRC_URL "https://raw.githubusercontent.com/llvm/llvm-project/release/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.x/llvm/utils/FileCheck/FileCheck.cpp")
-  endif()
+  set(FILECHECK_SRC_URL "https://raw.githubusercontent.com/llvm/llvm-project/release/${LLVM_VERSION_MAJOR}.x/llvm/utils/FileCheck/FileCheck.cpp")
   set(FILECHECK_SRC_FILE "${CMAKE_CURRENT_BINARY_DIR}/FileCheck.cpp")
   if (NOT EXISTS "${FILECHECK_SRC_FILE}")
     message(STATUS "Downloading LLVM FileCheck source")
@@ -102,11 +98,7 @@ if (DOWNLOAD_FILECHECK_SOURCE)
 endif()
 
 if (DOWNLOAD_NOT_SOURCE)
-  if (${LLVM_VERSION_MAJOR} GREATER 3)
-    set(NOT_SRC_URL "https://raw.githubusercontent.com/llvm/llvm-project/release/${LLVM_VERSION_MAJOR}.x/llvm/utils/not/not.cpp")
-  else()
-    set(NOT_SRC_URL "https://raw.githubusercontent.com/llvm/llvm-project/release/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.x/llvm/utils/not/not.cpp")
-  endif()
+  set(NOT_SRC_URL "https://raw.githubusercontent.com/llvm/llvm-project/release/${LLVM_VERSION_MAJOR}.x/llvm/utils/not/not.cpp")
   set(NOT_SRC_FILE "${CMAKE_CURRENT_BINARY_DIR}/not.cpp")
   if (NOT EXISTS "${NOT_SRC_FILE}")
     message(STATUS "Downloading LLVM not source")
diff --git a/test/Concrete/CMakeLists.txt b/test/Concrete/CMakeLists.txt
index 0f565bed..e7cf2416 100644
--- a/test/Concrete/CMakeLists.txt
+++ b/test/Concrete/CMakeLists.txt
@@ -6,9 +6,6 @@
 # License. See LICENSE.TXT for details.
 #
 #===------------------------------------------------------------------------===#
-if (${LLVM_VERSION_MAJOR} GREATER 4)
-  set(OZERO_OPT "-O0 -Xclang -disable-O0-optnone")
-else()
-  set(OZERO_OPT "-O0")
-endif()
+
+set(OZERO_OPT "-O0 -Xclang -disable-O0-optnone")
 configure_file(Makefile.cmake.test.in Makefile.cmake.test @ONLY)
diff --git a/test/lit.cfg b/test/lit.cfg
index 60bcb781..0d7aa1ed 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -157,8 +157,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 = { "3.8", "3.9", "4.0", "5.0", "6.0", "7.0", "7.1", "8.0",
-                        "9.0", "10.0", "11.0", "11.1", "12.0", "13.0" }
+known_llvm_versions = { "6.0", "7.0", "7.1", "8.0", "9.0", "10.0", "11.0", "11.1", "12.0", "13.0" }
 current_llvm_version_tuple = (int(config.llvm_version_major), int(config.llvm_version_minor))
 current_llvm_version = "%s.%s" % current_llvm_version_tuple
 
diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in
index e5fe3d89..849062b1 100644
--- a/test/lit.site.cfg.in
+++ b/test/lit.site.cfg.in
@@ -24,9 +24,7 @@ config.cxx = "@NATIVE_CXX@"
 
 # NOTE: any changes to compiler flags also have to be applied to
 #       test/Concrete/CMakeLists.txt
-config.O0opt = "-O0"
-if @LLVM_VERSION_MAJOR@ >= 5:
-  config.O0opt += " -Xclang -disable-O0-optnone"
+config.O0opt = "-O0 -Xclang -disable-O0-optnone"
 
 # Features
 config.enable_uclibc = True if @SUPPORT_KLEE_UCLIBC@ == 1 else False
diff --git a/test/regression/2018-10-30-llvm-pr39177.ll b/test/regression/2018-10-30-llvm-pr39177.ll
index 0b300c81..601a37bd 100644
--- a/test/regression/2018-10-30-llvm-pr39177.ll
+++ b/test/regression/2018-10-30-llvm-pr39177.ll
@@ -1,4 +1,3 @@
-; REQUIRES: geq-llvm-3.9
 ; RUN: rm -rf %t.klee-out
 ; RUN: llvm-as -f %s -o - | %klee -optimize -output-dir=%t.klee-out | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
diff --git a/unittests/TestMain.cpp b/unittests/TestMain.cpp
index 42dd721a..9512e59a 100644
--- a/unittests/TestMain.cpp
+++ b/unittests/TestMain.cpp
@@ -7,21 +7,13 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "klee/Config/Version.h"
-
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Signals.h"
 
 #include "gtest/gtest.h"
 
 int main(int argc, char **argv) {
-
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0], true);
-#else
-  llvm::sys::PrintStackTraceOnErrorSignal(true);
-#endif
-
   testing::InitGoogleTest(&argc, argv);
   return RUN_ALL_TESTS();
 }