Simplifier panics ("Tick in rule") after SpecConstr and CSE due to `postInlineUnconditionally` inside RULE LHS
In !3187 (closed) I rather unexpectedly hit a compiler panic. To reproduce, build a validate-x86_64-linux-deb9-dwarf job (source notes -g
and -O2
for SpecConstr are essential) of !3187 (closed). Then you'll eventually get
ghc-stage1: panic! (the 'impossible' happened)
(GHC version 8.11.0.20200508:
Tick in rule
src<libraries/Cabal/Cabal/Distribution/Simple/GHC/Internal.hs:456:30-58>
src<libraries/Cabal/Cabal/Distribution/Simple/Flag.hs:95:1-13>
ds60_sskS
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/GHC/Utils/Outputable.hs:1218:37 in ghc:GHC.Utils.Outputable
pprPanic, called at compiler/GHC/Core/Rules.hs:723:5 in ghc:GHC.Core.Rules
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
while compiling libraries/Cabal/Cabal/Distribution/Simple/GHC.hs. I couldn't come up with a smaller reproducer yet. But I managed to pin-point the faulty behavior to a flaw in a rather painful debugging process to postInlineUnconditionally
/occurrence analysis.
TLDR; As far as I can tell we need something like the occ_rules_only
taint from weakLoopBreaker
for OccMany
/basically all other OccInfo
fields to keep postInlineUnconditionally
from triggering when a varaible occurs in an LHS of a RULE.