Skip to content

Commit ed54515

Browse files
committed
Add a test for the tsan co-routine lowering order change
rdar://48719789
1 parent 7302b6f commit ed54515

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/IRGen/tsan_coroutines.swift

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
public class C { }
5+
6+
public struct Foobar {
7+
var things: [String: C] = [:]
8+
}
9+
10+
extension Foobar {
11+
public struct Index {
12+
fileprivate typealias MyIndex = Dictionary<String, C>.Values.Index
13+
14+
fileprivate let myIndex: MyIndex
15+
16+
fileprivate init(_ index: MyIndex) {
17+
self.myIndex = index
18+
}
19+
}
20+
21+
// We used to crash emitting the subscript function.
22+
// CHECK: define swiftcc { i8*, %T15tsan_coroutines1CC* } @"$s15tsan_coroutines6FoobarVyAA1CCAC5IndexVcir"
23+
@_borrowed
24+
public subscript(position: Index) -> C {
25+
return things.values[position.myIndex]
26+
}
27+
}

0 commit comments

Comments
 (0)