summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib')
-rw-r--r--compiler-rt/lib/msan/CMakeLists.txt17
-rw-r--r--compiler-rt/lib/msan/lit_tests/CMakeLists.txt31
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/getresid.cc25
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/glob.cc27
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/glob_altdirfunc.cc78
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/glob_nomatch.cc21
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/aa0
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/ab0
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/ba0
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/lit.local.cfg9
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/syscalls.cc107
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/tcgetattr.cc21
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/xattr.cc142
-rw-r--r--compiler-rt/lib/msan/lit_tests/Linux/xattr_test_root/a0
-rw-r--r--compiler-rt/lib/msan/lit_tests/SharedLibs/dso-origin-so.cc14
-rw-r--r--compiler-rt/lib/msan/lit_tests/SharedLibs/dso-origin.h4
-rw-r--r--compiler-rt/lib/msan/lit_tests/SharedLibs/lit.local.cfg4
-rw-r--r--compiler-rt/lib/msan/lit_tests/Unit/lit.site.cfg.in13
-rw-r--r--compiler-rt/lib/msan/lit_tests/allocator_returns_null.cc81
-rw-r--r--compiler-rt/lib/msan/lit_tests/backtrace.cc26
-rw-r--r--compiler-rt/lib/msan/lit_tests/c-strdup.c17
-rw-r--r--compiler-rt/lib/msan/lit_tests/cxa_atexit.cc28
-rw-r--r--compiler-rt/lib/msan/lit_tests/default_blacklist.cc3
-rw-r--r--compiler-rt/lib/msan/lit_tests/dlerror.cc14
-rw-r--r--compiler-rt/lib/msan/lit_tests/dso-origin.cc25
-rw-r--r--compiler-rt/lib/msan/lit_tests/dtls_test.c60
-rw-r--r--compiler-rt/lib/msan/lit_tests/errno.cc17
-rw-r--r--compiler-rt/lib/msan/lit_tests/getaddrinfo-positive.cc23
-rw-r--r--compiler-rt/lib/msan/lit_tests/getaddrinfo.cc24
-rw-r--r--compiler-rt/lib/msan/lit_tests/getline.cc30
-rw-r--r--compiler-rt/lib/msan/lit_tests/getline_test_data2
-rw-r--r--compiler-rt/lib/msan/lit_tests/heap-origin.cc31
-rw-r--r--compiler-rt/lib/msan/lit_tests/iconv.cc48
-rw-r--r--compiler-rt/lib/msan/lit_tests/if_indextoname.cc23
-rw-r--r--compiler-rt/lib/msan/lit_tests/ifaddrs.cc50
-rw-r--r--compiler-rt/lib/msan/lit_tests/initgroups.cc11
-rw-r--r--compiler-rt/lib/msan/lit_tests/inline.cc20
-rw-r--r--compiler-rt/lib/msan/lit_tests/insertvalue_origin.cc35
-rw-r--r--compiler-rt/lib/msan/lit_tests/ioctl.cc20
-rw-r--r--compiler-rt/lib/msan/lit_tests/ioctl_custom.cc33
-rw-r--r--compiler-rt/lib/msan/lit_tests/ioctl_sound.cc29
-rw-r--r--compiler-rt/lib/msan/lit_tests/keep-going-dso.cc33
-rw-r--r--compiler-rt/lib/msan/lit_tests/keep-going.cc34
-rw-r--r--compiler-rt/lib/msan/lit_tests/lit.cfg74
-rw-r--r--compiler-rt/lib/msan/lit_tests/lit.site.cfg.in5
-rw-r--r--compiler-rt/lib/msan/lit_tests/malloc_hook.cc36
-rw-r--r--compiler-rt/lib/msan/lit_tests/mmap_below_shadow.cc28
-rw-r--r--compiler-rt/lib/msan/lit_tests/no_sanitize_memory.cc34
-rw-r--r--compiler-rt/lib/msan/lit_tests/no_sanitize_memory_prop.cc33
-rw-r--r--compiler-rt/lib/msan/lit_tests/poison_in_free.cc16
-rw-r--r--compiler-rt/lib/msan/lit_tests/pthread_getattr_np_deadlock.cc22
-rw-r--r--compiler-rt/lib/msan/lit_tests/ptrace.cc36
-rw-r--r--compiler-rt/lib/msan/lit_tests/readdir64.cc27
-rw-r--r--compiler-rt/lib/msan/lit_tests/scandir.cc56
-rw-r--r--compiler-rt/lib/msan/lit_tests/scandir_null.cc34
-rw-r--r--compiler-rt/lib/msan/lit_tests/scandir_test_root/aaa0
-rw-r--r--compiler-rt/lib/msan/lit_tests/scandir_test_root/aab0
-rw-r--r--compiler-rt/lib/msan/lit_tests/scandir_test_root/bbb0
-rw-r--r--compiler-rt/lib/msan/lit_tests/select.cc22
-rw-r--r--compiler-rt/lib/msan/lit_tests/select_origin.cc22
-rw-r--r--compiler-rt/lib/msan/lit_tests/setlocale.cc13
-rw-r--r--compiler-rt/lib/msan/lit_tests/signal_stress_test.cc71
-rw-r--r--compiler-rt/lib/msan/lit_tests/sigwait.cc30
-rw-r--r--compiler-rt/lib/msan/lit_tests/sigwaitinfo.cc31
-rw-r--r--compiler-rt/lib/msan/lit_tests/stack-origin.cc31
-rw-r--r--compiler-rt/lib/msan/lit_tests/strerror_r-non-gnu.c18
-rw-r--r--compiler-rt/lib/msan/lit_tests/strlen_of_shadow.cc24
-rw-r--r--compiler-rt/lib/msan/lit_tests/sync_lock_set_and_test.cc7
-rw-r--r--compiler-rt/lib/msan/lit_tests/textdomain.cc12
-rw-r--r--compiler-rt/lib/msan/lit_tests/times.cc20
-rw-r--r--compiler-rt/lib/msan/lit_tests/tls_reuse.cc26
-rw-r--r--compiler-rt/lib/msan/lit_tests/tzset.cc16
-rw-r--r--compiler-rt/lib/msan/lit_tests/unaligned_read_origin.cc16
-rw-r--r--compiler-rt/lib/msan/lit_tests/use-after-free.cc34
-rw-r--r--compiler-rt/lib/msan/lit_tests/vector_cvt.cc23
-rw-r--r--compiler-rt/lib/msan/lit_tests/vector_select.cc13
-rw-r--r--compiler-rt/lib/msan/lit_tests/wrap_indirect_calls.cc64
-rw-r--r--compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/caller.cc51
-rw-r--r--compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/lit.local.cfg3
-rw-r--r--compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/one.cc3
-rw-r--r--compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/two.cc11
-rw-r--r--compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/wrapper.cc11
-rw-r--r--compiler-rt/lib/msan/lit_tests/wrap_indirect_calls2.cc42
-rw-r--r--compiler-rt/lib/msan/lit_tests/wrap_indirect_calls_in_rtl.cc80
-rw-r--r--compiler-rt/lib/msan/tests/CMakeLists.txt19
85 files changed, 14 insertions, 2330 deletions
diff --git a/compiler-rt/lib/msan/CMakeLists.txt b/compiler-rt/lib/msan/CMakeLists.txt
index 06f3f65d8e3..d876a73b36f 100644
--- a/compiler-rt/lib/msan/CMakeLists.txt
+++ b/compiler-rt/lib/msan/CMakeLists.txt
@@ -17,7 +17,7 @@ set(MSAN_RTL_CFLAGS
-ffreestanding)
# Static runtime library.
-set(MSAN_RUNTIME_LIBRARIES)
+add_custom_target(msan)
set(arch "x86_64")
if(CAN_TARGET_${arch})
add_compiler_rt_static_runtime(clang_rt.msan-${arch} ${arch}
@@ -26,25 +26,16 @@ if(CAN_TARGET_${arch})
$<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
$<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
CFLAGS ${MSAN_RTL_CFLAGS})
- list(APPEND MSAN_RUNTIME_LIBRARIES clang_rt.msan-${arch})
+ add_dependencies(msan clang_rt.msan-${arch})
if(UNIX)
add_sanitizer_rt_symbols(clang_rt.msan-${arch} msan.syms.extra)
- list(APPEND MSAN_RUNTIME_LIBRARIES clang_rt.msan-${arch}-symbols)
+ add_dependencies(msan clang_rt.msan-${arch}-symbols)
endif()
endif()
add_compiler_rt_resource_file(msan_blacklist msan_blacklist.txt)
-
-# We should only build MSan unit tests if we can build instrumented libcxx.
-set(MSAN_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/projects/libcxx)
-if(EXISTS ${MSAN_LIBCXX_PATH}/)
- set(MSAN_CAN_INSTRUMENT_LIBCXX TRUE)
-else()
- set(MSAN_CAN_INSTRUMENT_LIBCXX FALSE)
-endif()
+add_dependencies(msan msan_blacklist)
if(LLVM_INCLUDE_TESTS)
add_subdirectory(tests)
endif()
-
-add_subdirectory(lit_tests)
diff --git a/compiler-rt/lib/msan/lit_tests/CMakeLists.txt b/compiler-rt/lib/msan/lit_tests/CMakeLists.txt
deleted file mode 100644
index 38d1e59e709..00000000000
--- a/compiler-rt/lib/msan/lit_tests/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-set(MSAN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
-set(MSAN_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/..)
-
-configure_lit_site_cfg(
- ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
- ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
-
-if(MSAN_CAN_INSTRUMENT_LIBCXX)
- configure_lit_site_cfg(
- ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
- ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg)
-endif()
-
-if(COMPILER_RT_CAN_EXECUTE_TESTS AND CAN_TARGET_x86_64)
- # Run MSan tests only if we're sure we may produce working binaries.
- set(MSAN_TEST_DEPS
- ${SANITIZER_COMMON_LIT_TEST_DEPS}
- ${MSAN_RUNTIME_LIBRARIES}
- msan_blacklist)
- set(MSAN_TEST_PARAMS
- msan_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
- if(LLVM_INCLUDE_TESTS AND MSAN_CAN_INSTRUMENT_LIBCXX)
- list(APPEND MSAN_TEST_DEPS MsanUnitTests)
- endif()
- add_lit_testsuite(check-msan "Running the MemorySanitizer tests"
- ${CMAKE_CURRENT_BINARY_DIR}
- PARAMS ${MSAN_TEST_PARAMS}
- DEPENDS ${MSAN_TEST_DEPS}
- )
- set_target_properties(check-msan PROPERTIES FOLDER "MSan tests")
-endif()
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/getresid.cc b/compiler-rt/lib/msan/lit_tests/Linux/getresid.cc
deleted file mode 100644
index 5021009e836..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/getresid.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p 2>&1
-// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p 2>&1
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p 2>&1
-
-#include <assert.h>
-#include <unistd.h>
-
-#include <sanitizer/msan_interface.h>
-
-int main(int argc, char *argv[]) {
- uid_t uids[6];
- assert(0 == __msan_test_shadow(uids, 6 * sizeof(uid_t)));
- assert(0 == getresuid(&uids[0], &uids[2], &uids[4]));
- for (int i = 0; i < 3; i++)
- assert(sizeof(uid_t) ==
- __msan_test_shadow(uids + 2 * i, 2 * sizeof(uid_t)));
-
- gid_t gids[6];
- assert(0 == __msan_test_shadow(gids, 6 * sizeof(gid_t)));
- assert(0 == getresgid(&gids[0], &gids[2], &gids[4]));
- for (int i = 0; i < 3; i++)
- assert(sizeof(gid_t) ==
- __msan_test_shadow(gids + 2 * i, 2 * sizeof(gid_t)));
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/glob.cc b/compiler-rt/lib/msan/lit_tests/Linux/glob.cc
deleted file mode 100644
index 387ce3cf5f1..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/glob.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p 2>&1 | FileCheck %s
-
-#include <assert.h>
-#include <glob.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-int main(int argc, char *argv[]) {
- assert(argc == 2);
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s/%s", argv[1], "glob_test_root/*a");
-
- glob_t globbuf;
- int res = glob(buf, 0, 0, &globbuf);
-
- printf("%d %s\n", errno, strerror(errno));
- assert(res == 0);
- assert(globbuf.gl_pathc == 2);
- printf("%zu\n", strlen(globbuf.gl_pathv[0]));
- printf("%zu\n", strlen(globbuf.gl_pathv[1]));
- printf("PASS\n");
- // CHECK: PASS
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/glob_altdirfunc.cc b/compiler-rt/lib/msan/lit_tests/Linux/glob_altdirfunc.cc
deleted file mode 100644
index b8200c3ee89..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/glob_altdirfunc.cc
+++ /dev/null
@@ -1,78 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p 2>&1 | FileCheck %s
-
-#include <assert.h>
-#include <glob.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <unistd.h>
-
-#include <sanitizer/msan_interface.h>
-
-static void my_gl_closedir(void *dir) {
- if (!dir)
- exit(1);
- closedir((DIR *)dir);
-}
-
-static struct dirent *my_gl_readdir(void *dir) {
- if (!dir)
- exit(1);
- struct dirent *d = readdir((DIR *)dir);
- if (d) __msan_poison(d, d->d_reclen); // hehe
- return d;
-}
-
-static void *my_gl_opendir(const char *s) {
- assert(__msan_test_shadow(s, strlen(s) + 1) == (size_t)-1);
- return opendir(s);
-}
-
-static int my_gl_lstat(const char *s, struct stat *st) {
- assert(__msan_test_shadow(s, strlen(s) + 1) == (size_t)-1);
- if (!st)
- exit(1);
- return lstat(s, st);
-}
-
-static int my_gl_stat(const char *s, struct stat *st) {
- assert(__msan_test_shadow(s, strlen(s) + 1) == (size_t)-1);
- if (!st)
- exit(1);
- return lstat(s, st);
-}
-
-int main(int argc, char *argv[]) {
- assert(argc == 2);
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s/%s", argv[1], "glob_test_root/*a");
-
- glob_t globbuf;
- globbuf.gl_closedir = my_gl_closedir;
- globbuf.gl_readdir = my_gl_readdir;
- globbuf.gl_opendir = my_gl_opendir;
- globbuf.gl_lstat = my_gl_lstat;
- globbuf.gl_stat = my_gl_stat;
- for (int i = 0; i < 10000; ++i) {
- int res = glob(buf, GLOB_ALTDIRFUNC | GLOB_MARK, 0, &globbuf);
- assert(res == 0);
- printf("%d %s\n", errno, strerror(errno));
- assert(globbuf.gl_pathc == 2);
- printf("%zu\n", strlen(globbuf.gl_pathv[0]));
- printf("%zu\n", strlen(globbuf.gl_pathv[1]));
- __msan_poison(globbuf.gl_pathv[0], strlen(globbuf.gl_pathv[0]) + 1);
- __msan_poison(globbuf.gl_pathv[1], strlen(globbuf.gl_pathv[1]) + 1);
- globfree(&globbuf);
- }
-
- printf("PASS\n");
- // CHECK: PASS
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/glob_nomatch.cc b/compiler-rt/lib/msan/lit_tests/Linux/glob_nomatch.cc
deleted file mode 100644
index 0262034aec5..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/glob_nomatch.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p
-
-#include <assert.h>
-#include <glob.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-int main(int argc, char *argv[]) {
- assert(argc == 2);
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s/%s", argv[1], "glob_test_root/*c");
-
- glob_t globbuf;
- int res = glob(buf, 0, 0, &globbuf);
- assert(res == GLOB_NOMATCH);
- assert(globbuf.gl_pathc == 0);
- if (globbuf.gl_pathv == 0)
- exit(0);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/aa b/compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/aa
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/aa
+++ /dev/null
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/ab b/compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/ab
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/ab
+++ /dev/null
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/ba b/compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/ba
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/glob_test_root/ba
+++ /dev/null
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/lit.local.cfg b/compiler-rt/lib/msan/lit_tests/Linux/lit.local.cfg
deleted file mode 100644
index 57271b8078a..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/lit.local.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-def getRoot(config):
- if not config.parent:
- return config
- return getRoot(config.parent)
-
-root = getRoot(config)
-
-if root.host_os not in ['Linux']:
- config.unsupported = True
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/syscalls.cc b/compiler-rt/lib/msan/lit_tests/Linux/syscalls.cc
deleted file mode 100644
index ab5be380221..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/syscalls.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t 2>&1
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t 2>&1
-
-#include <assert.h>
-#include <errno.h>
-#include <glob.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <linux/aio_abi.h>
-#include <sys/ptrace.h>
-#include <sys/stat.h>
-
-#include <sanitizer/linux_syscall_hooks.h>
-#include <sanitizer/msan_interface.h>
-
-/* Test the presence of __sanitizer_syscall_ in the tool runtime, and general
- sanity of their behaviour. */
-
-int main(int argc, char *argv[]) {
- char buf[1000];
- const int kTen = 10;
- const int kFortyTwo = 42;
- memset(buf, 0, sizeof(buf));
- __msan_unpoison(buf, sizeof(buf));
- __sanitizer_syscall_pre_recvmsg(0, buf, 0);
- __sanitizer_syscall_pre_rt_sigpending(buf, kTen);
- __sanitizer_syscall_pre_getdents(0, buf, kTen);
- __sanitizer_syscall_pre_getdents64(0, buf, kTen);
-
- __msan_unpoison(buf, sizeof(buf));
- __sanitizer_syscall_post_recvmsg(0, 0, buf, 0);
- __sanitizer_syscall_post_rt_sigpending(-1, buf, kTen);
- __sanitizer_syscall_post_getdents(0, 0, buf, kTen);
- __sanitizer_syscall_post_getdents64(0, 0, buf, kTen);
- assert(__msan_test_shadow(buf, sizeof(buf)) == -1);
-
- __msan_unpoison(buf, sizeof(buf));
- __sanitizer_syscall_post_recvmsg(kTen, 0, buf, 0);
-
- // Tell the kernel that the output struct size is 10 bytes, verify that those
- // bytes are unpoisoned, and the next byte is not.
- __msan_poison(buf, kTen + 1);
- __sanitizer_syscall_post_rt_sigpending(0, buf, kTen);
- assert(__msan_test_shadow(buf, sizeof(buf)) == kTen);
-
- __msan_poison(buf, kTen + 1);
- __sanitizer_syscall_post_getdents(kTen, 0, buf, kTen);
- assert(__msan_test_shadow(buf, sizeof(buf)) == kTen);
-
- __msan_poison(buf, kTen + 1);
- __sanitizer_syscall_post_getdents64(kTen, 0, buf, kTen);
- assert(__msan_test_shadow(buf, sizeof(buf)) == kTen);
-
- __msan_poison(buf, sizeof(buf));
- __sanitizer_syscall_post_clock_getres(0, 0, buf);
- assert(__msan_test_shadow(buf, sizeof(buf)) == sizeof(long) * 2);
-
- __msan_poison(buf, sizeof(buf));
- __sanitizer_syscall_post_clock_gettime(0, 0, buf);
- assert(__msan_test_shadow(buf, sizeof(buf)) == sizeof(long) * 2);
-
- // Failed syscall does not write to the buffer.
- __msan_poison(buf, sizeof(buf));
- __sanitizer_syscall_post_clock_gettime(-1, 0, buf);
- assert(__msan_test_shadow(buf, sizeof(buf)) == 0);
-
- __msan_poison(buf, sizeof(buf));
- __sanitizer_syscall_post_read(5, 42, buf, 10);
- assert(__msan_test_shadow(buf, sizeof(buf)) == 5);
-
- __msan_poison(buf, sizeof(buf));
- __sanitizer_syscall_post_newfstatat(0, 5, "/path/to/file", buf, 0);
- assert(__msan_test_shadow(buf, sizeof(buf)) == sizeof(struct stat));
-
- __msan_poison(buf, sizeof(buf));
- int prio = 0;
- __sanitizer_syscall_post_mq_timedreceive(kFortyTwo, 5, buf, sizeof(buf), &prio, 0);
- assert(__msan_test_shadow(buf, sizeof(buf)) == kFortyTwo);
- assert(__msan_test_shadow(&prio, sizeof(prio)) == -1);
-
- __msan_poison(buf, sizeof(buf));
- __sanitizer_syscall_post_ptrace(0, PTRACE_PEEKUSER, kFortyTwo, 0xABCD, buf);
- assert(__msan_test_shadow(buf, sizeof(buf)) == sizeof(void *));
-
- __msan_poison(buf, sizeof(buf));
- struct iocb iocb[2];
- struct iocb *iocbp[2] = { &iocb[0], &iocb[1] };
- memset(iocb, 0, sizeof(iocb));
- iocb[0].aio_lio_opcode = IOCB_CMD_PREAD;
- iocb[0].aio_buf = (__u64)buf;
- iocb[0].aio_nbytes = kFortyTwo;
- iocb[1].aio_lio_opcode = IOCB_CMD_PREAD;
- iocb[1].aio_buf = (__u64)(&buf[kFortyTwo]);
- iocb[1].aio_nbytes = kFortyTwo;
- __sanitizer_syscall_pre_io_submit(0, 2, &iocbp);
- assert(__msan_test_shadow(buf, sizeof(buf)) == 2 * kFortyTwo);
-
- __msan_poison(buf, sizeof(buf));
- char *p = buf;
- __msan_poison(&p, sizeof(p));
- __sanitizer_syscall_post_io_setup(0, 1, &p);
- assert(__msan_test_shadow(&p, sizeof(p)) == -1);
- assert(__msan_test_shadow(buf, sizeof(buf)) >= 32);
-
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/tcgetattr.cc b/compiler-rt/lib/msan/lit_tests/Linux/tcgetattr.cc
deleted file mode 100644
index e6e101db884..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/tcgetattr.cc
+++ /dev/null
@@ -1,21 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p
-
-#include <assert.h>
-#include <glob.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <termios.h>
-#include <unistd.h>
-
-int main(int argc, char *argv[]) {
- int fd = getpt();
- assert(fd >= 0);
-
- struct termios t;
- int res = tcgetattr(fd, &t);
- assert(!res);
-
- if (t.c_iflag == 0)
- exit(0);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/xattr.cc b/compiler-rt/lib/msan/lit_tests/Linux/xattr.cc
deleted file mode 100644
index 583b2e3a9bd..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/xattr.cc
+++ /dev/null
@@ -1,142 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p 2>&1
-// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p 2>&1
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p 2>&1
-
-#include <argz.h>
-#include <assert.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <sanitizer/msan_interface.h>
-
-// Do not depend on libattr headers.
-#ifndef ENOATTR
-#define ENOATTR ENODATA
-#endif
-
-extern "C" {
-ssize_t listxattr(const char *path, char *list, size_t size);
-ssize_t llistxattr(const char *path, char *list, size_t size);
-ssize_t flistxattr(int fd, char *list, size_t size);
-ssize_t getxattr(const char *path, const char *name, void *value, size_t size);
-ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size);
-ssize_t fgetxattr(int fd, const char *name, void *value, size_t size);
-}
-
-char g_path[1024];
-int g_fd;
-
-// Life before closures...
-ssize_t listxattr_wrapper(char *buf, size_t size) {
- return listxattr(g_path, buf, size);
-}
-
-ssize_t llistxattr_wrapper(char *buf, size_t size) {
- return llistxattr(g_path, buf, size);
-}
-
-ssize_t flistxattr_wrapper(char *buf, size_t size) {
- return flistxattr(g_fd, buf, size);
-}
-
-ssize_t getxattr_wrapper(const char *name, char *buf, size_t size) {
- return getxattr(g_path, name, buf, size);
-}
-
-ssize_t lgetxattr_wrapper(const char *name, char *buf, size_t size) {
- return lgetxattr(g_path, name, buf, size);
-}
-
-ssize_t fgetxattr_wrapper(const char *name, char *buf, size_t size) {
- return fgetxattr(g_fd, name, buf, size);
-}
-
-size_t test_list(ssize_t fun(char*, size_t), char **buf) {
- int buf_size = 1024;
- while (true) {
- *buf = (char *)malloc(buf_size);
- assert(__msan_test_shadow(*buf, buf_size) != -1);
- ssize_t res = fun(*buf, buf_size);
- if (res >= 0) {
- assert(__msan_test_shadow(*buf, buf_size) == res);
- return res;
- }
- if (errno == ENOTSUP) {
- printf("Extended attributes are disabled. *xattr test is a no-op.\n");
- exit(0);
- }
- assert(errno == ERANGE);
- free(*buf);
- buf_size *= 2;
- }
-}
-
-// True means success. False means result inconclusive because we don't have
-// access to this attribute.
-bool test_get_single_attr(ssize_t fun(const char *, char *, size_t),
- const char *attr_name) {
- char *buf;
- int buf_size = 1024;
- while (true) {
- buf = (char *)malloc(buf_size);
- assert(__msan_test_shadow(buf, buf_size) != -1);
- ssize_t res = fun(attr_name, buf, buf_size);
- if (res >= 0) {
- assert(__msan_test_shadow(buf, buf_size) == res);
- free(buf);
- return true;
- }
- if (errno == ENOTSUP) {
- printf("Extended attributes are disabled. *xattr test is a no-op.\n");
- exit(0);
- }
- if (errno == ENOATTR)
- return false;
- assert(errno == ERANGE);
- free(buf);
- buf_size *= 2;
- }
-}
-
-void test_get(ssize_t fun(const char *, char *, size_t), const char *attr_list,
- size_t attr_list_size) {
- // Try every attribute, until we see one we can access. Attribute names are
- // null-separated strings in attr_list.
- size_t attr_list_len = argz_count(attr_list, attr_list_size);
- char **attrs = (char **)malloc((attr_list_len + 1) * sizeof(char *));
- size_t i;
- for (i = 0; (i < attr_list_len) && attrs[i]; i++) {
- if (test_get_single_attr(fun, attrs[i]))
- return;
- }
- printf("*xattr test could not access any attributes.\n");
-}
-
-// TODO: set some attributes before trying to retrieve them with *getxattr.
-// Currently the list is empty, so *getxattr is not tested.
-int main(int argc, char *argv[]) {
- assert(argc == 2);
- snprintf(g_path, sizeof(g_path), "%s/%s", argv[1], "xattr_test_root/a");
-
- g_fd = open(g_path, O_RDONLY);
- assert(g_fd);
-
- char *attr_list;
- size_t attr_list_size;
- attr_list_size = test_list(listxattr_wrapper, &attr_list);
- free(attr_list);
- attr_list_size = test_list(llistxattr_wrapper, &attr_list);
- free(attr_list);
- attr_list_size = test_list(flistxattr_wrapper, &attr_list);
-
- test_get(getxattr_wrapper, attr_list, attr_list_size);
- test_get(lgetxattr_wrapper, attr_list, attr_list_size);
- test_get(fgetxattr_wrapper, attr_list, attr_list_size);
-
- free(attr_list);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/Linux/xattr_test_root/a b/compiler-rt/lib/msan/lit_tests/Linux/xattr_test_root/a
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Linux/xattr_test_root/a
+++ /dev/null
diff --git a/compiler-rt/lib/msan/lit_tests/SharedLibs/dso-origin-so.cc b/compiler-rt/lib/msan/lit_tests/SharedLibs/dso-origin-so.cc
deleted file mode 100644
index 8930a715924..00000000000
--- a/compiler-rt/lib/msan/lit_tests/SharedLibs/dso-origin-so.cc
+++ /dev/null
@@ -1,14 +0,0 @@
-#include <stdlib.h>
-
-#include "dso-origin.h"
-
-void my_access(int *p) {
- volatile int tmp;
- // Force initialize-ness check.
- if (*p)
- tmp = 1;
-}
-
-void *my_alloc(unsigned sz) {
- return malloc(sz);
-}
diff --git a/compiler-rt/lib/msan/lit_tests/SharedLibs/dso-origin.h b/compiler-rt/lib/msan/lit_tests/SharedLibs/dso-origin.h
deleted file mode 100644
index ff926b3f61c..00000000000
--- a/compiler-rt/lib/msan/lit_tests/SharedLibs/dso-origin.h
+++ /dev/null
@@ -1,4 +0,0 @@
-extern "C" {
-void my_access(int *p);
-void *my_alloc(unsigned sz);
-}
diff --git a/compiler-rt/lib/msan/lit_tests/SharedLibs/lit.local.cfg b/compiler-rt/lib/msan/lit_tests/SharedLibs/lit.local.cfg
deleted file mode 100644
index b3677c17a0f..00000000000
--- a/compiler-rt/lib/msan/lit_tests/SharedLibs/lit.local.cfg
+++ /dev/null
@@ -1,4 +0,0 @@
-# Sources in this directory are compiled as shared libraries and used by
-# tests in parent directory.
-
-config.suffixes = []
diff --git a/compiler-rt/lib/msan/lit_tests/Unit/lit.site.cfg.in b/compiler-rt/lib/msan/lit_tests/Unit/lit.site.cfg.in
deleted file mode 100644
index 34ae3c0e017..00000000000
--- a/compiler-rt/lib/msan/lit_tests/Unit/lit.site.cfg.in
+++ /dev/null
@@ -1,13 +0,0 @@
-## Autogenerated by LLVM/Clang configuration.
-# Do not edit!
-
-# Load common config for all compiler-rt unit tests.
-lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/unittests/lit.common.unit.configured")
-
-# Setup config name.
-config.name = 'MemorySanitizer-Unit'
-
-# Setup test source and exec root. For unit tests, we define
-# it as build directory with MSan unit tests.
-config.test_exec_root = "@MSAN_BINARY_DIR@/tests"
-config.test_source_root = config.test_exec_root
diff --git a/compiler-rt/lib/msan/lit_tests/allocator_returns_null.cc b/compiler-rt/lib/msan/lit_tests/allocator_returns_null.cc
deleted file mode 100644
index aaa85cce711..00000000000
--- a/compiler-rt/lib/msan/lit_tests/allocator_returns_null.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// Test the behavior of malloc/calloc/realloc when the allocation size is huge.
-// By default (allocator_may_return_null=0) the process should crash.
-// With allocator_may_return_null=1 the allocator should return 0.
-//
-// RUN: %clangxx_msan -O0 %s -o %t
-// RUN: not %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mCRASH
-// RUN: MSAN_OPTIONS=allocator_may_return_null=0 not %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mCRASH
-// RUN: MSAN_OPTIONS=allocator_may_return_null=1 %t malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mNULL
-// RUN: MSAN_OPTIONS=allocator_may_return_null=0 not %t calloc 2>&1 | FileCheck %s --check-prefix=CHECK-cCRASH
-// RUN: MSAN_OPTIONS=allocator_may_return_null=1 %t calloc 2>&1 | FileCheck %s --check-prefix=CHECK-cNULL
-// RUN: MSAN_OPTIONS=allocator_may_return_null=0 not %t calloc-overflow 2>&1 | FileCheck %s --check-prefix=CHECK-coCRASH
-// RUN: MSAN_OPTIONS=allocator_may_return_null=1 %t calloc-overflow 2>&1 | FileCheck %s --check-prefix=CHECK-coNULL
-// RUN: MSAN_OPTIONS=allocator_may_return_null=0 not %t realloc 2>&1 | FileCheck %s --check-prefix=CHECK-rCRASH
-// RUN: MSAN_OPTIONS=allocator_may_return_null=1 %t realloc 2>&1 | FileCheck %s --check-prefix=CHECK-rNULL
-// RUN: MSAN_OPTIONS=allocator_may_return_null=0 not %t realloc-after-malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mrCRASH
-// RUN: MSAN_OPTIONS=allocator_may_return_null=1 %t realloc-after-malloc 2>&1 | FileCheck %s --check-prefix=CHECK-mrNULL
-
-#include <limits.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <assert.h>
-#include <limits>
-int main(int argc, char **argv) {
- volatile size_t size = std::numeric_limits<size_t>::max() - 10000;
- assert(argc == 2);
- char *x = 0;
- if (!strcmp(argv[1], "malloc")) {
- fprintf(stderr, "malloc:\n");
- x = (char*)malloc(size);
- }
- if (!strcmp(argv[1], "calloc")) {
- fprintf(stderr, "calloc:\n");
- x = (char*)calloc(size / 4, 4);
- }
-
- if (!strcmp(argv[1], "calloc-overflow")) {
- fprintf(stderr, "calloc-overflow:\n");
- volatile size_t kMaxSizeT = std::numeric_limits<size_t>::max();
- size_t kArraySize = 4096;
- volatile size_t kArraySize2 = kMaxSizeT / kArraySize + 10;
- x = (char*)calloc(kArraySize, kArraySize2);
- }
-
- if (!strcmp(argv[1], "realloc")) {
- fprintf(stderr, "realloc:\n");
- x = (char*)realloc(0, size);
- }
- if (!strcmp(argv[1], "realloc-after-malloc")) {
- fprintf(stderr, "realloc-after-malloc:\n");
- char *t = (char*)malloc(100);
- *t = 42;
- x = (char*)realloc(t, size);
- assert(*t == 42);
- }
- // The NULL pointer is printed differently on different systems, while (long)0
- // is always the same.
- fprintf(stderr, "x: %lx\n", (long)x);
- return x != 0;
-}
-// CHECK-mCRASH: malloc:
-// CHECK-mCRASH: MemorySanitizer's allocator is terminating the process
-// CHECK-cCRASH: calloc:
-// CHECK-cCRASH: MemorySanitizer's allocator is terminating the process
-// CHECK-coCRASH: calloc-overflow:
-// CHECK-coCRASH: MemorySanitizer's allocator is terminating the process
-// CHECK-rCRASH: realloc:
-// CHECK-rCRASH: MemorySanitizer's allocator is terminating the process
-// CHECK-mrCRASH: realloc-after-malloc:
-// CHECK-mrCRASH: MemorySanitizer's allocator is terminating the process
-
-// CHECK-mNULL: malloc:
-// CHECK-mNULL: x: 0
-// CHECK-cNULL: calloc:
-// CHECK-cNULL: x: 0
-// CHECK-coNULL: calloc-overflow:
-// CHECK-coNULL: x: 0
-// CHECK-rNULL: realloc:
-// CHECK-rNULL: x: 0
-// CHECK-mrNULL: realloc-after-malloc:
-// CHECK-mrNULL: x: 0
diff --git a/compiler-rt/lib/msan/lit_tests/backtrace.cc b/compiler-rt/lib/msan/lit_tests/backtrace.cc
deleted file mode 100644
index 48684c29c60..00000000000
--- a/compiler-rt/lib/msan/lit_tests/backtrace.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-#include <assert.h>
-#include <execinfo.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-__attribute__((noinline))
-void f() {
- void *buf[10];
- int sz = backtrace(buf, sizeof(buf) / sizeof(*buf));
- assert(sz > 0);
- for (int i = 0; i < sz; ++i)
- if (!buf[i])
- exit(1);
- char **s = backtrace_symbols(buf, sz);
- assert(s > 0);
- for (int i = 0; i < sz; ++i)
- printf("%d\n", strlen(s[i]));
-}
-
-int main(void) {
- f();
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/c-strdup.c b/compiler-rt/lib/msan/lit_tests/c-strdup.c
deleted file mode 100644
index 7772f0f307b..00000000000
--- a/compiler-rt/lib/msan/lit_tests/c-strdup.c
+++ /dev/null
@@ -1,17 +0,0 @@
-// RUN: %clang_msan -m64 -O0 %s -o %t && %t >%t.out 2>&1
-// RUN: %clang_msan -m64 -O1 %s -o %t && %t >%t.out 2>&1
-// RUN: %clang_msan -m64 -O2 %s -o %t && %t >%t.out 2>&1
-// RUN: %clang_msan -m64 -O3 %s -o %t && %t >%t.out 2>&1
-
-// Test that strdup in C programs is intercepted.
-// GLibC headers translate strdup to __strdup at -O1 and higher.
-
-#include <stdlib.h>
-#include <string.h>
-int main(int argc, char **argv) {
- char buf[] = "abc";
- char *p = strdup(buf);
- if (*p)
- exit(0);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/cxa_atexit.cc b/compiler-rt/lib/msan/lit_tests/cxa_atexit.cc
deleted file mode 100644
index f3641aadce0..00000000000
--- a/compiler-rt/lib/msan/lit_tests/cxa_atexit.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p
-
-// PR17377: C++ module destructors get stale argument shadow.
-
-#include <stdio.h>
-#include <stdlib.h>
-class A {
-public:
- // This destructor get stale argument shadow left from the call to f().
- ~A() {
- if (this)
- exit(0);
- }
-};
-
-A a;
-
-__attribute__((noinline))
-void f(long x) {
-}
-
-int main(void) {
- long x;
- long * volatile p = &x;
- // This call poisons TLS shadow for the first function argument.
- f(*p);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/default_blacklist.cc b/compiler-rt/lib/msan/lit_tests/default_blacklist.cc
deleted file mode 100644
index 32cc02257cb..00000000000
--- a/compiler-rt/lib/msan/lit_tests/default_blacklist.cc
+++ /dev/null
@@ -1,3 +0,0 @@
-// Test that MSan uses the default blacklist from resource directory.
-// RUN: %clangxx_msan -### %s 2>&1 | FileCheck %s
-// CHECK: fsanitize-blacklist={{.*}}msan_blacklist.txt
diff --git a/compiler-rt/lib/msan/lit_tests/dlerror.cc b/compiler-rt/lib/msan/lit_tests/dlerror.cc
deleted file mode 100644
index 281b3164fd7..00000000000
--- a/compiler-rt/lib/msan/lit_tests/dlerror.cc
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-#include <assert.h>
-#include <dlfcn.h>
-#include <stdio.h>
-#include <string.h>
-
-int main(void) {
- void *p = dlopen("/bad/file/name", RTLD_NOW);
- assert(!p);
- char *s = dlerror();
- printf("%s, %zu\n", s, strlen(s));
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/dso-origin.cc b/compiler-rt/lib/msan/lit_tests/dso-origin.cc
deleted file mode 100644
index 13661c65e74..00000000000
--- a/compiler-rt/lib/msan/lit_tests/dso-origin.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// Build a library with origin tracking and an executable w/o origin tracking.
-// Test that origin tracking is enabled at runtime.
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O0 %p/SharedLibs/dso-origin-so.cc \
-// RUN: -fPIC -shared -o %t-so.so
-// RUN: %clangxx_msan -m64 -O0 %s %t-so.so -o %t && not %t 2>&1 | FileCheck %s
-
-#include <stdlib.h>
-
-#include "SharedLibs/dso-origin.h"
-
-int main(int argc, char **argv) {
- int *x = (int *)my_alloc(sizeof(int));
- my_access(x);
- delete x;
-
- // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
- // CHECK: {{#0 0x.* in my_access .*dso-origin-so.cc:}}
- // CHECK: {{#1 0x.* in main .*dso-origin.cc:}}[[@LINE-5]]
- // CHECK: Uninitialized value was created by a heap allocation
- // CHECK: {{#0 0x.* in .*malloc}}
- // CHECK: {{#1 0x.* in my_alloc .*dso-origin-so.cc:}}
- // CHECK: {{#2 0x.* in main .*dso-origin.cc:}}[[@LINE-10]]
- // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*dso-origin-so.cc:.* my_access}}
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/dtls_test.c b/compiler-rt/lib/msan/lit_tests/dtls_test.c
deleted file mode 100644
index c88e50f1df0..00000000000
--- a/compiler-rt/lib/msan/lit_tests/dtls_test.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* RUN: %clang_msan -m64 %s -o %t
- RUN: %clang_msan -m64 %s -DBUILD_SO -fPIC -o %t-so.so -shared
- RUN: not %t 2>&1 | FileCheck %s
- CHECK: MemorySanitizer: use-of-uninitialized-value
-
- This is an actual bug in msan/glibc integration,
- see https://sourceware.org/bugzilla/show_bug.cgi?id=16291
-*/
-
-#ifndef BUILD_SO
-#include <assert.h>
-#include <dlfcn.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <pthread.h>
-
-typedef long *(* get_t)();
-get_t GetTls;
-void *Thread1(void *unused) {
- long uninitialized;
- long *x = GetTls();
- if (*x)
- fprintf(stderr, "bar\n");
- *x = uninitialized;
- fprintf(stderr, "stack: %p dtls: %p\n", &x, x);
- return 0;
-}
-
-void *Thread2(void *unused) {
- long *x = GetTls();
- fprintf(stderr, "stack: %p dtls: %p\n", &x, x);
- if (*x)
- fprintf(stderr, "foo\n"); // False negative here.
- return 0;
-}
-
-int main(int argc, char *argv[]) {
- char path[4096];
- snprintf(path, sizeof(path), "%s-so.so", argv[0]);
- int i;
-
- void *handle = dlopen(path, RTLD_LAZY);
- if (!handle) fprintf(stderr, "%s\n", dlerror());
- assert(handle != 0);
- GetTls = (get_t)dlsym(handle, "GetTls");
- assert(dlerror() == 0);
-
- pthread_t t;
- pthread_create(&t, 0, Thread1, 0);
- pthread_join(t, 0);
- pthread_create(&t, 0, Thread2, 0);
- pthread_join(t, 0);
- return 0;
-}
-#else // BUILD_SO
-__thread long huge_thread_local_array[1 << 17];
-long *GetTls() {
- return &huge_thread_local_array[0];
-}
-#endif
diff --git a/compiler-rt/lib/msan/lit_tests/errno.cc b/compiler-rt/lib/msan/lit_tests/errno.cc
deleted file mode 100644
index af27ad0b032..00000000000
--- a/compiler-rt/lib/msan/lit_tests/errno.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-#include <assert.h>
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-
-int main()
-{
- int x;
- int *volatile p = &x;
- errno = *p;
- int res = read(-1, 0, 0);
- assert(res == -1);
- if (errno) printf("errno %d\n", errno);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/getaddrinfo-positive.cc b/compiler-rt/lib/msan/lit_tests/getaddrinfo-positive.cc
deleted file mode 100644
index 7fde1fdfab9..00000000000
--- a/compiler-rt/lib/msan/lit_tests/getaddrinfo-positive.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <stdlib.h>
-
-volatile int z;
-
-int main(void) {
- struct addrinfo *ai;
- struct addrinfo hint;
- int res = getaddrinfo("localhost", NULL, NULL, &ai);
- if (ai) z = 1; // OK
- res = getaddrinfo("localhost", NULL, &hint, &ai);
- // CHECK: UMR in __interceptor_getaddrinfo at offset 0 inside
- // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
- // CHECK: #0 {{.*}} in main {{.*}}getaddrinfo-positive.cc:[[@LINE-3]]
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/getaddrinfo.cc b/compiler-rt/lib/msan/lit_tests/getaddrinfo.cc
deleted file mode 100644
index 0518cf4733d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/getaddrinfo.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <stdlib.h>
-
-void poison_stack_ahead() {
- char buf[100000];
- // With -O0 this poisons a large chunk of stack.
-}
-
-int main(void) {
- poison_stack_ahead();
-
- struct addrinfo *ai;
-
- // This should trigger loading of libnss_dns and friends.
- // Those libraries are typically uninstrumented.They will call strlen() on a
- // stack-allocated buffer, which is very likely to be poisoned. Test that we
- // don't report this as an UMR.
- int res = getaddrinfo("not-in-etc-hosts", NULL, NULL, &ai);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/getline.cc b/compiler-rt/lib/msan/lit_tests/getline.cc
deleted file mode 100644
index 27168a88560..00000000000
--- a/compiler-rt/lib/msan/lit_tests/getline.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// RUN: %clangxx_msan -O0 %s -o %t && %t %p
-
-#include <assert.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int main(int argc, char **argv) {
- assert(argc == 2);
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s/%s", argv[1], "getline_test_data");
-
- FILE *fp = fopen(buf, "r");
- assert(fp);
-
- char *line = 0;
- size_t len = 0;
- int n = getline(&line, &len, fp);
- assert(n == 6);
- assert(strcmp(line, "abcde\n") == 0);
-
- n = getline(&line, &len, fp);
- assert(n == 6);
- assert(strcmp(line, "12345\n") == 0);
-
- free(line);
- fclose(fp);
-
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/getline_test_data b/compiler-rt/lib/msan/lit_tests/getline_test_data
deleted file mode 100644
index 5ba1d4cec0d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/getline_test_data
+++ /dev/null
@@ -1,2 +0,0 @@
-abcde
-12345
diff --git a/compiler-rt/lib/msan/lit_tests/heap-origin.cc b/compiler-rt/lib/msan/lit_tests/heap-origin.cc
deleted file mode 100644
index dfe7edd27e8..00000000000
--- a/compiler-rt/lib/msan/lit_tests/heap-origin.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O1 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O2 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O1 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O2 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-
-#include <stdlib.h>
-int main(int argc, char **argv) {
- char *volatile x = (char*)malloc(5 * sizeof(char));
- return *x;
- // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
- // CHECK: {{#0 0x.* in main .*heap-origin.cc:}}[[@LINE-2]]
-
- // CHECK-ORIGINS: Uninitialized value was created by a heap allocation
- // CHECK-ORIGINS: {{#0 0x.* in .*malloc}}
- // CHECK-ORIGINS: {{#1 0x.* in main .*heap-origin.cc:}}[[@LINE-7]]
-
- // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*heap-origin.cc:.* main}}
-}
diff --git a/compiler-rt/lib/msan/lit_tests/iconv.cc b/compiler-rt/lib/msan/lit_tests/iconv.cc
deleted file mode 100644
index e7c30edd985..00000000000
--- a/compiler-rt/lib/msan/lit_tests/iconv.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 -g %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O0 -g -DPOSITIVE %s -o %t && not %t |& FileCheck %s
-
-#include <assert.h>
-#include <iconv.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-
-int main(void) {
- iconv_t cd = iconv_open("ASCII", "ASCII");
- assert(cd != (iconv_t)-1);
-
- char inbuf_[100];
- strcpy(inbuf_, "sample text");
- char outbuf_[100];
- char *inbuf = inbuf_;
- char *outbuf = outbuf_;
- size_t inbytesleft = strlen(inbuf_);
- size_t outbytesleft = sizeof(outbuf_);
-
-#ifdef POSITIVE
- {
- char u;
- char *volatile p = &u;
- inbuf_[5] = *p;
- }
-#endif
-
- size_t res;
- res = iconv(cd, 0, 0, 0, 0);
- assert(res != (size_t)-1);
-
- res = iconv(cd, 0, 0, &outbuf, &outbytesleft);
- assert(res != (size_t)-1);
-
- res = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
- // CHECK: MemorySanitizer: use-of-uninitialized-value
- // CHECK: #0 {{.*}} in main {{.*}}iconv.cc:[[@LINE-2]]
- assert(res != (size_t)-1);
- assert(inbytesleft == 0);
-
- assert(memcmp(inbuf_, outbuf_, strlen(inbuf_)) == 0);
-
- iconv_close(cd);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/if_indextoname.cc b/compiler-rt/lib/msan/lit_tests/if_indextoname.cc
deleted file mode 100644
index 7a5ba359953..00000000000
--- a/compiler-rt/lib/msan/lit_tests/if_indextoname.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t 2>&1
-// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t 2>&1
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t 2>&1
-
-#include <assert.h>
-#include <errno.h>
-#include <net/if.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <sanitizer/msan_interface.h>
-
-int main(int argc, char *argv[]) {
- char ifname[IF_NAMESIZE + 1];
- assert(0 == __msan_test_shadow(ifname, sizeof(ifname)));
- if (!if_indextoname(1, ifname)) {
- assert(errno == ENXIO);
- printf("No network interfaces found.\n");
- return 0;
- }
- assert(strlen(ifname) + 1 == __msan_test_shadow(ifname, sizeof(ifname)));
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/ifaddrs.cc b/compiler-rt/lib/msan/lit_tests/ifaddrs.cc
deleted file mode 100644
index fe11a9542dd..00000000000
--- a/compiler-rt/lib/msan/lit_tests/ifaddrs.cc
+++ /dev/null
@@ -1,50 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p 2>&1
-// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p 2>&1
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p 2>&1
-
-#include <assert.h>
-#include <errno.h>
-#include <ifaddrs.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <vector>
-
-#include <sanitizer/msan_interface.h>
-
-#define CHECK_AND_PUSH(addr, size) \
- if (addr) { \
- assert(-1 == __msan_test_shadow(addr, sizeof(size))); \
- ranges.push_back(std::make_pair((void *)addr, (size_t)size)); \
- }
-
-int main(int argc, char *argv[]) {
- struct ifaddrs *ifas;
-
- assert(0 == __msan_test_shadow(&ifas, sizeof(ifaddrs *)));
- int res = getifaddrs(&ifas);
- if (res == -1) {
- assert(errno == ENOSYS);
- printf("getifaddrs() is not implemented\n");
- return 0;
- }
- assert(res == 0);
- assert(-1 == __msan_test_shadow(&ifas, sizeof(ifaddrs *)));
-
- std::vector<std::pair<void *, size_t> > ranges;
- ifaddrs *p = ifas;
- while (p) {
- CHECK_AND_PUSH(p, sizeof(ifaddrs));
- CHECK_AND_PUSH(p->ifa_name, strlen(p->ifa_name) + 1);
- CHECK_AND_PUSH(p->ifa_addr, sizeof(*p->ifa_addr));
- CHECK_AND_PUSH(p->ifa_netmask, sizeof(*p->ifa_netmask));
- CHECK_AND_PUSH(p->ifa_broadaddr, sizeof(*p->ifa_broadaddr));
- CHECK_AND_PUSH(p->ifa_dstaddr, sizeof(*p->ifa_dstaddr));
- p = p->ifa_next;
- }
-
- freeifaddrs(ifas);
- for (int i = 0; i < ranges.size(); i++)
- assert(0 == __msan_test_shadow(ranges[i].first, ranges[i].second));
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/initgroups.cc b/compiler-rt/lib/msan/lit_tests/initgroups.cc
deleted file mode 100644
index adba5369579..00000000000
--- a/compiler-rt/lib/msan/lit_tests/initgroups.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-#include <sys/types.h>
-#include <grp.h>
-
-int main(void) {
- initgroups("root", 0);
- // The above fails unless you are root. Does not matter, MSan false positive
- // (which we are testing for) happens anyway.
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/inline.cc b/compiler-rt/lib/msan/lit_tests/inline.cc
deleted file mode 100644
index 4aeb15583f8..00000000000
--- a/compiler-rt/lib/msan/lit_tests/inline.cc
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clangxx_msan -O3 %s -o %t && %t
-
-// Test that no_sanitize_memory attribute applies even when the function would
-// be normally inlined.
-
-#include <stdlib.h>
-
-__attribute__((no_sanitize_memory))
-int f(int *p) {
- if (*p) // BOOOM?? Nope!
- exit(0);
- return 0;
-}
-
-int main(int argc, char **argv) {
- int x;
- int * volatile p = &x;
- int res = f(p);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/insertvalue_origin.cc b/compiler-rt/lib/msan/lit_tests/insertvalue_origin.cc
deleted file mode 100644
index 769ea45f8c4..00000000000
--- a/compiler-rt/lib/msan/lit_tests/insertvalue_origin.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s < %t.out
-
-// Test origin propagation through insertvalue IR instruction.
-
-#include <stdio.h>
-#include <stdint.h>
-
-struct mypair {
- int64_t x;
- int y;
-};
-
-mypair my_make_pair(int64_t x, int y) {
- mypair p;
- p.x = x;
- p.y = y;
- return p;
-}
-
-int main() {
- int64_t * volatile p = new int64_t;
- mypair z = my_make_pair(*p, 0);
- if (z.x)
- printf("zzz\n");
- // CHECK: MemorySanitizer: use-of-uninitialized-value
- // CHECK: {{in main .*insertvalue_origin.cc:}}[[@LINE-3]]
-
- // CHECK: Uninitialized value was created by a heap allocation
- // CHECK: {{in main .*insertvalue_origin.cc:}}[[@LINE-8]]
- delete p;
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/ioctl.cc b/compiler-rt/lib/msan/lit_tests/ioctl.cc
deleted file mode 100644
index caff80c2e5d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/ioctl.cc
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 -g %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O3 -g %s -o %t && %t
-
-#include <assert.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <unistd.h>
-
-int main(int argc, char **argv) {
- int fd = socket(AF_INET, SOCK_DGRAM, 0);
-
- unsigned int z;
- int res = ioctl(fd, FIOGETOWN, &z);
- assert(res == 0);
- close(fd);
- if (z)
- exit(0);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/ioctl_custom.cc b/compiler-rt/lib/msan/lit_tests/ioctl_custom.cc
deleted file mode 100644
index 94ed528c70b..00000000000
--- a/compiler-rt/lib/msan/lit_tests/ioctl_custom.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 -g %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O3 -g %s -o %t && %t
-
-// RUN: %clangxx_msan -DPOSITIVE -m64 -O0 -g %s -o %t && not %t 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -DPOSITIVE -m64 -O3 -g %s -o %t && not %t 2>&1 | FileCheck %s
-
-#include <assert.h>
-#include <stdlib.h>
-#include <net/if.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <unistd.h>
-
-int main(int argc, char **argv) {
- int fd = socket(AF_INET, SOCK_STREAM, 0);
-
- struct ifreq ifreqs[20];
- struct ifconf ifc;
- ifc.ifc_ifcu.ifcu_req = ifreqs;
-#ifndef POSITIVE
- ifc.ifc_len = sizeof(ifreqs);
-#endif
- int res = ioctl(fd, SIOCGIFCONF, (void *)&ifc);
- // CHECK: UMR in ioctl{{.*}} at offset 0
- // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
- // CHECK: #{{.*}} in main {{.*}}ioctl_custom.cc:[[@LINE-3]]
- assert(res == 0);
- for (int i = 0; i < ifc.ifc_len / sizeof(*ifc.ifc_ifcu.ifcu_req); ++i)
- printf("%d %zu %s\n", i, strlen(ifreqs[i].ifr_name), ifreqs[i].ifr_name);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/ioctl_sound.cc b/compiler-rt/lib/msan/lit_tests/ioctl_sound.cc
deleted file mode 100644
index 0611e0dc434..00000000000
--- a/compiler-rt/lib/msan/lit_tests/ioctl_sound.cc
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 -g %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O3 -g %s -o %t && %t
-
-#include <assert.h>
-#include <fcntl.h>
-#include <sound/asound.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <sys/socket.h>
-#include <unistd.h>
-
-#include <sanitizer/msan_interface.h>
-
-int main(int argc, char **argv) {
- int fd = open("/dev/snd/controlC0", O_RDONLY);
- if (fd < 0) {
- printf("Unable to open sound device.");
- return 0;
- }
- const unsigned sz = sizeof(snd_ctl_card_info);
- void *info = malloc(sz + 1);
- assert(__msan_test_shadow(info, sz) == 0);
- assert(ioctl(fd, SNDRV_CTL_IOCTL_CARD_INFO, info) >= 0);
- assert(__msan_test_shadow(info, sz + 1) == sz);
- close(fd);
- free(info);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/keep-going-dso.cc b/compiler-rt/lib/msan/lit_tests/keep-going-dso.cc
deleted file mode 100644
index 6d006756a11..00000000000
--- a/compiler-rt/lib/msan/lit_tests/keep-going-dso.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %t >%t.out 2>&1
-// FileCheck %s <%t.out
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %t >%t.out 2>&1
-// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
-
-// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && not %t >%t.out 2>&1
-// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
-// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %t >%t.out 2>&1
-// FileCheck %s <%t.out
-// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %t >%t.out 2>&1
-// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
-
-// Test how -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going affect reports
-// from interceptors.
-// -mllvm -msan-keep-going provides the default value of keep_going flag, but is
-// always overwritten by MSAN_OPTIONS
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int main(int argc, char **argv) {
- char *volatile x = (char*)malloc(5 * sizeof(char));
- x[4] = 0;
- if (strlen(x) < 3)
- exit(0);
- fprintf(stderr, "Done\n");
- // CHECK-NOT: Done
- // CHECK-KEEP-GOING: Done
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/keep-going.cc b/compiler-rt/lib/msan/lit_tests/keep-going.cc
deleted file mode 100644
index e33b137c76f..00000000000
--- a/compiler-rt/lib/msan/lit_tests/keep-going.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// FileCheck %s <%t.out
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %t >%t.out 2>&1
-// FileCheck %s <%t.out
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %t >%t.out 2>&1
-// FileCheck %s <%t.out
-
-// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && not %t >%t.out 2>&1
-// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
-// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=0 not %t >%t.out 2>&1
-// FileCheck %s <%t.out
-// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=keep_going=1 not %t >%t.out 2>&1
-// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
-// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=1 not %t >%t.out 2>&1
-// FileCheck %s <%t.out
-// RUN: %clangxx_msan -m64 -mllvm -msan-keep-going=1 -O0 %s -o %t && MSAN_OPTIONS=halt_on_error=0 not %t >%t.out 2>&1
-// FileCheck --check-prefix=CHECK-KEEP-GOING %s <%t.out
-
-// Test behaviour of -mllvm -msan-keep-going and MSAN_OPTIONS=keep_going.
-// -mllvm -msan-keep-going provides the default value of keep_going flag; value
-// of 1 can be overwritten by MSAN_OPTIONS, value of 0 can not.
-
-#include <stdio.h>
-#include <stdlib.h>
-
-int main(int argc, char **argv) {
- char *volatile x = (char*)malloc(5 * sizeof(char));
- if (x[0])
- exit(0);
- fprintf(stderr, "Done\n");
- // CHECK-NOT: Done
- // CHECK-KEEP-GOING: Done
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/lit.cfg b/compiler-rt/lib/msan/lit_tests/lit.cfg
deleted file mode 100644
index da1bde6dd04..00000000000
--- a/compiler-rt/lib/msan/lit_tests/lit.cfg
+++ /dev/null
@@ -1,74 +0,0 @@
-# -*- Python -*-
-
-import os
-
-import lit.util
-
-def get_required_attr(config, attr_name):
- attr_value = getattr(config, attr_name, None)
- if not attr_value:
- lit_config.fatal(
- "No attribute %r in test configuration! You may need to run "
- "tests from your build directory or add this attribute "
- "to lit.site.cfg " % attr_name)
- return attr_value
-
-# Setup config name.
-config.name = 'MemorySanitizer'
-
-# Setup source root.
-config.test_source_root = os.path.dirname(__file__)
-
-def DisplayNoConfigMessage():
- lit_config.fatal("No site specific configuration available! " +
- "Try running your test from the build tree or running " +
- "make check-msan")
-
-# Figure out LLVM source root.
-llvm_src_root = getattr(config, 'llvm_src_root', None)
-if llvm_src_root is None:
- # We probably haven't loaded the site-specific configuration: the user
- # is likely trying to run a test file directly, and the site configuration
- # wasn't created by the build system.
- msan_site_cfg = lit_config.params.get('msan_site_config', None)
- if (msan_site_cfg) and (os.path.exists(msan_site_cfg)):
- lit_config.load_config(config, msan_site_cfg)
- raise SystemExit
-
- # Try to guess the location of site-specific configuration using llvm-config
- # util that can point where the build tree is.
- llvm_config = lit.util.which("llvm-config", config.environment["PATH"])
- if not llvm_config:
- DisplayNoConfigMessage()
-
- # Find out the presumed location of generated site config.
- llvm_obj_root = lit.util.capture(["llvm-config", "--obj-root"]).strip()
- msan_site_cfg = os.path.join(llvm_obj_root, "projects", "compiler-rt",
- "lib", "msan", "lit_tests", "lit.site.cfg")
- if (not msan_site_cfg) or (not os.path.exists(msan_site_cfg)):
- DisplayNoConfigMessage()
-
- lit_config.load_config(config, msan_site_cfg)
- raise SystemExit
-
-# Setup default compiler flags used with -fsanitize=memory option.
-clang_msan_cflags = ["-fsanitize=memory",
- "-mno-omit-leaf-frame-pointer",
- "-fno-omit-frame-pointer",
- "-fno-optimize-sibling-calls",
- "-g",
- "-m64"]
-clang_msan_cxxflags = ["--driver-mode=g++ "] + clang_msan_cflags
-config.substitutions.append( ("%clang_msan ",
- " ".join([config.clang] + clang_msan_cflags) +
- " ") )
-config.substitutions.append( ("%clangxx_msan ",
- " ".join([config.clang] + clang_msan_cxxflags) +
- " ") )
-
-# Default test suffixes.
-config.suffixes = ['.c', '.cc', '.cpp']
-
-# MemorySanitizer tests are currently supported on Linux only.
-if config.host_os not in ['Linux']:
- config.unsupported = True
diff --git a/compiler-rt/lib/msan/lit_tests/lit.site.cfg.in b/compiler-rt/lib/msan/lit_tests/lit.site.cfg.in
deleted file mode 100644
index 6d1eccc01da..00000000000
--- a/compiler-rt/lib/msan/lit_tests/lit.site.cfg.in
+++ /dev/null
@@ -1,5 +0,0 @@
-# Load common config for all compiler-rt lit tests.
-lit_config.load_config(config, "@COMPILER_RT_BINARY_DIR@/test/lit.common.configured")
-
-# Load tool-specific config that would do the real work.
-lit_config.load_config(config, "@MSAN_SOURCE_DIR@/lit_tests/lit.cfg")
diff --git a/compiler-rt/lib/msan/lit_tests/malloc_hook.cc b/compiler-rt/lib/msan/lit_tests/malloc_hook.cc
deleted file mode 100644
index fc68fbc35fb..00000000000
--- a/compiler-rt/lib/msan/lit_tests/malloc_hook.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// RUN: %clangxx_msan -O2 %s -o %t
-// RUN: %t 2>&1 | FileCheck %s
-#include <stdlib.h>
-#include <unistd.h>
-
-extern "C" {
-int __msan_get_ownership(const void *p);
-
-void *global_ptr;
-
-// Note: avoid calling functions that allocate memory in malloc/free
-// to avoid infinite recursion.
-void __msan_malloc_hook(void *ptr, size_t sz) {
- if (__msan_get_ownership(ptr)) {
- write(1, "MallocHook\n", sizeof("MallocHook\n"));
- global_ptr = ptr;
- }
-}
-void __msan_free_hook(void *ptr) {
- if (__msan_get_ownership(ptr) && ptr == global_ptr)
- write(1, "FreeHook\n", sizeof("FreeHook\n"));
-}
-} // extern "C"
-
-int main() {
- volatile int *x = new int;
- // CHECK: MallocHook
- // Check that malloc hook was called with correct argument.
- if (global_ptr != (void*)x) {
- _exit(1);
- }
- *x = 0;
- delete x;
- // CHECK: FreeHook
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/mmap_below_shadow.cc b/compiler-rt/lib/msan/lit_tests/mmap_below_shadow.cc
deleted file mode 100644
index eb8b0e98189..00000000000
--- a/compiler-rt/lib/msan/lit_tests/mmap_below_shadow.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Test mmap behavior when map address is below shadow range.
-// With MAP_FIXED, we return EINVAL.
-// Without MAP_FIXED, we ignore the address hint and map somewhere in
-// application range.
-
-// RUN: %clangxx_msan -m64 -O0 -DFIXED=0 %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O0 -DFIXED=1 %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O0 -DFIXED=0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O0 -DFIXED=1 -D_FILE_OFFSET_BITS=64 %s -o %t && %t
-
-#include <assert.h>
-#include <errno.h>
-#include <stdint.h>
-#include <sys/mman.h>
-
-int main(void) {
- // Hint address just below shadow.
- uintptr_t hint = 0x4f0000000000ULL;
- const uintptr_t app_start = 0x600000000000ULL;
- uintptr_t p = (uintptr_t)mmap(
- (void *)hint, 4096, PROT_WRITE,
- MAP_PRIVATE | MAP_ANONYMOUS | (FIXED ? MAP_FIXED : 0), -1, 0);
- if (FIXED)
- assert(p == (uintptr_t)-1 && errno == EINVAL);
- else
- assert(p >= app_start);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/no_sanitize_memory.cc b/compiler-rt/lib/msan/lit_tests/no_sanitize_memory.cc
deleted file mode 100644
index 48afc17e35e..00000000000
--- a/compiler-rt/lib/msan/lit_tests/no_sanitize_memory.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t >%t.out 2>&1
-// RUN: %clangxx_msan -m64 -O1 %s -o %t && %t >%t.out 2>&1
-// RUN: %clangxx_msan -m64 -O2 %s -o %t && %t >%t.out 2>&1
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t >%t.out 2>&1
-
-// RUN: %clangxx_msan -m64 -O0 %s -o %t -DCHECK_IN_F && %t >%t.out 2>&1
-// RUN: %clangxx_msan -m64 -O1 %s -o %t -DCHECK_IN_F && %t >%t.out 2>&1
-// RUN: %clangxx_msan -m64 -O2 %s -o %t -DCHECK_IN_F && %t >%t.out 2>&1
-// RUN: %clangxx_msan -m64 -O3 %s -o %t -DCHECK_IN_F && %t >%t.out 2>&1
-
-// Test that (no_sanitize_memory) functions
-// * don't check shadow values (-DCHECK_IN_F)
-// * treat all values loaded from memory as fully initialized (-UCHECK_IN_F)
-
-#include <stdlib.h>
-#include <stdio.h>
-
-__attribute__((noinline))
-__attribute__((no_sanitize_memory))
-int f(void) {
- int x;
- int * volatile p = &x;
-#ifdef CHECK_IN_F
- if (*p)
- exit(0);
-#endif
- return *p;
-}
-
-int main(void) {
- if (f())
- exit(0);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/no_sanitize_memory_prop.cc b/compiler-rt/lib/msan/lit_tests/no_sanitize_memory_prop.cc
deleted file mode 100644
index 35515247885..00000000000
--- a/compiler-rt/lib/msan/lit_tests/no_sanitize_memory_prop.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t >%t.out 2>&1
-// RUN: %clangxx_msan -m64 -O1 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O2 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-
-// Test that (no_sanitize_memory) functions propagate shadow.
-
-// Note that at -O0 there is no report, because 'x' in 'f' is spilled to the
-// stack, and then loaded back as a fully initialiazed value (due to
-// no_sanitize_memory attribute).
-
-#include <stdlib.h>
-#include <stdio.h>
-
-__attribute__((noinline))
-__attribute__((no_sanitize_memory))
-int f(int x) {
- return x;
-}
-
-int main(void) {
- int x;
- int * volatile p = &x;
- int y = f(*p);
- // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
- // CHECK: {{#0 0x.* in main .*no_sanitize_memory_prop.cc:}}[[@LINE+1]]
- if (y)
- exit(0);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/poison_in_free.cc b/compiler-rt/lib/msan/lit_tests/poison_in_free.cc
deleted file mode 100644
index f134d05abb1..00000000000
--- a/compiler-rt/lib/msan/lit_tests/poison_in_free.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clangxx_msan -O0 %s -o %t && not %t >%t.out 2>&1
-// FileCheck %s <%t.out
-// RUN: %clangxx_msan -O0 %s -o %t && MSAN_OPTIONS=poison_in_free=0 %t >%t.out 2>&1
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-int main(int argc, char **argv) {
- char *volatile x = (char*)malloc(50 * sizeof(char));
- memset(x, 0, 50);
- free(x);
- return x[25];
- // CHECK: MemorySanitizer: use-of-uninitialized-value
- // CHECK: #0 {{.*}} in main{{.*}}poison_in_free.cc:[[@LINE-2]]
-}
diff --git a/compiler-rt/lib/msan/lit_tests/pthread_getattr_np_deadlock.cc b/compiler-rt/lib/msan/lit_tests/pthread_getattr_np_deadlock.cc
deleted file mode 100644
index 44dfc19b956..00000000000
--- a/compiler-rt/lib/msan/lit_tests/pthread_getattr_np_deadlock.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// RUN: %clangxx_msan -m64 -fsanitize-memory-track-origins -O0 %s -o %t && %t
-
-// Regression test for a deadlock in pthread_getattr_np
-
-#include <assert.h>
-#include <pthread.h>
-
-void *ThreadFn(void *) {
- pthread_attr_t attr;
- int res = pthread_getattr_np(pthread_self(), &attr);
- assert(!res);
- return 0;
-}
-
-int main(void) {
- pthread_t t;
- int res = pthread_create(&t, 0, ThreadFn, 0);
- assert(!res);
- res = pthread_join(t, 0);
- assert(!res);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/ptrace.cc b/compiler-rt/lib/msan/lit_tests/ptrace.cc
deleted file mode 100644
index d0e83eabd6a..00000000000
--- a/compiler-rt/lib/msan/lit_tests/ptrace.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-#include <assert.h>
-#include <stdio.h>
-#include <sys/ptrace.h>
-#include <sys/types.h>
-#include <sys/user.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-int main(void) {
- pid_t pid;
- pid = fork();
- if (pid == 0) { // child
- ptrace(PTRACE_TRACEME, 0, NULL, NULL);
- execl("/bin/true", "true", NULL);
- } else {
- wait(NULL);
- user_regs_struct regs;
- int res;
- res = ptrace(PTRACE_GETREGS, pid, NULL, &regs);
- assert(!res);
- if (regs.rip)
- printf("%zx\n", regs.rip);
-
- user_fpregs_struct fpregs;
- res = ptrace(PTRACE_GETFPREGS, pid, NULL, &fpregs);
- assert(!res);
- if (fpregs.mxcsr)
- printf("%x\n", fpregs.mxcsr);
-
- ptrace(PTRACE_CONT, pid, NULL, NULL);
- wait(NULL);
- }
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/readdir64.cc b/compiler-rt/lib/msan/lit_tests/readdir64.cc
deleted file mode 100644
index 0ec106c741f..00000000000
--- a/compiler-rt/lib/msan/lit_tests/readdir64.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O1 %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O2 %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t
-
-// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O1 -D_FILE_OFFSET_BITS=64 %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O2 -D_FILE_OFFSET_BITS=64 %s -o %t && %t
-// RUN: %clangxx_msan -m64 -O3 -D_FILE_OFFSET_BITS=64 %s -o %t && %t
-
-// Test that readdir64 is intercepted as well as readdir.
-
-#include <sys/types.h>
-#include <dirent.h>
-#include <stdlib.h>
-
-
-int main(void) {
- DIR *dir = opendir(".");
- struct dirent *d = readdir(dir);
- if (d->d_name[0]) {
- closedir(dir);
- exit(0);
- }
- closedir(dir);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/scandir.cc b/compiler-rt/lib/msan/lit_tests/scandir.cc
deleted file mode 100644
index 94672e1adbe..00000000000
--- a/compiler-rt/lib/msan/lit_tests/scandir.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p
-// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p
-
-#include <assert.h>
-#include <glob.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <unistd.h>
-
-#include <sanitizer/msan_interface.h>
-
-
-static int my_filter(const struct dirent *a) {
- assert(__msan_test_shadow(&a, sizeof(a)) == (size_t)-1);
- printf("%s\n", a->d_name);
- __msan_print_shadow(a, a->d_reclen);
- assert(__msan_test_shadow(a, a->d_reclen) == (size_t)-1);
- printf("%s\n", a->d_name);
- return strlen(a->d_name) == 3 && a->d_name[2] == 'b';
-}
-
-static int my_compar(const struct dirent **a, const struct dirent **b) {
- assert(__msan_test_shadow(a, sizeof(*a)) == (size_t)-1);
- assert(__msan_test_shadow(*a, (*a)->d_reclen) == (size_t)-1);
- assert(__msan_test_shadow(b, sizeof(*b)) == (size_t)-1);
- assert(__msan_test_shadow(*b, (*b)->d_reclen) == (size_t)-1);
- if ((*a)->d_name[1] == (*b)->d_name[1])
- return 0;
- return ((*a)->d_name[1] < (*b)->d_name[1]) ? 1 : -1;
-}
-
-int main(int argc, char *argv[]) {
- assert(argc == 2);
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s/%s", argv[1], "scandir_test_root/");
-
- struct dirent **d;
- int res = scandir(buf, &d, my_filter, my_compar);
- assert(res == 2);
- assert(__msan_test_shadow(&d, sizeof(*d)) == (size_t)-1);
- for (int i = 0; i < res; ++i) {
- assert(__msan_test_shadow(&d[i], sizeof(d[i])) == (size_t)-1);
- assert(__msan_test_shadow(d[i], d[i]->d_reclen) == (size_t)-1);
- }
-
- assert(strcmp(d[0]->d_name, "bbb") == 0);
- assert(strcmp(d[1]->d_name, "aab") == 0);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/scandir_null.cc b/compiler-rt/lib/msan/lit_tests/scandir_null.cc
deleted file mode 100644
index 84af7f418d2..00000000000
--- a/compiler-rt/lib/msan/lit_tests/scandir_null.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t %p
-// RUN: %clangxx_msan -m64 -O0 -D_FILE_OFFSET_BITS=64 %s -o %t && %t %p
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && %t %p
-
-#include <assert.h>
-#include <glob.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <dirent.h>
-#include <unistd.h>
-
-#include <sanitizer/msan_interface.h>
-
-
-int main(int argc, char *argv[]) {
- assert(argc == 2);
- char buf[1024];
- snprintf(buf, sizeof(buf), "%s/%s", argv[1], "scandir_test_root/");
-
- struct dirent **d;
- int res = scandir(buf, &d, NULL, NULL);
- assert(res >= 3);
- assert(__msan_test_shadow(&d, sizeof(*d)) == (size_t)-1);
- for (int i = 0; i < res; ++i) {
- assert(__msan_test_shadow(&d[i], sizeof(d[i])) == (size_t)-1);
- assert(__msan_test_shadow(d[i], d[i]->d_reclen) == (size_t)-1);
- }
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/scandir_test_root/aaa b/compiler-rt/lib/msan/lit_tests/scandir_test_root/aaa
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/scandir_test_root/aaa
+++ /dev/null
diff --git a/compiler-rt/lib/msan/lit_tests/scandir_test_root/aab b/compiler-rt/lib/msan/lit_tests/scandir_test_root/aab
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/scandir_test_root/aab
+++ /dev/null
diff --git a/compiler-rt/lib/msan/lit_tests/scandir_test_root/bbb b/compiler-rt/lib/msan/lit_tests/scandir_test_root/bbb
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/scandir_test_root/bbb
+++ /dev/null
diff --git a/compiler-rt/lib/msan/lit_tests/select.cc b/compiler-rt/lib/msan/lit_tests/select.cc
deleted file mode 100644
index a169a2dd911..00000000000
--- a/compiler-rt/lib/msan/lit_tests/select.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O1 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O2 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-
-#include <stdlib.h>
-int main(int argc, char **argv) {
- int x;
- int *volatile p = &x;
- int z = *p ? 1 : 0;
- if (z)
- exit(0);
- // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
- // CHECK: {{#0 0x.* in main .*select.cc:}}[[@LINE-3]]
-
- // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*select.cc:.* main}}
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/select_origin.cc b/compiler-rt/lib/msan/lit_tests/select_origin.cc
deleted file mode 100644
index f6f6a61b415..00000000000
--- a/compiler-rt/lib/msan/lit_tests/select_origin.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -O0 %s -o %t && not %t 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -O1 %s -o %t && not %t 2>&1 | FileCheck %s
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -O2 %s -o %t && not %t 2>&1 | FileCheck %s
-
-// Test condition origin propagation through "select" IR instruction.
-
-#include <stdio.h>
-#include <stdint.h>
-
-__attribute__((noinline))
-int *max_by_ptr(int *a, int *b) {
- return *a < *b ? b : a;
-}
-
-int main(void) {
- int x;
- int *volatile px = &x;
- int y = 43;
- int *p = max_by_ptr(px, &y);
- // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main'
- return *p;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/setlocale.cc b/compiler-rt/lib/msan/lit_tests/setlocale.cc
deleted file mode 100644
index a22b744d74d..00000000000
--- a/compiler-rt/lib/msan/lit_tests/setlocale.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-#include <assert.h>
-#include <locale.h>
-#include <stdlib.h>
-
-int main(void) {
- char *locale = setlocale (LC_ALL, "");
- assert(locale);
- if (locale[0])
- exit(0);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/signal_stress_test.cc b/compiler-rt/lib/msan/lit_tests/signal_stress_test.cc
deleted file mode 100644
index ea75eae1bda..00000000000
--- a/compiler-rt/lib/msan/lit_tests/signal_stress_test.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-// RUN: %clangxx_msan -std=c++11 -O0 %s -o %t && %t
-
-// Test that va_arg shadow from a signal handler does not leak outside.
-
-#include <signal.h>
-#include <stdarg.h>
-#include <sanitizer/msan_interface.h>
-#include <assert.h>
-#include <sys/time.h>
-#include <stdio.h>
-
-const int kSigCnt = 200;
-
-void f(bool poisoned, int n, ...) {
- va_list vl;
- va_start(vl, n);
- for (int i = 0; i < n; ++i) {
- void *p = va_arg(vl, void *);
- if (!poisoned)
- assert(__msan_test_shadow(&p, sizeof(p)) == -1);
- }
- va_end(vl);
-}
-
-int sigcnt;
-
-void SignalHandler(int signo) {
- assert(signo == SIGPROF);
- void *p;
- void **volatile q = &p;
- f(true, 10,
- *q, *q, *q, *q, *q,
- *q, *q, *q, *q, *q);
- ++sigcnt;
-}
-
-int main() {
- signal(SIGPROF, SignalHandler);
-
- itimerval itv;
- itv.it_interval.tv_sec = 0;
- itv.it_interval.tv_usec = 100;
- itv.it_value.tv_sec = 0;
- itv.it_value.tv_usec = 100;
- setitimer(ITIMER_PROF, &itv, NULL);
-
- void *p;
- void **volatile q = &p;
-
- do {
- f(false, 20,
- nullptr, nullptr, nullptr, nullptr, nullptr,
- nullptr, nullptr, nullptr, nullptr, nullptr,
- nullptr, nullptr, nullptr, nullptr, nullptr,
- nullptr, nullptr, nullptr, nullptr, nullptr);
- f(true, 20,
- *q, *q, *q, *q, *q,
- *q, *q, *q, *q, *q,
- *q, *q, *q, *q, *q,
- *q, *q, *q, *q, *q);
- } while (sigcnt < kSigCnt);
-
- itv.it_interval.tv_sec = 0;
- itv.it_interval.tv_usec = 0;
- itv.it_value.tv_sec = 0;
- itv.it_value.tv_usec = 0;
- setitimer(ITIMER_PROF, &itv, NULL);
-
- signal(SIGPROF, SIG_DFL);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/sigwait.cc b/compiler-rt/lib/msan/lit_tests/sigwait.cc
deleted file mode 100644
index 29aa86c938f..00000000000
--- a/compiler-rt/lib/msan/lit_tests/sigwait.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// RUN: %clangxx_msan -std=c++11 -O0 -g %s -o %t && %t
-
-#include <assert.h>
-#include <sanitizer/msan_interface.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <unistd.h>
-
-void test_sigwait() {
- sigset_t s;
- sigemptyset(&s);
- sigaddset(&s, SIGUSR1);
- sigprocmask(SIG_BLOCK, &s, 0);
-
- if (pid_t pid = fork()) {
- kill(pid, SIGUSR1);
- _exit(0);
- } else {
- int sig;
- int res = sigwait(&s, &sig);
- assert(!res);
- // The following checks that sig is initialized.
- assert(sig == SIGUSR1);
- }
-}
-
-int main(void) {
- test_sigwait();
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/sigwaitinfo.cc b/compiler-rt/lib/msan/lit_tests/sigwaitinfo.cc
deleted file mode 100644
index d4f004598a6..00000000000
--- a/compiler-rt/lib/msan/lit_tests/sigwaitinfo.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// RUN: %clangxx_msan -std=c++11 -O0 -g %s -o %t && %t
-
-#include <assert.h>
-#include <sanitizer/msan_interface.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <unistd.h>
-
-void test_sigwaitinfo() {
- sigset_t s;
- sigemptyset(&s);
- sigaddset(&s, SIGUSR1);
- sigprocmask(SIG_BLOCK, &s, 0);
-
- if (pid_t pid = fork()) {
- kill(pid, SIGUSR1);
- _exit(0);
- } else {
- siginfo_t info;
- int res = sigwaitinfo(&s, &info);
- assert(!res);
- // The following checks that sig is initialized.
- assert(info.si_signo == SIGUSR1);
- assert(-1 == __msan_test_shadow(&info, sizeof(info)));
- }
-}
-
-int main(void) {
- test_sigwaitinfo();
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/stack-origin.cc b/compiler-rt/lib/msan/lit_tests/stack-origin.cc
deleted file mode 100644
index b0b05d9658b..00000000000
--- a/compiler-rt/lib/msan/lit_tests/stack-origin.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O1 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O2 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O1 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O2 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-
-#include <stdlib.h>
-int main(int argc, char **argv) {
- int x;
- int *volatile p = &x;
- return *p;
- // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
- // CHECK: {{#0 0x.* in main .*stack-origin.cc:}}[[@LINE-2]]
-
- // CHECK-ORIGINS: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main'
- // CHECK-ORIGINS: {{#0 0x.* in main .*stack-origin.cc:}}[[@LINE-8]]
-
- // CHECK: SUMMARY: MemorySanitizer: use-of-uninitialized-value {{.*stack-origin.cc:.* main}}
-}
diff --git a/compiler-rt/lib/msan/lit_tests/strerror_r-non-gnu.c b/compiler-rt/lib/msan/lit_tests/strerror_r-non-gnu.c
deleted file mode 100644
index 8fb47055814..00000000000
--- a/compiler-rt/lib/msan/lit_tests/strerror_r-non-gnu.c
+++ /dev/null
@@ -1,18 +0,0 @@
-// RUN: %clang_msan -std=c99 -O0 -g %s -o %t && %t
-
-// strerror_r under a weird set of circumstances can be redirected to
-// __xpg_strerror_r. Test that MSan handles this correctly.
-
-#define _POSIX_C_SOURCE 200112
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-
-int main() {
- char buf[1000];
- int res = strerror_r(EINVAL, buf, sizeof(buf));
- assert(!res);
- volatile int z = strlen(buf);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/strlen_of_shadow.cc b/compiler-rt/lib/msan/lit_tests/strlen_of_shadow.cc
deleted file mode 100644
index cb2530e8fdd..00000000000
--- a/compiler-rt/lib/msan/lit_tests/strlen_of_shadow.cc
+++ /dev/null
@@ -1,24 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-// Check that strlen() and similar intercepted functions can be called on shadow
-// memory.
-
-#include <assert.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-
-const char *mem_to_shadow(const char *p) {
- return (char *)((uintptr_t)p & ~0x400000000000ULL);
-}
-
-int main(void) {
- const char *s = "abcdef";
- assert(strlen(s) == 6);
- assert(strlen(mem_to_shadow(s)) == 0);
-
- char *t = new char[42];
- t[41] = 0;
- assert(strlen(mem_to_shadow(t)) == 41);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/sync_lock_set_and_test.cc b/compiler-rt/lib/msan/lit_tests/sync_lock_set_and_test.cc
deleted file mode 100644
index 1023b3e5436..00000000000
--- a/compiler-rt/lib/msan/lit_tests/sync_lock_set_and_test.cc
+++ /dev/null
@@ -1,7 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-int main(void) {
- int i;
- __sync_lock_test_and_set(&i, 0);
- return i;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/textdomain.cc b/compiler-rt/lib/msan/lit_tests/textdomain.cc
deleted file mode 100644
index e3968233a9b..00000000000
--- a/compiler-rt/lib/msan/lit_tests/textdomain.cc
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 -g %s -o %t && %t
-
-#include <libintl.h>
-#include <stdio.h>
-
-int main() {
- const char *td = textdomain("abcd");
- if (td[0] == 0) {
- printf("Try read");
- }
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/times.cc b/compiler-rt/lib/msan/lit_tests/times.cc
deleted file mode 100644
index 1b7d00052fc..00000000000
--- a/compiler-rt/lib/msan/lit_tests/times.cc
+++ /dev/null
@@ -1,20 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 -g %s -o %t && %t
-
-#include <assert.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/times.h>
-
-
-int main(void) {
- struct tms t;
- clock_t res = times(&t);
- assert(res != (clock_t)-1);
-
- if (t.tms_utime) printf("1\n");
- if (t.tms_stime) printf("2\n");
- if (t.tms_cutime) printf("3\n");
- if (t.tms_cstime) printf("4\n");
-
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/tls_reuse.cc b/compiler-rt/lib/msan/lit_tests/tls_reuse.cc
deleted file mode 100644
index e1de7e87a1e..00000000000
--- a/compiler-rt/lib/msan/lit_tests/tls_reuse.cc
+++ /dev/null
@@ -1,26 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-// Check that when TLS block is reused between threads, its shadow is cleaned.
-
-#include <pthread.h>
-#include <stdio.h>
-
-int __thread x;
-
-void *ThreadFn(void *) {
- if (!x)
- printf("zzz\n");
- int y;
- int * volatile p = &y;
- x = *p;
- return 0;
-}
-
-int main(void) {
- pthread_t t;
- for (int i = 0; i < 100; ++i) {
- pthread_create(&t, 0, ThreadFn, 0);
- pthread_join(t, 0);
- }
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/tzset.cc b/compiler-rt/lib/msan/lit_tests/tzset.cc
deleted file mode 100644
index 7e1c2cfad56..00000000000
--- a/compiler-rt/lib/msan/lit_tests/tzset.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-
-extern char *tzname[2];
-
-int main(void) {
- if (!strlen(tzname[0]) || !strlen(tzname[1]))
- exit(1);
- tzset();
- if (!strlen(tzname[0]) || !strlen(tzname[1]))
- exit(1);
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/unaligned_read_origin.cc b/compiler-rt/lib/msan/lit_tests/unaligned_read_origin.cc
deleted file mode 100644
index fa29ab69de1..00000000000
--- a/compiler-rt/lib/msan/lit_tests/unaligned_read_origin.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s < %t.out
-
-#include <sanitizer/msan_interface.h>
-
-int main(int argc, char **argv) {
- int x;
- int *volatile p = &x;
- return __sanitizer_unaligned_load32(p);
- // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
- // CHECK: {{#0 0x.* in main .*unaligned_read_origin.cc:}}[[@LINE-2]]
- // CHECK: Uninitialized value was created by an allocation of 'x' in the stack frame of function 'main'
- // CHECK: {{#0 0x.* in main .*unaligned_read_origin.cc:}}[[@LINE-7]]
-}
diff --git a/compiler-rt/lib/msan/lit_tests/use-after-free.cc b/compiler-rt/lib/msan/lit_tests/use-after-free.cc
deleted file mode 100644
index ac47c0233a1..00000000000
--- a/compiler-rt/lib/msan/lit_tests/use-after-free.cc
+++ /dev/null
@@ -1,34 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O1 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O2 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-// RUN: %clangxx_msan -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out
-
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O0 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O1 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O2 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-// RUN: %clangxx_msan -fsanitize-memory-track-origins -m64 -O3 %s -o %t && not %t >%t.out 2>&1
-// RUN: FileCheck %s < %t.out && FileCheck %s --check-prefix=CHECK-ORIGINS < %t.out
-
-#include <stdlib.h>
-int main(int argc, char **argv) {
- int *volatile p = (int *)malloc(sizeof(int));
- *p = 42;
- free(p);
-
- if (*p)
- exit(0);
- // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
- // CHECK: {{#0 0x.* in main .*use-after-free.cc:}}[[@LINE-3]]
-
- // CHECK-ORIGINS: Uninitialized value was created by a heap allocation
- // CHECK-ORIGINS: {{#0 0x.* in .*free}}
- // CHECK-ORIGINS: {{#1 0x.* in main .*use-after-free.cc:}}[[@LINE-9]]
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/vector_cvt.cc b/compiler-rt/lib/msan/lit_tests/vector_cvt.cc
deleted file mode 100644
index c200c77de96..00000000000
--- a/compiler-rt/lib/msan/lit_tests/vector_cvt.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -o %t && %t
-// RUN: %clangxx_msan -DPOSITIVE -m64 -O0 %s -o %t && not %t 2>&1 | FileCheck %s
-
-#include <emmintrin.h>
-
-int to_int(double v) {
- __m128d t = _mm_set_sd(v);
- int x = _mm_cvtsd_si32(t);
- return x;
- // CHECK: WARNING: MemorySanitizer: use-of-uninitialized-value
- // CHECK: #{{.*}} in to_int{{.*}}vector_cvt.cc:[[@LINE-4]]
-}
-
-int main() {
-#ifdef POSITIVE
- double v;
-#else
- double v = 1.1;
-#endif
- double* volatile p = &v;
- int x = to_int(*p);
- return !x;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/vector_select.cc b/compiler-rt/lib/msan/lit_tests/vector_select.cc
deleted file mode 100644
index e8d55423293..00000000000
--- a/compiler-rt/lib/msan/lit_tests/vector_select.cc
+++ /dev/null
@@ -1,13 +0,0 @@
-// RUN: %clangxx_msan -m64 -O0 %s -c -o %t
-// RUN: %clangxx_msan -m64 -O3 %s -c -o %t
-
-// Regression test for MemorySanitizer instrumentation of a select instruction
-// with vector arguments.
-
-#include <emmintrin.h>
-
-__m128d select(bool b, __m128d c, __m128d d)
-{
- return b ? c : d;
-}
-
diff --git a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls.cc b/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls.cc
deleted file mode 100644
index b4bac1ecbd2..00000000000
--- a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls.cc
+++ /dev/null
@@ -1,64 +0,0 @@
-// Test indirect call wrapping in MemorySanitizer.
-
-// RUN: %clangxx_msan -O0 %p/wrap_indirect_calls/two.cc -fPIC -shared -o %t-two-so.so
-// RUN: %clangxx_msan -O0 %p/wrap_indirect_calls/wrapper.cc -fPIC -shared -o %t-wrapper-so.so
-
-// Disable fast path.
-
-// RUN: %clangxx_msan -O0 %p/wrap_indirect_calls/caller.cc %p/wrap_indirect_calls/one.cc %s \
-// RUN: %t-two-so.so %t-wrapper-so.so \
-// RUN: -mllvm -msan-wrap-indirect-calls=wrapper \
-// RUN: -mllvm -msan-wrap-indirect-calls-fast=0 \
-// RUN: -DSLOW=1 \
-// RUN: -Wl,--defsym=__executable_start=0 -o %t
-// RUN: %t
-
-// Enable fast path, call from executable, -O0.
-
-// RUN: %clangxx_msan -O0 %p/wrap_indirect_calls/caller.cc %p/wrap_indirect_calls/one.cc %s \
-// RUN: %t-two-so.so %t-wrapper-so.so \
-// RUN: -mllvm -msan-wrap-indirect-calls=wrapper \
-// RUN: -mllvm -msan-wrap-indirect-calls-fast=1 \
-// RUN: -DSLOW=0 \
-// RUN: -Wl,--defsym=__executable_start=0 -o %t
-// RUN: %t
-
-// Enable fast path, call from executable, -O3.
-
-// RUN: %clangxx_msan -O3 %p/wrap_indirect_calls/caller.cc %p/wrap_indirect_calls/one.cc %s \
-// RUN: %t-two-so.so %t-wrapper-so.so \
-// RUN: -mllvm -msan-wrap-indirect-calls=wrapper \
-// RUN: -mllvm -msan-wrap-indirect-calls-fast=1 \
-// RUN: -DSLOW=0 \
-// RUN: -Wl,--defsym=__executable_start=0 -o %t
-// RUN: %t
-
-// Enable fast path, call from DSO, -O0.
-
-// RUN: %clangxx_msan -O0 %p/wrap_indirect_calls/caller.cc %p/wrap_indirect_calls/one.cc -shared \
-// RUN: %t-two-so.so %t-wrapper-so.so \
-// RUN: -mllvm -msan-wrap-indirect-calls=wrapper \
-// RUN: -mllvm -msan-wrap-indirect-calls-fast=1 \
-// RUN: -DSLOW=0 \
-// RUN: -Wl,--defsym=__executable_start=0 -o %t-caller-so.so
-// RUN: %clangxx_msan -O0 %s %t-caller-so.so %t-two-so.so %t-wrapper-so.so -o %t
-// RUN: %t
-
-// Enable fast path, call from DSO, -O3.
-
-// RUN: %clangxx_msan -O3 %p/wrap_indirect_calls/caller.cc %p/wrap_indirect_calls/one.cc -shared \
-// RUN: %t-two-so.so %t-wrapper-so.so \
-// RUN: -mllvm -msan-wrap-indirect-calls=wrapper \
-// RUN: -mllvm -msan-wrap-indirect-calls-fast=1 \
-// RUN: -DSLOW=0 \
-// RUN: -Wl,--defsym=__executable_start=0 -o %t-caller-so.so
-// RUN: %clangxx_msan -O3 %s %t-caller-so.so %t-two-so.so %t-wrapper-so.so -o %t
-// RUN: %t
-
-// The actual test is in multiple files in wrap_indirect_calls/ directory.
-void run_test();
-
-int main() {
- run_test();
- return 0;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/caller.cc b/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/caller.cc
deleted file mode 100644
index a0af8b7bb0c..00000000000
--- a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/caller.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-// Indirectly call a bunch of functions.
-
-#include <assert.h>
-
-extern int cnt;
-
-typedef int (*F)(int, int);
-
-// A function in the same object.
-int f_local(int x, int y) {
- return x + y;
-}
-
-// A function in another object.
-int f_other_object(int x, int y);
-
-// A function in another DSO.
-int f_dso(int x, int y);
-
-// A function in another DSO that is replaced by the wrapper.
-int f_replaced(int x, int y);
-
-void run_test(void) {
- int x;
- int expected_cnt = 0;
- volatile F f;
-
- if (SLOW) ++expected_cnt;
- f = &f_local;
- x = f(1, 2);
- assert(x == 3);
- assert(cnt == expected_cnt);
-
- if (SLOW) ++expected_cnt;
- f = &f_other_object;
- x = f(2, 3);
- assert(x == 6);
- assert(cnt == expected_cnt);
-
- ++expected_cnt;
- f = &f_dso;
- x = f(2, 3);
- assert(x == 7);
- assert(cnt == expected_cnt);
-
- ++expected_cnt;
- f = &f_replaced;
- x = f(2, 3);
- assert(x == 11);
- assert(cnt == expected_cnt);
-}
diff --git a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/lit.local.cfg b/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/lit.local.cfg
deleted file mode 100644
index 5e01230c098..00000000000
--- a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/lit.local.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
-# Sources in this directory are used by tests in parent directory.
-
-config.suffixes = []
diff --git a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/one.cc b/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/one.cc
deleted file mode 100644
index ab7bf4125c0..00000000000
--- a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/one.cc
+++ /dev/null
@@ -1,3 +0,0 @@
-int f_other_object(int x, int y) {
- return x * y;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/two.cc b/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/two.cc
deleted file mode 100644
index c939a993bc9..00000000000
--- a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/two.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-int f_dso(int x, int y) {
- return 2 * x + y;
-}
-
-int f_replaced(int x, int y) {
- return x + y + 5;
-}
-
-int f_replacement(int x, int y) {
- return x + y + 6;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/wrapper.cc b/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/wrapper.cc
deleted file mode 100644
index 8fcd0c635d9..00000000000
--- a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls/wrapper.cc
+++ /dev/null
@@ -1,11 +0,0 @@
-int f_replaced(int x, int y);
-int f_replacement(int x, int y);
-
-int cnt;
-
-extern "C" void *wrapper(void *p) {
- ++cnt;
- if (p == (void *)f_replaced)
- return (void *)f_replacement;
- return p;
-}
diff --git a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls2.cc b/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls2.cc
deleted file mode 100644
index c188047ce50..00000000000
--- a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls2.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-// Test __msan_set_indirect_call_wrapper.
-
-// RUN: %clangxx_msan -mllvm -msan-wrap-indirect-calls=__msan_wrap_indirect_call \
-// RUN: -mllvm -msan-wrap-indirect-calls-fast=0 \
-// RUN: -O0 -g -rdynamic -Wl,--defsym=__executable_start=0 %s -o %t && %t
-
-// This test disables -msan-wrap-indirect-calls-fast, otherwise indirect calls
-// inside the same module are short-circuited and are never seen by the wrapper.
-
-#include <assert.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdint.h>
-
-extern "C" void __msan_set_indirect_call_wrapper(uintptr_t);
-
-bool done_f, done_g;
-
-void f(void) {
- assert(!done_g);
- done_f = true;
-}
-
-void g(void) {
- assert(done_f);
- done_g = true;
-}
-
-typedef void (*Fn)(void);
-extern "C" Fn my_wrapper(Fn target) {
- if (target == f) return g;
- return target;
-}
-
-int main(void) {
- volatile Fn fp;
- fp = &f;
- fp();
- __msan_set_indirect_call_wrapper((uintptr_t)my_wrapper);
- fp();
- return !(done_f && done_g);
-}
diff --git a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls_in_rtl.cc b/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls_in_rtl.cc
deleted file mode 100644
index 0d9051ba70f..00000000000
--- a/compiler-rt/lib/msan/lit_tests/wrap_indirect_calls_in_rtl.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// Test indirect call wrapping in MemorySanitizer runtime.
-
-// RUN: %clangxx_msan -O0 -g -rdynamic %s -o %t && %t
-
-#include <assert.h>
-#include <math.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdint.h>
-#include <sys/time.h>
-
-extern "C" void __msan_set_indirect_call_wrapper(uintptr_t);
-
-bool pthread_create_done;
-
-void *ThreadFn(void *) {
- printf("bad threadfn\n");
- return 0;
-}
-
-void *ThreadFn2(void *) {
- printf("good threadfn\n");
- pthread_create_done = true;
- return 0;
-}
-
-bool in_gettimeofday;
-bool in_lgamma;
-
-int my_gettimeofday(struct timeval *p, void *q) {
- p->tv_sec = 1;
- p->tv_usec = 2;
- return 42;
-}
-
-double my_lgamma(double x) {
- printf("zzz\n");
- return x;
-}
-
-extern "C" uintptr_t my_wrapper(uintptr_t f) {
- if (f == (uintptr_t)ThreadFn)
- return (uintptr_t)&ThreadFn2;
- if (in_gettimeofday)
- return (uintptr_t)my_gettimeofday;
- if (in_lgamma)
- return (uintptr_t)my_lgamma;
- return f;
-}
-
-int main(void) {
- __msan_set_indirect_call_wrapper((uintptr_t)my_wrapper);
-
- // ThreadFn is called indirectly from a wrapper function in MSan rtl and
- // is subject to indirect call wrapping (it could be an native-to-translated
- // edge).
- pthread_t t;
- pthread_create(&t, 0, ThreadFn, 0);
- pthread_join(t, 0);
- assert(pthread_create_done);
-
- // gettimeofday is intercepted in msan_interceptors.cc and the real one (from
- // libc) is called indirectly.
- struct timeval tv;
- in_gettimeofday = true;
- int res = gettimeofday(&tv, NULL);
- in_gettimeofday = false;
- assert(tv.tv_sec == 1);
- assert(tv.tv_usec == 2);
- assert(res == 42);
-
- // lgamma is intercepted in sanitizer_common_interceptors.inc and is also
- // called indirectly.
- in_lgamma = true;
- double dres = lgamma(1.1);
- in_lgamma = false;
- assert(dres == 1.1);
-
- return 0;
-}
diff --git a/compiler-rt/lib/msan/tests/CMakeLists.txt b/compiler-rt/lib/msan/tests/CMakeLists.txt
index 9c49f167fa1..d679524225d 100644
--- a/compiler-rt/lib/msan/tests/CMakeLists.txt
+++ b/compiler-rt/lib/msan/tests/CMakeLists.txt
@@ -6,9 +6,9 @@ include_directories(..)
include_directories(../..)
# Instrumented libcxx sources and build flags.
-file(GLOB MSAN_LIBCXX_SOURCES ${MSAN_LIBCXX_PATH}/src/*.cpp)
+file(GLOB MSAN_LIBCXX_SOURCES ${COMPILER_RT_LIBCXX_PATH}/src/*.cpp)
set(MSAN_LIBCXX_CFLAGS
- -I${MSAN_LIBCXX_PATH}/include
+ -I${COMPILER_RT_LIBCXX_PATH}/include
-fsanitize=memory
-fsanitize-memory-track-origins
-fPIC
@@ -39,7 +39,7 @@ set(MSAN_UNITTEST_HEADERS
)
set(MSANDR_UNITTEST_SOURCE msandr_test_so.cc)
set(MSAN_UNITTEST_COMMON_CFLAGS
- -I${MSAN_LIBCXX_PATH}/include
+ -I${COMPILER_RT_LIBCXX_PATH}/include
${COMPILER_RT_GTEST_INCLUDE_CFLAGS}
-I${COMPILER_RT_SOURCE_DIR}/include
-I${COMPILER_RT_SOURCE_DIR}/lib
@@ -78,7 +78,7 @@ macro(msan_compile obj_list source arch)
get_target_flags_for_arch(${arch} TARGET_CFLAGS)
clang_compile(${output_obj} ${source}
CFLAGS ${ARGN} ${TARGET_CFLAGS}
- DEPS gtest ${MSAN_RUNTIME_LIBRARIES} ${MSAN_UNITTEST_HEADERS})
+ DEPS gtest msan ${MSAN_UNITTEST_HEADERS})
list(APPEND ${obj_list} ${output_obj})
endmacro()
@@ -99,7 +99,7 @@ macro(add_msan_test test_suite test_name arch)
get_target_flags_for_arch(${arch} TARGET_LINK_FLAGS)
add_compiler_rt_test(${test_suite} ${test_name}
OBJECTS ${ARGN}
- DEPS ${MSAN_RUNTIME_LIBRARIES} ${ARGN}
+ DEPS msan ${ARGN}
${MSAN_LOADABLE_SO}
LINK_FLAGS ${MSAN_UNITTEST_LINK_FLAGS}
${TARGET_LINK_FLAGS}
@@ -128,7 +128,7 @@ macro(add_msan_tests_for_arch arch)
msan_link_shared(MSAN_INST_LIBCXX "libcxx" ${arch}
OBJECTS ${MSAN_INST_LIBCXX_OBJECTS}
LINKFLAGS ${MSAN_LIBCXX_LINK_FLAGS}
- DEPS ${MSAN_INST_LIBCXX_OBJECTS} ${MSAN_RUNTIME_LIBRARIES})
+ DEPS ${MSAN_INST_LIBCXX_OBJECTS} msan)
# Instrumented tests.
set(MSAN_INST_TEST_OBJECTS)
@@ -151,13 +151,13 @@ macro(add_msan_tests_for_arch arch)
set(MSAN_LOADABLE_SO)
msan_link_shared(MSAN_LOADABLE_SO "libmsan_loadable" ${arch}
OBJECTS ${MSAN_INST_LOADABLE_OBJECTS}
- DEPS ${MSAN_INST_LOADABLE_OBJECTS} ${MSAN_RUNTIME_LIBRARIES})
+ DEPS ${MSAN_INST_LOADABLE_OBJECTS} msan)
# Uninstrumented shared library tests.
set(MSANDR_TEST_SO)
msan_link_shared(MSANDR_TEST_SO "libmsandr_test" ${arch}
OBJECTS ${MSANDR_TEST_OBJECTS}
- DEPS ${MSANDR_TEST_OBJECTS} ${MSAN_RUNTIME_LIBRARIES})
+ DEPS ${MSANDR_TEST_OBJECTS} msan)
# Link everything together.
add_msan_test(MsanUnitTests "Msan-${arch}-Test" ${arch}
@@ -165,7 +165,8 @@ macro(add_msan_tests_for_arch arch)
${MSAN_INST_LIBCXX} ${MSANDR_TEST_SO})
endmacro()
-if(COMPILER_RT_CAN_EXECUTE_TESTS AND MSAN_CAN_INSTRUMENT_LIBCXX)
+# We should only build MSan unit tests if we can build instrumented libcxx.
+if(COMPILER_RT_CAN_EXECUTE_TESTS AND COMPILER_RT_HAS_LIBCXX_SOURCES)
if(CAN_TARGET_x86_64)
add_msan_tests_for_arch(x86_64)
endif()
OpenPOWER on IntegriCloud