|Anonymous | Login | Signup for a new account||2015-05-28 04:06 CEST|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005917||OCaml||OCaml backend (code generation)||public||2013-02-11 10:41||2014-09-04 00:25|
|Priority||normal||Severity||feature||Reproducibility||have not tried|
|Target Version||undecided||Fixed in Version|
|Summary||0005917: [patch] Generate direct call inside inlined function|
|Description||Currently when a function is inlined calls inside its body are not converted to direct call|
when it is possible. For instance:
let f x = x + x
let g h (x,y) = h x, h y
let i (x,y) = g f (x,y)
When i is compiled, g will be inlined giving:
let i (x,y) = f x, f y
but calls to f will be generic calls (in that particular case it could even be inlined).
To do that, this pach add an environment of approximate values to the Closure.substitute
function to be able to retrieve the function definition at call site.
This also prepare for future patch using that environment: there are many possible things
that can be improved in functions when approximate environment is known. Normally this is
not really important because usually the programmer will avoid writing stupid code, but
when a function body is inlined, it can become redundant.
I also would like to open a discution: should we separate closure conversion and constant
propagation in two different passes ?
If we add other optimisations to the constant propagation phase, we would need to implement
them both inside the close (lambda to clambda) and substitute (clambda to clambda) functions.
So I think it would probably be simpler to simplify the closure conversion and do only that
in the lambda to clambda pass and do a separate optimisation pass on the produced clambda
|Additional Information||Since the evaluation of function size for inlining is considered on the body without the|
potential inline, it can be innacurate and lead to code size explosition in contrieved
let f1 x = x + x
let f2 g (a,b) = g a, g b
let f3 g1 g2 (a,b) = g1 g2 (a,b), g1 g2 (a,b)
let f4 g1 g2 g3 (a,b) = g1 g2 g3 (a,b), g1 g2 g3 (a,b)
let f = f4 f3 f2 f1 (1,1)
If this bother someone, it is simple to forbid that by adding a limit to depth of allowed
This patch may be used to improve the patch submited for issue 0005894.
|Attached Files||0001-Direct-call-can-be-generated-in-inlined-code.patch [^] (14,833 bytes) 2013-02-11 10:41 [Show Content]|
|2013-02-11 10:41||chambart||New Issue|
|2013-02-11 10:41||chambart||File Added: 0001-Direct-call-can-be-generated-in-inlined-code.patch|
|2013-06-19 15:25||doligez||Status||new => acknowledged|
|2013-06-19 15:25||doligez||Target Version||=> 4.01.0+dev|
|2013-07-16 16:32||frisch||Target Version||4.01.0+dev => 4.02.0+dev|
|2013-12-16 14:16||doligez||Tag Attached: patch|
|2014-08-15 18:22||gasche||Target Version||4.02.0+dev => 4.02.1+dev|
|2014-09-04 00:25||doligez||Target Version||4.02.1+dev => undecided|
|Copyright © 2000 - 2011 MantisBT Group|