summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-04-20 19:14:22 -0400
committerBen Gamari <ben@smart-cactus.org>2020-05-20 13:15:50 -0400
commit0162ce429c5a4235bcd2f8a743f5dc6d852344db (patch)
treeac5736987e1b4bf6a9b460d28de40ff5f9280612
parent568d7279a80cf945271f0659f11a94eea3f1433d (diff)
downloadhaskell-wip/noinline-panic.tar.gz
compiler: Don't inline panic functionswip/noinline-panic
While working on making runRW# simplify (#15127) 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.
-rw-r--r--compiler/GHC/Utils/Panic/Plain.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/GHC/Utils/Panic/Plain.hs b/compiler/GHC/Utils/Panic/Plain.hs
index 37e0574d4b..dd3bd01d75 100644
--- a/compiler/GHC/Utils/Panic/Plain.hs
+++ b/compiler/GHC/Utils/Panic/Plain.hs
@@ -117,6 +117,10 @@ panic x = unsafeDupablePerformIO $ do
if null stack
then throwPlainGhcException (PlainPanic x)
else throwPlainGhcException (PlainPanic (x ++ '\n' : renderStack stack))
+-- These are otherwise inlined and result in unnecessary code bloat.
+{-# NOINLINE panic #-}
+{-# NOINLINE sorry #-}
+{-# NOINLINE pgmError #-}
sorry x = throwPlainGhcException (PlainSorry x)
pgmError x = throwPlainGhcException (PlainProgramError x)