Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / speculative_load2.cpp
blob51051eb2b75b1e813a9204d387af6b927d8bd410
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 typedef union {
8 short q;
9 struct {
10 short x;
11 short y;
12 int for_alignment;
13 } w;
14 } U;
16 int main() {
17 char *buf = new char[2];
18 buf[0] = buf[1] = 0x0;
19 U *u = (U *)buf;
20 short result = u->q == 0 ? 0 : u->w.y;
21 delete[] buf;
22 return result;