]>
git.proxmox.com Git - rustc.git/blob - src/compiler-rt/test/asan/TestCases/speculative_load.cc
1 // Verifies that speculative loads from unions do not happen under asan.
2 // RUN: %clangxx_asan -O0 %s -o %t && %run %t 2>&1
3 // RUN: %clangxx_asan -O1 %s -o %t && %run %t 2>&1
4 // RUN: %clangxx_asan -O2 %s -o %t && %run %t 2>&1
5 // RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1
7 #include <sanitizer/asan_interface.h>
27 __asan_poison_memory_region(_data
._s
._ch
, 23);
30 bool is_long() const {
31 return _data
._s
._size
& 1;
34 const char* get_pointer() const {
35 return is_long() ? _data
._l
._ptr
: _data
._s
._ch
;
40 inline void side_effect(const void *arg
) {
41 __asm__
__volatile__("" : : "r" (arg
) : "memory");
44 int main(int argc
, char **argv
) {
46 side_effect(&s
); // optimizer is too smart otherwise
47 const char *ptr
= s
.get_pointer();
48 side_effect(ptr
); // force use ptr