brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 3e7527c Raw
62 lines · plain
1; This test checks that we are not instrumenting unwanted acesses to globals:2; - Instructions with the !nosanitize metadata (e.g. -fprofile-arcs instrumented counter accesses)3; - Instruction profiler counter instrumentation has known intended races.4;5; RUN: opt < %s -passes='function(tsan),module(tsan-module)' -S | FileCheck %s6 7target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"8target triple = "x86_64-apple-macosx10.9"9 10@__profc_test_gep = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 811@__profc_test_bitcast = private global [2 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 812@__profc_test_bitcast_foo = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 813 14@__llvm_gcov_ctr = internal global [1 x i64] zeroinitializer15@__llvm_gcov_ctr.1 = internal global [1 x i64] zeroinitializer16@__llvm_gcov_global_state_pred = internal global i32 017@__llvm_gcda_foo = internal global i32 018 19define i32 @test_gep() sanitize_thread {20entry:21  %pgocount = load i64, ptr @__profc_test_gep, !nosanitize !022  %0 = add i64 %pgocount, 123  store i64 %0, ptr @__profc_test_gep, !nosanitize !024 25  %gcovcount = load i64, ptr @__llvm_gcov_ctr, !nosanitize !026  %1 = add i64 %gcovcount, 127  store i64 %1, ptr @__llvm_gcov_ctr, !nosanitize !028 29  %gcovcount.1 = load i64, ptr @__llvm_gcov_ctr.1, !nosanitize !030  %2 = add i64 %gcovcount.1, 131  store i64 %2, ptr @__llvm_gcov_ctr.1, !nosanitize !032 33  ret i32 134}35 36define i32 @test_bitcast() sanitize_thread {37entry:38  %0 = load <2 x i64>, ptr @__profc_test_bitcast, align 8, !nosanitize !039  %.promoted5 = load i64, ptr @__profc_test_bitcast_foo, align 8, !nosanitize !040  %1 = add i64 %.promoted5, 1041  %2 = add <2 x i64> %0, <i64 1, i64 10>42  store <2 x i64> %2, ptr @__profc_test_bitcast, align 8, !nosanitize !043  store i64 %1, ptr @__profc_test_bitcast_foo, align 8, !nosanitize !044  ret i32 undef45}46 47define void @test_load() sanitize_thread {48entry:49  %0 = load i32, ptr @__llvm_gcov_global_state_pred, !nosanitize !050  store i32 1, ptr @__llvm_gcov_global_state_pred, !nosanitize !051 52  %1 = load i32, ptr @__llvm_gcda_foo, !nosanitize !053  store i32 1, ptr @__llvm_gcda_foo, !nosanitize !054 55  ret void56}57 58!0 = !{}59 60; CHECK-NOT: {{call void @__tsan_write}}61; CHECK: __tsan_init62