[compiler-hacking] @inline attribute?

Anil Madhavapeddy anil at recoil.org
Thu Oct 30 16:01:19 GMT 2014


On 30 Oct 2014, at 14:42, Leo White <lpw25 at cam.ac.uk> wrote:
> 
>> I'm interested in people's thoughts on adding an @inline attribute,
>> along the lines of GHC's {-# INLINE #-}:
>> 
>>   https://www.haskell.org/ghc/docs/7.0.2/html/users_guide/pragmas.html#inline-noinline-pragma
>> 
>> It'd be useful to have a way of encouraging the compiler to inline
>> functions which its own heuristics might discount as too large or
>> otherwise too expensive.
> 
> I'd like it to go one step further and give a warning or error if
> inlining could not be done for some reason (e.g. .cmx file not
> present). I think this is very much inline with OCaml's philosophy of
> predictable performance -- rather than just hope that the compiler
> inlines something I can be certain of it.

I agree.  I would also like the reverse mode: a compiler mode that
annotates existing source code with @inline attributes where it
does actually take place, so that the programmer can get a sense
of where it has happened in existing code.

This might better be supported through Merlin or something, but I
always liked how ocamlprof rewrote the source code with comments.

Another hopefully simple option that would be handy is a compiler
flag that flags a missing .cmx as an error for the purposes of
cross-module inlining in ocamlopt, to prevent silently missing
inlining opportunities due to build system bugs.

-anil


More information about the Cam-compiler-hacking mailing list