Skip to content

Suggestions for failed specialisations should be clearer on what method failed specialization failed on.

Motivation

Currently GHC will give a warning like this:

compiler\GHC\CmmToAsm\X86.hs: warning: [-Wall-missed-specialisations]
    Could not specialise imported function `mkLoadInstr'
      when specialising `GHC.CmmToAsm.Reg.Linear.allocRegsAndSpill_spill'
      when specialising `GHC.CmmToAsm.Reg.Linear.allocateRegsAndSpill'
      when specialising `GHC.CmmToAsm.Reg.Linear.genRaInsn'
      when specialising `GHC.CmmToAsm.Reg.Linear.$wraInsn'
      when specialising `GHC.CmmToAsm.Reg.Linear.raInsn'
      when specialising `GHC.CmmToAsm.Reg.Linear.linearRA'
      when specialising `GHC.CmmToAsm.Reg.Linear.processBlock'
      when specialising `GHC.CmmToAsm.Reg.Linear.process'
      when specialising `GHC.CmmToAsm.Reg.Linear.linearRA_SCCs'
      when specialising GHC.CmmToAsm.Reg.Linear.$wlinearRegAlloc'
      when specialising GHC.CmmToAsm.Reg.Linear.linearRegAlloc'
      when specialising `GHC.CmmToAsm.Reg.Linear.linearRegAlloc'
    Probable fix: add INLINABLE pragma on `mkLoadInstr'

However in GHC for example there is both a typeclass with a mkLoadInstr and multiple definitions for mkLoadInstr for different instruction sets.

So it isn't always trivial to trace back this warning to a definition site.

Proposal

The error should include the module containing the binding in the suggestion. In the example above we would instead print

Probable fix: add INLINABLE pragma on `mkLoadInstr' in `GHC.CmmToAsm.Instr'

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