Skip to content

Commit 9b099a6

Browse files
authored
Add dump mod post optimizations option (#1694)
1 parent d89dbce commit 9b099a6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/api.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,10 @@ function EnzymeReplaceFunctionImplementation(mod)
763763
ccall((:EnzymeReplaceFunctionImplementation, libEnzyme),Cvoid,(LLVM.API.LLVMModuleRef,), mod)
764764
end
765765

766+
function EnzymeDumpModuleRef(mod)
767+
ccall((:EnzymeDumpModuleRef, libEnzyme),Cvoid,(LLVM.API.LLVMModuleRef,), mod)
768+
end
769+
766770
EnzymeComputeByteOffsetOfGEP(B, V, T) = LLVM.Value(ccall((:EnzymeComputeByteOffsetOfGEP, libEnzyme), LLVM.API.LLVMValueRef, (LLVM.API.LLVMBuilderRef, LLVM.API.LLVMValueRef, LLVM.API.LLVMTypeRef), B, V, T))
767771

768772
EnzymeAllocaType(al) = LLVM.LLVMType(ccall((:EnzymeAllocaType, libEnzyme), LLVM.API.LLVMTypeRef, (LLVM.API.LLVMValueRef,), al))

src/compiler.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6866,6 +6866,8 @@ function _link(job, (mod, adjoint_name, primal_name, TapeType))
68666866
return CompileResult(adjoint_ptr, primal_ptr, TapeType)
68676867
end
68686868

6869+
const DumpPostOpt = Ref(false)
6870+
68696871
# actual compilation
68706872
function _thunk(job, postopt::Bool=true)
68716873
mod, meta = codegen(:llvm, job; optimize=false)
@@ -6888,6 +6890,9 @@ function _thunk(job, postopt::Bool=true)
68886890
if postopt
68896891
if job.config.params.ABI <: FFIABI || job.config.params.ABI <: NonGenABI
68906892
post_optimze!(mod, JIT.get_tm())
6893+
if DumpPostOpt[]
6894+
API.EnzymeDumpModuleRef(mod.ref)
6895+
end
68916896
else
68926897
propagate_returned!(mod)
68936898
end

0 commit comments

Comments
 (0)