@@ -25,7 +25,7 @@ function handle_contribution!(ir::Compiler.IRCode, inst::Compiler.Instruction, k
2525 replace_call! (ir, pos, Expr (:call , Base. setindex!, which, sum, slot))
2626end
2727
28- function compute_slot_ranges (info:: MappingInfo , callee_key, var_assignment, eq_assignment)
28+ function compute_slot_ranges (caller_state :: TransformationState , info:: MappingInfo , callee_key, var_assignment, eq_assignment)
2929 # Compute the ranges for this child's states in the parent range.
3030 # We rely upon earlier stages of the pipeline having put these adjacent to each other
3131 # and in order. We could just trust that, but because it's a little bit tricky, here
@@ -47,6 +47,7 @@ function compute_slot_ranges(info::MappingInfo, callee_key, var_assignment, eq_a
4747 caller_map = info. mapping. var_coeffs[callee_var]
4848 isa (caller_map, Const) && continue
4949 caller_var = only (rowvals (caller_map. row))- 1
50+ varkind (caller_state, caller_var) == Intrinsics. Continuous || continue
5051
5152 callee_kind = classify_var (info. result. var_to_diff, callee_key, callee_var)
5253 callee_kind === nothing && continue
@@ -166,7 +167,7 @@ function rhs_finish!(
166167 push! (stmt. args, in_vars)
167168
168169 # Ordering from tearing is (AssignedDiff, UnassignedDiff, Algebraic, Explicit)
169- slot_ranges = compute_slot_ranges (info, callee_key, var_assignment, eq_assignment)
170+ slot_ranges = compute_slot_ranges (state, info, callee_key, var_assignment, eq_assignment)
170171 for (arg, range) in zip (arg_range, slot_ranges)
171172 push! (stmt. args, insert_node! (ir, SSAValue (i),
172173 NewInstruction (inst;
@@ -183,6 +184,12 @@ function rhs_finish!(
183184 error ()
184185 elseif is_known_invoke (stmt, variable, ir)
185186 varnum = idnum (ir. stmts. type[i])
187+ kind = varkind (state, varnum)
188+ if kind == Intrinsics. Epsilon
189+ replace_call! (ir, SSAValue (i), 0. )
190+ continue
191+ end
192+ @assert kind == Intrinsics. Continuous
186193
187194 assgn = var_assignment[varnum]
188195 if assgn == nothing
0 commit comments