| ... |
... |
@@ -4598,13 +4598,21 @@ mkLetUnfolding :: SimplEnv -> TopLevelFlag -> UnfoldingSource |
|
4598
|
4598
|
-> InId -> Bool -- True <=> this is a join point
|
|
4599
|
4599
|
-> OutExpr -> SimplM Unfolding
|
|
4600
|
4600
|
mkLetUnfolding env top_lvl src id is_join new_rhs
|
|
4601
|
|
- = return (mkUnfolding uf_opts src is_top_lvl is_bottoming is_join new_rhs Nothing)
|
|
4602
|
|
- -- We make an unfolding *even for loop-breakers*.
|
|
4603
|
|
- -- Reason: (a) It might be useful to know that they are WHNF
|
|
4604
|
|
- -- (b) In GHC.Iface.Tidy we currently assume that, if we want to
|
|
4605
|
|
- -- expose the unfolding then indeed we *have* an unfolding
|
|
4606
|
|
- -- to expose. (We could instead use the RHS, but currently
|
|
4607
|
|
- -- we don't.) The simple thing is always to have one.
|
|
|
4601
|
+ | is_join
|
|
|
4602
|
+ , UnfNever <- guidance
|
|
|
4603
|
+ = -- For large join points, don't keep an unfolding at all if it is large
|
|
|
4604
|
+ -- This is just an attempt to keep residency under control in
|
|
|
4605
|
+ -- deeply-nested join-point such as those arising in #26425
|
|
|
4606
|
+ return NoUnfolding
|
|
|
4607
|
+
|
|
|
4608
|
+ | otherwise
|
|
|
4609
|
+ = return (mkCoreUnfolding src is_top_lvl new_rhs Nothing guidance)
|
|
|
4610
|
+ -- We make an unfolding *even for loop-breakers*.
|
|
|
4611
|
+ -- Reason: (a) It might be useful to know that they are WHNF
|
|
|
4612
|
+ -- (b) In GHC.Iface.Tidy we currently assume that, if we want to
|
|
|
4613
|
+ -- expose the unfolding then indeed we *have* an unfolding
|
|
|
4614
|
+ -- to expose. (We could instead use the RHS, but currently
|
|
|
4615
|
+ -- we don't.) The simple thing is always to have one.
|
|
4608
|
4616
|
where
|
|
4609
|
4617
|
-- !opts: otherwise, we end up retaining all the SimpleEnv
|
|
4610
|
4618
|
!uf_opts = seUnfoldingOpts env
|
| ... |
... |
@@ -4615,6 +4623,9 @@ mkLetUnfolding env top_lvl src id is_join new_rhs |
|
4615
|
4623
|
-- See Note [Force bottoming field]
|
|
4616
|
4624
|
!is_bottoming = isDeadEndId id
|
|
4617
|
4625
|
|
|
|
4626
|
+ is_top_bottoming = is_top_lvl && is_bottoming
|
|
|
4627
|
+ guidance = calcUnfoldingGuidance uf_opts is_top_bottoming is_join new_rhs
|
|
|
4628
|
+
|
|
4618
|
4629
|
-------------------
|
|
4619
|
4630
|
simplStableUnfolding :: SimplEnv -> BindContext
|
|
4620
|
4631
|
-> InId
|