summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-06-21 11:24:50 -0400
committerBen Gamari <ben@smart-cactus.org>2019-06-26 13:46:33 -0400
commit9781903c83bf7ddc962db774973412fbb36e6f03 (patch)
treef6196770a917b56040f474a5bd079073a18cbcaf
parent2191ad85d0c51ce83e698f3e17e0d5b4374db915 (diff)
downloadhaskell-9781903c83bf7ddc962db774973412fbb36e6f03.tar.gz
CoreToStg: Enable CAFfyness checking with -dstg-lint
The debugging involved in finding #16846 wouldn't have been necessary had the consistentCafInfo check been enabled. However, :wq (cherry picked from commit cd753410da64bc1c2b1e8a9dc0331e96f4990004)
-rw-r--r--compiler/stgSyn/CoreToStg.hs13
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/stgSyn/CoreToStg.hs b/compiler/stgSyn/CoreToStg.hs
index e8f159b569..f53a5d4e9f 100644
--- a/compiler/stgSyn/CoreToStg.hs
+++ b/compiler/stgSyn/CoreToStg.hs
@@ -268,7 +268,7 @@ coreTopBindToStg dflags this_mod env ccs (NonRec id rhs)
bind = StgTopLifted $ StgNonRec id stg_rhs
in
- ASSERT2(consistentCafInfo id bind, ppr id )
+ assertConsistentCaInfo dflags id bind (ppr bind)
-- NB: previously the assertion printed 'rhs' and 'bind'
-- as well as 'id', but that led to a black hole
-- where printing the assertion error tripped the
@@ -296,9 +296,18 @@ coreTopBindToStg dflags this_mod env ccs (Rec pairs)
bind = StgTopLifted $ StgRec (zip binders stg_rhss)
in
- ASSERT2(consistentCafInfo (head binders) bind, ppr binders)
+ assertConsistentCaInfo dflags (head binders) bind (ppr binders)
(env', ccs', bind)
+-- | CAF consistency issues will generally result in segfaults and are quite
+-- difficult to debug (see #16846). We enable checking of the
+-- 'consistentCafInfo' invariant with @-dstg-lint@ to increase the chance that
+-- we catch these issues.
+assertConsistentCaInfo :: DynFlags -> Id -> StgTopBinding -> SDoc -> a -> a
+assertConsistentCaInfo dflags id bind err_doc result
+ | gopt Opt_DoStgLinting dflags || debugIsOn
+ , not $ consistentCafInfo id bind = pprPanic "assertConsistentCaInfo" err_doc
+ | otherwise = result
-- Assertion helper: this checks that the CafInfo on the Id matches
-- what CoreToStg has figured out about the binding's SRT. The