From df20f1883ece2ca9b346568ea3f82f2f6247a283 Mon Sep 17 00:00:00 2001 From: William Moses Date: Mon, 4 Nov 2024 18:27:43 -0600 Subject: [PATCH] Debug specfunc (#2052) * Debug specfunc * Add test * Update optimize.jl --- src/compiler.jl | 2 +- test/optimize.jl | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/compiler.jl b/src/compiler.jl index 786fba0134..e35fd8b6a1 100644 --- a/src/compiler.jl +++ b/src/compiler.jl @@ -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)) diff --git a/test/optimize.jl b/test/optimize.jl index 7bc89ecc74..4792ac0570 100644 --- a/test/optimize.jl +++ b/test/optimize.jl @@ -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