diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2026-01-29 14:39:34 -0800 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2026-01-29 14:39:34 -0800 |
| commit | 7b3f189a1369f9348c007730ddea953b1e68acb1 (patch) | |
| tree | 7db8969ee8a34a10b6c8ae033c939c9d653376f6 /compiler-rt/test | |
| parent | f3d6dae13ae710323a2ddbaf87af71b1abcbfada (diff) | |
| parent | 0893b70ecfc4f4aca0a20a078476d191edc1e623 (diff) | |
| download | llvm-users/pcc/spr/codegen-introduce-machinefunctiongetpreferredalignment.zip llvm-users/pcc/spr/codegen-introduce-machinefunctiongetpreferredalignment.tar.gz llvm-users/pcc/spr/codegen-introduce-machinefunctiongetpreferredalignment.tar.bz2 | |
Created using spr 1.3.6-beta.1
Diffstat (limited to 'compiler-rt/test')
| -rw-r--r-- | compiler-rt/test/dfsan/custom.cpp | 2 | ||||
| -rw-r--r-- | compiler-rt/test/dfsan/lit.cfg.py | 8 | ||||
| -rw-r--r-- | compiler-rt/test/dfsan/origin_endianness.c | 4 | ||||
| -rw-r--r-- | compiler-rt/test/dfsan/pair.cpp | 15 | ||||
| -rw-r--r-- | compiler-rt/test/dfsan/struct.c | 9 | ||||
| -rw-r--r-- | compiler-rt/test/orc/TestCases/Linux/Generic/ctor-dtor.cpp | 86 | ||||
| -rw-r--r-- | compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp | 8 |
7 files changed, 115 insertions, 17 deletions
diff --git a/compiler-rt/test/dfsan/custom.cpp b/compiler-rt/test/dfsan/custom.cpp index 873af5c..b4d6b18 100644 --- a/compiler-rt/test/dfsan/custom.cpp +++ b/compiler-rt/test/dfsan/custom.cpp @@ -2240,7 +2240,7 @@ void test_sscanf() { strcpy(input_buf, "-559038737"); test_sscanf_chunk(-559038737, "%d", input_ptr, 1); strcpy(input_buf, "3735928559"); - test_sscanf_chunk(3735928559, "%u", input_ptr, 1); + test_sscanf_chunk(3735928559, "%lu", input_ptr, 1); strcpy(input_buf, "12345"); test_sscanf_chunk(12345, "%i", input_ptr, 1); strcpy(input_buf, "0751"); diff --git a/compiler-rt/test/dfsan/lit.cfg.py b/compiler-rt/test/dfsan/lit.cfg.py index b26ff3e..ec07db5 100644 --- a/compiler-rt/test/dfsan/lit.cfg.py +++ b/compiler-rt/test/dfsan/lit.cfg.py @@ -10,6 +10,9 @@ config.test_source_root = os.path.dirname(__file__) # Setup default compiler flags used with -fsanitize=dataflow option. clang_dfsan_cflags = ["-fsanitize=dataflow"] + [config.target_cflags] +# s390x arch needs -mbackchain to print stack backtrace of origin. +if config.target_arch == "s390x": + clang_dfsan_cflags.append("-mbackchain") clang_dfsan_cxxflags = config.cxx_mode_flags + clang_dfsan_cflags @@ -25,5 +28,8 @@ config.substitutions.append(("%clangxx_dfsan ", build_invocation(clang_dfsan_cxx config.suffixes = [".c", ".cpp"] # DataFlowSanitizer tests are currently supported on Linux only. -if not (config.target_os in ["Linux"] and config.target_arch in ["aarch64", "x86_64", "loongarch64"]): +if not ( + config.target_os in ["Linux"] + and config.target_arch in ["aarch64", "x86_64", "loongarch64", "s390x"] +): config.unsupported = True diff --git a/compiler-rt/test/dfsan/origin_endianness.c b/compiler-rt/test/dfsan/origin_endianness.c index a73dcda..cd0b198 100644 --- a/compiler-rt/test/dfsan/origin_endianness.c +++ b/compiler-rt/test/dfsan/origin_endianness.c @@ -16,10 +16,10 @@ __attribute__((noinline)) FULL_TYPE foo(FULL_TYPE a, FULL_TYPE b) { int main(int argc, char *argv[]) { FULL_TYPE a = 1; FULL_TYPE b = 10; - dfsan_set_label(4, (HALF_TYPE *)&a, sizeof(HALF_TYPE)); + dfsan_set_label(4, (HALF_TYPE *)&a + 1, sizeof(HALF_TYPE)); FULL_TYPE c = foo(a, b); dfsan_print_origin_trace(&c, NULL); - dfsan_print_origin_trace((HALF_TYPE *)&c, NULL); + dfsan_print_origin_trace((HALF_TYPE *)&c + 1, NULL); } // CHECK: Taint value 0x4 {{.*}} origin tracking () diff --git a/compiler-rt/test/dfsan/pair.cpp b/compiler-rt/test/dfsan/pair.cpp index 94bbfc7..e3b3bcc 100644 --- a/compiler-rt/test/dfsan/pair.cpp +++ b/compiler-rt/test/dfsan/pair.cpp @@ -6,6 +6,9 @@ #include <sanitizer/dfsan_interface.h> #include <utility> +// SystemZ identifies labels for struct elements precisely across all +// optimization labels. + __attribute__((noinline)) std::pair<int *, int> make_pair(int *p, int i) { return {p, i}; } @@ -65,7 +68,7 @@ void test_simple_constructors() { int i1 = pair1.second; int *ptr1 = pair1.first; -#ifdef O0 +#if defined(O0) && !defined(__s390x__) assert(dfsan_read_label(&i1, sizeof(i1)) == 10); assert(dfsan_read_label(&ptr1, sizeof(ptr1)) == 10); #else @@ -77,7 +80,7 @@ void test_simple_constructors() { int i2 = pair2.second; int *ptr2 = pair2.first; -#ifdef O0 +#if defined(O0) && !defined(__s390x__) assert(dfsan_read_label(&i2, sizeof(i2)) == 10); assert(dfsan_read_label(&ptr2, sizeof(ptr2)) == 10); #else @@ -89,7 +92,7 @@ void test_simple_constructors() { int i3 = pair3.second; int *ptr3 = pair3.first; -#ifdef O0 +#if defined(O0) && !defined(__s390x__) assert(dfsan_read_label(&i3, sizeof(i3)) == 10); assert(dfsan_read_label(&ptr3, sizeof(ptr3)) == 10); #else @@ -101,7 +104,7 @@ void test_simple_constructors() { int i4 = pair4.second; int *ptr4 = pair4.first; -#ifdef O0 +#if defined(O0) && !defined(__s390x__) assert(dfsan_read_label(&i4, sizeof(i4)) == 10); assert(dfsan_read_label(&ptr4, sizeof(ptr4)) == 10); #else @@ -139,7 +142,7 @@ void test_branches() { { std::pair<const char *, uint32_t> r = return_ptr_and_i32(q, res); -#ifdef O0 +#if defined(O0) && !defined(__s390x__) assert(dfsan_read_label(&r.first, sizeof(r.first)) == 10); assert(dfsan_read_label(&r.second, sizeof(r.second)) == 10); #else @@ -150,7 +153,7 @@ void test_branches() { { std::pair<const char *, uint64_t> r = return_ptr_and_i64(q, res); -#ifdef O0 +#if defined(O0) && !defined(__s390x__) assert(dfsan_read_label(&r.first, sizeof(r.first)) == 10); assert(dfsan_read_label(&r.second, sizeof(r.second)) == 10); #else diff --git a/compiler-rt/test/dfsan/struct.c b/compiler-rt/test/dfsan/struct.c index 7ba0016..fa976434 100644 --- a/compiler-rt/test/dfsan/struct.c +++ b/compiler-rt/test/dfsan/struct.c @@ -4,6 +4,9 @@ #include <assert.h> #include <sanitizer/dfsan_interface.h> +// SystemZ identifies labels for struct elements precisely across all +// optimization labels. + typedef struct Pair { int i; char *ptr; @@ -47,7 +50,7 @@ int main(void) { dfsan_label i1_label = dfsan_read_label(&i1, sizeof(i1)); dfsan_label ptr1_label = dfsan_read_label(&ptr1, sizeof(ptr1)); -#if defined(O0) +#if defined(O0) && !defined(__s390x__) assert(i1_label == (i_label | ptr_label)); assert(ptr1_label == (i_label | ptr_label)); #else @@ -61,7 +64,7 @@ int main(void) { dfsan_label i2_label = dfsan_read_label(&i2, sizeof(i2)); dfsan_label ptr2_label = dfsan_read_label(&ptr2, sizeof(ptr2)); -#if defined(O0) +#if defined(O0) && !defined(__s390x__) assert(i2_label == (i_label | ptr_label)); assert(ptr2_label == (i_label | ptr_label)); #else @@ -75,7 +78,7 @@ int main(void) { dfsan_label i3_label = dfsan_read_label(&i3, sizeof(i3)); dfsan_label ptr3_label = dfsan_read_label(&ptr3, sizeof(ptr3)); -#if defined(O0) +#if defined(O0) && !defined(__s390x__) assert(i3_label == (i_label | ptr_label)); assert(ptr3_label == (i_label | ptr_label)); #else diff --git a/compiler-rt/test/orc/TestCases/Linux/Generic/ctor-dtor.cpp b/compiler-rt/test/orc/TestCases/Linux/Generic/ctor-dtor.cpp new file mode 100644 index 0000000..d5a1e80 --- /dev/null +++ b/compiler-rt/test/orc/TestCases/Linux/Generic/ctor-dtor.cpp @@ -0,0 +1,86 @@ +// Check that constructors and destructors are run in the expected order. +// +// RUN: %clang -c -o %t.o %s +// RUN: %llvm_jitlink %t.o | FileCheck %s +// +// REQUIRES: system-linux && host-arch-compatible + +// CHECK: <init_array.101> +// CHECK: <init_array.102> +// CHECK: <init_array.103> +// CHECK: <init_array> +// CHECK: <ctors.103> +// CHECK: <ctors.102> +// CHECK: <ctors.101> +// CHECK: <ctors> +// CHECK: <dtors> +// CHECK: <dtors.101> +// CHECK: <dtors.102> +// CHECK: <dtors.103> +// CHECK: <fini_array> +// CHECK: <fini_array.103> +// CHECK: <fini_array.102> +// CHECK: <fini_array.101> +#include <stdio.h> + +typedef void (*ctor_t)(void); +typedef void (*dtor_t)(void); + +__attribute__((constructor)) void init_array() { puts("<init_array>"); } + +__attribute__((constructor(101))) void init_array_101() { + puts("<init_array.101>"); +} + +__attribute__((constructor(102))) void init_array_102() { + puts("<init_array.102>"); +} +__attribute__((constructor(103))) void init_array_103() { + puts("<init_array.103>"); +} + +static void ctors(void) { puts("<ctors>"); } +__attribute__((section(".ctors"), used)) static ctor_t ctors_ptr = ctors; + +static void ctors_101(void) { puts("<ctors.101>"); } +__attribute__((section(".ctors.101"), used)) static ctor_t ctors_1_ptr = + ctors_101; + +static void ctors_102(void) { puts("<ctors.102>"); } +__attribute__((section(".ctors.102"), used)) static ctor_t ctors_2_ptr = + ctors_102; + +static void ctors_103(void) { puts("<ctors.103>"); } +__attribute__((section(".ctors.103"), used)) static ctor_t ctors_3_ptr = + ctors_103; + +__attribute__((destructor)) void fini_array() { puts("<fini_array>"); } + +__attribute__((destructor(101))) void fini_array_101() { + puts("<fini_array.101>"); +} + +__attribute__((destructor(102))) void fini_array_102() { + puts("<fini_array.102>"); +} + +__attribute__((destructor(103))) void fini_array_103() { + puts("<fini_array.103>"); +} + +static void dtors(void) { puts("<dtors>"); } +__attribute__((section(".dtors"), used)) static dtor_t dtors_ptr = dtors; + +static void dtors_101(void) { puts("<dtors.101>"); } +__attribute__((section(".dtors.101"), used)) static dtor_t dtors_1_ptr = + dtors_101; + +static void dtors_102(void) { puts("<dtors.102>"); } +__attribute__((section(".dtors.102"), used)) static dtor_t dtors_2_ptr = + dtors_102; + +static void dtors_103(void) { puts("<dtors.103>"); } +__attribute__((section(".dtors.103"), used)) static dtor_t dtors_3_ptr = + dtors_103; + +int main(void) { return 0; } diff --git a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp index 6fdd23b..933997c 100644 --- a/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp +++ b/compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp @@ -24,10 +24,10 @@ // Check inline-8bit-counters // RUN: echo 'section "__sancov_cntrs"' > patterns.txt -// RUN: echo '%[0-9]\+ = load i8, ptr @__sancov_gen_' >> patterns.txt -// RUN: echo 'store i8 %[0-9]\+, ptr @__sancov_gen_' >> patterns.txt -// RUN: echo '%[0-9]\+ = load i8, ptr getelementptr (\[[0-9]\+ x i8\], ptr @__sancov_gen_' >> patterns.txt -// RUN: echo 'store i8 %[0-9]\+, ptr getelementptr (\[[0-9]\+ x i8\], ptr @__sancov_gen_' >> patterns.txt +// RUN: echo '%[0-9][0-9]* = load i8, ptr @__sancov_gen_' >> patterns.txt +// RUN: echo 'store i8 %[0-9][0-9]*, ptr @__sancov_gen_' >> patterns.txt +// RUN: echo '%[0-9][0-9]* = load i8, ptr getelementptr (\[[0-9][0-9]* x i8\], ptr @__sancov_gen_' >> patterns.txt +// RUN: echo 'store i8 %[0-9][0-9]*, ptr getelementptr (\[[0-9][0-9]* x i8\], ptr @__sancov_gen_' >> patterns.txt // Check indirect-calls // RUN: echo 'call void @__sanitizer_cov_trace_pc_indir' >> patterns.txt |
