Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/gradientutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ function get_or_insert_conditional_execute!(fn::LLVM.Function; force_run=false,
if force_run
newname = newname * "forcerun."
end
if extra_rt
newname = newname * "extra_rt."
end
if preprocess !== nothing
newname = newname * ".po_$(preprocess)"
end
Expand All @@ -132,6 +135,10 @@ function get_or_insert_conditional_execute!(fn::LLVM.Function; force_run=false,
end
newname = newname * LLVM.name(fn)
cfn, _ = get_function!(mod, newname, FT)
if !isa(cfn, LLVM.Function)
message = "Failed to find function for $newname, types $(string(FT)), found $(string(cfn)), from $(string(operands(cfn)[1])), fn=$(string(fn))"
throw(AssertionError(message))
end
if isempty(blocks(cfn))
linkage!(cfn, LLVM.API.LLVMInternalLinkage)
let builder = IRBuilder()
Expand Down Expand Up @@ -189,6 +196,7 @@ function get_or_insert_conditional_execute!(fn::LLVM.Function; force_run=false,
end
end
push!(function_attributes(fn), EnumAttribute("alwaysinline"))
push!(function_attributes(fn), StringAttribute("enzyme_preserve_primal", "*"))
end
return cfn
end
Expand Down
Loading