Inlining braindamage

Simon Peyton-Jones simonpj@microsoft.com
Mon, 5 Mar 2001 00:54:56 -0800


GHC doesn't inline anything in the RHS of an INLINE thing,
for good reasons.  Consider
	
	f x = ...g...
	{-# INLINE f #-}

where g is very large, but only called once.  If we inlined g,
we'd end up inlining a big thing instead of a small thing.

If f is exported, GHC keeps the defn of f, in case it doesn't get
inlined anywhere.

So I'm not surprised that lookahead still exists, nor that $ isn't
inlined in its RHS (though that rule could be made a bit more lenient).

What I don't understand is why lookahead isn't inlined at its call sites
which you imply it isn't.

If you can boil it down a little it would help.

S

| -----Original Message-----
| From: Marcin 'Qrczak' Kowalczyk [mailto:qrczak@knm.org.pl]
| Sent: 05 March 2001 00:48
| To: cvs-ghc@haskell.org
| Subject: Inlining braindamage
| 
| 
| I'm compiling hsc2hs using ghc from March 1, with -O. A function
| marked as inline is compiled out of line thus:
| 
| lookAhead = NO_CCS[] \u[] PrelBase.$ Main.Parser lvl72_sbNJ;
| 
| Explicit reference to PrelBase.$ (which is also marked inline) is
| a horrible mistake. Removing INLINE pragmas from hsc2hs causes
| lookAhead to actually get inlined!
| 
| -- 
|  __("<  Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/
|  \__/
|   ^^                      SYGNATURA ZASTEPCZA
| QRCZAK
| 
| 
| _______________________________________________
| Cvs-ghc mailing list
| Cvs-ghc@haskell.org
| http://www.haskell.org/mailman/listinfo/cvs-ghc
| 
|