summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-08-16 22:24:47 +0000
committerVedant Kumar <vsk@apple.com>2018-08-16 22:24:47 +0000
commitee6c233ae045f36f5bb5c7a8d14cfc9d41c634d0 (patch)
treef743e5d472f7bd629ce33757b8b837644a976f07 /llvm/test
parentada3f77e4420d30e7bf39e215763a66e1ebdbe97 (diff)
downloadbcm5719-llvm-ee6c233ae045f36f5bb5c7a8d14cfc9d41c634d0.tar.gz
bcm5719-llvm-ee6c233ae045f36f5bb5c7a8d14cfc9d41c634d0.zip
[InstrProf] Use atomic profile counter updates for TSan
Thread sanitizer instrumentation fails to skip all loads and stores to profile counters. This can happen if profile counter updates are merged: %.sink = phi i64* ... %pgocount5 = load i64, i64* %.sink %27 = add i64 %pgocount5, 1 %28 = bitcast i64* %.sink to i8* call void @__tsan_write8(i8* %28) store i64 %27, i64* %.sink To suppress TSan diagnostics about racy counter updates, make the counter updates atomic when TSan is enabled. If there's general interest in this mode it can be surfaced as a clang/swift driver option. Testing: check-{llvm,clang,profile} rdar://40477803 Differential Revision: https://reviews.llvm.org/D50867 llvm-svn: 339955
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll14
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll b/llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll
new file mode 100644
index 00000000000..7230a205dff
--- /dev/null
+++ b/llvm/test/Instrumentation/InstrProfiling/atomic-updates.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -S -instrprof -instrprof-atomic-counter-update-all | FileCheck %s
+
+target triple = "x86_64-apple-macosx10.10.0"
+
+@__profn_foo = hidden constant [3 x i8] c"foo"
+
+; CHECK-LABEL: define void @foo
+; CHECK-NEXT: atomicrmw add i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i64 0, i64 0), i64 1 monotonic
+define void @foo() {
+ call void @llvm.instrprof.increment(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @__profn_foo, i32 0, i32 0), i64 0, i32 1, i32 0)
+ ret void
+}
+
+declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
OpenPOWER on IntegriCloud