[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 8 commits: Clarify -XGADTs enables existential quantification

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Tue Jun 18 04:15:45 UTC 2024



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
6bad0de7 by sheaf at 2024-06-18T00:15:09-04:00
Clarify -XGADTs enables existential quantification

Even though -XGADTs does not turn on -XExistentialQuantification,
it does allow the user of existential quantification syntax, without
needing to use GADT-style syntax.

Fixes #20865

- - - - -
1f005635 by David Binder at 2024-06-18T00:15:13-04:00
Add RTS flag --read-tix-file (GHC Proposal 612)

This commit introduces the RTS flag `--read-tix-file=<yes|no>` which
controls whether a preexisting .tix file is read in at the beginning
of a program run. The default is currently `--read-tix-file=yes` but
will change to `--read-tix-file=no` in a future release of GHC. For
this reason, whenever a .tix file is read in a warning is emitted to
stderr. This warning can be silenced by explicitly passing the
`--read-tix-file=yes` option. Details can be found in the GHC proposal
cited below.

Users can query whether this flag has been used with the help of the
module `GHC.RTS.Flags`. A new field `readTixFile` was added to the
record `HpcFlags`.

These changes have been discussed and approved in
- GHC proposal 612: https://github.com/ghc-proposals/ghc-proposals/pull/612
- CLC proposal 276: https://github.com/haskell/core-libraries-committee/issues/276

- - - - -
5a3c2dca by Andreas Klebinger at 2024-06-18T00:15:13-04:00
Improve documentation of @Any@ type.

In particular mention possible uses for non-lifted types.

Fixes #23100.

- - - - -
d4ffd058 by Jakob Bruenker at 2024-06-18T00:15:15-04:00
Update user guide to indicate support for 64-tuples

- - - - -
754d4d2c by Andreas Klebinger at 2024-06-18T00:15:15-04:00
lint notes: Add more info to notes.stdout

When fixing a note reference CI fails with a somewhat confusing diff.
See #21123. This commit adds a line to the output file being compared
which hopefully makes it clear this is the list of broken refs, not all
refs.

Fixes #21123

- - - - -
379ed573 by Andreas Klebinger at 2024-06-18T00:15:17-04:00
GHCi interpreter: Tag constructor closures when possible.

When evaluating PUSH_G try to tag the reference we are pushing if it's a
constructor or function. This is potentially helpful for performance and required to
fix #24870.

- - - - -
3c350a5c by Jakob Bruenker at 2024-06-18T00:15:18-04:00
docs: Update mention of ($) type in user guide

Fixes #24909

- - - - -
35de8a60 by Sjoerd Visscher at 2024-06-18T00:15:24-04:00
Bump stm submodule to current master

- - - - -


28 changed files:

- compiler/GHC/Builtin/Types.hs
- compiler/GHC/ByteCode/Instr.hs
- docs/users_guide/9.12.1-notes.rst
- docs/users_guide/bugs.rst
- docs/users_guide/exts/gadt.rst
- docs/users_guide/exts/representation_polymorphism.rst
- docs/users_guide/profiling.rst
- docs/users_guide/runtime_control.rst
- libraries/base/changelog.md
- libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc
- libraries/ghc-internal/src/GHC/Internal/Unsafe/Coerce.hs
- libraries/ghc-prim/GHC/Types.hs
- libraries/stm
- linters/lint-notes/Main.hs
- rts/Hpc.c
- rts/Interpreter.c
- rts/RtsFlags.c
- rts/include/rts/Flags.h
- testsuite/tests/interface-stability/base-exports.stdout
- testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
- testsuite/tests/interface-stability/base-exports.stdout-mingw32
- testsuite/tests/interface-stability/base-exports.stdout-ws-32
- testsuite/tests/linters/notes.stdout
- + testsuite/tests/th/should_compile/T24870/Def.hs
- + testsuite/tests/th/should_compile/T24870/T24870.stderr
- + testsuite/tests/th/should_compile/T24870/T24870.stderr-mingw32
- + testsuite/tests/th/should_compile/T24870/Use.hs
- + testsuite/tests/th/should_compile/T24870/all.T


Changes:

=====================================
compiler/GHC/Builtin/Types.hs
=====================================
@@ -445,7 +445,15 @@ It has these properties:
   * When instantiated at a lifted type it is inhabited by at least one value,
     namely bottom
 
-  * You can safely coerce any /lifted/ type to Any, and back with unsafeCoerce.
+  * You can safely coerce any /lifted/ type to Any and back with unsafeCoerce.
+    You can safely coerce any /unlifted/ type to Any and back with unsafeCoerceUnlifted.
+    You can coerce /any/ type to Any and back with unsafeCoerce#, but it's only safe when
+    the kinds of both the type and Any match.
+
+    For lifted/unlifted types unsafeCoerce[Unlifted] should be preferred over unsafeCoerce#
+    as they prevent accidentally coercing between types with kinds that don't match.
+
+    See examples in ghc-prim:GHC.Types
 
   * It does not claim to be a *data* type, and that's important for
     the code generator, because the code gen may *enter* a data value


=====================================
compiler/GHC/ByteCode/Instr.hs
=====================================
@@ -83,7 +83,7 @@ data BCInstr
    | PUSH16_W !ByteOff
    | PUSH32_W !ByteOff
 
-   -- Push a ptr  (these all map to PUSH_G really)
+   -- Push a (heap) ptr  (these all map to PUSH_G really)
    | PUSH_G       Name
    | PUSH_PRIMOP  PrimOp
    | PUSH_BCO     (ProtoBCO Name)


=====================================
docs/users_guide/9.12.1-notes.rst
=====================================
@@ -91,6 +91,11 @@ Runtime system
 
 - Reduce fragmentation incurred by the nonmoving GC's segment allocator. In one application this reduced resident set size by 26%. See :ghc-ticket:`24150`.
 
+- The new runtime flag :rts-flag:`--read-tix-file=\<yes|no\>` allows to modify whether a preexisting .tix file is read in at the beginning of a program run.
+  The default is currently ``--read-tix-file=yes`` but will change to ``--read-tix-file=no`` in a future version of GHC.
+  For this reason, a warning is emitted if a .tix file is read in implicitly. You can silence this warning by explicitly passing ``--read-tix-file=yes``.
+  Details can be found in `GHC proposal 612 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0612-fhpc-accumulation.md>`__.
+
 ``base`` library
 ~~~~~~~~~~~~~~~~
 


=====================================
docs/users_guide/bugs.rst
=====================================
@@ -553,7 +553,7 @@ Unchecked floating-point arithmetic
 Large tuple support
     The Haskell Report only requires implementations to provide tuple
     types and their accompanying standard instances up to size 15. GHC
-    limits the size of tuple types to 62 and provides instances of
+    limits the size of tuple types to 64 and provides instances of
     ``Eq``, ``Ord``, ``Bounded``, ``Read``, ``Show``, and ``Ix`` for
     tuples up to size 15.
 


=====================================
docs/users_guide/exts/gadt.rst
=====================================
@@ -93,6 +93,12 @@ also sets :extension:`GADTSyntax` and :extension:`MonoLocalBinds`.
          -- essentially the same as:
          -- MkG :: Int -> Int -> G Int
 
+   Note that, even though :extension:`GADTs` technically does not imply
+   :extension:`ExistentialQuantification`, enabling :extension:`GADTs`
+   does also enable the syntax for existential quantification: ::
+
+        data SomeShow = forall a. Show a => SomeShow a
+
 -  It is permitted to declare an ordinary algebraic data type using
    GADT-style syntax. What makes a GADT into a GADT is not the syntax,
    but rather the presence of data constructors whose result type is not


=====================================
docs/users_guide/exts/representation_polymorphism.rst
=====================================
@@ -79,14 +79,26 @@ representation-polymorphic type.
 
 However, not all is lost. We can still do this: ::
 
-  ($) :: forall r (a :: Type) (b :: TYPE r).
+  good :: forall r (a :: Type) (b :: TYPE r).
          (a -> b) -> a -> b
-  f $ x = f x
+  good f x = f x
 
 Here, only ``b`` is representation-polymorphic. There are no variables
 with a representation-polymorphic type. And the code generator has no
-trouble with this. Indeed, this is the true type of GHC's ``$`` operator,
-slightly more general than the Haskell 98 version.
+trouble with this. Nonetheless, there is a way to write a definition with
+``bad``'s type: ::
+
+
+  ($) :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep)
+                (a :: TYPE r1) (b :: TYPE r2).
+         (a -> b) -> a -> b
+  ($) f = f
+
+By eta-reducing, we got rid of ``x``, and thus have no variable with a
+representation-polymorphic type.  Indeed, this is the true type of GHC's ``$``
+operator, slightly more general than the Haskell 98 version. However, its
+strictness properties are different: ``(good undefined) `seq` ()`` is equivalent
+to ``()``, whereas ``(($) undefined) `seq` ()`` diverges.
 
 Because the code generator must store and move arguments as well
 as variables, the logic above applies equally well to function arguments,


