From 5a9c6980f5469133100200f47cb880e6e691923d Mon Sep 17 00:00:00 2001 From: Daniel Wennberg Date: Thu, 3 Oct 2024 12:43:50 -0700 Subject: [PATCH] Fix justActive condition Closes #1935 --- src/compiler.jl | 2 +- test/runtests.jl | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/compiler.jl b/src/compiler.jl index 16d54481cf..a38aae7ad8 100644 --- a/src/compiler.jl +++ b/src/compiler.jl @@ -467,7 +467,7 @@ end subT = fieldtype(T, f) - if justActive && !allocatedinline(subT) + if justActive && ismutabletype(subT) return Val(AnyState) end diff --git a/test/runtests.jl b/test/runtests.jl index 902b9e4f65..e85f1afae4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -144,6 +144,17 @@ end @test Enzyme.Compiler.active_reg_inner(Tuple, (), nothing) == Enzyme.Compiler.DupState @test Enzyme.Compiler.active_reg_inner(Tuple, (), nothing, #=justactive=#Val(false), #=unionsret=#Val(false), #=abstractismixed=#Val(true)) == Enzyme.Compiler.MixedState @test Enzyme.Compiler.active_reg_inner(Tuple{A,A} where A, (), nothing, #=justactive=#Val(false), #=unionsret=#Val(false), #=abstractismixed=#Val(true)) == Enzyme.Compiler.MixedState + + # issue #1935 + struct Incomplete + x::Float64 + y + Incomplete(x) = new(x) + # incomplete constructor & non-bitstype field => !Base.allocatedinline(Incomplete) + end + @test Enzyme.Compiler.active_reg_inner(Tuple{Incomplete}, (), nothing, #=justActive=#Val(false)) == Enzyme.Compiler.MixedState + @test Enzyme.Compiler.active_reg_inner(Tuple{Incomplete}, (), nothing, #=justActive=#Val(true)) == Enzyme.Compiler.ActiveState + world = codegen_world_age(typeof(f0), Tuple{Float64}) 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)) 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))