Skip to content

Commit 31df4af

Browse files
committed
Add an execution test case for a failure caused by LLVM's shrink wrapping
The issue was fixed in llvm/llvm-project/pull/73945 rdar://117925937
1 parent d270dad commit 31df4af

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/Concurrency/ShrinkWrap.swift

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift -Xfrontend -disable-availability-checking -O %s -o %t/main
3+
// RUN: %target-codesign %t/main
4+
// RUN: %target-run %t/main | %FileCheck %s
5+
6+
// REQUIRES: executable_test
7+
// REQUIRES: concurrency
8+
9+
// CHECK: Setting field Field(rawValue: "fxxxxxxx/0")
10+
// CHECK: Setting field Field(rawValue: "fxxxxxxx/1")
11+
// CHECK: Setting field Field(rawValue: "fxxxxxxx/2")
12+
// CHECK: Setting field Field(rawValue: "fxxxxxxx/3")
13+
14+
internal struct Field: Equatable, Hashable, Sendable {
15+
internal var rawValue: String
16+
17+
internal static var c0: Field { Field(rawValue: "fxxxxxxx/0") }
18+
internal static var c1: Field { Field(rawValue: "fxxxxxxx/1") }
19+
internal static var c2: Field { Field(rawValue: "fxxxxxxx/2") }
20+
internal static var c3: Field { Field(rawValue: "fxxxxxxx/3") }
21+
22+
internal static func c(_ c: Int) -> Field {
23+
switch c {
24+
case 0: return self.c0
25+
case 1: return self.c1
26+
case 2: return self.c2
27+
case 3: return self.c3
28+
default:
29+
preconditionFailure("Only 0..<4 are valid")
30+
}
31+
}
32+
}
33+
34+
internal actor A {
35+
@inline(never)
36+
internal func set(_ field: Field) async throws {
37+
print("Setting field \(field)")
38+
}
39+
}
40+
41+
func doit() async throws {
42+
let a = A()
43+
for c in 0..<Int(4) {
44+
try await Task.sleep(nanoseconds: 50_000_000)
45+
try await a.set(.c(c))
46+
}
47+
}
48+
49+
try await doit()

0 commit comments

Comments
 (0)