brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 92abe4f Raw
124 lines · cpp
1// RUN: %clangxx %s -o %t && %t | FileCheck %s2// RUN: %clangxx %s -o %t -fexperimental-sanitize-metadata=covered && %t | FileCheck -check-prefix=CHECK-C %s3// RUN: %clangxx %s -o %t -fexperimental-sanitize-metadata=atomics && %t | FileCheck -check-prefix=CHECK-A %s4// RUN: %clangxx %s -o %t -fexperimental-sanitize-metadata=uar && %t | FileCheck -check-prefix=CHECK-U %s5// RUN: %clangxx %s -o %t -fexperimental-sanitize-metadata=covered,atomics && %t | FileCheck -check-prefix=CHECK-CA %s6// RUN: %clangxx %s -o %t -fexperimental-sanitize-metadata=covered,uar && %t | FileCheck -check-prefix=CHECK-CU %s7// RUN: %clangxx %s -o %t -fexperimental-sanitize-metadata=atomics,uar && %t | FileCheck -check-prefix=CHECK-AU %s8// RUN: %clangxx %s -o %t -fexperimental-sanitize-metadata=covered,atomics,uar && %t | FileCheck -check-prefix=CHECK-CAU %s9// RUN: %clangxx %s -o %t -mcmodel=large -fexperimental-sanitize-metadata=covered,atomics,uar && %t | FileCheck -check-prefix=CHECK-CAU %s10 11const int const_global = 42;12 13__attribute__((noinline, not_tail_called)) void escape(const volatile void *p) {14  [[maybe_unused]] static const volatile void *sink;15  sink = p;16}17 18// CHECK-NOT: metadata add19// CHECK: main20// CHECK-NOT: metadata del21 22// CHECK-C:      empty: features=023// CHECK-A-NOT:  empty:24// CHECK-U-NOT:  empty:25// CHECK-CA:     empty: features=026// CHECK-CU:     empty: features=027// CHECK-AU-NOT: empty:28// CHECK-CAU:    empty: features=029void empty() {}30 31// CHECK-C:  normal: features=032// CHECK-A:  normal: features=133// CHECK-U:  normal: features=234// CHECK-CA: normal: features=135// CHECK-CU: normal: features=236// CHECK-AU: normal: features=337// CHECK-CAU:normal: features=338void normal() {39  int x;40  escape(&x);41}42 43// CHECK-C:      with_const_global: features=044// CHECK-A-NOT:  with_const_global:45// CHECK-U-NOT:  with_const_global:46// CHECK-CA:     with_const_global: features=047// CHECK-CU:     with_const_global: features=048// CHECK-AU-NOT: with_const_global:49// CHECK-CAU:    with_const_global: features=050int with_const_global() { return *((const volatile int *)&const_global); }51 52// CHECK-C:     with_atomic: features=053// CHECK-A:     with_atomic: features=154// CHECK-U-NOT: with_atomic:55// CHECK-CA:    with_atomic: features=156// CHECK-CU:    with_atomic: features=057// CHECK-AU:    with_atomic: features=158// CHECK-CAU:   with_atomic: features=159int with_atomic(int *p) { return __atomic_load_n(p, __ATOMIC_RELAXED); }60 61// CHECK-C:   with_atomic_escape: features=062// CHECK-A:   with_atomic_escape: features=163// CHECK-U:   with_atomic_escape: features=264// CHECK-CA:  with_atomic_escape: features=165// CHECK-CU:  with_atomic_escape: features=266// CHECK-AU:  with_atomic_escape: features=367// CHECK-CAU: with_atomic_escape: features=368int with_atomic_escape(int *p) {69  escape(&p);70  return __atomic_load_n(p, __ATOMIC_RELAXED);71}72 73// CHECK-C:   with_atomic_escape_lots_of_args: features=074// CHECK-A:   with_atomic_escape_lots_of_args: features=175// CHECK-U:   with_atomic_escape_lots_of_args: features=676// CHECK-CA:  with_atomic_escape_lots_of_args: features=177// CHECK-CU:  with_atomic_escape_lots_of_args: features=678// CHECK-AU:  with_atomic_escape_lots_of_args: features=779// CHECK-CAU: with_atomic_escape_lots_of_args: features=780long with_atomic_escape_lots_of_args(int *p, long a0, long a1, long a2, long a3,81                                     long a4, long a5, long a6) {82  escape(&p);83  return a0 + a1 + a2 + a3 + a4 + a5 + a6 +84         __atomic_load_n(p, __ATOMIC_RELAXED);85}86 87// CHECK-C:     ellipsis: features=088// CHECK-A:     ellipsis: features=189// CHECK-U-NOT: ellipsis:90// CHECK-CA:    ellipsis: features=191// CHECK-CU:    ellipsis: features=092// CHECK-AU:    ellipsis: features=193// CHECK-CAU:   ellipsis: features=194void ellipsis(int *p, ...) {95  escape(&p);96  [[maybe_unused]] volatile int x;97  x = 0;98}99 100// CHECK-C:     ellipsis_with_atomic: features=0101// CHECK-A:     ellipsis_with_atomic: features=1102// CHECK-U-NOT: ellipsis_with_atomic:103// CHECK-CA:    ellipsis_with_atomic: features=1104// CHECK-CU:    ellipsis_with_atomic: features=0105// CHECK-AU:    ellipsis_with_atomic: features=1106// CHECK-CAU:   ellipsis_with_atomic: features=1107int ellipsis_with_atomic(int *p, ...) {108  escape(&p);109  return __atomic_load_n(p, __ATOMIC_RELAXED);110}111 112#define FUNCTIONS                                                              \113  FN(empty);                                                                   \114  FN(normal);                                                                  \115  FN(with_const_global);                                                       \116  FN(with_atomic);                                                             \117  FN(with_atomic_escape);                                                      \118  FN(with_atomic_escape_lots_of_args);                                         \119  FN(ellipsis);                                                                \120  FN(ellipsis_with_atomic);                                                    \121  /**/122 123#include "common.h"124