WIP: compiler: Don't inline panic functions
While working on making runRW#
simplify (#15127 (closed)) I noticed that we tend
to inline these panic functions pretty ubiquitously. For instance, in
GHC.CmmToAsm.PPC.Regs
we alone inlined PlainPanic.panic
six times,
each of which generating a 20-something term binding, each differing
only in the error message string. For instance,
-- RHS size: {terms: 17, types: 41, coercions: 0, joins: 0/0}
GHC.CmmToAsm.PPC.Regs.regDotColor2
:: GHC.Prim.State# GHC.Prim.RealWorld -> Outputable.SDoc
[GblId, Arity=1, Str=<L,U>, Cpr=b, Unf=OtherCon []]
GHC.CmmToAsm.PPC.Regs.regDotColor2
= \ (eta_s8Vu [Occ=Once] :: GHC.Prim.State# GHC.Prim.RealWorld) ->
case GHC.Prim.getCurrentCCS#
@GHC.Base.String @GHC.Prim.RealWorld x1_r7VT eta_s8Vu
of
{ (# s'_s8Vw [Occ=Once], addr_s8Vx [Occ=Once] #) ->
case GHC.Stack.CCS.$wgo
addr_s8Vx (GHC.Types.[] @[GHC.Types.Char]) s'_s8Vw
of
{ (# ipv_s8Vz [Occ=Once], ipv1_s8VA [Occ=Once] #) ->
case PlainPanic.panic1
@GHC.Platform.Reg.Class.RegClass ipv_s8Vz ipv1_s8VA x1_r7VT
of {
}
}
}
Given how this is a failure path, this seems silly. Frankly, it's surprising that we choose to inline at all. Part of me things that we should apply some sort of penalty for inlining a bottoming function.
This is tracked as #18086 (closed).
Edited by Ben Gamari