You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apple Swift version 5.4-dev (LLVM 0eb4a6165bbbce5, Swift 288a0db849d8506)
Target: x86_64-apple-darwin20.3.0
Additional Detail from JIRA
Votes
1
Component/s
Compiler
Labels
Bug, AutoDiff
Assignee
pgp (JIRA)
Priority
Medium
md5: 4bd8592e77d009035310c80a5fd2e9bc
relates to:
SR-14298 [AutoDiff] SIL verification failed: non-contiguous lexical scope at -Onone
Issue Description:
Hello,
I don't have much experience filing Swift compiler bugs so please, excuse me if this is a duplicate. I tried searching for the keywords here but no dice. Closest match I could find is SR-8114 but it is marked as resolved.
The following code fails to compile:
import _Differentiation
letvalues:[[Double]]=[[0,0],[0,0]]letconst= 1.12345
letresult=add(const, to: values)@differentiable(reverse)func add(_ const:Double, to values:[[Double]])->[[Double]]{varresult= values
for i in withoutDerivative(at: values.indices){
for j in withoutDerivative(at: values.indices){
result.updated(at: i, j, with:values[i][j]+ const)}}return result
}extensionArraywhere Element ==[Double]{@differentiable(reverse)mutatingfunc updated(at i:Int, _ j:Int, with newValue:Double){self[i][j]= newValue
}@derivative(of: updated)mutatingfunc vjpUpdated(at i:Int, _ j:Int, with newValue:Double)->(value:Void, pullback:(inoutTangentVector)->(Double.TangentVector)){self.updated(at: i, j, with: newValue)func pullback(dSelf:inoutTangentVector)->(Double.TangentVector){letdElement=dSelf[i][j]
dSelf.base[i].base[j]=0return dElement
}letvalue:Void=()return(value, pullback)}}
This is the error message when running swiftc main.swift. The full output is attached.
SIL verification failed: Basic block contains a non-contiguous lexical scope at -Onone: DS == LastSeenScope
Verifying instruction:
**%360** = destructure_struct %359 : $_AD__$s4main3add_2toSaySaySdGGSd_AEtF_bb2__PB__src_0_wrt_0_1 // user: %370
-> switch_enum %360 : $_AD__$s4main3add_2toSaySaySdGGSd_AEtF_bb2__Pred__src_0_wrt_0_1, case #_AD__$s4main3add_2toSaySaySdGGSd_AEtF_bb2__Pred__src_0_wrt_0_1.bb1!enumelt: bb1 // id: %370
In function:
...
I've also noticed two things that may be helpful. First, differentiating a version of the code that uses a 1D array, i.e. [Double], works fine. And second, turning on the optimization, i.e. the `-O` flag works fine as well.
The text was updated successfully, but these errors were encountered:
Attachment: Download
Environment
Development snapshot from 2/24 on macOS 11.2.2:
Additional Detail from JIRA
md5: 4bd8592e77d009035310c80a5fd2e9bc
relates to:
Issue Description:
Hello,
I don't have much experience filing Swift compiler bugs so please, excuse me if this is a duplicate. I tried searching for the keywords here but no dice. Closest match I could find is SR-8114 but it is marked as resolved.
The following code fails to compile:
This is the error message when running
swiftc main.swift
. The full output is attached.I've also noticed two things that may be helpful. First, differentiating a version of the code that uses a 1D array, i.e.
[Double]
, works fine. And second, turning on the optimization, i.e. the `-O` flag works fine as well.The text was updated successfully, but these errors were encountered: