1 // ParamTLS has limited size. Everything that does not fit is considered fully
4 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -O0 %s -o %t && %run %t
5 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins -O0 %s -o %t && %run %t
6 // RUN: %clangxx_msan -fno-sanitize-memory-param-retval -fsanitize-memory-track-origins=2 -O0 %s -o %t && %run %t
8 // AArch64 and LoongArch64 fail with:
9 // void f801(S<801>): Assertion `__msan_test_shadow(&s, sizeof(s)) == -1' failed
10 // XFAIL: target={{(aarch64|loongarch64).*}}
11 // When passing huge structs by value, SystemZ uses pointers, therefore this
12 // test in its present form is unfortunately not applicable.
13 // ABI says: "A struct or union of any other size <snip>. Replace such an
14 // argument by a pointer to the object, or to a copy where necessary to enforce
15 // call-by-value semantics."
16 // XFAIL: target=s390x{{.*}}
18 #include <sanitizer/msan_interface.h>
21 // This test assumes that ParamTLS size is 800 bytes.
23 // This test passes poisoned values through function argument list.
24 // In case of overflow, argument is unpoisoned.
25 #define OVERFLOW(x) assert(__msan_test_shadow(&x, sizeof(x)) == -1)
26 // In case of no overflow, it is still poisoned.
27 #define NO_OVERFLOW(x) assert(__msan_test_shadow(&x, sizeof(x)) == 0)
29 #if defined(__x86_64__)
30 // In x86_64, if argument is partially outside tls, it is considered completely
32 #define PARTIAL_OVERFLOW(x) OVERFLOW(x)
34 // In other archs, bigger arguments are splitted in multiple IR arguments, so
35 // they are considered poisoned till tls limit. Checking last byte of such arg:
36 #define PARTIAL_OVERFLOW(x) assert(__msan_test_shadow((char *)(&(x) + 1) - 1, 1) == -1)
57 void f1000(S
<1000> s
) {
61 void f_many(int a
, double b
, S
<800> s
, int c
, double d
) {
69 // -8 bytes for "int a", aligned by 8
70 // -2 to make "int c" a partial fit
71 void f_many2(int a
, S
<800 - 8 - 2> s
, int c
, double d
) {
90 f_many(i
, d
, s800
, i
, d
);
93 f_many2(i
, s788
, i
, d
);