Skip to content

Commit 623d204

Browse files
committed
Perform deferred codegen-optimization after regular optimization.
1 parent f5232e4 commit 623d204

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/driver.jl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,20 @@ const __llvm_initialized = Ref(false)
263263
# merge constants (such as exception messages)
264264
constant_merge!(pm)
265265

266-
if do_deferred_codegen
266+
run!(pm, ir)
267+
end
268+
end
269+
270+
if optimize
271+
@timeit_debug to "optimization" begin
272+
optimize!(job, ir)
273+
274+
# deferred codegen has some special optimization requirements,
275+
# which also need to happen _after_ regular optimization.
276+
# XXX: make these part of the optimizer pipeline?
277+
do_deferred_codegen && ModulePassManager() do pm
267278
# inline and optimize the call to e deferred code. in particular we want
268279
# to remove unnecessary alloca's created by pass-by-ref semantics.
269-
# TODO: is this still necesary, now that we optimize after codegen?
270280
instruction_combining!(pm)
271281
always_inliner!(pm)
272282
scalar_repl_aggregates_ssa!(pm)
@@ -276,14 +286,10 @@ const __llvm_initialized = Ref(false)
276286
# merge duplicate functions, since each compilation invocation emits everything
277287
# XXX: ideally we want to avoid emitting these in the first place
278288
merge_functions!(pm)
279-
end
280289

281-
run!(pm, ir)
290+
run!(pm, ir)
291+
end
282292
end
283-
end
284-
285-
if optimize
286-
@timeit_debug to "optimization" optimize!(job, ir)
287293

288294
# optimization may have replaced functions, so look the entry point up again
289295
entry = functions(ir)[entry_fn]

0 commit comments

Comments
 (0)