codeGen: Fix LFInfo of imported datacon wrappers
As noted in #23231 and in the previous commit, we were failing to give a an LFInfo of LFCon to a nullary datacon wrapper from another module, failing to properly tag pointers which ultimately led to the segmentation fault in #23146. On top of the previous commit which now considers wrappers where we previously only considered workers, we change the order of the guards so that we check for the arity of the binding before we check whether it is a constructor. This allows us to (1) Correctly assign `LFReEntrant` to imported wrappers whose worker was nullary, which we previously would fail to do (2) Remove the `isNullaryRepDataCon` predicate: (a) which was previously wrong, since it considered wrappers whose workers had zero-width arguments to be non-nullary and would fail to give `LFCon` to them (b) is now unnecessary, since arity == 0 guarantees - that the worker takes no arguments at all - and the wrapper takes no arguments and its RHS must be an application of the worker to zero-width-args only. - we lint these two items with an assertion that the datacon `hasNoNonZeroWidthArgs` We also update `isTagged` to use the new logic in determining the LFInfos of imported Ids. The creation of LFInfos for imported Ids and this detail are explained in Note [The LFInfo of Imported Ids]. Note that before the patch to those issues we would already consider these nullary wrappers to have `LFCon` lambda form info; but failed to re-construct that information in `mkLFImported` Closes #23231, #23146 (I've additionally batched some fixes to documentation I found while investigating this issue)
Showing
- compiler/GHC/Cmm/CLabel.hs 1 addition, 0 deletionscompiler/GHC/Cmm/CLabel.hs
- compiler/GHC/Core/DataCon.hs 28 additions, 11 deletionscompiler/GHC/Core/DataCon.hs
- compiler/GHC/Core/Tidy.hs 2 additions, 2 deletionscompiler/GHC/Core/Tidy.hs
- compiler/GHC/Stg/InferTags/Rewrite.hs 4 additions, 9 deletionscompiler/GHC/Stg/InferTags/Rewrite.hs
- compiler/GHC/Stg/Syntax.hs 1 addition, 1 deletioncompiler/GHC/Stg/Syntax.hs
- compiler/GHC/Stg/Unarise.hs 2 additions, 0 deletionscompiler/GHC/Stg/Unarise.hs
- compiler/GHC/StgToCmm/Closure.hs 109 additions, 9 deletionscompiler/GHC/StgToCmm/Closure.hs
- compiler/GHC/StgToCmm/Env.hs 1 addition, 1 deletioncompiler/GHC/StgToCmm/Env.hs
- compiler/GHC/StgToCmm/Types.hs 9 additions, 6 deletionscompiler/GHC/StgToCmm/Types.hs
- compiler/GHC/Types/Id.hs 2 additions, 0 deletionscompiler/GHC/Types/Id.hs
- compiler/GHC/Types/Id/Info.hs 2 additions, 1 deletioncompiler/GHC/Types/Id/Info.hs
- testsuite/tests/codeGen/should_run/T23146/T23146_lifted_unlifted.hs 14 additions, 0 deletions...tests/codeGen/should_run/T23146/T23146_lifted_unlifted.hs
- testsuite/tests/codeGen/should_run/T23146/T23146_lifted_unlifted.stdout 1 addition, 0 deletions...s/codeGen/should_run/T23146/T23146_lifted_unlifted.stdout
- testsuite/tests/codeGen/should_run/T23146/T23146_lifted_unliftedA.hs 13 additions, 0 deletions...ests/codeGen/should_run/T23146/T23146_lifted_unliftedA.hs
- testsuite/tests/codeGen/should_run/T23146/all.T 1 addition, 1 deletiontestsuite/tests/codeGen/should_run/T23146/all.T
Loading
Please register or sign in to comment