1*9880d681SAndroid Build Coastguard Worker; This test checks that we are not instrumenting unwanted acesses to globals: 2*9880d681SAndroid Build Coastguard Worker; - Instruction profiler counter instrumentation has known intended races. 3*9880d681SAndroid Build Coastguard Worker; - The gcov counters array has a known intended race. 4*9880d681SAndroid Build Coastguard Worker; 5*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -tsan -S | FileCheck %s 6*9880d681SAndroid Build Coastguard Worker 7*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 8*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-macosx10.9" 9*9880d681SAndroid Build Coastguard Worker 10*9880d681SAndroid Build Coastguard Worker@__profc_test_gep = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 11*9880d681SAndroid Build Coastguard Worker@__profc_test_bitcast = private global [2 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 12*9880d681SAndroid Build Coastguard Worker@__profc_test_bitcast_foo = private global [1 x i64] zeroinitializer, section "__DATA,__llvm_prf_cnts", align 8 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker@__llvm_gcov_ctr = internal global [1 x i64] zeroinitializer 15*9880d681SAndroid Build Coastguard Worker@__llvm_gcov_ctr.1 = internal global [1 x i64] zeroinitializer 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Workerdefine i32 @test_gep() sanitize_thread { 18*9880d681SAndroid Build Coastguard Workerentry: 19*9880d681SAndroid Build Coastguard Worker %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test_gep, i64 0, i64 0) 20*9880d681SAndroid Build Coastguard Worker %0 = add i64 %pgocount, 1 21*9880d681SAndroid Build Coastguard Worker store i64 %0, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test_gep, i64 0, i64 0) 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard Worker %gcovcount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_gcov_ctr, i64 0, i64 0) 24*9880d681SAndroid Build Coastguard Worker %1 = add i64 %gcovcount, 1 25*9880d681SAndroid Build Coastguard Worker store i64 %1, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_gcov_ctr, i64 0, i64 0) 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard Worker %gcovcount.1 = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_gcov_ctr.1, i64 0, i64 0) 28*9880d681SAndroid Build Coastguard Worker %2 = add i64 %gcovcount.1, 1 29*9880d681SAndroid Build Coastguard Worker store i64 %2, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__llvm_gcov_ctr.1, i64 0, i64 0) 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Worker ret i32 1 32*9880d681SAndroid Build Coastguard Worker} 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Workerdefine i32 @test_bitcast() sanitize_thread { 35*9880d681SAndroid Build Coastguard Workerentry: 36*9880d681SAndroid Build Coastguard Worker %0 = load <2 x i64>, <2 x i64>* bitcast ([2 x i64]* @__profc_test_bitcast to <2 x i64>*), align 8 37*9880d681SAndroid Build Coastguard Worker %.promoted5 = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test_bitcast_foo, i64 0, i64 0), align 8 38*9880d681SAndroid Build Coastguard Worker %1 = add i64 %.promoted5, 10 39*9880d681SAndroid Build Coastguard Worker %2 = add <2 x i64> %0, <i64 1, i64 10> 40*9880d681SAndroid Build Coastguard Worker store <2 x i64> %2, <2 x i64>* bitcast ([2 x i64]* @__profc_test_bitcast to <2 x i64>*), align 8 41*9880d681SAndroid Build Coastguard Worker store i64 %1, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_test_bitcast_foo, i64 0, i64 0), align 8 42*9880d681SAndroid Build Coastguard Worker ret i32 undef 43*9880d681SAndroid Build Coastguard Worker} 44*9880d681SAndroid Build Coastguard Worker 45*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: {{call void @__tsan_write}} 46*9880d681SAndroid Build Coastguard Worker; CHECK: __tsan_init 47