|
| 1 | +// RUN: %target-swift-frontend -O -emit-sil %s -verify |
| 2 | +// REQUIRES: asserts |
| 3 | + |
| 4 | +// TF-1126: Generic specialization crash during capture propagation. |
| 5 | +// Related to `@differentiable` function with `partial_apply` operands, |
| 6 | +// to be specialized. Occurs only with `-O`. |
| 7 | + |
| 8 | +struct A: Differentiable{ |
| 9 | + var b: SIMD8<Float> |
| 10 | +} |
| 11 | + |
| 12 | +@differentiable |
| 13 | +func function(a: A) -> A { |
| 14 | + var a = a |
| 15 | + a.b = a.b - SIMD8<Float>(repeating: 1.0) |
| 16 | + return a |
| 17 | +} |
| 18 | + |
| 19 | +let masks: [SIMD8<Float>] = [[1,0,0,0,0,0,0,0], |
| 20 | + [0,1,0,0,0,0,0,0], |
| 21 | + [0,0,1,0,0,0,0,0], |
| 22 | + [0,0,0,1,0,0,0,0], |
| 23 | + [0,0,0,0,1,0,0,0], |
| 24 | + [0,0,0,0,0,1,0,0], |
| 25 | + [0,0,0,0,0,0,1,0], |
| 26 | + [0,0,0,0,0,0,0,1]] |
| 27 | + |
| 28 | +extension SIMD8 where Scalar == Float{ |
| 29 | + @differentiable(where Scalar: Differentiable) |
| 30 | + func updated(at index: Int, with newValue: Scalar) -> Self { |
| 31 | + let mask = masks[index] |
| 32 | + let result = self - (self * mask) + (newValue * mask) |
| 33 | + return result |
| 34 | + } |
| 35 | +} |
| 36 | + |
| 37 | +// Looking for a function: $ss4SIMDPss14DifferentiableRzSB6Scalars11SIMDStoragePRpzsAA13TangentVectorsACPRpzSBAhI_AdFRPzrlE12_vjpSubtract3lhs3rhsx5value_AJ_AJtAJc8pullbacktx_xtFZs5SIMD8VySfG_Tg5 |
| 38 | +// Expected type: @convention(method) (@in_guaranteed SIMD8<Float>, @in_guaranteed SIMD8<Float>, @thick SIMD8<Float>.Type) -> (@out SIMD8<Float>, @owned @callee_guaranteed (@in_guaranteed SIMD8<Float>) -> (@out SIMD8<Float>, @out SIMD8<Float>)) |
| 39 | +// Found type: @convention(method) (SIMD8<Float>, SIMD8<Float>, @thick SIMD8<Float>.Type) -> (@out SIMD8<Float>, @owned @callee_guaranteed (@in_guaranteed SIMD8<Float>) -> (@out SIMD8<Float>, @out SIMD8<Float>)) |
| 40 | +// Assertion failed: (ReInfo.getSpecializedType() == SpecializedF->getLoweredFunctionType() && "Previously specialized function does not match expected type."), function lookupSpecialization, file /Users/swiftninjas/s4tf/swift/lib/SILOptimizer/Utils/Generics.cpp, line 1833. |
| 41 | +// Stack dump: |
| 42 | +// ... |
| 43 | +// 1. Swift version 5.2-dev (Swift bf631dc2e4) |
| 44 | +// 2. While running pass #113021 SILFunctionTransform "CapturePropagation" on SILFunction "@AD__$ss5SIMD8V6deleteSfRszrlE7updated2at4withABySfGSi_SftF__vjp_src_0_wrt_1_2". |
| 45 | +// for 'updated(at:with:)' (at /Users/porter/Dropbox (PassiveLogic)/Team/Team Members Scratch Space/Porter/Experiments/Playgrounds/delete/delete/main.swift:75:5) |
| 46 | +// llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37 |
| 47 | +// llvm::sys::RunSignalHandlers() + 85 |
| 48 | +// SignalHandler(int) + 278 |
| 49 | +// _sigtramp + 29 |
| 50 | +// _sigtramp + 2821162056 |
| 51 | +// abort + 127 |
| 52 | +// basename_r + 0 |
| 53 | +// swift::GenericFuncSpecializer::lookupSpecialization() (.cold.1) + 35 |
| 54 | +// swift::GenericFuncSpecializer::lookupSpecialization() + 2109 |
| 55 | +// (anonymous namespace)::CapturePropagation::optimizePartialApply(swift::PartialApplyInst*) + 1301 |
| 56 | +// (anonymous namespace)::CapturePropagation::run() + 265 |
0 commit comments