Skip to content

Commit b5118fd

Browse files
committed
[AutoDiff] Add negative test for SR-12641.
Add negative test exposing SR-12641: SILGen verification error regarding reabstraction thunking for `@differentiable` functions.
1 parent d49c83c commit b5118fd

File tree

1 file changed

+36
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)