Note [Always expose compulsory unfoldings]
We must make absolutely sure that unsafeCoerce# is inlined. You might think that giving it a compulsory unfolding is enough. However, unsafeCoerce# is put in an interface file just like any other definition. So, unless we take special precuations - If we compiled Unsafe.Coerce with -O0, we might not put the unfolding into the interface file. - If we compile a module M, that imports Unsafe.Coerce, with -O0 we might not read the unfolding out of the interface file. So we need to take care, to ensure that Compulsory unfoldings are written and read. That makes sense: they are compulsory, after all. There are three places this is actioned: * GHC.Iface.Tidy.addExternal. Export end: expose compulsory unfoldings, even with -O0. * GHC.IfaceToCore.tcIdInfo. Import end: when reading in from interface file, even with -O0 (fignore-interface-pragmas.) we must load a compulsory unfolding
References 0
This Note does not link to any other.
Referenced by 4
- GHC.Iface.Tidy call site ×2
- Wiring in unsafeCoerce# GHC.HsToCore
- GHC.IfaceToCore call site