Skip to content

Commit 20e21e8

Browse files
authored
Merge pull request #315 from JuliaGPU/tb/finish
Add a hook to post-process all IR.
2 parents e89d6b6 + e7b0c91 commit 20e21e8

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/driver.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@ const __llvm_initialized = Ref(false)
358358
end
359359
end
360360

361+
entry = finish_ir!(job, ir, entry)
362+
361363
# replace non-entry function definitions with a declaration
362364
# NOTE: we can't do this before optimization, because the definitions of called
363365
# functions may affect optimization.

src/interface.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ end
228228
# post-Julia optimization processing of the module
229229
optimize_module!(@nospecialize(job::CompilerJob), mod::LLVM.Module) = return
230230

231-
# final processing of the IR module, right before validation and machine-code generation
231+
# finalization of the module, before deferred codegen and optimization
232232
function finish_module!(@nospecialize(job::CompilerJob), mod::LLVM.Module, entry::LLVM.Function)
233233
ctx = context(mod)
234234
entry_fn = LLVM.name(entry)
@@ -241,6 +241,11 @@ function finish_module!(@nospecialize(job::CompilerJob), mod::LLVM.Module, entry
241241
return functions(mod)[entry_fn]
242242
end
243243

244+
# final processing of the IR, right before validation and machine-code generation
245+
function finish_ir!(@nospecialize(job::CompilerJob), mod::LLVM.Module, entry::LLVM.Function)
246+
return entry
247+
end
248+
244249
add_lowering_passes!(@nospecialize(job::CompilerJob), pm::LLVM.PassManager) = return
245250

246251
link_libraries!(@nospecialize(job::CompilerJob), mod::LLVM.Module,

0 commit comments

Comments
 (0)