Unexpected failure to inline, even with pragma

Simon Peyton Jones simonpj at microsoft.com
Fri May 2 08:45:32 UTC 2014


| Is -O required for optimization across module bounds?

Yes, without -O GHC doesn’t put inlinings into interface files, so an importing module can't see them.  Use -fno-omit-interface-pragmas to tell GHC to put the stuff in the interface file regardless.

| Also, since I really want a certain level of inlining for a plugin I'm
| working on; is there a way to force (from the plugin, i.e. using the
| API) to force inlining of a term at its call-site?

Yes, use the magic function 'inline'.  http://www.haskell.org/ghc/docs/7.8.2/html/libraries/base-4.7.0.0/GHC-Exts.html#v%3Ainline
(But I don’t know how much people have exercised this recently, and I think it's a bit fragile because it vanishes after a single inlining.)

| Alternatively
| (weaker), can I force - from a compiler plugin - the inliner to behave
| as if -O was set even if it wasn't?

Well, you could invoke the simplifier from the plugin, setting the DynFlags to -O first.  But I don’t think the plugin can side-effect the DynFlags for downstream passes.

Simon



More information about the ghc-devs mailing list