Skip to content

Commit bcf996a

Browse files
authored
Clarify comment and add Core.throw anyway
1 parent e09f407 commit bcf996a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/compiler/reverse.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ function adjointcfg(pr::Primal)
257257
branch!(rb, preds[i].id, unless = cond)
258258
end
259259
if isempty(preds) || (!isempty(branches(b)) && branches(b)[end] == IRTools.unreachable)
260-
# An unreachable block in the primal will also be unreachable in the adjoint
260+
# If `b` is unreachable, then no context produced by the primal should end up branching to `rb`
261+
push!(rb, xcall(Core, :throw, "unreachable")) # `throw` is necessary for inference not to hit the `unreachable`
261262
branch!(rb, 0)
262263
end
263264
end

0 commit comments

Comments
 (0)