Skip to content

Commit 5647a8f

Browse files
committed
add some fixes from Enzyme
1 parent 01444be commit 5647a8f

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

test/helpers/enzyme.jl

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,18 @@ function deferred_codegen_id_generator(world::UInt, source, self, ft::Type, tt::
8181
# prepare a new code info
8282
new_ci = copy(ci)
8383
empty!(new_ci.code)
84-
if VERSION >= v"1.12.0-DEV.173"
85-
else
86-
empty!(new_ci.codelocs)
87-
empty!(new_ci.linetable)
88-
end
84+
@static if isdefined(Core, :DebugInfo)
85+
new_ci.debuginfo = Core.DebugInfo(:none)
86+
else
87+
empty!(new_ci.codelocs)
88+
resize!(new_ci.linetable, 1) # see note below
89+
end
8990
empty!(new_ci.ssaflags)
9091
new_ci.ssavaluetypes = 0
9192

9293
# propagate edge metadata
93-
new_ci.min_world = min_world[]
94+
# new_ci.min_world = min_world[]
95+
new_ci.min_world = world
9496
new_ci.max_world = max_world[]
9597
new_ci.edges = Core.MethodInstance[mi]
9698

@@ -110,14 +112,17 @@ end
110112
# return the deferred_codegen_id
111113
push!(new_ci.code, CC.ReturnNode(id))
112114
push!(new_ci.ssaflags, 0x00)
113-
if VERSION >= v"1.12.0-DEV.173"
114-
new_ci.debuginfo = Core.DebugInfo(:none)
115-
else
116-
push!(new_ci.linetable, GPUCompiler.@LineInfoNode(mi))
117-
push!(new_ci.codelocs, 1)
118-
end
115+
@static if isdefined(Core, :DebugInfo)
116+
else
117+
push!(new_ci.codelocs, 1) # see note below
118+
end
119119
new_ci.ssavaluetypes += 1
120120

121+
# NOTE: we keep the first entry of the original linetable, and use it for location info
122+
# on the call to check_cache. we can't not have a codeloc (using 0 causes
123+
# corruption of the back trace), and reusing the target function's info
124+
# has as advantage that we see the name of the kernel in the backtraces.
125+
121126
return new_ci
122127
end
123128

0 commit comments

Comments
 (0)