Skip to content

Commit a78bb2d

Browse files
committed
assert check the world we encode in enzyme_extrace_world
1 parent 70ef0dd commit a78bb2d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/compiler.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,7 @@ function set_module_types!(interp, mod::LLVM.Module, primalf::Union{Nothing, LLV
10831083
end
10841084

10851085
world = enzyme_extract_world(f)
1086+
@assert world == interp.world
10861087

10871088
if expectLen != length(parameters(f))
10881089
continue
@@ -1665,6 +1666,7 @@ function shadow_alloc_rewrite(V::LLVM.API.LLVMValueRef, gutils::API.EnzymeGradie
16651666
mode == API.DEM_ReverseModeCombined
16661667
fn = LLVM.parent(LLVM.parent(V))
16671668
world = enzyme_extract_world(fn)
1669+
@assert world == enzyme_gutils_context(gutils).world
16681670
if !guaranteed_nonactive(Ty, world)
16691671
B = LLVM.IRBuilder()
16701672
position!(B, V)

src/errors.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ function julia_error(
475475
) #=error=#
476476
world = enzyme_extract_world(f)
477477
end
478+
@assert world == enzyme_gutils_context(gutils).world
478479
throw(IllegalTypeAnalysisException(msg, mi, world, sval, ir, bt))
479480
elseif errtype == API.ET_NoType
480481
@assert B != C_NULL
@@ -550,6 +551,7 @@ function julia_error(
550551
illegal = false
551552
created = LLVM.Instruction[]
552553
world = enzyme_extract_world(LLVM.parent(position(IRBuilder(B))))
554+
@assert world == enzyme_context(gutils).world
553555
width = get_width(gutils)
554556
function make_batched(@nospecialize(cur::LLVM.Value), B::LLVM.IRBuilder)::LLVM.Value
555557
if width == 1
@@ -944,7 +946,7 @@ end
944946
end
945947
end
946948

947-
mi = nothing
949+
mi = nothing
948950
world = nothing
949951

950952
if isa(val, LLVM.Instruction)
@@ -962,6 +964,7 @@ end
962964
) #=error=#
963965
world = enzyme_extract_world(f)
964966
end
967+
@assert world == enzyme_gutils_context(gutils).world
965968
mode = Enzyme.API.DEM_ReverseModeCombined
966969

967970
if mi !== nothing

0 commit comments

Comments
 (0)