Skip to content

Commit 345a945

Browse files
committed
Fix justActive condition
Closes EnzymeAD#1935
1 parent 3c0871d commit 345a945

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/compiler.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ end
467467

468468
subT = fieldtype(T, f)
469469

470-
if justActive && !allocatedinline(subT)
470+
if justActive && ismutabletype(subT)
471471
return Val(AnyState)
472472
end
473473

test/runtests.jl

+10
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ end
144144
@test Enzyme.Compiler.active_reg_inner(Tuple, (), nothing) == Enzyme.Compiler.DupState
145145
@test Enzyme.Compiler.active_reg_inner(Tuple, (), nothing, #=justactive=#Val(false), #=unionsret=#Val(false), #=abstractismixed=#Val(true)) == Enzyme.Compiler.MixedState
146146
@test Enzyme.Compiler.active_reg_inner(Tuple{A,A} where A, (), nothing, #=justactive=#Val(false), #=unionsret=#Val(false), #=abstractismixed=#Val(true)) == Enzyme.Compiler.MixedState
147+
148+
# issue #1935
149+
struct Partial
150+
x::Float64
151+
box::Core.Box
152+
Partial(x) = new(x) # partial constructor => Base.allocatedinline(Partial) == false
153+
end
154+
@test Enzyme.Compiler.active_reg_inner(Tuple{Partial}, (), nothing, #=justActive=#Val(false)) == Enzyme.Compiler.MixedState
155+
@test Enzyme.Compiler.active_reg_inner(Tuple{Partial}, (), nothing, #=justActive=#Val(true)) == Enzyme.Compiler.ActiveState
156+
147157
world = codegen_world_age(typeof(f0), Tuple{Float64})
148158
thunk_a = Enzyme.Compiler.thunk(Val(world), Const{typeof(f0)}, Active, Tuple{Active{Float64}}, Val(API.DEM_ReverseModeCombined), Val(1), Val((false, false)), Val(false), Val(false), DefaultABI, Val(false), Val(false))
149159
thunk_b = Enzyme.Compiler.thunk(Val(world), Const{typeof(f0)}, Const, Tuple{Const{Float64}}, Val(API.DEM_ReverseModeCombined), Val(1), Val((false, false)), Val(false), Val(false), DefaultABI, Val(false), Val(false))

0 commit comments

Comments
 (0)