1 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S                       -fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK
2 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S -fsanitize=address    -fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,ASAN
3 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S -fsanitize=bounds     -fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,BOUNDS
4 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S -fsanitize=memory     -fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,MSAN
5 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S -fsanitize=thread     -fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,TSAN
6 // RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S -fsanitize=undefined  -fsanitize-coverage=trace-pc,trace-cmp -o - -flegacy-pass-manager | FileCheck %s --check-prefixes=CHECK,UBSAN
7 //
8 // Host armv7 is currently unsupported: https://bugs.llvm.org/show_bug.cgi?id=46117
9 // UNSUPPORTED: armv7, armv7l, thumbv7, armv8l
10 // The same issue also occurs on a riscv32 host.
11 // XFAIL: riscv32
12 
13 int x[10];
14 
15 // CHECK-LABEL: define dso_local void @foo(
foo(int n)16 void foo(int n) {
17   // CHECK-DAG: call void @__sanitizer_cov_trace_pc
18   // CHECK-DAG: call void @__sanitizer_cov_trace_const_cmp
19   // ASAN-DAG: call void @__asan_report_store
20   // MSAN-DAG: call void @__msan_warning
21   // BOUNDS-DAG: call void @__ubsan_handle_out_of_bounds
22   // TSAN-DAG: call void @__tsan_func_entry
23   // UBSAN-DAG: call void @__ubsan_handle
24   if (n)
25     x[n] = 42;
26 }
27 // CHECK-LABEL: declare void
28