-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Differentiating FFTW fftshift #1652
Comments
Can you paste the whole code to reproduce and error log? |
Certainly! Here is a simplified version of the full code that produces the error: using Enzyme, Pkg, UnPack, Plots, HDF5, LinearAlgebra, LineSearches, DSP, Optim, FFTW, SignalAnalysis, Statistics, Random, LaTeXStrings
Xd = ones(4,200000)
t = range(start=5,step=0.005,length=200000)
dt_data = 0.005
N_t_data = Int(500/dt_data)
X_1011 = transpose(Xd[:, 1:N_t_data])
ts = range(; start=0, step = dt_data, length=N_t_data)
ts = ts*2
# Y variables parameterization
function U_det(Xk, b0, b1, b2, b3)
U = b0 + b1*Xk + b2/10.0*Xk^2 + b3/100.0*Xk^3
return U
end
function U_p(Xk, b0, b1, b2, b3, e_tk)
U = U_det(Xk, b0, b1, b2, b3) + e_tk
return U
end
# dX rhs
function dXrhs(k, X, b0, b1, b2, b3, e_t)
dXk = - X[k - 1] * (X[k - 2] - X[k + 1]) - X[k] + F - U_p(X[k], b0, b1, b2, b3, e_t[k])
return dXk
end
# Euler step
function euler_step(model_struct)
@unpack N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, dX, dXm1, dXm2, e_t, e_tm1, sig_e_t, sig_e_tm1, X_array = model_struct
# Compute derivatives
dX[1] = - X[K] * (X[K - 1] - X[2]) - X[1] + F - U_p(X[1], b0, b1, b2, b3, e_t[1])
dX[2] = - X[1] * (X[K] - X[3]) - X[2] + F - U_p(X[2], b0, b1, b2, b3, e_t[2])
dX[K] = - X[K - 1] * (X[K - 2] - X[1]) - X[K] + F - U_p(X[K], b0, b1, b2, b3, e_t[K])
# Update X
X[1] += dt * dX[1]
X[2] += dt * dX[2]
X[K] += dt * dX[3]
for k = 3:K-1
dX[k] = dXrhs(k, X, b0, b1, b2, b3, e_t)
X[k] += dt * dX[k]
end
# Update dXs
dXm1[:] = dX[:]
dXm2[:] = dXm1[:]
@pack! model_struct = X, dX, dXm1, dXm2
return nothing
end
# AB-3 rhs
function adams_bashforth3(x, dt, dx, dxm1, dxm2)
rhs = x + dt * ((23/12) * dx
- (16/12) * dxm1
+ (5/12) * dxm2)
return rhs
end
# AB-3 step
function ab3_step(model_struct)
@unpack N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, dX, dXm1, dXm2, e_t, e_tm1, sig_e_t, sig_e_tm1, X_array = model_struct
# Compute derivatives
dX[1] = - X[K] * (X[K - 1] - X[2]) - X[1] + F - U_p(X[1], b0, b1, b2, b3, e_t[1])
dX[2] = - X[1] * (X[K] - X[3]) - X[2] + F - U_p(X[2], b0, b1, b2, b3, e_t[2])
dX[K] = - X[K - 1] * (X[K - 2] - X[1]) - X[K] + F - U_p(X[K], b0, b1, b2, b3, e_t[K])
# Update X
X[1] = adams_bashforth3(X[1], dt, dX[1], dXm1[1], dXm2[1])
X[2] = adams_bashforth3(X[2], dt, dX[2], dXm1[2], dXm2[2])
X[K] = adams_bashforth3(X[K], dt, dX[K], dXm1[K], dXm2[K])
for k = 3:K-1
dX[k] = dXrhs(k, X, b0, b1, b2, b3, e_t)
X[k] = adams_bashforth3(X[k], dt, dX[k], dXm1[k], dXm2[k])
end
# Update dXs
dXm1[:] = dX[:]
dXm2[:] = dXm1[:]
@pack! model_struct = X, dX, dXm1, dXm2
return nothing
end
# AR(1) process
function AR1(model_struct)
@unpack N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, dX, dXm1, dXm2, e_t, e_tm1, sig_e_t, sig_e_tm1, X_array = model_struct
for k = 1:K
sig_e_t[k] = sig1*abs(X[k]) + sig0
e_t[k] = sig_e_t[k]*(1-10^(-phi))*e_tm1[k]/sig_e_tm1[k] + sig_e_t[k]*sqrt(1 - (1-10^(-phi))^2)*randn()
end
# Update e_t, sig_e_t
e_tm1[:] = e_t[:]
sig_e_tm1[:] = sig_e_t[:]
@pack! model_struct = e_t, e_tm1, sig_e_t, sig_e_tm1
return nothing
end
mutable struct cost
# Model set-up parameters
N_t::Int64
dt::Float64
K::Int64
h::Float64
F::Float64
b::Float64
c::Float64
# Forecast control parameters
b0::Float64
b1::Float64
b2::Float64
b3::Float64
phi::Float64
sig0::Float64
sig1::Float64
# Variables
X::Vector{Float64}
dX::Vector{Float64}
dXm1::Vector{Float64}
dXm2::Vector{Float64}
# Random
e_t::Vector{Float64}
e_tm1::Vector{Float64}
sig_e_t::Vector{Float64}
sig_e_tm1::Vector{Float64}
# Data in time array
X_array::Matrix{Float64}
# Data
data::Matrix{Float64}
step_factor::Int64
# Objective function
J0::Float64
end
function init_cost(N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, data, step_factor, J0)
# Memory allocation
dX = zeros(Float64, K)
dXm1 = zeros(Float64, K)
dXm2 = zeros(Float64, K)
e_t = zeros(Float64, K)
e_tm1 = zeros(Float64, K)
sig_e_t = zeros(Float64, K) .+ sig0
sig_e_tm1 = zeros(Float64, K) .+ sig0
X_array = zeros(Float64, K, N_t+1)
# Construct initial L96 object
J0_L96 = cost(N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, dX, dXm1, dXm2,
e_t, e_tm1, sig_e_t, sig_e_tm1, X_array, data, step_factor, J0)
# Set intial conditions in X_array
J0_L96.X_array[:, 1] = J0_L96.X[:]
return J0_L96
end
function forward_model_cost(model_struct)
@unpack N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, dX,
dXm1, dXm2, e_t, e_tm1, sig_e_t, sig_e_tm1, X_array, data, step_factor, J0 = model_struct
js = 1:step_factor:N_t
for i in 1:2
AR1(model_struct)
euler_step(model_struct)
X_array[:, i+1] = X[:]
end
for i in 2:N_t
AR1(model_struct)
ab3_step(model_struct)
X_array[:, i+1] = X[:]
end
model_signal = X_array[2,1:5:N_t].-mean(X_array[2,1:5:N_t])
data_signal = data[2,:].-mean(data[2,:])
ff = fftshift(fft(model_signal))[1321:1681]
ffd = fftshift(fft(data_signal))[1321:1681]
f = log10.(abs2.(ff))
fd = log10.(abs2.(ffd))
misfit = f .- fd
J0 = J0 + dot(misfit, misfit)
@pack! model_struct = X_array, J0
return J0
end
# Data parameter
step_factor = 5
# Model parameters
N_t = 500000
dt = 0.001
K = 4
h = 5.
F = 20.
b = 25.
c = 25.
b0 = 5.4
b1 = 4.4
b2 = -4.3
b3 = 1.2
phi = 0.19
sig0 = 1.5
sig1 = 1.1
X = copy(Xd[:,1])
const data = X_1011'
# Initial conditions
J0 = 0.0
function adjoint_J0(model_struct)
@unpack N_t, dt, K = model_struct
@unpack data, step_factor, J0 = model_struct
adjoint_vars = init_cost(
N_t, dt,
K, h, F, b, c,
b0, b1, b2, b3, phi, sig0, sig1,
zeros(Float64, K),
zeros(Float64, K, N_t+1), step_factor, 0.0)
autodiff(Reverse, forward_model_cost, Duplicated(model_struct, adjoint_vars))
return adjoint_vars
end
J0_model = init_cost(N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, data,
step_factor, J0)
J0_for_adjoint = init_cost(N_t, dt, K, phi, sig0, sig1, h, F, b, c, b0, b1, b2, b3, X, data,
step_factor, J0)
forward_model_cost(J0_model)
J0_adj = adjoint_J0(J0_for_adjoint)
print(J0_adj.b0) The error it produces is:
The code runs fine (no errors) if the following block is removed: ff = fftshift(fft(model_signal))[1321:1681]
ffd = fftshift(fft(data_signal))[1321:1681]
f = log10.(abs2.(ff))
fd = log10.(abs2.(ffd))
misfit = f .- fd
J0 = J0 + dot(misfit, misfit) I'm not sure how to produce the error log you might be looking for. Apologies for the length of the code and my unfamiliarity with the error log -- I can probably come up with a simpler example to produce this error if needed. |
@trostelm can you share the "data.h5" file, or update the code to not need it [e.g. make it use zeros or an appropriate size or something] |
Of course, I've updated the code above. Thanks!! |
I believe the problem is not # ╔═╡ 964afc32-481e-11ef-0ce7-ddc5430a25d2
using Enzyme
# ╔═╡ 477e8d70-716c-4b7c-90d6-4e1f6fab6d5a
using FFTW
# ╔═╡ e87d8cd9-ea20-4727-8960-3c3aa7983c5b
using Zygote
# ╔═╡ 1eb7c19c-7ff4-402b-beb6-0df22e28f9de
fftest(x) = sum(abs2, x.^2 .- fftshift(x))
# ╔═╡ 3d8f7184-0f5f-4d19-9aac-81038ff269fa
ll = [1.0,2.0, 3.0, 4.0, 5.0]
# ╔═╡ 294b28b5-2cce-4bfb-8d1a-b9a3809bfc03
dll = make_zero(ll)
# ╔═╡ b0d7a3bb-c87d-43d0-b8ff-0d00ec0927af
Enzyme.autodiff(Enzyme.ReverseWithPrimal, fftest, Duplicated(ll, dll))
# ╔═╡ 16bea1a4-c6a5-441a-baa2-31b0127e1a85
dll
# ╔═╡ 218eb198-015b-4f35-bea5-1ccae095dda7
Zygote.gradient(fftest, ll)
|
using Enzyme, UnPack, LinearAlgebra, Random
Xd = ones(4,200000)
t = range(start=5,step=0.005,length=200000)
dt_data = 0.005
N_t_data = Int(500/dt_data)
X_1011 = transpose(Xd[:, 1:N_t_data])
ts = range(; start=0, step = dt_data, length=N_t_data)
ts = ts*2
# Y variables parameterization
function U_det(Xk, b0, b1, b2, b3)
U = b0 + b1*Xk + b2/10.0*Xk^2 + b3/100.0*Xk^3
return U
end
function U_p(Xk, b0, b1, b2, b3, e_tk)
U = U_det(Xk, b0, b1, b2, b3) + e_tk
return U
end
# dX rhs
function dXrhs(k, X, b0, b1, b2, b3, e_t)
dXk = - X[k - 1] * (X[k - 2] - X[k + 1]) - X[k] + F - U_p(X[k], b0, b1, b2, b3, e_t[k])
return dXk
end
# Euler step
function euler_step(model_struct)
@unpack N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, dX, dXm1, dXm2, e_t, e_tm1, sig_e_t, sig_e_tm1, X_array = model_struct
# Compute derivatives
dX[1] = - X[K] * (X[K - 1] - X[2]) - X[1] + F - U_p(X[1], b0, b1, b2, b3, e_t[1])
dX[2] = - X[1] * (X[K] - X[3]) - X[2] + F - U_p(X[2], b0, b1, b2, b3, e_t[2])
dX[K] = - X[K - 1] * (X[K - 2] - X[1]) - X[K] + F - U_p(X[K], b0, b1, b2, b3, e_t[K])
# Update X
X[1] += dt * dX[1]
X[2] += dt * dX[2]
X[K] += dt * dX[3]
for k = 3:K-1
dX[k] = dXrhs(k, X, b0, b1, b2, b3, e_t)
X[k] += dt * dX[k]
end
# Update dXs
dXm1[:] = dX[:]
dXm2[:] = dXm1[:]
return nothing
end
# AB-3 rhs
function adams_bashforth3(x, dt, dx, dxm1, dxm2)
rhs = x + dt * ((23/12) * dx
- (16/12) * dxm1
+ (5/12) * dxm2)
return rhs
end
# AB-3 step
function ab3_step(model_struct)
@unpack N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, dX, dXm1, dXm2, e_t, e_tm1, sig_e_t, sig_e_tm1, X_array = model_struct
# Compute derivatives
dX[1] = - X[K] * (X[K - 1] - X[2]) - X[1] + F - U_p(X[1], b0, b1, b2, b3, e_t[1])
# Update X
X[1] = dX[1]
return nothing
end
mutable struct cost
# Model set-up parameters
N_t::Int64
dt::Float64
K::Int64
h::Float64
F::Float64
b::Float64
c::Float64
# Forecast control parameters
b0::Float64
b1::Float64
b2::Float64
b3::Float64
phi::Float64
sig0::Float64
sig1::Float64
# Variables
X::Vector{Float64}
dX::Vector{Float64}
dXm1::Vector{Float64}
dXm2::Vector{Float64}
# Random
e_t::Vector{Float64}
e_tm1::Vector{Float64}
sig_e_t::Vector{Float64}
sig_e_tm1::Vector{Float64}
# Data in time array
X_array::Matrix{Float64}
# Data
data::Matrix{Float64}
step_factor::Int64
# Objective function
J0::Float64
end
function init_cost(N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, data, step_factor, J0)
# Memory allocation
dX = zeros(Float64, K)
dXm1 = zeros(Float64, K)
dXm2 = zeros(Float64, K)
e_t = zeros(Float64, K)
e_tm1 = zeros(Float64, K)
sig_e_t = zeros(Float64, K) .+ sig0
sig_e_tm1 = zeros(Float64, K) .+ sig0
X_array = zeros(Float64, K, N_t+1)
# Construct initial L96 object
J0_L96 = cost(N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, dX, dXm1, dXm2,
e_t, e_tm1, sig_e_t, sig_e_tm1, X_array, data, step_factor, J0)
# Set intial conditions in X_array
J0_L96.X_array[:, 1] = J0_L96.X[:]
return J0_L96
end
function forward_model_cost(model_struct)
for i in 1:2
euler_step(model_struct)
end
for i in 2:model_struct.N_t
ab3_step(model_struct)
end
ff = model_struct.X
return dot(ff, ff)
end
# Data parameter
step_factor = 5
# Model parameters
N_t = 500000
dt = 0.001
K = 4
h = 5.
F = 20.
b = 25.
c = 25.
b0 = 5.4
b1 = 4.4
b2 = -4.3
b3 = 1.2
phi = 0.19
sig0 = 1.5
sig1 = 1.1
X = copy(Xd[:,1])
const data = X_1011'
# Initial conditions
J0 = 0.0
function adjoint_J0(model_struct)
@unpack N_t, dt, K = model_struct
@unpack data, step_factor, J0 = model_struct
adjoint_vars = init_cost(
N_t, dt,
K, h, F, b, c,
b0, b1, b2, b3, phi, sig0, sig1,
zeros(Float64, K),
zeros(Float64, K, N_t+1), step_factor, 0.0)
autodiff(Reverse, forward_model_cost, Duplicated(model_struct, adjoint_vars))
return adjoint_vars
end
J0_model = init_cost(N_t, dt, K, h, F, b, c, b0, b1, b2, b3, phi, sig0, sig1, X, data,
step_factor, J0)
J0_for_adjoint = init_cost(N_t, dt, K, phi, sig0, sig1, h, F, b, c, b0, b1, b2, b3, X, data,
step_factor, J0)
forward_model_cost(J0_model)
J0_adj = adjoint_J0(J0_for_adjoint)
print(J0_adj.b0) |
using Enzyme, LinearAlgebra, Random
Enzyme.API.printall!(true)
Enzyme.Compiler.DumpPostOpt[] = true
# Y variables parameterization
function U_det(Xk, b0, b1, b2, b3)
U = b2 + Xk + b3 + Xk
return U
end
function U_p(Xk, b0, b1, b2, b3, e_tk)
U = U_det(Xk, b0, b1, b2, b3)
return U
end
function euler_step(model_struct)
X = model_struct.X
dX = model_struct.dX
dXm1 = model_struct.dXm1
@inbounds X[1] = 0.1 * @inbounds dX[1]
for k = 3:3
X[k] += X[k] + F
end
# Update dXs
@inbounds dXm1[:] = dX[:]
return nothing
end
# AB-3 step
function ab3_step(model_struct)
b2 = model_struct.b2
b3 = model_struct.b3
e_t = model_struct.e_t
dX = model_struct.dX
X = model_struct.X
# Compute derivatives
X1 = @inbounds X[1]
X2 = @inbounds X[2]
e1 = @inbounds e_t[1]
@inbounds dX[1] = X2 * X2 + F - U_p(X1, 1.0, 1.0, b2, b3, e1)
# Update X
@inbounds X[1] = @inbounds dX[1]
return nothing
end
mutable struct cost
# Forecast control parameters
b2::Float64
b3::Float64
# Variables
X::Vector{Float64}
dX::Vector{Float64}
dXm1::Vector{Float64}
# Random
e_t::Vector{Float64}
# Data in time array
X_array::Matrix{Float64}
end
function init_cost(N_t, K, b2, b3, X)
# Memory allocation
dX = zeros(Float64, K)
dXm1 = zeros(Float64, K)
e_t = zeros(Float64, K)
X_array = zeros(Float64, K, N_t+1)
# Construct initial L96 object
J0_L96 = cost(b2, b3, X, dX, dXm1,
e_t, X_array)
return J0_L96
end
function forward_model_cost(model_struct, N)
for i in 1:2
euler_step(model_struct)
end
for i in 2:N
ab3_step(model_struct)
end
ff = model_struct.X
return @inbounds ff[1]
end
# Model parameters
N_t = 500000
K = 4
F = 20.
b2 = -4.3
b3 = 1.2
X = ones(4)
J0_model = init_cost(N_t, K, b2, b3, X)
forward_model_cost(J0_model, N_t)
model_struct = init_cost(N_t, K, b2, b3, X)
adjoint_vars = init_cost(
N_t,
K,
b2, b3,
zeros(Float64, K))
autodiff(Reverse, forward_model_cost, Duplicated(model_struct, adjoint_vars), Const(N_t)) resulting in
|
using Enzyme, LinearAlgebra, Random
Enzyme.API.printall!(true)
Enzyme.Compiler.DumpPostOpt[] = true
# Y variables parameterization
function U_det(Xk, b2, b3)
U = b2 + Xk + b3 + Xk
return U
end
function U_p(Xk, b0, b1, b2, b3, e_tk)
U = U_det(Xk, b2, b3)
return U
end
function euler_step(X, dX, dXm1)
@inbounds X[1] = 0.1 * @inbounds dX[1]
for k = 3:3
Xk = @inbounds X[k]
X[k] += Xk + F
end
# Update dXs
@inbounds dXm1[:] = dX[:]
return nothing
end
# AB-3 step
function ab3_step(X, dX, b2, b3, e1)
# Compute derivatives
X1 = @inbounds X[1]
X2 = @inbounds X[2]
@inbounds dX[1] = X2 * X2 + F - U_p(X1, 1.0, 1.0, b2, b3, e1)
# Update X
@inbounds X[1] = @inbounds dX[1]
return nothing
end
function forward_model_cost(dXm1, N, b2, b3, e1, X, dX)
# dXm1 = model_struct.dXm1
for i in 1:2
euler_step(X, dX, dXm1)
end
for i in 2:N
ab3_step(X, dX, b2, b3, e1)
end
return @inbounds X[1]
end
# Model parameters
N_t = 500000
K = 4
F = 20.
X = ones(4)
dXm1 = zeros(Float64, K)
dX = zeros(Float64, K)
forward_model_cost(dXm1, N_t, 1.2, -4.3, 1.2, X, dX)
autodiff(Reverse,
forward_model_cost,
Duplicated(dXm1, zero(dXm1)),
Const(N_t), Const(1.2), Const(-4.3), Const(1.2),
Duplicated(X, zero(X)),
Duplicated(dX, zero(dX))
) |
cc @gbaraldi |
after simplification :
; Function Attrs: mustprogress nofree readonly willreturn
define "enzyme_type"="{[-1]:Float@double}" double @preprocess_julia___2607(double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %0, double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %1) local_unnamed_addr #4 !dbg !23 {
top:
%2 = call {}*** @julia.get_pgcstack() #5
call void @llvm.dbg.value(metadata double %0, metadata !26, metadata !DIExpression()) #5, !dbg !28
call void @llvm.dbg.value(metadata double %1, metadata !27, metadata !DIExpression()) #5, !dbg !28
%ptls_field3 = getelementptr inbounds {}**, {}*** %2, i64 2
%3 = bitcast {}*** %ptls_field3 to i64***
%ptls_load45 = load i64**, i64*** %3, align 8, !tbaa !16
%4 = getelementptr inbounds i64*, i64** %ptls_load45, i64 2
%safepoint = load i64*, i64** %4, align 8, !tbaa !20
fence syncscope("singlethread") seq_cst
call void @julia.safepoint(i64* %safepoint) #5, !dbg !29
fence syncscope("singlethread") seq_cst
%5 = fadd double %0, %1, !dbg !29
ret double %5, !dbg !29
}
; Function Attrs: mustprogress nofree readonly willreturn
define internal double @augmented_julia___2607(double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %0, double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %1) local_unnamed_addr #4 !dbg !30 {
top:
%2 = alloca double, align 8
%3 = call {}*** @julia.get_pgcstack() #5
%ptls_field3 = getelementptr inbounds {}**, {}*** %3, i64 2
%4 = bitcast {}*** %ptls_field3 to i64***
%ptls_load45 = load i64**, i64*** %4, align 8, !tbaa !16, !alias.scope !35, !noalias !38
%5 = getelementptr inbounds i64*, i64** %ptls_load45, i64 2
%safepoint = load i64*, i64** %5, align 8, !tbaa !20, !alias.scope !40, !noalias !43
fence syncscope("singlethread") seq_cst
call void @julia.safepoint(i64* %safepoint) #5, !dbg !45
fence syncscope("singlethread") seq_cst
%6 = fadd double %0, %1, !dbg !45
store double %6, double* %2, align 8, !dbg !45
%7 = load double, double* %2, align 8, !dbg !45
ret double %7, !dbg !45
}
; Function Attrs: mustprogress nofree readonly willreturn
define internal { double } @diffejulia___2607(double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %0, double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %1, double %differeturn) local_unnamed_addr #4 !dbg !49 {
top:
%"'de" = alloca double, align 8
%2 = getelementptr double, double* %"'de", i64 0
store double 0.000000e+00, double* %2, align 8
%"'de1" = alloca double, align 8
%3 = getelementptr double, double* %"'de1", i64 0
store double 0.000000e+00, double* %3, align 8
%4 = call {}*** @julia.get_pgcstack() #7
br label %inverttop, !dbg !54
inverttop: ; preds = %top
store double %differeturn, double* %"'de", align 8
%5 = load double, double* %"'de", align 8, !dbg !54
store double 0.000000e+00, double* %"'de", align 8, !dbg !54
%6 = load double, double* %"'de1", align 8, !dbg !54
%7 = fadd fast double %6, %5, !dbg !54
store double %7, double* %"'de1", align 8, !dbg !54
fence syncscope("singlethread") seq_cst
fence syncscope("singlethread") seq_cst
%8 = load double, double* %"'de1", align 8
%9 = insertvalue { double } undef, double %8, 0
ret { double } %9
}
; ModuleID = 'start'
source_filename = "start"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-linux-gnu"
; Function Attrs: inaccessiblemem_or_argmemonly nofree noinline optnone
declare void @julia.safepoint(i64*) local_unnamed_addr #0
; Function Attrs: nofree noinline optnone readonly
define { double } @augmented_julia___2607wrap(double %0, double %1) #1 !dbg !4 {
entry:
%thread_ptr = call i8* asm "movq %fs:0, $0", "=r"() #7
%tls_ppgcstack = getelementptr i8, i8* %thread_ptr, i64 -8
%2 = bitcast i8* %tls_ppgcstack to {}****
%tls_pgcstack = load {}***, {}**** %2, align 8
%ptls_field3.i = getelementptr inbounds {}**, {}*** %tls_pgcstack, i64 2
%3 = bitcast {}*** %ptls_field3.i to i64***
%ptls_load45.i = load i64**, i64*** %3, align 8, !tbaa !8, !alias.scope !12, !noalias !15
%4 = getelementptr inbounds i64*, i64** %ptls_load45.i, i64 2
%safepoint.i = load i64*, i64** %4, align 8, !tbaa !17, !alias.scope !19, !noalias !22
fence syncscope("singlethread") seq_cst
%5 = load volatile i64, i64* %safepoint.i, align 8, !dbg !24
fence syncscope("singlethread") seq_cst
%6 = fadd double %0, %1, !dbg !24
%7 = insertvalue { double } zeroinitializer, double %6, 0
ret { double } %7
}
; Function Attrs: nofree noinline nosync optnone readonly
define [1 x { double }] @diffejulia___2607wrap(double %0, double %1, double %2) #2 !dbg !35 {
entry:
fence syncscope("singlethread") seq_cst
%.unpack1 = insertvalue { double } zeroinitializer, double %2, 0
%3 = insertvalue [1 x { double }] zeroinitializer, { double } %.unpack1, 0
ret [1 x { double }] %3
}
; Function Attrs: argmemonly nocallback nofree noinline nosync nounwind optnone willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #3
; Function Attrs: argmemonly nocallback nofree noinline nosync nounwind optnone willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #3
; Function Attrs: inaccessiblemem_or_argmemonly noinline optnone
declare void @ijl_gc_queue_root({} addrspace(10)*) #4
; Function Attrs: noinline optnone allocsize(2)
declare noalias nonnull {} addrspace(10)* @ijl_gc_pool_alloc(i8*, i32, i32) #5
; Function Attrs: noinline optnone allocsize(1)
declare noalias nonnull {} addrspace(10)* @ijl_gc_big_alloc(i8*, i64) #6
; Function Attrs: noinline optnone allocsize(1)
declare noalias nonnull {} addrspace(10)* @ijl_gc_alloc_typed(i8*, i64, i8*) #6
attributes #0 = { inaccessiblemem_or_argmemonly nofree noinline optnone "enzyme_inactive" "enzyme_no_escaping_allocation" "enzymejl_world"="31477" }
attributes #1 = { nofree noinline optnone readonly "enzymejl_world"="31477" }
attributes #2 = { nofree noinline nosync optnone readonly "enzymejl_world"="31477" }
attributes #3 = { argmemonly nocallback nofree noinline nosync nounwind optnone willreturn }
attributes #4 = { inaccessiblemem_or_argmemonly noinline optnone }
attributes #5 = { noinline optnone allocsize(2) }
attributes #6 = { noinline optnone allocsize(1) }
attributes #7 = { nounwind }
!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}
!0 = !{i32 2, !"Dwarf Version", i32 4}
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = distinct !DICompileUnit(language: DW_LANG_Julia, file: !3, producer: "julia", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, nameTableKind: None)
!3 = !DIFile(filename: "julia", directory: ".")
!4 = distinct !DISubprogram(name: "augmented_julia___2607wrap", linkageName: "augmented_julia___2607wrap", scope: null, file: !5, type: !6, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !7)
!5 = !DIFile(filename: "float.jl", directory: ".")
!6 = !DISubroutineType(types: !7)
!7 = !{}
!8 = !{!9, !9, i64 0}
!9 = !{!"jtbaa_gcframe", !10, i64 0}
!10 = !{!"jtbaa", !11, i64 0}
!11 = !{!"jtbaa"}
!12 = !{!13}
!13 = distinct !{!13, !14, !"primal"}
!14 = distinct !{!14, !" diff: %"}
!15 = !{!16}
!16 = distinct !{!16, !14, !"shadow_0"}
!17 = !{!18, !18, i64 0, i64 0}
!18 = !{!"jtbaa_const", !10, i64 0}
!19 = !{!20}
!20 = distinct !{!20, !21, !"primal"}
!21 = distinct !{!21, !" diff: %ptls_load45"}
!22 = !{!23}
!23 = distinct !{!23, !21, !"shadow_0"}
!24 = !DILocation(line: 409, scope: !25, inlinedAt: !34)
!25 = distinct !DISubprogram(name: "+", linkageName: "julia_+_2607", scope: null, file: !5, line: 409, type: !26, scopeLine: 409, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !30)
!26 = !DISubroutineType(types: !27)
!27 = !{!28, !29, !28, !28}
!28 = !DIBasicType(name: "Float64", size: 64, encoding: DW_ATE_unsigned)
!29 = !DICompositeType(tag: DW_TAG_structure_type, name: "#+", align: 8, elements: !7, runtimeLang: DW_LANG_Julia, identifier: "127923598536992")
!30 = !{!31, !32, !33}
!31 = !DILocalVariable(name: "#self#", arg: 1, scope: !25, file: !5, line: 409, type: !29)
!32 = !DILocalVariable(name: "x", arg: 2, scope: !25, file: !5, line: 409, type: !28)
!33 = !DILocalVariable(name: "y", arg: 3, scope: !25, file: !5, line: 409, type: !28)
!34 = distinct !DILocation(line: 0, scope: !4)
!35 = distinct !DISubprogram(name: "diffejulia___2607wrap", linkageName: "diffejulia___2607wrap", scope: null, file: !5, type: !6, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !7)
after simplification :
; Function Attrs: mustprogress nofree readonly willreturn
define "enzyme_type"="{[-1]:Float@double}" double @preprocess_julia___2738(double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %0, double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %1) local_unnamed_addr #4 !dbg !23 {
top:
%2 = call {}*** @julia.get_pgcstack() #5
call void @llvm.dbg.value(metadata double %0, metadata !26, metadata !DIExpression()) #5, !dbg !28
call void @llvm.dbg.value(metadata double %1, metadata !27, metadata !DIExpression()) #5, !dbg !28
%ptls_field3 = getelementptr inbounds {}**, {}*** %2, i64 2
%3 = bitcast {}*** %ptls_field3 to i64***
%ptls_load45 = load i64**, i64*** %3, align 8, !tbaa !16
%4 = getelementptr inbounds i64*, i64** %ptls_load45, i64 2
%safepoint = load i64*, i64** %4, align 8, !tbaa !20
fence syncscope("singlethread") seq_cst
call void @julia.safepoint(i64* %safepoint) #5, !dbg !29
fence syncscope("singlethread") seq_cst
%5 = fadd double %0, %1, !dbg !29
ret double %5, !dbg !29
}
; Function Attrs: mustprogress nofree readonly willreturn
define internal double @augmented_julia___2738(double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %0, double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %1) local_unnamed_addr #4 !dbg !30 {
top:
%2 = alloca double, align 8
%3 = call {}*** @julia.get_pgcstack() #5
%ptls_field3 = getelementptr inbounds {}**, {}*** %3, i64 2
%4 = bitcast {}*** %ptls_field3 to i64***
%ptls_load45 = load i64**, i64*** %4, align 8, !tbaa !16, !alias.scope !35, !noalias !38
%5 = getelementptr inbounds i64*, i64** %ptls_load45, i64 2
%safepoint = load i64*, i64** %5, align 8, !tbaa !20, !alias.scope !40, !noalias !43
fence syncscope("singlethread") seq_cst
call void @julia.safepoint(i64* %safepoint) #5, !dbg !45
fence syncscope("singlethread") seq_cst
%6 = fadd double %0, %1, !dbg !45
store double %6, double* %2, align 8, !dbg !45
%7 = load double, double* %2, align 8, !dbg !45
ret double %7, !dbg !45
}
; Function Attrs: mustprogress nofree readonly willreturn
define internal { double, double } @diffejulia___2738(double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %0, double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %1, double %differeturn) local_unnamed_addr #4 !dbg !49 {
top:
%"'de" = alloca double, align 8
%2 = getelementptr double, double* %"'de", i64 0
store double 0.000000e+00, double* %2, align 8
%"'de1" = alloca double, align 8
%3 = getelementptr double, double* %"'de1", i64 0
store double 0.000000e+00, double* %3, align 8
%"'de2" = alloca double, align 8
%4 = getelementptr double, double* %"'de2", i64 0
store double 0.000000e+00, double* %4, align 8
%5 = call {}*** @julia.get_pgcstack() #7
br label %inverttop, !dbg !54
inverttop: ; preds = %top
store double %differeturn, double* %"'de", align 8
%6 = load double, double* %"'de", align 8, !dbg !54
store double 0.000000e+00, double* %"'de", align 8, !dbg !54
%7 = load double, double* %"'de1", align 8, !dbg !54
%8 = fadd fast double %7, %6, !dbg !54
store double %8, double* %"'de1", align 8, !dbg !54
%9 = load double, double* %"'de2", align 8, !dbg !54
%10 = fadd fast double %9, %6, !dbg !54
store double %10, double* %"'de2", align 8, !dbg !54
fence syncscope("singlethread") seq_cst
fence syncscope("singlethread") seq_cst
%11 = load double, double* %"'de1", align 8
%12 = load double, double* %"'de2", align 8
%13 = insertvalue { double, double } undef, double %11, 0
%14 = insertvalue { double, double } %13, double %12, 1
ret { double, double } %14
}
; ModuleID = 'start'
source_filename = "start"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-linux-gnu"
; Function Attrs: inaccessiblemem_or_argmemonly nofree noinline optnone
declare void @julia.safepoint(i64*) local_unnamed_addr #0
; Function Attrs: nofree noinline optnone readonly
define { double } @augmented_julia___2738wrap(double %0, double %1) #1 !dbg !4 {
entry:
%thread_ptr = call i8* asm "movq %fs:0, $0", "=r"() #7
%tls_ppgcstack = getelementptr i8, i8* %thread_ptr, i64 -8
%2 = bitcast i8* %tls_ppgcstack to {}****
%tls_pgcstack = load {}***, {}**** %2, align 8
%ptls_field3.i = getelementptr inbounds {}**, {}*** %tls_pgcstack, i64 2
%3 = bitcast {}*** %ptls_field3.i to i64***
%ptls_load45.i = load i64**, i64*** %3, align 8, !tbaa !8, !alias.scope !12, !noalias !15
%4 = getelementptr inbounds i64*, i64** %ptls_load45.i, i64 2
%safepoint.i = load i64*, i64** %4, align 8, !tbaa !17, !alias.scope !19, !noalias !22
fence syncscope("singlethread") seq_cst
%5 = load volatile i64, i64* %safepoint.i, align 8, !dbg !24
fence syncscope("singlethread") seq_cst
%6 = fadd double %0, %1, !dbg !24
%7 = insertvalue { double } zeroinitializer, double %6, 0
ret { double } %7
}
; Function Attrs: nofree noinline nosync optnone readonly
define [1 x [2 x double]] @diffejulia___2738wrap(double %0, double %1, double %2) #2 !dbg !35 {
entry:
fence syncscope("singlethread") seq_cst
%3 = insertvalue [2 x double] zeroinitializer, double %2, 0
%.unpack3 = insertvalue [2 x double] %3, double %2, 1
%4 = insertvalue [1 x [2 x double]] zeroinitializer, [2 x double] %.unpack3, 0
ret [1 x [2 x double]] %4
}
; Function Attrs: argmemonly nocallback nofree noinline nosync nounwind optnone willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #3
; Function Attrs: argmemonly nocallback nofree noinline nosync nounwind optnone willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #3
; Function Attrs: inaccessiblemem_or_argmemonly noinline optnone
declare void @ijl_gc_queue_root({} addrspace(10)*) #4
; Function Attrs: noinline optnone allocsize(2)
declare noalias nonnull {} addrspace(10)* @ijl_gc_pool_alloc(i8*, i32, i32) #5
; Function Attrs: noinline optnone allocsize(1)
declare noalias nonnull {} addrspace(10)* @ijl_gc_big_alloc(i8*, i64) #6
; Function Attrs: noinline optnone allocsize(1)
declare noalias nonnull {} addrspace(10)* @ijl_gc_alloc_typed(i8*, i64, i8*) #6
attributes #0 = { inaccessiblemem_or_argmemonly nofree noinline optnone "enzyme_inactive" "enzyme_no_escaping_allocation" "enzymejl_world"="31477" }
attributes #1 = { nofree noinline optnone readonly "enzymejl_world"="31477" }
attributes #2 = { nofree noinline nosync optnone readonly "enzymejl_world"="31477" }
attributes #3 = { argmemonly nocallback nofree noinline nosync nounwind optnone willreturn }
attributes #4 = { inaccessiblemem_or_argmemonly noinline optnone }
attributes #5 = { noinline optnone allocsize(2) }
attributes #6 = { noinline optnone allocsize(1) }
attributes #7 = { nounwind }
!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}
!0 = !{i32 2, !"Dwarf Version", i32 4}
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = distinct !DICompileUnit(language: DW_LANG_Julia, file: !3, producer: "julia", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, nameTableKind: None)
!3 = !DIFile(filename: "julia", directory: ".")
!4 = distinct !DISubprogram(name: "augmented_julia___2738wrap", linkageName: "augmented_julia___2738wrap", scope: null, file: !5, type: !6, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !7)
!5 = !DIFile(filename: "float.jl", directory: ".")
!6 = !DISubroutineType(types: !7)
!7 = !{}
!8 = !{!9, !9, i64 0}
!9 = !{!"jtbaa_gcframe", !10, i64 0}
!10 = !{!"jtbaa", !11, i64 0}
!11 = !{!"jtbaa"}
!12 = !{!13}
!13 = distinct !{!13, !14, !"primal"}
!14 = distinct !{!14, !" diff: %"}
!15 = !{!16}
!16 = distinct !{!16, !14, !"shadow_0"}
!17 = !{!18, !18, i64 0, i64 0}
!18 = !{!"jtbaa_const", !10, i64 0}
!19 = !{!20}
!20 = distinct !{!20, !21, !"primal"}
!21 = distinct !{!21, !" diff: %ptls_load45"}
!22 = !{!23}
!23 = distinct !{!23, !21, !"shadow_0"}
!24 = !DILocation(line: 409, scope: !25, inlinedAt: !34)
!25 = distinct !DISubprogram(name: "+", linkageName: "julia_+_2738", scope: null, file: !5, line: 409, type: !26, scopeLine: 409, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !30)
!26 = !DISubroutineType(types: !27)
!27 = !{!28, !29, !28, !28}
!28 = !DIBasicType(name: "Float64", size: 64, encoding: DW_ATE_unsigned)
!29 = !DICompositeType(tag: DW_TAG_structure_type, name: "#+", align: 8, elements: !7, runtimeLang: DW_LANG_Julia, identifier: "127923598536992")
!30 = !{!31, !32, !33}
!31 = !DILocalVariable(name: "#self#", arg: 1, scope: !25, file: !5, line: 409, type: !29)
!32 = !DILocalVariable(name: "x", arg: 2, scope: !25, file: !5, line: 409, type: !28)
!33 = !DILocalVariable(name: "y", arg: 3, scope: !25, file: !5, line: 409, type: !28)
!34 = distinct !DILocation(line: 0, scope: !4)
!35 = distinct !DISubprogram(name: "diffejulia___2738wrap", linkageName: "diffejulia___2738wrap", scope: null, file: !5, type: !6, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !7)
after simplification :
; Function Attrs: mustprogress willreturn
define noundef nonnull align 16 dereferenceable(40) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" {} addrspace(10)* @preprocess_julia_setindex__2765({} addrspace(10)* noundef nonnull returned align 16 dereferenceable(40) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="127923554507456" "enzymejl_parmtype_ref"="2" %0, double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %1, i64 signext "enzyme_inactive" "enzyme_type"="{[-1]:Integer}" "enzymejl_parmtype"="127923625262592" "enzymejl_parmtype_ref"="0" %2) local_unnamed_addr #5 !dbg !53 {
top:
%3 = call {}*** @julia.get_pgcstack() #6
call void @llvm.dbg.value(metadata {} addrspace(10)* null, metadata !56, metadata !DIExpression(DW_OP_deref)) #6, !dbg !59
call void @llvm.dbg.value(metadata {} addrspace(10)* %0, metadata !56, metadata !DIExpression(DW_OP_deref)) #6, !dbg !59
call void @llvm.dbg.value(metadata double %1, metadata !57, metadata !DIExpression()) #6, !dbg !59
call void @llvm.dbg.value(metadata i64 %2, metadata !58, metadata !DIExpression()) #6, !dbg !59
%ptls_field3 = getelementptr inbounds {}**, {}*** %3, i64 2
%4 = bitcast {}*** %ptls_field3 to i64***
%ptls_load45 = load i64**, i64*** %4, align 8, !tbaa !23
%5 = getelementptr inbounds i64*, i64** %ptls_load45, i64 2
%safepoint = load i64*, i64** %5, align 8, !tbaa !27
fence syncscope("singlethread") seq_cst
call void @julia.safepoint(i64* %safepoint) #6, !dbg !60
fence syncscope("singlethread") seq_cst
%6 = add i64 %2, -1, !dbg !60
%7 = addrspacecast {} addrspace(10)* %0 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !60
%arraylen_ptr = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %7, i64 0, i32 1, !dbg !60
%arraylen = load i64, i64 addrspace(11)* %arraylen_ptr, align 8, !dbg !60, !tbaa !30, !range !33, !alias.scope !34, !noalias !37
%inbounds = icmp ult i64 %6, %arraylen, !dbg !60
br i1 %inbounds, label %idxend, label %oob, !dbg !60
oob: ; preds = %top
%errorbox = alloca i64, align 8, !dbg !60
store i64 %2, i64* %errorbox, align 8, !dbg !60, !noalias !61
%8 = addrspacecast {} addrspace(10)* %0 to {} addrspace(12)*, !dbg !60
call void @ijl_bounds_error_ints({} addrspace(12)* noundef %8, i64* noundef nonnull align 8 %errorbox, i64 noundef 1) #7, !dbg !60
unreachable, !dbg !60
idxend: ; preds = %top
%9 = addrspacecast {} addrspace(10)* %0 to double addrspace(13)* addrspace(11)*, !dbg !60
%arrayptr6 = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %9, align 16, !dbg !60, !tbaa !45, !alias.scope !64, !noalias !37, !nonnull !14
%10 = getelementptr inbounds double, double addrspace(13)* %arrayptr6, i64 %6, !dbg !60
store double %1, double addrspace(13)* %10, align 8, !dbg !60, !tbaa !48, !alias.scope !51, !noalias !65
ret {} addrspace(10)* %0, !dbg !60
}
; Function Attrs: mustprogress willreturn
define internal { {} addrspace(10)*, {} addrspace(10)* } @augmented_julia_setindex__2765({} addrspace(10)* noundef nonnull align 16 dereferenceable(40) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="127923554507456" "enzymejl_parmtype_ref"="2" %0, {} addrspace(10)* align 16 "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="127923554507456" "enzymejl_parmtype_ref"="2" %"'", double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %1, i64 signext "enzyme_inactive" "enzyme_type"="{[-1]:Integer}" "enzymejl_parmtype"="127923625262592" "enzymejl_parmtype_ref"="0" %2) local_unnamed_addr #5 !dbg !66 {
top:
%3 = alloca { {} addrspace(10)*, {} addrspace(10)* }, align 8
%4 = call {}*** @julia.get_pgcstack() #6
%ptls_field3 = getelementptr inbounds {}**, {}*** %4, i64 2
%5 = bitcast {}*** %ptls_field3 to i64***
%ptls_load45 = load i64**, i64*** %5, align 8, !tbaa !23, !alias.scope !72, !noalias !75
%6 = getelementptr inbounds i64*, i64** %ptls_load45, i64 2
%safepoint = load i64*, i64** %6, align 8, !tbaa !27, !alias.scope !77, !noalias !80
fence syncscope("singlethread") seq_cst
call void @julia.safepoint(i64* %safepoint) #6, !dbg !82
fence syncscope("singlethread") seq_cst
%7 = add i64 %2, -1, !dbg !82
%8 = addrspacecast {} addrspace(10)* %0 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !82
%arraylen_ptr = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %8, i64 0, i32 1, !dbg !82
%arraylen = load i64, i64 addrspace(11)* %arraylen_ptr, align 8, !dbg !82, !tbaa !30, !range !33, !alias.scope !83, !noalias !86
%inbounds = icmp ult i64 %7, %arraylen, !dbg !82
br i1 %inbounds, label %idxend, label %oob, !dbg !82
oob: ; preds = %top
%errorbox = alloca i64, align 8, !dbg !82
store i64 %2, i64* %errorbox, align 8, !dbg !82, !noalias !88
%9 = addrspacecast {} addrspace(10)* %0 to {} addrspace(12)*, !dbg !82
call void @ijl_bounds_error_ints({} addrspace(12)* noundef %9, i64* noundef nonnull align 8 %errorbox, i64 noundef 1) #7, !dbg !82
unreachable, !dbg !82
idxend: ; preds = %top
%"'ipc" = addrspacecast {} addrspace(10)* %"'" to double addrspace(13)* addrspace(11)*, !dbg !82
%10 = addrspacecast {} addrspace(10)* %0 to double addrspace(13)* addrspace(11)*, !dbg !82
%"arrayptr6'ipl" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc", align 16, !dbg !82, !tbaa !45, !alias.scope !91, !noalias !94, !nonnull !14
%arrayptr6 = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %10, align 16, !dbg !82, !tbaa !45, !alias.scope !95, !noalias !86, !nonnull !14
%11 = getelementptr inbounds double, double addrspace(13)* %arrayptr6, i64 %7, !dbg !82
store double %1, double addrspace(13)* %11, align 8, !dbg !82, !tbaa !48, !alias.scope !96, !noalias !99
%12 = getelementptr inbounds { {} addrspace(10)*, {} addrspace(10)* }, { {} addrspace(10)*, {} addrspace(10)* }* %3, i32 0, i32 0, !dbg !82
store {} addrspace(10)* %0, {} addrspace(10)** %12, align 8, !dbg !82
%13 = getelementptr inbounds { {} addrspace(10)*, {} addrspace(10)* }, { {} addrspace(10)*, {} addrspace(10)* }* %3, i32 0, i32 1, !dbg !82
store {} addrspace(10)* %"'", {} addrspace(10)** %13, align 8, !dbg !82
%14 = load { {} addrspace(10)*, {} addrspace(10)* }, { {} addrspace(10)*, {} addrspace(10)* }* %3, align 8, !dbg !82
ret { {} addrspace(10)*, {} addrspace(10)* } %14, !dbg !82
}
; Function Attrs: mustprogress willreturn
define internal { double } @diffejulia_setindex__2765({} addrspace(10)* align 16 dereferenceable(40) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="127923554507456" "enzymejl_parmtype_ref"="2" %0, {} addrspace(10)* align 16 "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="127923554507456" "enzymejl_parmtype_ref"="2" %"'", double "enzyme_type"="{[-1]:Float@double}" "enzymejl_parmtype"="127923625261792" "enzymejl_parmtype_ref"="0" %1, i64 signext "enzyme_inactive" "enzyme_type"="{[-1]:Integer}" "enzymejl_parmtype"="127923625262592" "enzymejl_parmtype_ref"="0" %2) local_unnamed_addr #5 !dbg !104 {
top:
%"'de" = alloca double, align 8
%3 = getelementptr double, double* %"'de", i64 0
store double 0.000000e+00, double* %3, align 8
%4 = call {}*** @julia.get_pgcstack() #8
%5 = add i64 %2, -1, !dbg !110
br i1 true, label %idxend, label %oob, !dbg !110
oob: ; preds = %top
unreachable
idxend: ; preds = %top
%"'ipc" = addrspacecast {} addrspace(10)* %"'" to double addrspace(13)* addrspace(11)*, !dbg !110
%"arrayptr6'ipl" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc", align 16, !dbg !110, !tbaa !45, !alias.scope !111, !noalias !114, !nonnull !14
%"'ipg" = getelementptr inbounds double, double addrspace(13)* %"arrayptr6'ipl", i64 %5, !dbg !110
br label %invertidxend, !dbg !110
inverttop: ; preds = %invertidxend
fence syncscope("singlethread") seq_cst
fence syncscope("singlethread") seq_cst
%6 = load double, double* %"'de", align 8
%7 = insertvalue { double } undef, double %6, 0
ret { double } %7
invertidxend: ; preds = %idxend
%8 = load double, double addrspace(13)* %"'ipg", align 8, !dbg !110, !tbaa !48, !alias.scope !116, !noalias !119
store double 0.000000e+00, double addrspace(13)* %"'ipg", align 8, !dbg !110, !tbaa !48, !alias.scope !116, !noalias !119
%9 = load double, double* %"'de", align 8, !dbg !110
%10 = fadd fast double %9, %8, !dbg !110
store double %10, double* %"'de", align 8, !dbg !110
br label %inverttop
}
; ModuleID = 'start'
source_filename = "start"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-linux-gnu"
; Function Attrs: inaccessiblemem_or_argmemonly nofree noinline optnone
declare void @julia.safepoint(i64*) local_unnamed_addr #0
; Function Attrs: noinline noreturn optnone
declare void @ijl_bounds_error_ints({} addrspace(12)*, i64*, i64) local_unnamed_addr #1
; Function Attrs: noinline optnone
define { {} addrspace(10)*, {} addrspace(10)* } @augmented_julia_setindex__2765wrap({} addrspace(10)* %0, {} addrspace(10)* %1, double %2, i64 %3) #2 !dbg !4 {
entry:
%thread_ptr = call i8* asm "movq %fs:0, $0", "=r"() #9
%tls_ppgcstack = getelementptr i8, i8* %thread_ptr, i64 -8
%4 = bitcast i8* %tls_ppgcstack to {}****
%tls_pgcstack = load {}***, {}**** %4, align 8
%ptls_field3.i = getelementptr inbounds {}**, {}*** %tls_pgcstack, i64 2
%5 = bitcast {}*** %ptls_field3.i to i64***
%ptls_load45.i = load i64**, i64*** %5, align 8, !tbaa !8, !alias.scope !12, !noalias !15
%6 = getelementptr inbounds i64*, i64** %ptls_load45.i, i64 2
%safepoint.i = load i64*, i64** %6, align 8, !tbaa !17, !alias.scope !19, !noalias !22
fence syncscope("singlethread") seq_cst
%7 = load volatile i64, i64* %safepoint.i, align 8, !dbg !24
fence syncscope("singlethread") seq_cst
%8 = add i64 %3, -1, !dbg !24
%9 = bitcast {} addrspace(10)* %0 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(10)*, !dbg !24
%10 = addrspacecast { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(10)* %9 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !24
%arraylen_ptr.i = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %10, i64 0, i32 1, !dbg !24
%arraylen.i = load i64, i64 addrspace(11)* %arraylen_ptr.i, align 8, !dbg !24, !tbaa !42, !range !45, !alias.scope !46, !noalias !51
%inbounds.i = icmp ult i64 %8, %arraylen.i, !dbg !24
br i1 %inbounds.i, label %augmented_julia_setindex__2765.exit, label %oob.i, !dbg !24
oob.i: ; preds = %entry
%errorbox.i = alloca i64, align 8, !dbg !24
store i64 %3, i64* %errorbox.i, align 8, !dbg !24, !noalias !57
%11 = addrspacecast {} addrspace(10)* %0 to {} addrspace(12)*, !dbg !24
call void @ijl_bounds_error_ints({} addrspace(12)* noundef %11, i64* noundef nonnull align 8 %errorbox.i, i64 noundef 1) #10, !dbg !24
unreachable, !dbg !24
augmented_julia_setindex__2765.exit: ; preds = %entry
%12 = bitcast {} addrspace(10)* %0 to double addrspace(13)* addrspace(10)*, !dbg !24
%13 = addrspacecast double addrspace(13)* addrspace(10)* %12 to double addrspace(13)* addrspace(11)*, !dbg !24
%arrayptr6.i = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %13, align 16, !dbg !24, !tbaa !62, !alias.scope !64, !noalias !51, !nonnull !7
%14 = getelementptr inbounds double, double addrspace(13)* %arrayptr6.i, i64 %8, !dbg !24
store double %2, double addrspace(13)* %14, align 8, !dbg !24, !tbaa !67, !alias.scope !70, !noalias !73
%15 = insertvalue { {} addrspace(10)*, {} addrspace(10)* } zeroinitializer, {} addrspace(10)* %0, 0
%16 = insertvalue { {} addrspace(10)*, {} addrspace(10)* } %15, {} addrspace(10)* %1, 1
ret { {} addrspace(10)*, {} addrspace(10)* } %16
}
; Function Attrs: nofree noinline nosync optnone
define [1 x { double }] @diffejulia_setindex__2765wrap({} addrspace(10)* nocapture nofree readnone %0, {} addrspace(10)* nocapture nofree readonly %1, double %2, i64 %3) #3 !dbg !75 {
entry:
%4 = add i64 %3, -1, !dbg !76
%5 = bitcast {} addrspace(10)* %1 to double addrspace(13)* addrspace(10)*, !dbg !76
%"'ipc.i" = addrspacecast double addrspace(13)* addrspace(10)* %5 to double addrspace(13)* addrspace(11)*, !dbg !76
%"arrayptr6'ipl.i" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc.i", align 16, !dbg !76, !tbaa !62, !alias.scope !84, !noalias !89, !nonnull !7
%"'ipg.i" = getelementptr inbounds double, double addrspace(13)* %"arrayptr6'ipl.i", i64 %4, !dbg !76
%6 = load double, double addrspace(13)* %"'ipg.i", align 8, !dbg !76, !tbaa !67, !alias.scope !91, !noalias !94
store double 0.000000e+00, double addrspace(13)* %"'ipg.i", align 8, !dbg !76, !tbaa !67, !alias.scope !91, !noalias !96
fence syncscope("singlethread") seq_cst
%.unpack1 = insertvalue { double } zeroinitializer, double %6, 0
%7 = insertvalue [1 x { double }] zeroinitializer, { double } %.unpack1, 0
ret [1 x { double }] %7
}
; Function Attrs: argmemonly nocallback nofree noinline nosync nounwind optnone willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #4
; Function Attrs: argmemonly nocallback nofree noinline nosync nounwind optnone willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #4
; Function Attrs: nocallback nofree noinline nosync nounwind optnone willreturn
declare i8* @llvm.stacksave() #5
; Function Attrs: nocallback nofree noinline nosync nounwind optnone willreturn
declare void @llvm.stackrestore(i8*) #5
; Function Attrs: inaccessiblemem_or_argmemonly noinline optnone
declare void @ijl_gc_queue_root({} addrspace(10)*) #6
; Function Attrs: noinline optnone allocsize(2)
declare noalias nonnull {} addrspace(10)* @ijl_gc_pool_alloc(i8*, i32, i32) #7
; Function Attrs: noinline optnone allocsize(1)
declare noalias nonnull {} addrspace(10)* @ijl_gc_big_alloc(i8*, i64) #8
; Function Attrs: noinline optnone allocsize(1)
declare noalias nonnull {} addrspace(10)* @ijl_gc_alloc_typed(i8*, i64, i8*) #8
attributes #0 = { inaccessiblemem_or_argmemonly nofree noinline optnone "enzyme_inactive" "enzyme_no_escaping_allocation" "enzymejl_world"="31477" }
attributes #1 = { noinline noreturn optnone "enzymejl_world"="31477" }
attributes #2 = { noinline optnone "enzymejl_world"="31477" }
attributes #3 = { nofree noinline nosync optnone "enzymejl_world"="31477" }
attributes #4 = { argmemonly nocallback nofree noinline nosync nounwind optnone willreturn }
attributes #5 = { nocallback nofree noinline nosync nounwind optnone willreturn }
attributes #6 = { inaccessiblemem_or_argmemonly noinline optnone }
attributes #7 = { noinline optnone allocsize(2) }
attributes #8 = { noinline optnone allocsize(1) }
attributes #9 = { nounwind }
attributes #10 = { mustprogress noreturn willreturn }
!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}
!0 = !{i32 2, !"Dwarf Version", i32 4}
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = distinct !DICompileUnit(language: DW_LANG_Julia, file: !3, producer: "julia", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, nameTableKind: None)
!3 = !DIFile(filename: "julia", directory: ".")
!4 = distinct !DISubprogram(name: "augmented_julia_setindex__2765wrap", linkageName: "augmented_julia_setindex__2765wrap", scope: null, file: !5, type: !6, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !7)
!5 = !DIFile(filename: "array.jl", directory: ".")
!6 = !DISubroutineType(types: !7)
!7 = !{}
!8 = !{!9, !9, i64 0}
!9 = !{!"jtbaa_gcframe", !10, i64 0}
!10 = !{!"jtbaa", !11, i64 0}
!11 = !{!"jtbaa"}
!12 = !{!13}
!13 = distinct !{!13, !14, !"primal"}
!14 = distinct !{!14, !" diff: %"}
!15 = !{!16}
!16 = distinct !{!16, !14, !"shadow_0"}
!17 = !{!18, !18, i64 0, i64 0}
!18 = !{!"jtbaa_const", !10, i64 0}
!19 = !{!20}
!20 = distinct !{!20, !21, !"primal"}
!21 = distinct !{!21, !" diff: %ptls_load45"}
!22 = !{!23}
!23 = distinct !{!23, !21, !"shadow_0"}
!24 = !DILocation(line: 1021, scope: !25, inlinedAt: !41)
!25 = distinct !DISubprogram(name: "setindex!", linkageName: "julia_setindex!_2765", scope: null, file: !5, line: 1021, type: !26, scopeLine: 1021, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !36)
!26 = !DISubroutineType(types: !27)
!27 = !{!28, !33, !28, !34, !35}
!28 = !DIDerivedType(tag: DW_TAG_typedef, name: "Array", baseType: !29)
!29 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !30, size: 64, align: 64)
!30 = !DICompositeType(tag: DW_TAG_structure_type, name: "jl_value_t", file: !31, line: 71, align: 64, elements: !32)
!31 = !DIFile(filename: "julia.h", directory: "")
!32 = !{!29}
!33 = !DICompositeType(tag: DW_TAG_structure_type, name: "#setindex!", align: 8, elements: !7, runtimeLang: DW_LANG_Julia, identifier: "127923603541552")
!34 = !DIBasicType(name: "Float64", size: 64, encoding: DW_ATE_unsigned)
!35 = !DIBasicType(name: "Int64", size: 64, encoding: DW_ATE_unsigned)
!36 = !{!37, !38, !39, !40}
!37 = !DILocalVariable(name: "#self#", arg: 1, scope: !25, file: !5, line: 1021, type: !33)
!38 = !DILocalVariable(name: "A", arg: 2, scope: !25, file: !5, line: 1021, type: !28)
!39 = !DILocalVariable(name: "x", arg: 3, scope: !25, file: !5, line: 1021, type: !34)
!40 = !DILocalVariable(name: "i1", arg: 4, scope: !25, file: !5, line: 1021, type: !35)
!41 = distinct !DILocation(line: 0, scope: !4)
!42 = !{!43, !43, i64 0}
!43 = !{!"jtbaa_arraylen", !44, i64 0}
!44 = !{!"jtbaa_array", !10, i64 0}
!45 = !{i64 0, i64 9223372036854775807}
!46 = !{!47, !49}
!47 = distinct !{!47, !48, !"primal"}
!48 = distinct !{!48, !" diff: %"}
!49 = !{!"jnoalias_typemd", !50}
!50 = !{!"jnoalias"}
!51 = !{!52, !53, !54, !55, !56}
!52 = distinct !{!52, !48, !"shadow_0"}
!53 = !{!"jnoalias_gcframe", !50}
!54 = !{!"jnoalias_stack", !50}
!55 = !{!"jnoalias_data", !50}
!56 = !{!"jnoalias_const", !50}
!57 = !{!58, !60}
!58 = distinct !{!58, !59, !"na_addr13"}
!59 = distinct !{!59, !"addr13"}
!60 = distinct !{!60, !61, !"na_addr13"}
!61 = distinct !{!61, !"addr13"}
!62 = !{!63, !63, i64 0}
!63 = !{!"jtbaa_arrayptr", !44, i64 0}
!64 = !{!58, !47, !65, !49}
!65 = distinct !{!65, !66, !"na_addr13"}
!66 = distinct !{!66, !"addr13"}
!67 = !{!68, !68, i64 0}
!68 = !{!"jtbaa_arraybuf", !69, i64 0}
!69 = !{!"jtbaa_data", !10, i64 0}
!70 = !{!71, !55}
!71 = distinct !{!71, !72, !"primal"}
!72 = distinct !{!72, !" diff: %arrayptr6"}
!73 = !{!58, !74, !65, !53, !54, !49, !56}
!74 = distinct !{!74, !72, !"shadow_0"}
!75 = distinct !DISubprogram(name: "diffejulia_setindex__2765wrap", linkageName: "diffejulia_setindex__2765wrap", scope: null, file: !5, type: !6, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !7)
!76 = !DILocation(line: 1021, scope: !77, inlinedAt: !83)
!77 = distinct !DISubprogram(name: "setindex!", linkageName: "julia_setindex!_2765", scope: null, file: !5, line: 1021, type: !26, scopeLine: 1021, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !78)
!78 = !{!79, !80, !81, !82}
!79 = !DILocalVariable(name: "#self#", arg: 1, scope: !77, file: !5, line: 1021, type: !33)
!80 = !DILocalVariable(name: "A", arg: 2, scope: !77, file: !5, line: 1021, type: !28)
!81 = !DILocalVariable(name: "x", arg: 3, scope: !77, file: !5, line: 1021, type: !34)
!82 = !DILocalVariable(name: "i1", arg: 4, scope: !77, file: !5, line: 1021, type: !35)
!83 = distinct !DILocation(line: 0, scope: !75)
!84 = !{!58, !85, !87, !49}
!85 = distinct !{!85, !86, !"shadow_0"}
!86 = distinct !{!86, !" diff: %"}
!87 = distinct !{!87, !88, !"na_addr13"}
!88 = distinct !{!88, !"addr13"}
!89 = !{!90, !53, !54, !55, !56}
!90 = distinct !{!90, !86, !"primal"}
!91 = !{!92, !55}
!92 = distinct !{!92, !93, !"shadow_0"}
!93 = distinct !{!93, !" diff: %arrayptr6"}
!94 = !{!95, !87, !53, !54, !49, !56}
!95 = distinct !{!95, !93, !"primal"}
!96 = !{!58, !95, !87, !53, !54, !49, !56}
GC error (probable corruption)
Allocations: 27089595 (Pool: 27035466; Big: 54129); GC: 39
Base.getindex
thread 0 ptr queue:
~~~~~~~~~~ ptr queue top ~~~~~~~~~~
<?#0x745891cbf8e0::(nil)>
==========
!!! ERROR in jl_ -- ABORTING !!!
==========
Array{Float64, (4,)}[0, 0, 0, 0]
==========
Array{Float64, (4,)}[inf, 0, 0, 0]
==========
<?#0x745891d17a00::(nil)>
==========
~~~~~~~~~~ ptr queue bottom ~~~~~~~~~~
[774624] signal (6.-6): Aborted
in expression starting at /home/wmoses/git/Enzyme.jl/fft.jl:76
pthread_kill at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
raise at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
gc_dump_queue_and_abort at /home/wmoses/git/Enzyme.jl/julia10/src/gc.c:1822
gc_mark_outrefs at /home/wmoses/git/Enzyme.jl/julia10/src/gc.c:2528 [inlined]
gc_mark_loop_serial_ at /home/wmoses/git/Enzyme.jl/julia10/src/gc.c:2697
gc_mark_loop_serial at /home/wmoses/git/Enzyme.jl/julia10/src/gc.c:2720
gc_mark_loop at /home/wmoses/git/Enzyme.jl/julia10/src/gc.c:2901
_jl_gc_collect at /home/wmoses/git/Enzyme.jl/julia10/src/gc.c:3234
ijl_gc_collect at /home/wmoses/git/Enzyme.jl/julia10/src/gc.c:3531
maybe_collect at /home/wmoses/git/Enzyme.jl/julia10/src/gc.c:937
jl_gc_pool_alloc_inner at /home/wmoses/git/Enzyme.jl/julia10/src/gc.c:1300
ijl_gc_pool_alloc at /home/wmoses/git/Enzyme.jl/julia10/src/gc.c:1348
ab3_step at /home/wmoses/git/Enzyme.jl/fft.jl:41
forward_model_cost at /home/wmoses/git/Enzyme.jl/fft.jl:57 [inlined]
diffejulia_forward_model_cost_827wrap at /home/wmoses/git/Enzyme.jl/fft.jl:0
macro expansion at /home/wmoses/git/Enzyme.jl/src/compiler.jl:6819 [inlined]
enzyme_call at /home/wmoses/git/Enzyme.jl/src/compiler.jl:6419 [inlined]
CombinedAdjointThunk at /home/wmoses/git/Enzyme.jl/src/compiler.jl:6296 [inlined]
autodiff at /home/wmoses/git/Enzyme.jl/src/Enzyme.jl:314 [inlined]
autodiff at /home/wmoses/git/Enzyme.jl/src/Enzyme.jl:338 [inlined]
autodiff at /home/wmoses/git/Enzyme.jl/src/Enzyme.jl:323
unknown function (ip: 0x745883f1da8a)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2895
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
jl_apply at /home/wmoses/git/Enzyme.jl/julia10/src/julia.h:1982
do_call at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:126
eval_value at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:223
eval_stmt_value at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:174
eval_body at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:617
jl_interpret_toplevel_thunk at /home/wmoses/git/Enzyme.jl/julia10/src/interpreter.c:775
jl_toplevel_eval_flex at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:934
jl_toplevel_eval_flex at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:877
ijl_toplevel_eval at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:943
ijl_toplevel_eval_in at /home/wmoses/git/Enzyme.jl/julia10/src/toplevel.c:985
eval at ./boot.jl:385 [inlined]
include_string at ./loading.jl:2076
jl_fptr_args at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2537
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2876
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
_include at ./loading.jl:2136
include at ./Base.jl:495
jfptr_include_46707 at /home/wmoses/git/Enzyme.jl/julia10/usr/lib/julia/sys-debug.so (unknown line)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2876
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
exec_options at ./client.jl:318
_start at ./client.jl:552
jfptr__start_83017 at /home/wmoses/git/Enzyme.jl/julia10/usr/lib/julia/sys-debug.so (unknown line)
_jl_invoke at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:2876
ijl_apply_generic at /home/wmoses/git/Enzyme.jl/julia10/src/gf.c:3077
jl_apply at /home/wmoses/git/Enzyme.jl/julia10/src/julia.h:1982
true_main at /home/wmoses/git/Enzyme.jl/julia10/src/jlapi.c:582
jl_repl_entrypoint at /home/wmoses/git/Enzyme.jl/julia10/src/jlapi.c:731
jl_load_repl at /home/wmoses/git/Enzyme.jl/julia10/cli/loader_lib.c:568
main at /home/wmoses/git/Enzyme.jl/julia10/cli/loader_exe.c:58
unknown function (ip: 0x74589c829d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at ./julia10/julia (unknown line)
Allocations: 27089595 (Pool: 27035466; Big: 54129); GC: 39
wmoses@beast:~/git/Enzyme.jl (fcc2) $ |
Idk why LLC hates us but the module of relevance: |
from https://godbolt.org/z/EacKPahbf estimated problem child in 735: |
Running Julia alloc opt on https://godbolt.org/z/77f9K43bj breaks |
FYI for those following here. This turns out to be a bug in the julia compiler itself (fixed here JuliaLang/julia#55306) |
Closing as a relevant issue is open in julia proper -- and unfortauntely there's nothing we can do in this package. |
Thanks for looking into this @wsmoses ! |
Not sure how to understand this error. This occurs when I use FFTW's fftshift to compute the cost function to be differentiated.
`Enzyme execution failed.
Enzyme: The original primal code hits this error condition, thus differentiating it does not make sense
Stacktrace:
[1] multiple call sites
@ unknown:0
Stacktrace:
[1] throwerr(cstr::Cstring)
@ Enzyme.Compiler ~/.julia/packages/Enzyme/Pljwm/src/compiler.jl:1678
`
The text was updated successfully, but these errors were encountered: