Skip to content

Transform some StgRhsClosure into StgRhsCon after unarisation (#25166)

Sylvain Henry requested to merge hsyl20/ghc:hsyl20/25166-static-closure into master

Before unarisation we may have code like:

      Test.foo :: Test.D
      [GblId, Unf=OtherCon []] =
          \u []
              case (# |_| #) [GHC.Types.(##)] of sat_sAw [Occ=Once1] {
              __DEFAULT -> Test.D [GHC.Types.True sat_sAw];
              };

After unarisation we get:

      Test.foo :: Test.D
      [GblId, Unf=OtherCon []] =
          {} \u [] Test.D [GHC.Types.True 2#];

Notice that it's still an Updatable closure for no reason anymore. This patch transforms appropriate StgRhsClosures into StgRhsCons after unarisation, allowing these closures to be statically allocated. Now we get the expected:

      Test.foo :: Test.D
      [GblId, Unf=OtherCon []] =
          Test.D! [GHC.Types.True 2#];

Fix #25166 (closed)

Edited by Sylvain Henry

Merge request reports

Loading