Skip to content

Commit 5eecb81

Browse files
committed
fix
1 parent f7058f2 commit 5eecb81

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

src/absint.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function absint(@nospecialize(arg::LLVM.Value), partial::Bool = false, istracked
2828
return (true, v)
2929
end
3030
end
31+
@assert !startswith(gname, "ejl_inserted")
3132
end
3233
if isa(ce, LLVM.LoadInst)
3334
gv = operands(ce)[1]

src/compiler/validation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function check_ir!(interp, @nospecialize(job::CompilerJob), errors::Vector{IRErr
262262
end
263263
if isa(addr, LLVM.ConstantInt)
264264

265-
ccall(:jl_, Cvoid, (Any,), ("pre", gname, ptr, string(addr)))
265+
ccall(:jl_, Cvoid, (Any,), ("pre", gname, off, string(addr), string(inst), string(inst0)))
266266

267267
ptr = Base.reinterpret(Ptr{Ptr{Cvoid}}, convert(UInt, addr) + off)
268268
if load1

src/errors.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ function julia_error(
12581258
if cur in keys(seen)
12591259
return seen[cur]
12601260
end
1261-
1261+
12621262
if isa(cur, LLVM.LoadInst)
12631263
larg, off = get_base_and_offset(operands(cur)[1])
12641264
if off == 0 && isa(larg, LLVM.AllocaInst)
@@ -1310,7 +1310,7 @@ function julia_error(
13101310
return make_batched(ncur, prevbb)
13111311
end
13121312
if active_reg(TT, world) == ActiveState &&
1313-
isa(cur, LLVM.ConstantExpr) &&
1313+
( isa(cur, LLVM.ConstantExpr) || isa(cur, LLVM.GlobalVariable)) &&
13141314
cur == data2
13151315
if width == 1
13161316
if mode == API.DEM_ForwardMode
@@ -1364,6 +1364,7 @@ end
13641364
if obj0 isa Core.Binding
13651365
sv = sv *" binded at "*string(obj0)
13661366
end
1367+
sv
13671368
else
13681369
"Unknown object of type" * " " * string(TT)
13691370
end

src/utils.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function unsafe_to_llvm(B::LLVM.IRBuilder, @nospecialize(val); insert_name_if_no
107107
end
108108
end
109109

110-
function setup_global(k, v)
110+
function setup_global(k, v, force_inactive=false)
111111
mod = LLVM.parent(LLVM.parent(LLVM.position(B)))
112112
globs = LLVM.globals(mod)
113113
if Base.haskey(globs, "ejl_" * k)
@@ -116,7 +116,7 @@ function unsafe_to_llvm(B::LLVM.IRBuilder, @nospecialize(val); insert_name_if_no
116116
gv = LLVM.GlobalVariable(mod, T_jlvalue, "ejl_" * k, Tracked)
117117

118118
API.SetMD(gv, "enzyme_ta_norecur", LLVM.MDNode(LLVM.Metadata[]))
119-
inactive = Enzyme.Compiler.is_memory_instance(v)
119+
inactive = force_inactive && Enzyme.Compiler.is_memory_instance(v)
120120
if !inactive && v isa Core.SimpleVector && length(v) == 0
121121
inactive = true
122122
end
@@ -150,7 +150,9 @@ function unsafe_to_llvm(B::LLVM.IRBuilder, @nospecialize(val); insert_name_if_no
150150
if insert_name_if_not_exists !== nothing
151151
insert_name_if_not_exists = "inserted\$"*string(Base.reinterpret(UInt, Compiler.unsafe_to_ptr(val)))*"\$"*insert_name_if_not_exists
152152
Compiler.JuliaEnzymeNameMap[insert_name_if_not_exists] = val
153-
return setup_global(insert_name_if_not_exists, val)
153+
# Since the legacy behavior was to force inactive for global constants, we retain that here (for now)
154+
force_inactive = true
155+
return setup_global(insert_name_if_not_exists, val, force_inactive)
154156
end
155157

156158
# XXX: This prevents code from being runtime relocatable

0 commit comments

Comments
 (0)