Skip to content

Commit 1eabe78

Browse files
Merge pull request #23238 from aschwaighofer/test_for_tsan_coroutine_lowering_change
Add a test for the tsan co-routine lowering order change
2 parents fad6ba9 + 034ef7d commit 1eabe78

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/IRGen/tsan_coroutines.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// This test case used to crash when tsan ran before co-routine lowering.
2+
// RUN: %target-swift-frontend -emit-ir -sanitize=thread %s | %FileCheck %s
3+
4+
// TSan is currently only supported on 64 bit mac and simulators.
5+
// (We do not test the simulators here.)
6+
// REQUIRES: CPU=x86_64, OS=macosx
7+
8+
public class C { }
9+
10+
public struct Foobar {
11+
var things: [String: C] = [:]
12+
}
13+
14+
extension Foobar {
15+
public struct Index {
16+
fileprivate typealias MyIndex = Dictionary<String, C>.Values.Index
17+
18+
fileprivate let myIndex: MyIndex
19+
20+
fileprivate init(_ index: MyIndex) {
21+
self.myIndex = index
22+
}
23+
}
24+
25+
// We used to crash emitting the subscript function.
26+
// CHECK: define swiftcc { i8*, %T15tsan_coroutines1CC* } @"$s15tsan_coroutines6FoobarVyAA1CCAC5IndexVcir"
27+
@_borrowed
28+
public subscript(position: Index) -> C {
29+
return things.values[position.myIndex]
30+
}
31+
}

0 commit comments

Comments
 (0)