1 // RUN: %clangxx %s -O1 -o %t -fexperimental-sanitize-metadata=covered,uar && %t | FileCheck %s
2 // RUN: %clangxx %s -O1 -o %t -fexperimental-sanitize-metadata=covered,uar -fsanitize=address,signed-integer-overflow,alignment && %t | FileCheck %s
3 // RUN: %clangxx %s -O1 -o %t -mcmodel=large -fexperimental-sanitize-metadata=covered,uar -fsanitize=address,signed-integer-overflow,alignment && %t | FileCheck %s
5 // CHECK: metadata add version 2
7 __attribute__((noinline
, not_tail_called
)) void escape(const volatile void *p
) {
8 [[maybe_unused
]] static const volatile void *sink
;
12 __attribute__((noinline
, not_tail_called
)) void use(int x
) {
13 static volatile int sink
;
17 // CHECK: empty: features=0 stack_args=0
20 // CHECK: simple: features=0 stack_args=0
21 int simple(int *data
, int index
) { return data
[index
+ 1]; }
23 // CHECK: builtins: features=0 stack_args=0
26 __builtin_prefetch(&x
);
30 // CHECK: ellipsis: features=0 stack_args=0
31 void ellipsis(const char *fmt
, ...) {
36 // CHECK: non_empty_function: features=2 stack_args=0
37 void non_empty_function() {
42 // CHECK: no_stack_args: features=2 stack_args=0
43 void no_stack_args(long a0
, long a1
, long a2
, long a3
, long a4
, long a5
) {
48 // CHECK: stack_args: features=6 stack_args=16
49 void stack_args(long a0
, long a1
, long a2
, long a3
, long a4
, long a5
, long a6
) {
54 // CHECK: more_stack_args: features=6 stack_args=32
55 void more_stack_args(long a0
, long a1
, long a2
, long a3
, long a4
, long a5
,
56 long a6
, long a7
, long a8
) {
61 // CHECK: struct_stack_args: features=6 stack_args=144
65 void struct_stack_args(large a
) {
70 __attribute__((noinline
)) int tail_called(int x
) { return x
; }
72 // CHECK: with_tail_call: features=2
73 int with_tail_call(int x
) { [[clang::musttail
]] return tail_called(x
); }
75 __attribute__((noinline
, noreturn
)) int noreturn(int x
) { __builtin_trap(); }
77 // CHECK: with_noreturn_tail_call: features=0
78 int with_noreturn_tail_call(int x
) { return noreturn(x
); }
80 // CHECK: local_array: features=0
81 void local_array(int x
) {
86 // CHECK: local_alloca: features=0
87 void local_alloca(int size
, int i
, int j
) {
88 volatile int *p
= static_cast<int *>(__builtin_alloca(size
));
93 // CHECK: escaping_alloca: features=2
94 void escaping_alloca(int size
, int i
) {
95 volatile int *p
= static_cast<int *>(__builtin_alloca(size
));
104 FN(non_empty_function); \
107 FN(more_stack_args); \
108 FN(struct_stack_args); \
109 FN(with_tail_call); \
110 FN(with_noreturn_tail_call); \
113 FN(escaping_alloca); \