[NFC][AArch64] Explicitly define undefined bits for instructions (#122129)
[llvm-project.git] / compiler-rt / test / ubsan / TestCases / Misc / builtins.cpp
blob2702065bce0678edd89f61adf78a364ca52b1d60
1 // REQUIRES: target={{x86_64.*}}
2 //
3 // RUN: %clangxx -fsanitize=builtin -fno-inline -w %s -O3 -o %t
4 // RUN: %run %t 2>&1 | FileCheck %s --check-prefix=RECOVER
5 // RUN: %clangxx -fsanitize=builtin -fno-inline -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 __builtin_ctz(), which is not a valid argument
10 // RECOVER: builtins.cpp:[[@LINE+1]]:17: runtime error: passing zero to __builtin_ctz(), which is not a valid argument
11 __builtin_ctz(n);
13 // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to __builtin_ctz(), which is not a valid argument
14 __builtin_ctzl(n);
16 // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to __builtin_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 __builtin_clz(), which is not a valid argument
22 __builtin_clz(n);
24 // RECOVER: builtins.cpp:[[@LINE+1]]:18: runtime error: passing zero to __builtin_clz(), which is not a valid argument
25 __builtin_clzl(n);
27 // RECOVER: builtins.cpp:[[@LINE+1]]:19: runtime error: passing zero to __builtin_clz(), which is not a valid argument
28 __builtin_clzll(n);
31 void check_assume(int n) {
32 // RECOVER: builtins.cpp:[[@LINE+1]]:20: runtime error: assumption is violated during execution
33 __builtin_assume(n);
36 void check_assume_attr(int n) {
37 // RECOVER: builtins.cpp:[[@LINE+1]]:25: runtime error: assumption is violated during execution
38 __attribute__((assume(n)));
41 int main() {
42 check_ctz(0);
43 check_clz(0);
44 check_assume(0);
45 check_assume_attr(0);
46 return 0;