@@ -493,8 +493,29 @@ function uncompressed_ast(m::Method, s::CodeInfo)
493
493
return s
494
494
end
495
495
496
+ # this type mirrors jl_cgparams_t (documented in julia.h)
497
+ immutable CodegenParams
498
+ cached:: Cint
499
+
500
+ runtime:: Cint
501
+ exceptions:: Cint
502
+ track_allocations:: Cint
503
+ code_coverage:: Cint
504
+ static_alloc:: Cint
505
+ dynamic_alloc:: Cint
506
+
507
+ CodegenParams (;cached:: Bool = true ,
508
+ runtime:: Int = 1 , exceptions:: Int = 1 ,
509
+ track_allocations:: Int = 1 , code_coverage:: Int = 1 ,
510
+ static_alloc:: Int = 1 , dynamic_alloc:: Int = 1 ) =
511
+ new (Cint (cached),
512
+ Cint (runtime), Cint (exceptions),
513
+ Cint (track_allocations), Cint (code_coverage),
514
+ Cint (static_alloc), Cint (dynamic_alloc))
515
+ end
516
+
496
517
# Printing code representations in IR and assembly
497
- function _dump_function (f:: ANY , t:: ANY , native:: Bool , wrapper:: Bool , strip_ir_metadata:: Bool , dump_module:: Bool , syntax:: Symbol = :att )
518
+ function _dump_function (f:: ANY , t:: ANY , native:: Bool , wrapper:: Bool , strip_ir_metadata:: Bool , dump_module:: Bool , syntax:: Symbol = :att , optimize :: Bool = true , params :: CodegenParams = CodegenParams () )
498
519
ccall (:jl_is_in_pure_context , Bool, ()) && error (" code reflection cannot be used from generated functions" )
499
520
if isa (f, Core. Builtin)
500
521
throw (ArgumentError (" argument is not a generic function" ))
@@ -509,17 +530,17 @@ function _dump_function(f::ANY, t::ANY, native::Bool, wrapper::Bool, strip_ir_me
509
530
meth = func_for_method_checked (meth, tt)
510
531
linfo = ccall (:jl_specializations_get_linfo , Ref{Core. MethodInstance}, (Any, Any, Any), meth, tt, env)
511
532
# get the code for it
512
- return _dump_function (linfo, native, wrapper, strip_ir_metadata, dump_module, syntax)
533
+ return _dump_function (linfo, native, wrapper, strip_ir_metadata, dump_module, syntax, optimize, params )
513
534
end
514
535
515
- function _dump_function (linfo:: Core.MethodInstance , native:: Bool , wrapper:: Bool , strip_ir_metadata:: Bool , dump_module:: Bool , syntax:: Symbol = :att )
536
+ function _dump_function (linfo:: Core.MethodInstance , native:: Bool , wrapper:: Bool , strip_ir_metadata:: Bool , dump_module:: Bool , syntax:: Symbol = :att , optimize :: Bool = true , params :: CodegenParams = CodegenParams () )
516
537
if syntax != :att && syntax != :intel
517
538
throw (ArgumentError (" 'syntax' must be either :intel or :att" ))
518
539
end
519
540
if native
520
- llvmf = ccall (:jl_get_llvmf_decl , Ptr{Void}, (Any, Bool), linfo, wrapper)
541
+ llvmf = ccall (:jl_get_llvmf_decl , Ptr{Void}, (Any, Bool, CodegenParams ), linfo, wrapper, params )
521
542
else
522
- llvmf = ccall (:jl_get_llvmf_defn , Ptr{Void}, (Any, Bool), linfo, wrapper)
543
+ llvmf = ccall (:jl_get_llvmf_defn , Ptr{Void}, (Any, Bool, Bool, CodegenParams ), linfo, wrapper, optimize, params )
523
544
end
524
545
if llvmf == C_NULL
525
546
error (" could not compile the specified method" )
0 commit comments