Skip to content

Commit 2ea4316

Browse files
authored
[AutoDiff] Add SR-12656 negative test. (swiftlang#31673)
Add negative test for SR-12656: differentiation transform crash for opaque result types.
1 parent c70dce0 commit 2ea4316

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: not --crash %target-swift-frontend -disable-availability-checking -emit-sil -verify %s
2+
// REQUIRES: asserts
3+
4+
// SR-12656: Differentiation transform crashes for original function with opaque
5+
// result type.
6+
//
7+
// If supporting this is non-trivial, we could reject earlier during Sema.
8+
9+
import _Differentiation
10+
11+
@differentiable
12+
func opaqueResult(_ x: Float) -> some Differentiable { x }
13+
14+
// swift: swift/lib/SILOptimizer/Differentiation/PullbackEmitter.cpp:244: void swift::autodiff::PullbackEmitter::addAdjointValue(swift::SILBasicBlock *, swift::SILValue, swift::autodiff::AdjointValue, swift::SILLocation): Assertion `newAdjointValue.getType() == getRemappedTangentType(originalValue->getType())' failed.
15+
// Stack dump:
16+
// ...
17+
// 1. Swift version 5.3-dev (LLVM f66b332548, Swift 05c47da664)
18+
// 2. While evaluating request ExecuteSILPipelineRequest(Run pipelines { Guaranteed Passes } on SIL for main.main)
19+
// 3. While running pass #15 SILModuleTransform "Differentiation".
20+
// 4. While processing // differentiability witness for opaqueResult(_:)
21+
// sil_differentiability_witness hidden [parameters 0] [results 0] @$s4main12opaqueResultyQrSfF : $@convention(thin) (Float) -> @out @_opaqueReturnTypeOf("$s4main12opaqueResultyQrSfF", 0) 🦸 {
22+
// }
23+
// on SIL function "@$s4main12opaqueResultyQrSfF".
24+
// for 'opaqueResult(_:)' (at swift/test/AutoDiff/compiler_crashers/sr12656-differentiation-opaque-result-type.swift:13:1)
25+
// 5. While generating VJP for SIL function "@$s4main12opaqueResultyQrSfF".
26+
// for 'opaqueResult(_:)' (at swift/test/AutoDiff/compiler_crashers/sr12656-differentiation-opaque-result-type.swift:13:1)
27+
// 6. While generating pullback for SIL function "@$s4main12opaqueResultyQrSfF".
28+
// for 'opaqueResult(_:)' (at swift/test/AutoDiff/compiler_crashers/sr12656-differentiation-opaque-result-type.swift:13:1)

0 commit comments

Comments
 (0)