Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / asan / TestCases / ill.cpp
blobd7b5350916719a9943da128b6091eae38f9e31b6
1 // Test the handle_sigill option.
2 //
3 // RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=0 not --crash %run %t 2>&1 | FileCheck %s --check-prefix=CHECK0
4 // RUN: %clangxx_asan %s -o %t && %env_asan_opts=handle_sigill=1 not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK1
5 // REQUIRES: x86-target-arch
7 #ifdef _WIN32
8 #include <windows.h>
9 #endif
11 int main(int argc, char **argv) {
12 #ifdef _WIN32
13 // Sometimes on Windows this test generates a WER fault dialog. Suppress that.
14 UINT new_flags = SEM_FAILCRITICALERRORS |
15 SEM_NOGPFAULTERRORBOX |
16 SEM_NOOPENFILEERRORBOX;
17 // Preserve existing error mode, as discussed at
18 // http://blogs.msdn.com/oldnewthing/archive/2004/07/27/198410.aspx
19 UINT existing_flags = SetErrorMode(new_flags);
20 SetErrorMode(existing_flags | new_flags);
21 #endif
23 if (argc)
24 __builtin_trap();
25 // Unreachable code to avoid confusing the Windows unwinder.
26 #ifdef _WIN32
27 SetErrorMode(0);
28 #endif
30 // CHECK0-NOT: ERROR: AddressSanitizer
31 // CHECK1: ERROR: AddressSanitizer: {{ILL|illegal-instruction}} on unknown address {{0x0*}}