[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: eventlog: Ensure that IPE output contains actual info table pointers

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Mon Nov 14 15:37:56 UTC 2022



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


Commits:
268a3ce9 by Ben Gamari at 2022-11-14T09:36:57-05:00
eventlog: Ensure that IPE output contains actual info table pointers

The refactoring in 866c736e introduced a rather subtle change in the
semantics of the IPE eventlog output, changing the eventlog field from
encoding info table pointers to "TNTC pointers" (which point to entry
code when tables-next-to-code is enabled). Fix this.

Fixes #22452.

- - - - -
52213820 by Matthew Pickering at 2022-11-14T10:37:45-05:00
testsuite: Add tests for T22347

These are fixed in recent versions but might as well add regression
tests.

See #22347

- - - - -
4f98c9f3 by Matthew Pickering at 2022-11-14T10:37:47-05:00
testsuite: Improve output from tests which have failing pre_cmd

There are two changes:

* If a pre_cmd fails, then don't attempt to run the test.
* If a pre_cmd fails, then print the stdout and stderr from running that
  command (which hopefully has a nice error message).

For example:

```
=====> 1 of 1 [0, 0, 0]
*** framework failure for test-defaulting-plugin(normal) pre_cmd failed: 2
** pre_cmd was "$MAKE -s --no-print-directory -C defaulting-plugin package.test-defaulting-plugin TOP={top}".
stdout:
stderr:
DefaultLifted.hs:19:13: error: [GHC-76037]
    Not in scope: type constructor or class ‘Typ’
    Suggested fix:
      Perhaps use one of these:
        ‘Type’ (imported from GHC.Tc.Utils.TcType),
        data constructor ‘Type’ (imported from GHC.Plugins)
   |
19 | instance Eq Typ where
   |             ^^^
make: *** [Makefile:17: package.test-defaulting-plugin] Error 1

Performance Metrics (test environment: local):
```

Fixes #22329

- - - - -


6 changed files:

- rts/eventlog/EventLog.c
- rts/include/rts/IPE.h
- testsuite/driver/testlib.py
- + testsuite/tests/simplCore/should_compile/T22347.hs
- + testsuite/tests/simplCore/should_compile/T22347a.hs
- testsuite/tests/simplCore/should_compile/all.T


Changes:

=====================================
rts/eventlog/EventLog.c
=====================================
@@ -1429,7 +1429,7 @@ void postIPE(const InfoProvEnt *ipe)
     ensureRoomForVariableEvent(&eventBuf, len);
     postEventHeader(&eventBuf, EVENT_IPE);
     postPayloadSize(&eventBuf, len);
-    postWord64(&eventBuf, (StgWord) ipe->info);
+    postWord64(&eventBuf, (StgWord) INFO_PTR_TO_STRUCT(ipe->info));
     postString(&eventBuf, ipe->prov.table_name);
     postString(&eventBuf, ipe->prov.closure_desc);
     postString(&eventBuf, ipe->prov.ty_desc);


=====================================
rts/include/rts/IPE.h
=====================================
@@ -24,6 +24,8 @@ typedef struct InfoProv_ {
 } InfoProv;
 
 typedef struct InfoProvEnt_ {
+    // When TNTC is enabled this will point to the entry code
+    // not the info table itself.
     const StgInfoTable *info;
     InfoProv prov;
 } InfoProvEnt;
@@ -50,6 +52,8 @@ typedef uint32_t StringIdx;
 // The size of this must be a multiple of the word size
 // to ensure correct packing.
 typedef struct {
+    // When TNTC is enabled this will point to the entry code
+    // not the info table itself.
     const StgInfoTable *info;
     StringIdx table_name;
     StringIdx closure_desc;


=====================================
testsuite/driver/testlib.py
=====================================
@@ -1247,14 +1247,23 @@ def do_test(name: TestName,
             dst_makefile.write_text(makefile, encoding='UTF-8')
 
     if opts.pre_cmd:
+        stdout_path = in_testdir(name, 'pre_cmd_stdout')
+        stderr_path = in_testdir(name, 'pre_cmd_stderr')
         exit_code = runCmd('cd "{0}" && {1}'.format(opts.testdir, override_options(opts.pre_cmd)),
-                           stderr = subprocess.STDOUT,
+                           stdout = stdout_path,
+                           stderr = stderr_path,
                            print_output = config.verbose >= 3)
 
         # If user used expect_broken then don't record failures of pre_cmd
         if exit_code != 0 and opts.expect not in ['fail']:
             framework_fail(name, way, 'pre_cmd failed: {0}'.format(exit_code))
             if_verbose(1, '** pre_cmd was "{0}".'.format(override_options(opts.pre_cmd)))
+            stderr_contents = stderr_path.read_text(encoding='UTF-8', errors='replace')
+            stdout_contents = stdout_path.read_text(encoding='UTF-8', errors='replace')
+            if_verbose(1, 'stdout: {0}'.format(stdout_contents))
+            if_verbose(1, 'stderr: {0}'.format(stderr_contents))
+            # Don't continue and try to run the test if the pre_cmd fails.
+            return
 
     result = func(*[name,way] + args)
 


=====================================
testsuite/tests/simplCore/should_compile/T22347.hs
=====================================
@@ -0,0 +1,20 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+module M where
+
+import Control.Monad.ST
+import Data.Array.ST
+import Data.Array.Unboxed
+
+bfs :: Array Int [Int] -> ST s (STArray s Int ())
+bfs g = do
+    vis :: STArray s Int () <- newArray (bounds g) ()
+    ch :: STArray s Int () <- newArray (bounds g) ()
+    let go [] = pure () :: ST s ()
+        go q = do
+            flip mapM_ q $ \u -> do
+                readArray vis (head (g!u))
+                readArray ch u
+                writeArray ch u ()
+            go []
+    go []
+    pure ch


=====================================
testsuite/tests/simplCore/should_compile/T22347a.hs
=====================================
@@ -0,0 +1,20 @@
+{-# LANGUAGE ScopedTypeVariables #-}
+module M where
+
+import Control.Monad.ST
+import Data.Array.ST
+import Data.Array.Unboxed
+
+bfs :: Array Int [Int] -> ST s (STArray s Int ())
+bfs g = do
+    vis :: STArray s Int () <- newArray (bounds g) ()
+    ch :: STArray s Int () <- newArray (bounds g) ()
+    let go [] = pure () :: ST s ()
+        go q = do
+            flip mapM_ q $ \u -> do
+                readArray vis (head (g!u))
+                readArray ch u
+                writeArray ch u ()
+            go []
+    go []
+    pure ch


=====================================
testsuite/tests/simplCore/should_compile/all.T
=====================================
@@ -437,6 +437,8 @@ test('T22097', [grep_errmsg(r'case.*wgoEven') ], multimod_compile, ['T22097', '-
 
 test('T13873',  [ grep_errmsg(r'SPEC') ], compile, ['-O -ddump-rules'])
 test('T22357',  normal, compile, ['-O'])
+test('T22347',  normal, compile, ['-O -fno-full-laziness'])
+test('T22347a', normal, compile, ['-O2 -fno-full-laziness'])
 
 # T17366: expecting to see a rule
 #    Rule fired: SPEC/T17366 f @(Tagged tag) @_ (T17366)



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c938a1db8e51bba1cff55f5493157e4c8afea8b8...4f98c9f3781ebd64b84336ea90a4c5dbb7a66221

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c938a1db8e51bba1cff55f5493157e4c8afea8b8...4f98c9f3781ebd64b84336ea90a4c5dbb7a66221
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/20221114/91d07427/attachment-0001.html>


More information about the ghc-commits mailing list