@@ -151,7 +151,7 @@ function forward_diff_uncached!(ir::IRCode, interp::AbstractInterpreter, irsv::I
151
151
frule_result = insert_node! (ir, ssa, NewInstruction (
152
152
frule_call, frule_rt, info. frule_call. info, inst[:line ],
153
153
frule_flag))
154
- ir[ ssa][ :inst ] = Expr (:call , GlobalRef (Core, :getfield ), frule_result, 1 )
154
+ replace_call! (ir, ssa, Expr (:call , GlobalRef (Core, :getfield ), frule_result, 1 ) )
155
155
Δssa = insert_node! (ir, ssa, NewInstruction (
156
156
Expr (:call , GlobalRef (Core, :getfield ), frule_result, 2 ), CC. getfield_tfunc (CC. typeinf_lattice (interp), frule_rt, Const (2 ))), #= attach_after=# true )
157
157
return Δssa
@@ -285,15 +285,13 @@ function forward_diff_no_inf!(ir::IRCode, to_diff::Vector{Pair{SSAValue,Int}};
285
285
newargs = map (stmt. args[2 : end ]) do @nospecialize arg
286
286
maparg (arg, SSAValue (ssa), order)
287
287
end
288
- inst[:inst ] = Expr (:call , ∂☆ {order} (), newargs... )
289
- inst[:type ] = Any
288
+ replace_call! (ir, SSAValue (ssa), Expr (:call , ∂☆ {order} (), newargs... ))
290
289
elseif isexpr (stmt, :call ) || isexpr (stmt, :new )
291
290
newargs = map (stmt. args) do @nospecialize arg
292
291
maparg (arg, SSAValue (ssa), order)
293
292
end
294
293
f = isexpr (stmt, :call ) ? ∂☆ {order} () : ∂☆new {order} ()
295
- inst[:inst ] = Expr (:call , f, newargs... )
296
- inst[:type ] = Any
294
+ replace_call! (ir, SSAValue (ssa), Expr (:call , f, newargs... ))
297
295
elseif isa (stmt, PiNode)
298
296
# TODO : New PiNode that discriminates based on primal?
299
297
inst[:inst ] = maparg (stmt. val, SSAValue (ssa), order)
@@ -304,8 +302,7 @@ function forward_diff_no_inf!(ir::IRCode, to_diff::Vector{Pair{SSAValue,Int}};
304
302
stmt = insert_node! (ir, ssa, NewInstruction (inst))
305
303
end
306
304
307
- inst[:inst ] = Expr (:call , ZeroBundle{order}, stmt)
308
- inst[:type ] = Any
305
+ replace_call! (ir, SSAValue (ssa), Expr (:call , ZeroBundle{order}, stmt))
309
306
elseif isa (stmt, SSAValue) || isa (stmt, QuoteNode)
310
307
inst[:inst ] = maparg (stmt, SSAValue (ssa), order)
311
308
inst[:type ] = Any
0 commit comments