Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / ubsan / TestCases / Misc / builtins.cpp
blobf8f564cb7baae2c808304de997924862e4f74024
1 // REQUIRES: target={{x86_64.*}}
2 //
3 // RUN: %clangxx -fsanitize=builtin -w %s -O3 -o %t
4 // RUN: %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
5 // RUN: %clangxx -fsanitize=builtin -fno-sanitize-recover=builtin -w %s -O3 -o %t.abort
6 // RUN: not %run %t.abort 2>&1 | FileCheck %s --check-prefix=ABORT
8 void check_ctz(int n) {
9 // ABORT: builtins.cpp:[[@LINE+2]]:17: runtime error: passing zero to ctz(), which is not a valid argument
10 // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to ctz(), which is not a valid argument
11 __builtin_ctz(n);
13 // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to ctz(), which is not a valid argument
14 __builtin_ctzl(n);
16 // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to ctz(), which is not a valid argument
17 __builtin_ctzll(n);
20 void check_clz(int n) {
21 // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to clz(), which is not a valid argument
22 __builtin_clz(n);
24 // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to clz(), which is not a valid argument
25 __builtin_clzl(n);
27 // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to clz(), which is not a valid argument
28 __builtin_clzll(n);
31 int main() {
32 check_ctz(0);
33 check_clz(0);
34 return 0;