Skip to content

Commit a36d852

Browse files
staticfloatoxinabox
authored andcommitted
Custom forward rule for Expr(:new, ) in forward_diff_no_inf!
Frames and I tracked down an issue where the type argument to an `Expr(:new, )` (argument #1) was getting wrapped in a `ZeroBundle`. This commit adds a special-case for `Expr(:new, )` into `forward_diff_no_inf!()` that mimics what we see elsewhere, making use of `∂☆new`.
1 parent fb4e03d commit a36d852

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/codegen/forward_demand.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,11 +280,12 @@ function forward_diff_no_inf!(ir::IRCode, to_diff::Vector{Pair{SSAValue,Int}};
280280
end
281281
inst[:inst] = Expr(:call, ∂☆{order}(), newargs...)
282282
inst[:type] = Any
283-
elseif isexpr(stmt, :call)
283+
elseif isexpr(stmt, :call) || isexpr(stmt, :new)
284284
newargs = map(stmt.args) do @nospecialize arg
285285
maparg(arg, SSAValue(ssa), order)
286286
end
287-
inst[:inst] = Expr(:call, ∂☆{order}(), newargs...)
287+
f = isexpr(stmt, :call) ? ∂☆{order}() : ∂☆new{order}()
288+
inst[:inst] = Expr(:call, f, newargs...)
288289
inst[:type] = Any
289290
elseif isa(stmt, PiNode)
290291
# TODO: New PiNode that discriminates based on primal?

0 commit comments

Comments
 (0)