Files
swift-mirror/test/IRGen/tsan-attributes.swift
Julian Lettner 105e4ad592 [TSan] Add positive test for TSan + Dispatch on Linux
1) Enable tests that use `import Dispatch` on Linux. Add substitution
   `%import-libdispatch` that needs to be used for all cross-platform
   tests (i.e., tests that are intended to be run on other platforms
   than Darwin) that do `import Dispatch` or enable thread sanitizer.

2) Make sure as many existing Dispatch and TSan tests as possible run on
   Linux. Mark tests that would require substantial work with
   `UNSUPPORTED: OS=linux-gnu`.

3) Add integration-style Swift test that shows that TSan finds a simple
   race when using `Dispatch.async` incorrectly. A more complete test
   suite for TSan's libdispatch support lives on the LLVM/compiler-rt
   side.

rdar://problem/49177535
2019-06-10 14:24:53 -07:00

26 lines
625 B
Swift

// This test verifies that we add the function attributes used by TSan.
// RUN: %target-swift-frontend -emit-ir -sanitize=thread %s | %FileCheck %s -check-prefix=TSAN
// TSan is only supported on 64 bit.
// REQUIRES: PTRSIZE=64
// TSAN: define {{.*}} @"$s4main4testyyF"() [[DEFAULT_ATTRS:#[0-9]+]]
public func test() {
}
// TSAN: define {{.*}} @"$s4main1xSivr"({{.*}}) [[COROUTINE_ATTRS:#[0-9]+]]
public var x: Int {
_read {
yield 0
}
}
// TSAN: attributes [[DEFAULT_ATTRS]] =
// TSAN-SAME: sanitize_thread
// TSAN-SAME: }
// TSAN: attributes [[COROUTINE_ATTRS]] =
// TSAN-SAME: sanitize_thread
// TSAN-SAME: }