@@ -256,11 +256,7 @@ function forward_diff_no_inf!(ir::IRCode, to_diff::Vector{Pair{SSAValue,Int}};
256
256
# TODO : Should we remember whether the callbacks wanted the arg?
257
257
return transform! (ir, arg, order)
258
258
elseif isa (arg, GlobalRef)
259
- if ! isconst (arg)
260
- # Non-const GlabalRefs need to need to be accessed as seperate statements
261
- arg = insert_node! (ir, ssa, NewInstruction (arg, Any))
262
- end
263
-
259
+ @assert isconst (arg)
264
260
return insert_node! (ir, ssa, NewInstruction (Expr (:call , ZeroBundle{order}, arg), Any))
265
261
elseif isa (arg, QuoteNode)
266
262
return ZeroBundle {order} (arg. value)
@@ -302,7 +298,15 @@ function forward_diff_no_inf!(ir::IRCode, to_diff::Vector{Pair{SSAValue,Int}};
302
298
# TODO : New PiNode that discriminates based on primal?
303
299
inst[:inst ] = maparg (stmt. val, SSAValue (ssa), order)
304
300
inst[:type ] = Any
305
- elseif isa (stmt, GlobalRef) || isa (stmt, SSAValue) || isa (stmt, QuoteNode)
301
+ elseif isa (stmt, GlobalRef)
302
+ if ! isconst (stmt)
303
+ # Non-const GlobalRefs need to need to be accessed as seperate statements
304
+ stmt = insert_node! (ir, ssa, NewInstruction (inst))
305
+ end
306
+
307
+ inst[:inst ] = Expr (:call , ZeroBundle{order}, stmt)
308
+ inst[:type ] = Any
309
+ elseif isa (stmt, SSAValue) || isa (stmt, QuoteNode)
306
310
inst[:inst ] = maparg (stmt, SSAValue (ssa), order)
307
311
inst[:type ] = Any
308
312
elseif isa (stmt, Expr) || isa (stmt, PhiNode) || isa (stmt, PhiCNode) ||
0 commit comments