Skip to content

Commit 1d4ba59

Browse files
authored
[AutoDiff] Add negative test for SR-12641. (#31207)
Add negative test exposing SR-12641: SILGen verification error regarding reabstraction thunking for `@differentiable` functions.
1 parent a41a2ff commit 1d4ba59

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// RUN: not --crash %target-swift-frontend -emit-sil -verify %s
2+
// REQUIRES: asserts
3+
4+
// SR-12641: SILGen verification error regarding `ImmutableAddressUseVerifier` and AutoDiff-generated code.
5+
6+
import _Differentiation
7+
import DifferentiationUnittest
8+
9+
class Class: Differentiable {
10+
var x: Tracked<Float>
11+
init(_ x: Tracked<Float>) {
12+
self.x = x
13+
}
14+
}
15+
16+
func getter(_ c: Class) -> Tracked<Float> {
17+
return c.x
18+
}
19+
_ = gradient(at: Class(10), in: getter)
20+
21+
// Assertion failed: (conv.isIndirectConvention() && "Expect an indirect convention"), function isConsumingOrMutatingArgumentConvention, file swift/lib/SIL/Verifier/SILVerifier.cpp, line 453.
22+
// Stack dump:
23+
// ...
24+
// 1. Swift version 5.3-dev (LLVM ca0260ddec, Swift b17e1b23fe)
25+
// 2. While evaluating request SILGenWholeModuleRequest(SIL Generation for module main)
26+
// 3. While verifying SIL function "@$s4main5ClassC13TangentVectorV23DifferentiationUnittest7TrackedVySfGIeggr_AeIIegnr_TR".
27+
// for <<debugloc at "<compiler-generated>":0:0>>0 swift 0x000000010d6b4138 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
28+
// 1 swift 0x000000010d6b30b8 llvm::sys::RunSignalHandlers() + 248
29+
// 2 swift 0x000000010d6b472d SignalHandler(int) + 285
30+
// 3 libsystem_platform.dylib 0x00007fff718335fd _sigtramp + 29
31+
// 4 libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603338611739168
32+
// 5 libsystem_c.dylib 0x00007fff71709808 abort + 120
33+
// 6 libsystem_c.dylib 0x00007fff71708ac6 err + 0
34+
// 7 swift 0x000000010da31c23 (anonymous namespace)::ImmutableAddressUseVerifier::isConsumingOrMutatingApplyUse(swift::Operand*) (.cold.4) + 35
35+
// 8 swift 0x0000000109c74d11 (anonymous namespace)::ImmutableAddressUseVerifier::isConsumingOrMutatingApplyUse(swift::Operand*) + 289
36+
// 9 swift 0x0000000109c73c1d (anonymous namespace)::ImmutableAddressUseVerifier::isMutatingOrConsuming(swift::SILValue) + 157
37+
// 10 swift 0x0000000109c5cea9 (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) + 1161

0 commit comments

Comments
 (0)