Skip to content

Always inline code which would result in static indirections.

Motivation

Certain code will always be compiled to a static indirection.

In particular this is true if all a binding does is coercing a value to a different type like b in the example below.

This is bad since we have to follow the indirection at runtime, and can't short it out at compile time.

module B where

import A (a)

newtype Foo = Foo Int

{-# NOINLINE b #-}
b = Foo a

------------------------------

module C where

import B

data C = C !Foo

c = C b

Proposal

GHC in these cases should ignore the NOINLINE pragma and always force b to be inlined.

This would also help with avoiding untagged things ending up in strict fields. See #14677 (closed)

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