=====================================
docs/users_guide/profiling.rst
=====================================
@@ -1502,9 +1502,9 @@ Running the program generates a file with the ``.tix`` suffix, in this
 case :file:`Recip.tix`, which contains the coverage data for this run of the
 program. The program may be run multiple times (e.g. with different test
 data), and the coverage data from the separate runs is accumulated in
-the ``.tix`` file. To reset the coverage data and start again, just
-remove the ``.tix`` file. You can control where the ``.tix`` file
-is generated using the environment variable :envvar:`HPCTIXFILE`.
+the ``.tix`` file. This behaviour can be controlled with the :rts-flag:`--read-tix-file=\<yes|no\>`
+You can control where the ``.tix`` file is generated using the
+environment variable :envvar:`HPCTIXFILE`.
 
 .. envvar:: HPCTIXFILE
 


=====================================
docs/users_guide/runtime_control.rst
=====================================
@@ -1373,7 +1373,22 @@ and can be controlled by the following flags.
 .. index::
     single: RTS options, hpc
 
-.. rts-flag:: --write-tix-file
+.. rts-flag:: --read-tix-file=<yes|no>
+
+    :default: enabled
+    :since: 9.12
+
+    The RTS can be instructed to read a ``<program>.tix`` file during the startup
+    phase. The datastructures which accumulate the coverage information during
+    program execution are then initialized with the information from this file.
+    This option is useful for aggregating coverage information over multiple runs
+    of an executable.
+
+    The default for this flag is currently ``--read-tix-file=yes`` but will change
+    to ``-read-tix-file=no`` in a future version of GHC according to the accepted
+    `GHC proposal 612 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0612-fhpc-accumulation.md>`__.
+
+.. rts-flag:: --write-tix-file=<yes|no>
 
     :default: enabled
     :since: 9.10


=====================================
libraries/base/changelog.md
=====================================
@@ -1,6 +1,7 @@
 # Changelog for [`base` package](http://hackage.haskell.org/package/base)
 
 ## 4.21.0.0 *TBA*
+  * Add a `readTixFile` field to the `HpcFlags` record in `GHC.RTS.Flags` ([CLC proposal #276](https://github.com/haskell/core-libraries-committee/issues/276))
   * Add the `MonadFix` instance for `(,) a`, similar to the one for `Writer a` ([CLC proposal #238](https://github.com/haskell/core-libraries-committee/issues/238))
   * Improve `toInteger :: Word32 -> Integer` on 64-bit platforms ([CLC proposal #259](https://github.com/haskell/core-libraries-committee/issues/259))
   * Make `flip` representation polymorphic ([CLC proposal #245](https://github.com/haskell/core-libraries-committee/issues/245))


=====================================
libraries/ghc-internal/src/GHC/Internal/RTS/Flags.hsc
=====================================
@@ -382,7 +382,11 @@ data ParFlags = ParFlags
 --
 -- @since base-4.20.0.0
 data HpcFlags = HpcFlags
-    { writeTixFile :: Bool
+    { readTixFile :: Bool
+      -- ^ Controls whether a @<program>.tix@ file is read at
+      -- the start of execution to initialize the RTS internal
+      -- HPC datastructures.
+    , writeTixFile :: Bool
       -- ^ Controls whether the @<program>.tix@ file should be
       -- written after the execution of the program.
     }
@@ -498,6 +502,8 @@ getHpcFlags = do
   let ptr = (#ptr RTS_FLAGS, HpcFlags) rtsFlagsPtr
   HpcFlags
     <$> (toBool <$>
+          (#{peek HPC_FLAGS, readTixFile} ptr :: IO CBool))
+    <*> (toBool <$>
           (#{peek HPC_FLAGS, writeTixFile} ptr :: IO CBool))
 
 getConcFlags :: IO ConcFlags


=====================================
libraries/ghc-internal/src/GHC/Internal/Unsafe/Coerce.hs
=====================================
@@ -336,6 +336,10 @@ unsafeCoerceAddr x = case unsafeEqualityProof @a @b of UnsafeRefl -> x
 -- to another. Misuse of this function can invite the garbage collector
 -- to trounce upon your data and then laugh in your face. You don't want
 -- this function. Really.
+--
+-- This becomes more obvious when looking at its actual type:
+-- @forall (r1 :: RuntimeRep) (r2 :: RuntimeRep)  (a :: TYPE r1) (b :: TYPE r2). a -> b@
+-- Which often get's rendered as @a -> b@ in haddock for technical reasons.
 unsafeCoerce# :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep)
                         (a :: TYPE r1) (b :: TYPE r2).
                  a -> b


=====================================
libraries/ghc-prim/GHC/Types.hs
=====================================
@@ -283,11 +283,43 @@ data Symbol
 *                                                                      *
 ********************************************************************* -}
 
--- | The type constructor 'Any' is type to which you can unsafely coerce any
--- lifted type, and back. More concretely, for a lifted type @t@ and
--- value @x :: t@, @unsafeCoerce (unsafeCoerce x :: Any) :: t@ is equivalent
--- to @x at .
+-- | The type constructor @Any :: forall k. k@ is a type to which you can unsafely coerce any type, and back.
 --
+-- For @unsafeCoerce@ this means for all lifted types @t@ that
+-- @unsafeCoerce (unsafeCoerce x :: Any) :: t@ is equivalent to @x@ and safe.
+--
+-- The same is true for *all* types when using
+-- @
+--   unsafeCoerce# :: forall (r1 :: RuntimeRep) (r2 :: RuntimeRep)
+--                   (a :: TYPE r1) (b :: TYPE r2).
+--                   a -> b
+-- @
+-- but /only/ if you instantiate @r1@ and @r2@ to the /same/ runtime representation.
+-- For example using @(unsafeCoerce# :: forall (a :: TYPE IntRep) (b :: TYPE IntRep). a -> b) x@
+-- is fine, but @(unsafeCoerce# :: forall (a :: TYPE IntRep) (b :: TYPE FloatRep). a -> b)@
+-- will likely cause seg-faults or worse.
+-- For this resason, users should always prefer unsafeCoerce over unsafeCoerce# when possible.
+--
+-- Here are some more examples:
+-- @
+--    bad_a1 :: Any @(TYPE 'IntRep)
+--    bad_a1 = unsafeCoerce# True
+--
+--    bad_a2 :: Any @(TYPE ('BoxedRep 'UnliftedRep))
+--    bad_a2 = unsafeCoerce# True
+-- @
+-- Here @bad_a1@ is bad because we started with @True :: (Bool :: Type)@, represented by a boxed heap pointer,
+-- and coerced it to @a1 :: Any @(TYPE 'IntRep)@, whose representation is a non-pointer integer.
+-- That's why we had to use `unsafeCoerce#`; it is really unsafe because it can change representations.
+-- Similarly @bad_a2@ is bad because although both @True@ and @bad_a2@ are represented by a heap pointer,
+-- @True@ is lifted but @bad_a2@ is not; bugs here may be rather subtle.
+--
+-- If you must use unsafeCoerce# to cast to `Any`, type annotations are recommended
+-- to make sure that @Any@ has the correct kind. As casting between different runtimereps is
+-- unsound. For example to cast a @ByteArray#@ to @Any@ you might use:
+-- @
+--    unsafeCoerce# b :: (Any :: TYPE ('BoxedRep 'Unlifted))
+-- @
 type family Any :: k where { }
 -- See Note [Any types] in GHC.Builtin.Types. Also, for a bit of history on Any see
 -- #10886. Note that this must be a *closed* type family: we need to ensure


=====================================
libraries/stm
=====================================
@@ -1 +1 @@
-Subproject commit 4e7aa7885b3f9724b19e68d12cbd2774b11b9bd0
+Subproject commit 8de008f1928e029e54b822d85a16f1804d7e99a6


=====================================
linters/lint-notes/Main.hs
=====================================
@@ -37,7 +37,9 @@ main = do
         parseMode "unreferenced" = Just $ printNoteDefs . S.toList . unreferencedNotes
         parseMode "defs"         = Just $ printNoteDefs . allNoteDefs
         parseMode "refs"         = Just $ printNoteRefs . allNoteRefs
-        parseMode "broken-refs"  = Just $ printNoteRefs . map fst . brokenNoteRefs
+        parseMode "broken-refs"  = Just $ \notedb -> do
+          putStrLn "Broken note references (target note not found!):"
+          printNoteRefs . map fst . brokenNoteRefs $ notedb
         parseMode "broken-refs-suggest" = Just $ mapM_ printNoteRefsSugg . brokenNoteRefs
         parseMode _              = Nothing
 


=====================================
rts/Hpc.c
=====================================
@@ -236,7 +236,14 @@ startupHpc(void)
     sprintf(tixFilename, "%s.tix", prog_name);
   }
 
-  if (init_open(__rts_fopen(tixFilename,"r"))) {
+  if ((RtsFlags.HpcFlags.readTixFile == HPC_YES_IMPLICIT) && init_open(__rts_fopen(tixFilename,"r"))) {
+    fprintf(stderr,"Deprecation warning:\n"
+                   "I am reading in the existing tix file, and will add hpc info from this run to the existing data in that file.\n"
+                   "GHC 9.14 will cease looking for an existing tix file by default.\n"
+                   "If you positively want to add hpc info to the current tix file, use the RTS option --read-tix-file=yes.\n"
+                   "More information can be found in the accepted GHC proposal 612.\n");
+    readTix();
+  } else if ((RtsFlags.HpcFlags.readTixFile == HPC_YES_EXPLICIT) && init_open(__rts_fopen(tixFilename,"r"))) {
     readTix();
   }
 }


=====================================
rts/Interpreter.c
=====================================
@@ -4,6 +4,30 @@
  * Copyright (c) The GHC Team, 1994-2002.
  * ---------------------------------------------------------------------------*/
 
+/*
+Note [CBV Functions and the interpreter]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+When the byte code interpreter loads a reference to a value it often
+ends up as a non-tagged pointers *especially* if we already know a value
+is a certain constructor and therefore don't perform an eval on the reference.
+This causes friction with CBV functions which assume
+their value arguments are properly tagged by the caller.
+
+In order to ensure CBV functions still get passed tagged functions we have
+three options:
+a)  Special case the interpreter behaviour into the tag inference analysis.
+    If we assume the interpreter can't properly tag value references the STG passes
+    would then wrap such calls in appropriate evals which are executed at runtime.
+    This would ensure tags by doing additional evals at runtime.
+b)  When the interpreter pushes references for known constructors instead of
+    pushing the objects address add the tag to the value pushed. This is what
+    the NCG backends do.
+c)  When the interpreter pushes a reference inspect the closure of the object
+    and apply the appropriate tag at runtime.
+
+For now we use approach c). Mostly because it's easiest to implement. We also don't
+tag functions as tag inference currently doesn't rely on those being properly tagged.
+*/
 
 #include "rts/PosixSource.h"
 #include "Rts.h"
@@ -290,6 +314,18 @@ STATIC_INLINE StgClosure *tagConstr(StgClosure *con) {
     return TAG_CLOSURE(stg_min(TAG_MASK, 1 + GET_TAG(con)), con);
 }
 
+// Compute the pointer tag for the function and tag the pointer;
+STATIC_INLINE StgClosure *tagFun(StgClosure *fun) {
+    StgHalfWord tag = GET_TAG(fun);
+    if(tag > TAG_MASK) { return fun; }
+    else {
+        return TAG_CLOSURE(tag, fun);
+    }
+
+
+}
+
+
 static StgWord app_ptrs_itbl[] = {
     (W_)&stg_ap_p_info,
     (W_)&stg_ap_pp_info,
@@ -1304,7 +1340,52 @@ run_BCO:
 
         case bci_PUSH_G: {
             W_ o1 = BCO_GET_LARGE_ARG;
-            SpW(-1) = BCO_PTR(o1);
+            StgClosure *tagged_obj = (StgClosure*) BCO_PTR(o1);
+
+            tag_push_g:
+            ASSERT(LOOKS_LIKE_CLOSURE_PTR((StgClosure*) tagged_obj));
+            // Here we make sure references we push are tagged.
+            // See Note [CBV Functions and the interpreter] in Info.hs
+
+            //Safe some memory reads if we already have a tag.
+            if(GET_CLOSURE_TAG(tagged_obj) == 0) {
+                StgClosure *obj = UNTAG_CLOSURE(tagged_obj);
+                switch ( get_itbl(obj)->type ) {
+                    case IND:
+                    case IND_STATIC:
+                    {
+                        tagged_obj = ACQUIRE_LOAD(&((StgInd*)obj)->indirectee);
+                        goto tag_push_g;
+                    }
+                    case CONSTR:
+                    case CONSTR_1_0:
+                    case CONSTR_0_1:
+                    case CONSTR_2_0:
+                    case CONSTR_1_1:
+                    case CONSTR_0_2:
+                    case CONSTR_NOCAF:
+                        // The value is already evaluated, so we can just return it. However,
+                        // before we do, we MUST ensure that the pointer is tagged, because we
+                        // might return to a native `case` expression, which assumes the returned
+                        // pointer is tagged so it can use the tag to select an alternative.
+                        tagged_obj = tagConstr(obj);
+                        break;
+                    case FUN:
+                    case FUN_1_0:
+                    case FUN_0_1:
+                    case FUN_2_0:
+                    case FUN_1_1:
+                    case FUN_0_2:
+                    case FUN_STATIC:
+                        // Purely for performance since we already hit memory anyway.
+                        tagged_obj = tagFun(obj);
+                        break;
+                    default:
+                        break;
+                }
+            }
+
+            SpW(-1) = (W_) tagged_obj;
             Sp_subW(1);
             goto nextInsn;
         }


=====================================
rts/RtsFlags.c
=====================================
@@ -297,6 +297,7 @@ void initRtsFlagsDefaults(void)
     RtsFlags.TickyFlags.showTickyStats   = false;
     RtsFlags.TickyFlags.tickyFile        = NULL;
 #endif
+    RtsFlags.HpcFlags.readTixFile        = HPC_YES_IMPLICIT;
     RtsFlags.HpcFlags.writeTixFile       = true;
 }
 
@@ -565,6 +566,10 @@ usage_text[] = {
 "             HeapOverflow exception before the exception is thrown again, if",
 "             the program is still exceeding the heap limit.",
 "",
+"  --read-tix-file=<yes|no>",
+"             Whether to initialize HPC datastructures from  <program>.tix "
+"             at the start of execution. (default: yes)",
+"",
 "  --write-tix-file=<yes|no>",
 "             Whether to write <program>.tix at the end of execution.",
 "             (default: yes)",
@@ -1068,6 +1073,16 @@ error = true;
                         RtsFlags.GcFlags.nonmovingDenseAllocatorCount = threshold;
                       }
                   }
+                  else if (strequal("read-tix-file=yes",
+                              &rts_argv[arg][2])) {
+                       OPTION_UNSAFE;
+                       RtsFlags.HpcFlags.readTixFile = HPC_YES_EXPLICIT;
+                  }
+                  else if (strequal("read-tix-file=no",
+                              &rts_argv[arg][2])) {
+                       OPTION_UNSAFE;
+                       RtsFlags.HpcFlags.readTixFile = HPC_NO_EXPLICIT;
+                  }
                   else if (strequal("write-tix-file=yes",
                               &rts_argv[arg][2])) {
                        OPTION_UNSAFE;


=====================================
rts/include/rts/Flags.h
=====================================
@@ -302,10 +302,26 @@ typedef struct _PAR_FLAGS {
   bool           setAffinity;    /* force thread affinity with CPUs */
 } PAR_FLAGS;
 
+/* Corresponds to the RTS flag `--read-tix-file=<yes|no>`.
+ * The accepted GHC proposal 612 introduced a one-release warning period
+ * during which we emit a warning if we read a .tix file and the flag
+ * isn't explicitly set. In order to distinguish between whether the flag
+ * was explicitly set or defaulted we need to use a tri-state variable.
+ */
+typedef enum _HPC_READ_FILE {
+    HPC_NO_EXPLICIT = 0,  /* The user has specified --read-tix-file=no */
+    HPC_YES_IMPLICIT = 1, /* The user hasn't specified an option and we emit
+                           * a warning when we read a tix file.
+                           */
+    HPC_YES_EXPLICIT = 2  /* The user has specified --read-tix-file=yes */
+  } HPC_READ_FILE;
+
 /* See Note [Synchronization of flags and base APIs] */
 typedef struct _HPC_FLAGS {
   bool           writeTixFile;   /* Whether the RTS should write a tix
                                     file at the end of execution */
+  HPC_READ_FILE  readTixFile;    /* Whether the RTS should read a tix
+                                    file at the beginning of execution */
 } HPC_FLAGS;
 
 /* See Note [Synchronization of flags and base APIs] */


=====================================
testsuite/tests/interface-stability/base-exports.stdout
=====================================
@@ -9105,7 +9105,7 @@ module GHC.RTS.Flags where
   type GiveGCStats :: *
   data GiveGCStats = NoGCStats | CollectGCStats | OneLineGCStats | SummaryGCStats | VerboseGCStats
   type HpcFlags :: *
-  data HpcFlags = HpcFlags {writeTixFile :: GHC.Types.Bool}
+  data HpcFlags = HpcFlags {readTixFile :: GHC.Types.Bool, writeTixFile :: GHC.Types.Bool}
   type IoManagerFlag :: *
   data IoManagerFlag = IoManagerFlagAuto | IoManagerFlagSelect | IoManagerFlagMIO | IoManagerFlagWinIO | IoManagerFlagWin32Legacy
   type IoSubSystem :: *


=====================================
testsuite/tests/interface-stability/base-exports.stdout-javascript-unknown-ghcjs
=====================================
@@ -12147,7 +12147,7 @@ module GHC.RTS.Flags where
   type GiveGCStats :: *
   data GiveGCStats = NoGCStats | CollectGCStats | OneLineGCStats | SummaryGCStats | VerboseGCStats
   type HpcFlags :: *
-  data HpcFlags = HpcFlags {writeTixFile :: GHC.Types.Bool}
+  data HpcFlags = HpcFlags {readTixFile :: GHC.Types.Bool, writeTixFile :: GHC.Types.Bool}
   type IoManagerFlag :: *
   data IoManagerFlag = IoManagerFlagAuto | IoManagerFlagSelect | IoManagerFlagMIO | IoManagerFlagWinIO | IoManagerFlagWin32Legacy
   type IoSubSystem :: *


=====================================
testsuite/tests/interface-stability/base-exports.stdout-mingw32
=====================================
@@ -9329,7 +9329,7 @@ module GHC.RTS.Flags where
   type GiveGCStats :: *
   data GiveGCStats = NoGCStats | CollectGCStats | OneLineGCStats | SummaryGCStats | VerboseGCStats
   type HpcFlags :: *
-  data HpcFlags = HpcFlags {writeTixFile :: GHC.Types.Bool}
+  data HpcFlags = HpcFlags {readTixFile :: GHC.Types.Bool, writeTixFile :: GHC.Types.Bool}
   type IoManagerFlag :: *
   data IoManagerFlag = IoManagerFlagAuto | IoManagerFlagSelect | IoManagerFlagMIO | IoManagerFlagWinIO | IoManagerFlagWin32Legacy
   type IoSubSystem :: *


=====================================
testsuite/tests/interface-stability/base-exports.stdout-ws-32
=====================================
@@ -9105,7 +9105,7 @@ module GHC.RTS.Flags where
   type GiveGCStats :: *
   data GiveGCStats = NoGCStats | CollectGCStats | OneLineGCStats | SummaryGCStats | VerboseGCStats
   type HpcFlags :: *
-  data HpcFlags = HpcFlags {writeTixFile :: GHC.Types.Bool}
+  data HpcFlags = HpcFlags {readTixFile :: GHC.Types.Bool, writeTixFile :: GHC.Types.Bool}
   type IoManagerFlag :: *
   data IoManagerFlag = IoManagerFlagAuto | IoManagerFlagSelect | IoManagerFlagMIO | IoManagerFlagWinIO | IoManagerFlagWin32Legacy
   type IoSubSystem :: *


=====================================
testsuite/tests/linters/notes.stdout
=====================================
@@ -1,39 +1,40 @@
+Broken note references (target note not found!):
 ref    compiler/GHC/Core/Coercion/Axiom.hs:472:2:     Note [RoughMap and rm_empty]
 ref    compiler/GHC/Core/Opt/OccurAnal.hs:1157:7:     Note [Loop breaking]
-ref    compiler/GHC/Core/Opt/SetLevels.hs:1586:30:     Note [Top level scope]
-ref    compiler/GHC/Core/Opt/Simplify/Iteration.hs:2832:13:     Note [Case binder next]
-ref    compiler/GHC/Core/Opt/Simplify/Iteration.hs:4023:8:     Note [Lambda-bound unfoldings]
-ref    compiler/GHC/Core/Opt/Simplify/Utils.hs:1342:37:     Note [Gentle mode]
+ref    compiler/GHC/Core/Opt/SetLevels.hs:1688:30:     Note [Top level scope]
+ref    compiler/GHC/Core/Opt/Simplify/Iteration.hs:2937:13:     Note [Case binder next]
+ref    compiler/GHC/Core/Opt/Simplify/Iteration.hs:4253:8:     Note [Lambda-bound unfoldings]
+ref    compiler/GHC/Core/Opt/Simplify/Utils.hs:1406:37:     Note [Gentle mode]
 ref    compiler/GHC/Core/Opt/Specialise.hs:1763:29:     Note [Arity decrease]
-ref    compiler/GHC/Core/TyCo/Rep.hs:1652:31:     Note [What prevents a constraint from floating]
-ref    compiler/GHC/Driver/DynFlags.hs:1251:52:     Note [Eta-reduction in -O0]
-ref    compiler/GHC/Driver/Main.hs:1749:34:     Note [simpleTidyPgm - mkBootModDetailsTc]
-ref    compiler/GHC/Hs/Expr.hs:191:63:     Note [Pending Splices]
-ref    compiler/GHC/Hs/Expr.hs:1727:87:     Note [Lifecycle of a splice]
-ref    compiler/GHC/Hs/Expr.hs:1763:7:     Note [Pending Splices]
-ref    compiler/GHC/Hs/Extension.hs:147:5:     Note [Strict argument type constraints]
-ref    compiler/GHC/Hs/Pat.hs:141:74:     Note [Lifecycle of a splice]
+ref    compiler/GHC/Core/TyCo/Rep.hs:1677:31:     Note [What prevents a constraint from floating]
+ref    compiler/GHC/Driver/DynFlags.hs:1254:52:     Note [Eta-reduction in -O0]
+ref    compiler/GHC/Driver/Main.hs:1750:34:     Note [simpleTidyPgm - mkBootModDetailsTc]
+ref    compiler/GHC/Hs/Expr.hs:192:63:     Note [Pending Splices]
+ref    compiler/GHC/Hs/Expr.hs:1955:87:     Note [Lifecycle of a splice]
+ref    compiler/GHC/Hs/Expr.hs:1991:7:     Note [Pending Splices]
+ref    compiler/GHC/Hs/Extension.hs:144:5:     Note [Strict argument type constraints]
+ref    compiler/GHC/Hs/Pat.hs:146:74:     Note [Lifecycle of a splice]
 ref    compiler/GHC/HsToCore/Pmc/Solver.hs:856:20:     Note [COMPLETE sets on data families]
-ref    compiler/GHC/HsToCore/Quote.hs:1487:7:     Note [How brackets and nested splices are handled]
-ref    compiler/GHC/Stg/Unarise.hs:438:32:     Note [Renaming during unarisation]
-ref    compiler/GHC/Tc/Gen/HsType.hs:556:56:     Note [Skolem escape prevention]
-ref    compiler/GHC/Tc/Gen/HsType.hs:2676:7:     Note [Matching a kind signature with a declaration]
-ref    compiler/GHC/Tc/Gen/Pat.hs:174:20:     Note [Typing patterns in pattern bindings]
-ref    compiler/GHC/Tc/Gen/Pat.hs:1163:7:     Note [Matching polytyped patterns]
-ref    compiler/GHC/Tc/Gen/Sig.hs:80:10:     Note [Overview of type signatures]
+ref    compiler/GHC/HsToCore/Quote.hs:1505:7:     Note [How brackets and nested splices are handled]
+ref    compiler/GHC/Stg/Unarise.hs:451:32:     Note [Renaming during unarisation]
+ref    compiler/GHC/Tc/Gen/HsType.hs:561:56:     Note [Skolem escape prevention]
+ref    compiler/GHC/Tc/Gen/HsType.hs:2707:7:     Note [Matching a kind signature with a declaration]
+ref    compiler/GHC/Tc/Gen/Pat.hs:286:20:     Note [Typing patterns in pattern bindings]
+ref    compiler/GHC/Tc/Gen/Pat.hs:1385:7:     Note [Matching polytyped patterns]
+ref    compiler/GHC/Tc/Gen/Sig.hs:77:10:     Note [Overview of type signatures]
 ref    compiler/GHC/Tc/Gen/Splice.hs:358:16:     Note [How brackets and nested splices are handled]
 ref    compiler/GHC/Tc/Gen/Splice.hs:533:35:     Note [PendingRnSplice]
-ref    compiler/GHC/Tc/Gen/Splice.hs:657:7:     Note [How brackets and nested splices are handled]
-ref    compiler/GHC/Tc/Gen/Splice.hs:891:11:     Note [How brackets and nested splices are handled]
+ref    compiler/GHC/Tc/Gen/Splice.hs:660:7:     Note [How brackets and nested splices are handled]
+ref    compiler/GHC/Tc/Gen/Splice.hs:904:11:     Note [How brackets and nested splices are handled]
 ref    compiler/GHC/Tc/Instance/Family.hs:406:35:     Note [Constrained family instances]
-ref    compiler/GHC/Tc/Solver/Rewrite.hs:1010:7:     Note [Stability of rewriting]
+ref    compiler/GHC/Tc/Solver/Rewrite.hs:1006:7:     Note [Stability of rewriting]
 ref    compiler/GHC/Tc/TyCl.hs:1316:6:     Note [Unification variables need fresh Names]
 ref    compiler/GHC/Tc/Types/Constraint.hs:206:38:     Note [NonCanonical Semantics]
-ref    compiler/GHC/Types/Demand.hs:301:25:     Note [Preserving Boxity of results is rarely a win]
+ref    compiler/GHC/Types/Demand.hs:303:25:     Note [Preserving Boxity of results is rarely a win]
 ref    compiler/GHC/Unit/Module/Deps.hs:83:13:     Note [Structure of dep_boot_mods]
 ref    compiler/GHC/Utils/Monad.hs:410:34:     Note [multiShotIO]
-ref    compiler/Language/Haskell/Syntax/Binds.hs:200:31:     Note [fun_id in Match]
-ref    configure.ac:203:10:     Note [Linking ghc-bin against threaded stage0 RTS]
+ref    compiler/Language/Haskell/Syntax/Binds.hs:220:31:     Note [fun_id in Match]
+ref    configure.ac:191:10:     Note [Linking ghc-bin against threaded stage0 RTS]
 ref    docs/core-spec/core-spec.mng:177:6:     Note [TyBinders]
 ref    hadrian/src/Expression.hs:145:30:     Note [Linking ghc-bin against threaded stage0 RTS]
 ref    linters/lint-notes/Notes.hs:32:29:     Note [" <> T.unpack x <> "]
@@ -51,18 +52,18 @@ ref    testsuite/tests/typecheck/should_compile/tc228.hs:9:7:     Note [Inferenc
 ref    testsuite/tests/typecheck/should_compile/tc231.hs:12:16:     Note [Important subtlety in oclose]
 ref    testsuite/tests/typecheck/should_fail/UnliftedNewtypesMultiFieldGadt.hs:11:28:     Note [Kind-checking the field type]
 ref    testsuite/tests/typecheck/should_fail/tcfail093.hs:13:7:     Note [Important subtlety in oclose]
-ref    utils/haddock/haddock-api/src/Haddock/Convert.hs<line>:<no>:     Note [Eta reduction for data family axioms]
-ref    utils/haddock/haddock-api/src/Haddock/Convert.hs<line>:<no>:     Note [Invariant: Never expand type synonyms]
-ref    utils/haddock/haddock-api/src/Haddock/Convert.hs<line>:<no>:     Note [Invariant: Never expand type synonyms]
-ref    utils/haddock/haddock-api/src/Haddock/Convert.hs<line>:<no>:     Note [Invariant: Never expand type synonyms]
-ref    utils/haddock/haddock-api/src/Haddock/Convert.hs<line>:<no>:     Note [Invariant: Never expand type synonyms]
-ref    utils/haddock/haddock-api/src/Haddock/Convert.hs<line>:<no>:     Note [Invariant: Never expand type synonyms]
-ref    utils/haddock/haddock-api/src/Haddock/Convert.hs<line>:<no>:     Note [Invariant: Never expand type synonyms]
-ref    utils/haddock/haddock-api/src/Haddock/Convert.hs<line>:<no>:     Note [Invariant: Never expand type synonyms]
-ref    utils/haddock/haddock-api/src/Haddock/Convert.hs<line>:<no>:     Note [Invariant: Never expand type synonyms]
-ref    utils/haddock/haddock-api/src/Haddock/Interface/Create.hs<line>:<no>:     Note [Exporting built-in items]
-ref    utils/haddock/haddock-api/src/Haddock/Interface/Create.hs<line>:<no>:     Note [Exporting built-in items]
-ref    utils/haddock/haddock-api/src/Haddock/Interface/Create.hs<line>:<no>:     Note [Exporting built-in items]
-ref    utils/haddock/haddock-api/src/Haddock/InterfaceFile.hs<line>:<no>:     Note [The DocModule story]
-ref    utils/haddock/haddock-api/src/Haddock/Types.hs<line>:<no>:     Note [Pass sensitive types]
+ref    utils/haddock/haddock-api/src/Haddock/Convert.hs:1068:13:     Note [Eta reduction for data family axioms]
+ref    utils/haddock/haddock-api/src/Haddock/Convert.hs:1085:0:     Note [Invariant: Never expand type synonyms]
+ref    utils/haddock/haddock-api/src/Haddock/Convert.hs:1101:7:     Note [Invariant: Never expand type synonyms]
+ref    utils/haddock/haddock-api/src/Haddock/Convert.hs:1108:9:     Note [Invariant: Never expand type synonyms]
+ref    utils/haddock/haddock-api/src/Haddock/Convert.hs:1117:9:     Note [Invariant: Never expand type synonyms]
+ref    utils/haddock/haddock-api/src/Haddock/Convert.hs:1131:9:     Note [Invariant: Never expand type synonyms]
+ref    utils/haddock/haddock-api/src/Haddock/Convert.hs:1145:9:     Note [Invariant: Never expand type synonyms]
+ref    utils/haddock/haddock-api/src/Haddock/Convert.hs:1147:9:     Note [Invariant: Never expand type synonyms]
+ref    utils/haddock/haddock-api/src/Haddock/Convert.hs:1156:9:     Note [Invariant: Never expand type synonyms]
+ref    utils/haddock/haddock-api/src/Haddock/Interface/Create.hs:120:11:     Note [Exporting built-in items]
+ref    utils/haddock/haddock-api/src/Haddock/Interface/Create.hs:185:9:     Note [Exporting built-in items]
+ref    utils/haddock/haddock-api/src/Haddock/Interface/Create.hs:255:7:     Note [Exporting built-in items]
+ref    utils/haddock/haddock-api/src/Haddock/InterfaceFile.hs:118:3:     Note [The DocModule story]
+ref    utils/haddock/haddock-api/src/Haddock/Types.hs:17:3:     Note [Pass sensitive types]
 


=====================================
testsuite/tests/th/should_compile/T24870/Def.hs
=====================================
@@ -0,0 +1,9 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module SDef where
+
+{-# NOINLINE aValue #-}
+aValue = True
+
+{-# NOINLINE aStrictFunction #-}
+aStrictFunction !x = [| x |]


=====================================
testsuite/tests/th/should_compile/T24870/T24870.stderr
=====================================
@@ -0,0 +1,2 @@
+[1 of 2] Compiling SDef             ( Def.hs, Def.o, Def.dyn_o )
+[2 of 2] Compiling SUse             ( Use.hs, Use.o )


=====================================
testsuite/tests/th/should_compile/T24870/T24870.stderr-mingw32
=====================================
@@ -0,0 +1,2 @@
+[1 of 2] Compiling SDef             ( Def.hs, Def.o )
+[2 of 2] Compiling SUse             ( Use.hs, Use.o )


=====================================
testsuite/tests/th/should_compile/T24870/Use.hs
=====================================
@@ -0,0 +1,9 @@
+{-# LANGUAGE TemplateHaskell #-}
+
+module SUse where
+
+import qualified Language.Haskell.TH.Syntax as TH
+import SDef
+import GHC.Exts
+
+bar = $( inline aStrictFunction aValue )


=====================================
testsuite/tests/th/should_compile/T24870/all.T
=====================================
@@ -0,0 +1,6 @@
+# The interpreter must uphold tagging invariants, and failed to do so in #24870
+# We test this here by having the interpreter calls a strict worker function
+# with a reference to a value it constructed.
+# See also Note [CBV Functions and the interpreter]
+test('T24870', [extra_files(['Def.hs', 'Use.hs']), req_th],
+	      multimod_compile, ['Def Use', '-dtag-inference-checks'])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/460e65edf5851696f15c250390c057f2e55fe59e...35de8a60fdf5fcd285de56ebaa290e3f87bad4fd

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/460e65edf5851696f15c250390c057f2e55fe59e...35de8a60fdf5fcd285de56ebaa290e3f87bad4fd
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240618/3ff4384f/attachment-0001.html>


More information about the ghc-commits mailing list