|
| 1 | +// RUN: %target-swift-frontend -emit-sil %s -verify |
| 2 | +// REQUIRES: asserts |
| 3 | + |
| 4 | +// TF-1159: `begin_borrow` instruction unhandled in the |
| 5 | +// `reapplyFunctionConversion` helper function. |
| 6 | + |
| 7 | +func id<T>(_ x: T) -> T { x } |
| 8 | + |
| 9 | +@differentiable |
| 10 | +func TF_1159(_ x: Float) -> Float { |
| 11 | + // Note: code below generates `partial_apply` and `begin_borrow`. |
| 12 | + let fn: (Float) -> Float = id |
| 13 | + return fn(x) |
| 14 | +} |
| 15 | + |
| 16 | +// Unhandled function conversion instruction |
| 17 | +// UNREACHABLE executed at swift/lib/SILOptimizer/Mandatory/Differentiation.cpp:433! |
| 18 | +// Stack dump: |
| 19 | +// ... |
| 20 | +// 1. Swift version 5.2-dev (Swift 415d33b3f1) |
| 21 | +// 2. While running pass #27 SILModuleTransform "Differentiation". |
| 22 | +// 3. While canonicalizing `differentiable_function` SIL node %12 = differentiable_function [parameters 0] %10 : $@callee_guaranteed (Float) -> Float // users: %17, %13 |
| 23 | +// 4. While ...in SIL function "@AD__$s4main3fooyS2fF__vjp_src_0_wrt_0". |
| 24 | +// for 'foo(_:)' (at tf-1159.swift:4:1) |
| 25 | +// 0 swift 0x0000000107b15105 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37 |
| 26 | +// 1 swift 0x0000000107b14078 llvm::sys::RunSignalHandlers() + 248 |
| 27 | +// 2 swift 0x0000000107b15706 SignalHandler(int) + 278 |
| 28 | +// 3 libsystem_platform.dylib 0x00007fff68ed2b5d _sigtramp + 29 |
| 29 | +// 4 libsystem_platform.dylib 0x0000000000000053 _sigtramp + 2534593811 |
| 30 | +// 5 libsystem_c.dylib 0x00007fff68d8c6a6 abort + 127 |
| 31 | +// 6 swift 0x0000000108dcc09e llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 462 |
| 32 | +// 7 swift 0x0000000104047ec2 reapplyFunctionConversion(swift::autodiff::ADContext&, swift::SILValue, swift::SILValue, swift::SILValue, swift::SILBuilder&, swift::SILLocation, llvm::SmallVectorImpl<swift::AllocStackInst*>&, swift::IndexSubset*, swift::GenericSignature) + 1506 |
| 33 | +// 8 swift 0x000000010402d5c0 (anonymous namespace)::DifferentiationTransformer::promoteToDifferentiableFunction(swift::DifferentiableFunctionInst*, swift::SILBuilder&, swift::SILLocation, swift::autodiff::DifferentiationInvoker) + 8880 |
| 34 | +// 9 swift 0x00000001040292ea (anonymous namespace)::DifferentiationTransformer::processDifferentiableFunctionInst(swift::DifferentiableFunctionInst*) + 426 |
| 35 | +// 10 swift 0x0000000104026b06 (anonymous namespace)::Differentiation::run() + 1174 |
0 commit comments