Skip to content

Commit

Permalink
Debug specfunc (#2052)
Browse files Browse the repository at this point in the history
* Debug specfunc

* Add test

* Update optimize.jl
  • Loading branch information
wsmoses authored Nov 5, 2024
1 parent 2e18dfc commit df20f18
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3453,7 +3453,7 @@ function annotate!(mod, mode)
LLVM.API.LLVMRemoveEnumAttributeAtIndex(
fn,
reinterpret(LLVM.API.LLVMAttributeIndex, LLVM.API.LLVMAttributeFunctionIndex),
kind(EnumAttribute("allockind")),
kind(EnumAttribute("allockind", AllocFnKind(AFKE_Alloc).data)),
)
push!(function_attributes(fn), no_escaping_alloc)
push!(function_attributes(fn), LLVM.EnumAttribute("allockind", (AllocFnKind(AFKE_Alloc) | AllocFnKind(AFKE_Uninitialized)).data))
Expand Down
15 changes: 15 additions & 0 deletions test/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,18 @@ end
Enzyme.Const(dist)
)
end

@noinline function mc_g(i, _not_used)
k = (0.25)
return (i, k)
end

function mc_f(_not_used)
i = (0.0, 3.9555)
t = mc_g(i, _not_used)
return t[1][2]
end

@testset "Memcopy of constant" begin
@test Enzyme.autodiff(Enzyme.Forward, mc_f, Duplicated(2.7, 1.0))[1] 0.0
end

0 comments on commit df20f18

Please sign in to comment.