Skip to content

Commit 0a95867

Browse files
committed
Error handler fix
1 parent 1b723af commit 0a95867

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/rules/llvmrules.jl

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,20 @@ end
255255
API.moveBefore(newo, err, B)
256256
normal =
257257
(unsafe_load(normalR) != C_NULL) ? LLVM.Instruction(unsafe_load(normalR)) : nothing
258-
if shadowR != C_NULL && normal !== nothing
259-
t_shadow = normal
258+
if shadowR != C_NULL
259+
t_shadow1 = if normal !== nothing
260+
normal
261+
else
262+
LLVM.null(value_type(orig))
263+
end
264+
t_shadow = t_shadow1
260265
width = get_width(gutils)
261266
if width != 1
262267
t_shadow = UndefValue(
263-
LLVM.LLVMType(API.EnzymeGetShadowType(width, value_type(normal))),
268+
LLVM.LLVMType(API.EnzymeGetShadowType(width, value_type(t_shadow1))),
264269
)
265270
for idx = 1:width
266-
t_shadow = insert_value!(B, t_shadow, normal, idx - 1)
271+
t_shadow = insert_value!(B, t_shadow, t_shadow1, idx - 1)
267272
end
268273
end
269274
unsafe_store!(shadowR, t_shadow.ref)

0 commit comments

Comments
 (0)