1 // RUN: %clang %s -target arm64-apple-darwin -emit-llvm -S -fsanitize-coverage=trace-pc-guard -mllvm -sanitizer-coverage-gated-trace-callbacks=1 -o - | FileCheck %s --check-prefixes=CHECK,GATED
2 // RUN: %clang %s -target arm64-apple-darwin -emit-llvm -S -fsanitize-coverage=trace-pc-guard -mllvm -sanitizer-coverage-gated-trace-callbacks=0 -o - | FileCheck %s --check-prefixes=CHECK,PLAIN
3 // RUN: not %clang %s -target arm64-apple-darwin -emit-llvm -S -fsanitize-coverage=trace-pc -mllvm -sanitizer-coverage-gated-trace-callbacks=1 -o /dev/null 2>&1 | FileCheck %s --check-prefixes=INCOMPATIBLE
4 // RUN: not %clang %s -target arm64-apple-darwin -emit-llvm -S -fsanitize-coverage=inline-8bit-counters -mllvm -sanitizer-coverage-gated-trace-callbacks=1 -o /dev/null 2>&1 | FileCheck %s --check-prefixes=INCOMPATIBLE
5 // RUN: not %clang %s -target arm64-apple-darwin -emit-llvm -S -fsanitize-coverage=inline-bool-flag -mllvm -sanitizer-coverage-gated-trace-callbacks=1 -o /dev/null 2>&1 | FileCheck %s --check-prefixes=INCOMPATIBLE
7 // Verify that we do not emit the __sancov_gate section for "plain" trace-pc-guard
8 // GATED: section "__DATA,__sancov_gate"
9 // PLAIN-NOT: section "__DATA,__sancov_gate"
11 // Produce an error for all incompatible sanitizer coverage modes.
12 // INCOMPATIBLE: error: 'sanitizer-coverage-gated-trace-callbacks' is only supported with trace-pc-guard
16 // CHECK: define{{.*}} void @foo
17 void foo(int n
, int m
) {
18 // COM: Verify that we're emitting the call to __sanitizer_cov_trace_pc_guard upon
19 // COM: checking the value of __sancov_should_track.
20 // GATED: [[VAL:%.*]] = load i64, {{.*}}@__sancov_should_track
21 // GATED-NOT: [[VAL:%.*]] = load i64, i64* @__sancov_should_track
22 // GATED-NEXT: [[CMP:%.*]] = icmp ne i64 [[VAL]], 0
23 // GATED-NEXT: br i1 [[CMP]], label %[[L_TRUE:.*]], label %[[L_FALSE:.*]], !prof [[WEIGHTS:!.+]]
25 // GATED-NEXT: call void @__sanitizer_cov_trace_pc_guard
26 // GATED: br i1 [[CMP]], label %[[L_TRUE_2:.*]], label %[[L_FALSE_2:.*]]
27 // GATED: [[L_TRUE_2]]:
28 // GATED-NEXT: call void @__sanitizer_cov_trace_pc_guard
29 // GATED: [[WEIGHTS]] = !{!"branch_weights", i32 1, i32 100000}
31 // COM: With the non-gated instrumentation, we should not emit the
32 // COM: __sancov_should_track global.
33 // PLAIN-NOT: __sancov_should_track
34 // But we should still be emitting the calls to the callback.
35 // PLAIN: call void @__sanitizer_cov_trace_pc_guard