@@ -1067,6 +1067,7 @@ function common_jl_getfield_fwd(offset, B, orig, gutils, normalR, shadowR)
10671067 shadowres = UndefValue (
10681068 LLVM. LLVMType (API. EnzymeGetShadowType (width, value_type (normal))),
10691069 )
1070+ position! (B, LLVM. Instruction (LLVM. API. LLVMGetNextInstruction (normal)))
10701071 for idx = 1 : width
10711072 shadowres = insert_value! (B, shadowres, normal, idx - 1 )
10721073 end
@@ -1534,8 +1535,13 @@ end
15341535 end
15351536 origops = collect (operands (orig))
15361537 width = get_width (gutils)
1537- if ! is_constant_value (gutils, origops[1 ])
1538- shadowin = invert_pointer (gutils, origops[1 ], B)
1538+ if ! is_constant_value (gutils, origops[1 ]) || ! get_runtime_activity (gutils)
1539+ shadowin = if ! is_constant_value (gutils, origops[1 ])
1540+ invert_pointer (gutils, origops[1 ], B)
1541+ else
1542+ estr = " Mismatched activity for: " * string (orig) * " const input " * string (origops[1 ]) * " , differentiable return"
1543+ LLVM. Value (julia_error (estr, orig. ref, API. ET_MixedActivityError, gutils. ref, origops[1 ]. ref, B. ref))
1544+ end
15391545 if width == 1
15401546 args = LLVM. Value[
15411547 shadowin
@@ -1565,6 +1571,7 @@ end
15651571 shadowres = UndefValue (
15661572 LLVM. LLVMType (API. EnzymeGetShadowType (width, value_type (normal))),
15671573 )
1574+ position! (B, LLVM. Instruction (LLVM. API. LLVMGetNextInstruction (normal)))
15681575 for idx = 1 : width
15691576 shadowres = insert_value! (B, shadowres, normal, idx - 1 )
15701577 end
0 commit comments