Skip to content

Occurrence analysis and RULES

Something is wrong with the occurrence analysis of rules.

module Foo where

f :: Int -> Int
{-# NOINLINE [1] f #-}
f x = x+1

{-# RULES
   "map/f" map f = map (f . f)
#-}

At least with -DDEBUG you'll see

WARNING: file compiler/simplCore/OccurAnal.hs, line 73
  Glomming in Foo: [rgg :->]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1237:29 in ghc:Outputable
        warnPprTrace, called at compiler/simplCore/OccurAnal.hs:72:6 in ghc:OccurAnal
WARNING: file compiler/simplCore/OccurAnal.hs, line 73
  Glomming in Foo: [rgg :->]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1237:29 in ghc:Outputable
        warnPprTrace, called at compiler/simplCore/OccurAnal.hs:72:6 in ghc:OccurAnal
WARNING: file compiler/simplCore/OccurAnal.hs, line 73
  Glomming in Foo: [rgg :->]
  Call stack:
      CallStack (from HasCallStack):
        callStackDoc, called at compiler/utils/Outputable.hs:1237:29 in ghc:Outputable
        warnPprTrace, called at compiler/simplCore/OccurAnal.hs:72:6 in ghc:OccurAnal

Etc. We glom in every simplifier run. This is silly.

It happens because of Note [Preventing loops due to imported functions rules], but it's clearly wrong to do repeated glomming.

Maybe not urgent, but it'd be good to attend to this.

Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information