From b048a9f4e28186d2245427d2d83f08418573fae5 Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Fri, 11 Mar 2022 13:48:05 -0500 Subject: codeGen: Ensure that static datacon apps are included in SRTs When generating an SRT for a recursive group, GHC.Cmm.Info.Build.oneSRT filters out recursive references, as described in Note [recursive SRTs]. However, doing so for static functions would be unsound, for the reason described in Note [Invalid optimisation: shortcutting]. However, the same argument applies to static data constructor applications, as we discovered in #20959. Fix this by ensuring that static data constructor applications are included in recursive SRTs. The approach here is not entirely satisfactory, but it is a starting point. Fixes #20959. --- rts/sm/Storage.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'rts') diff --git a/rts/sm/Storage.h b/rts/sm/Storage.h index 00f2943a51..0fecc50208 100644 --- a/rts/sm/Storage.h +++ b/rts/sm/Storage.h @@ -147,6 +147,12 @@ void move_STACK (StgStack *src, StgStack *dest); bits = link_field & 3; if ((bits | prev_static_flag) != 3) { ... } + However, this mechanism for tracking liveness has an important implication: + once a static object becomes unreachable it must never become reachable again. + One would think that this can by definition never happen but in the past SRT + generation bugs have caused precisely this behavior with disasterous results. + See Note [No static object resurrection] in GHC.Cmm.Info.Build for details. + -------------------------------------------------------------------------- */ #define STATIC_BITS 3 -- cgit v1.2.1