Opened 9 years ago

Closed 9 years ago

#4346 closed bug (fixed)

Behaviour of INLINABLE depends on whether the modules included are already compiled.

Reported by: milan Owned by: simonmar
Priority: high Milestone: 7.0.1
Component: Compiler Version: 7.1
Keywords: Cc: simonpj
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


When investigating containers performance, I came across the following problem:

My Data.Map annotates nearly every method as INLINABLE. My main module Main.hs is trivial:

import Data.Map as M

main = print $ M.lookup 5 $ foldr (\x -> insert x x) empty [1..100]

Suppose my tree contains only .hs files, no .hi or .o. I can compile either by

  • ghc --make -c -O Main.hs, which compiles Data/Map.hs automatically, or
  • ghc --make -c -O Data/Map.hs && ghc --make -c -O Main.hs, which compiles Data/Map.hs explicitely with the same arguments first.

Expected result of both compilations: Main.o is the same.

Actual result: in the first case, Data.Map.lookup method does not get inlined in Main.o, but in the second case the Data.Map.lookup method gets inlined in Main.o.

If affects both ghc-7.0 and ghc-head branches.

I am not sure this is a bug, but I would definitely expect both of the compilation methods to yield the same file.

The self-contained source tree is attached.

Attachments (1)

tree.tar.gz (28.0 KB) - added by milan 9 years ago.

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by milan

Attachment: tree.tar.gz added

comment:1 Changed 9 years ago by simonmar

Milestone: 7.0.1
Priority: normalhigh

That's deeply suspicious. Let's investigate before the release.

comment:2 Changed 9 years ago by simonmar

Owner: set to simonmar

comment:3 Changed 9 years ago by simonmar

Status: newmerge

Fixed - thanks for a great report, and well done for spotting the problem.

Fri Oct 15 10:48:36 BST 2010  Simon Marlow <>
  * Fix #4346 (INLINABLE pragma not behaving consistently)
  Debugged thanks to lots of help from Simon PJ: we weren't updating the
  UnfoldingGuidance when the unfolding changed.
  Also, a bit of refactoring and additinoal comments.

comment:4 Changed 9 years ago by igloo

Resolution: fixed
Status: mergeclosed


Note: See TracTickets for help on using tickets.