Cheng Shao pushed to branch wip/fix-cmm-dump-labels at Glasgow Haskell Compiler / GHC
Commits:
-
f586c885
by Simon Jakobi at 2026-07-24T18:05:00-04:00
-
306120d2
by Duncan Coutts at 2026-07-24T18:05:43-04:00
-
7b116a0b
by Cheng Shao at 2026-07-24T18:06:24-04:00
-
27fc2f8a
by Cheng Shao at 2026-07-25T11:20:53+02:00
4 changed files:
- .gitlab-ci.yml
- + changelog.d/fix-cmm-dump-labels
- compiler/GHC/Cmm/Pipeline.hs
- testsuite/tests/process/T3994.hs
Changes:
| ... | ... | @@ -23,6 +23,10 @@ variables: |
| 23 | 23 | # Always start with a fresh clone to avoid non-hermetic builds
|
| 24 | 24 | GIT_STRATEGY: clone
|
| 25 | 25 | |
| 26 | + # Shallow submodule clones. Overridden by individual jobs that need deeper
|
|
| 27 | + # submodule history.
|
|
| 28 | + GIT_SUBMODULE_DEPTH: 1
|
|
| 29 | + |
|
| 26 | 30 | # Overridden by individual jobs
|
| 27 | 31 | CONFIGURE_ARGS: ""
|
| 28 | 32 | |
| ... | ... | @@ -262,7 +266,8 @@ lint-changelog: |
| 262 | 266 | GIT_SUBMODULE_STRATEGY: none
|
| 263 | 267 | before_script:
|
| 264 | 268 | - export PATH="/opt/toolchain/bin:$PATH"
|
| 265 | - - git config --global --add safe.directory "$CI_PROJECT_DIR"
|
|
| 269 | + # workaround for docker permissions
|
|
| 270 | + - sudo chown ghc:ghc -R .
|
|
| 266 | 271 | script:
|
| 267 | 272 | - .gitlab/ci.sh lint_changelog
|
| 268 | 273 | dependencies: []
|
| ... | ... | @@ -279,6 +284,9 @@ lint-linters: |
| 279 | 284 | variables:
|
| 280 | 285 | GIT_DEPTH: 1
|
| 281 | 286 | GIT_SUBMODULE_STRATEGY: none
|
| 287 | + before_script:
|
|
| 288 | + # workaround for docker permissions
|
|
| 289 | + - sudo chown ghc:ghc -R .
|
|
| 282 | 290 | script:
|
| 283 | 291 | - mypy testsuite/tests/linters/regex-linters/*.py
|
| 284 | 292 | dependencies: []
|
| ... | ... | @@ -290,6 +298,9 @@ lint-testsuite: |
| 290 | 298 | variables:
|
| 291 | 299 | GIT_DEPTH: 1
|
| 292 | 300 | GIT_SUBMODULE_STRATEGY: none
|
| 301 | + before_script:
|
|
| 302 | + # workaround for docker permissions
|
|
| 303 | + - sudo chown ghc:ghc -R .
|
|
| 293 | 304 | script:
|
| 294 | 305 | - make -Ctestsuite list_broken TEST_HC=$GHC
|
| 295 | 306 | dependencies: []
|
| ... | ... | @@ -301,6 +312,9 @@ typecheck-testsuite: |
| 301 | 312 | variables:
|
| 302 | 313 | GIT_DEPTH: 1
|
| 303 | 314 | GIT_SUBMODULE_STRATEGY: none
|
| 315 | + before_script:
|
|
| 316 | + # workaround for docker permissions
|
|
| 317 | + - sudo chown ghc:ghc -R .
|
|
| 304 | 318 | script:
|
| 305 | 319 | - mypy testsuite/driver/runtests.py
|
| 306 | 320 | dependencies: []
|
| ... | ... | @@ -313,6 +327,7 @@ typecheck-testsuite: |
| 313 | 327 | extends: .lint-params
|
| 314 | 328 | variables:
|
| 315 | 329 | BUILD_FLAVOUR: default
|
| 330 | + GIT_SUBMODULE_DEPTH: 0 # full history
|
|
| 316 | 331 | script:
|
| 317 | 332 | - .gitlab/ci.sh configure
|
| 318 | 333 | - .gitlab/ci.sh run_hadrian stage0:exe:lint-submodule-refs
|
| ... | ... | @@ -330,6 +345,9 @@ lint-author: |
| 330 | 345 | extends: .lint
|
| 331 | 346 | variables:
|
| 332 | 347 | GIT_SUBMODULE_STRATEGY: none
|
| 348 | + before_script:
|
|
| 349 | + # workaround for docker permissions
|
|
| 350 | + - sudo chown ghc:ghc -R .
|
|
| 333 | 351 | script:
|
| 334 | 352 | - git fetch "$CI_MERGE_REQUEST_PROJECT_URL" $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
|
| 335 | 353 | - base="$(git merge-base FETCH_HEAD $CI_COMMIT_SHA)"
|
| 1 | +section: compiler
|
|
| 2 | +synopsis: Fix missing top-level procedure labels in some intermediate Cmm pass dumps.
|
|
| 3 | +issues: #27553
|
|
| 4 | +mrs: !16406 |
| ... | ... | @@ -8,6 +8,7 @@ import GHC.Prelude |
| 8 | 8 | import GHC.Driver.Flags
|
| 9 | 9 | |
| 10 | 10 | import GHC.Cmm
|
| 11 | +import GHC.Cmm.CLabel
|
|
| 11 | 12 | import GHC.Cmm.Config
|
| 12 | 13 | import GHC.Cmm.ContFlowOpt
|
| 13 | 14 | import GHC.Cmm.CommonBlockElim
|
| ... | ... | @@ -80,14 +81,14 @@ cpsTop logger platform cfg dus proc = |
| 80 | 81 | --
|
| 81 | 82 | CmmProc h l v g <- {-# SCC "cmmCfgOpts(1)" #-}
|
| 82 | 83 | return $ cmmCfgOptsProc splitting_proc_points proc
|
| 83 | - dump Opt_D_dump_cmm_cfg "Post control-flow optimisations (1)" g
|
|
| 84 | + dump l Opt_D_dump_cmm_cfg "Post control-flow optimisations (1)" g
|
|
| 84 | 85 | |
| 85 | 86 | let !TopInfo {stack_info=StackInfo { arg_space = entry_off
|
| 86 | 87 | , do_layout = do_layout }} = h
|
| 87 | 88 | |
| 88 | 89 | ----------- Eliminate common blocks -------------------------------------
|
| 89 | 90 | g <- {-# SCC "elimCommonBlocks" #-}
|
| 90 | - condPass (cmmOptElimCommonBlks cfg) elimCommonBlocks g
|
|
| 91 | + condPass l (cmmOptElimCommonBlks cfg) elimCommonBlocks g
|
|
| 91 | 92 | Opt_D_dump_cmm_cbe "Post common block elimination"
|
| 92 | 93 | |
| 93 | 94 | -- Any work storing block Labels must be performed _after_
|
| ... | ... | @@ -98,7 +99,7 @@ cpsTop logger platform cfg dus proc = |
| 98 | 99 | then {-# SCC "createSwitchPlans" #-}
|
| 99 | 100 | pure $ runUniqueDSM dus $ cmmImplementSwitchPlans platform g
|
| 100 | 101 | else pure (g, dus)
|
| 101 | - dump Opt_D_dump_cmm_switch "Post switch plan" g
|
|
| 102 | + dump l Opt_D_dump_cmm_switch "Post switch plan" g
|
|
| 102 | 103 | |
| 103 | 104 | ----------- ThreadSanitizer instrumentation -----------------------------
|
| 104 | 105 | g <- {-# SCC "annotateTSAN" #-}
|
| ... | ... | @@ -111,7 +112,7 @@ cpsTop logger platform cfg dus proc = |
| 111 | 112 | return $ initUs_ us $
|
| 112 | 113 | annotateTSAN platform g
|
| 113 | 114 | else return g
|
| 114 | - dump Opt_D_dump_cmm_thread_sanitizer "ThreadSanitizer instrumentation" g
|
|
| 115 | + dump l Opt_D_dump_cmm_thread_sanitizer "ThreadSanitizer instrumentation" g
|
|
| 115 | 116 | |
| 116 | 117 | ----------- Proc points -------------------------------------------------
|
| 117 | 118 | let
|
| ... | ... | @@ -134,11 +135,11 @@ cpsTop logger platform cfg dus proc = |
| 134 | 135 | if do_layout
|
| 135 | 136 | then runUniqueDSM dus $ cmmLayoutStack cfg proc_points entry_off g
|
| 136 | 137 | else ((g, mapEmpty), dus)
|
| 137 | - dump Opt_D_dump_cmm_sp "Layout Stack" g
|
|
| 138 | + dump l Opt_D_dump_cmm_sp "Layout Stack" g
|
|
| 138 | 139 | |
| 139 | 140 | ----------- Sink and inline assignments --------------------------------
|
| 140 | 141 | g <- {-# SCC "sink" #-} -- See Note [Sinking after stack layout]
|
| 141 | - condPass (cmmOptSink cfg) (cmmSink platform) g
|
|
| 142 | + condPass l (cmmOptSink cfg) (cmmSink platform) g
|
|
| 142 | 143 | Opt_D_dump_cmm_sink "Sink assignments"
|
| 143 | 144 | |
| 144 | 145 | ------------- CAF analysis ----------------------------------------------
|
| ... | ... | @@ -182,11 +183,11 @@ cpsTop logger platform cfg dus proc = |
| 182 | 183 | dumps flag name
|
| 183 | 184 | = mapM_ (dumpWith logger flag name FormatCMM . pdoc platform)
|
| 184 | 185 | |
| 185 | - condPass do_opt pass g dumpflag dumpname =
|
|
| 186 | + condPass lbl do_opt pass g dumpflag dumpname =
|
|
| 186 | 187 | if do_opt
|
| 187 | 188 | then do
|
| 188 | 189 | g <- return $ pass g
|
| 189 | - dump dumpflag dumpname g
|
|
| 190 | + dump lbl dumpflag dumpname g
|
|
| 190 | 191 | return g
|
| 191 | 192 | else return g
|
| 192 | 193 | |
| ... | ... | @@ -359,10 +360,10 @@ generator later. |
| 359 | 360 | |
| 360 | 361 | -}
|
| 361 | 362 | |
| 362 | -dumpGraph :: Logger -> Platform -> Bool -> DumpFlag -> String -> CmmGraph -> IO ()
|
|
| 363 | -dumpGraph logger platform do_linting flag name g = do
|
|
| 363 | +dumpGraph :: Logger -> Platform -> Bool -> CLabel -> DumpFlag -> String -> CmmGraph -> IO ()
|
|
| 364 | +dumpGraph logger platform do_linting lbl flag name g = do
|
|
| 364 | 365 | when do_linting $ do_lint g
|
| 365 | - dumpWith logger flag name FormatCMM (pdoc platform g)
|
|
| 366 | + dumpWith logger flag name FormatCMM (pdoc platform lbl $$ pdoc platform g)
|
|
| 366 | 367 | where
|
| 367 | 368 | do_lint g = case cmmLintGraph platform g of
|
| 368 | 369 | Just err -> do { fatalErrorMsg logger err
|
| 1 | 1 | module Main where
|
| 2 | 2 | |
| 3 | 3 | import Control.Concurrent
|
| 4 | +import Control.Exception
|
|
| 5 | +import Control.Monad
|
|
| 4 | 6 | import System.IO
|
| 7 | +import System.IO.Error
|
|
| 5 | 8 | import System.Process
|
| 6 | 9 | |
| 7 | 10 | main :: IO ()
|
| ... | ... | @@ -9,14 +12,24 @@ main = do (_,Just hout,_,p) <- createProcess (proc "./T3994app" ["start", "10000 |
| 9 | 12 | { std_out = CreatePipe, create_group = True }
|
| 10 | 13 | start <- hGetLine hout
|
| 11 | 14 | putStrLn start
|
| 12 | - interruptProcessGroupOf p
|
|
| 13 | - t <- myThreadId
|
|
| 14 | - -- timeout
|
|
| 15 | - forkIO $ do
|
|
| 16 | - threadDelay 5000000
|
|
| 17 | - putStrLn "Interrupting a Running Process Failed"
|
|
| 18 | - hFlush stdout
|
|
| 19 | - killThread t
|
|
| 20 | - waitForProcess p
|
|
| 15 | + |
|
| 16 | + -- On FreeBSD if we're _really_ unlucky with scheduling, then the
|
|
| 17 | + -- call to interruptProcessGroupOf can fail due to the process
|
|
| 18 | + -- having already terminated (despite it running for at least 10ms!)
|
|
| 19 | + -- If so, we just skip doing anything rather than fail the test,
|
|
| 20 | + -- since this isn't our fault and is rare and scheduling dependent.
|
|
| 21 | + -- See #27512 and https://reviews.freebsd.org/D58393
|
|
| 22 | + handleJust (guard . isDoesNotExistError) (\_ -> return ()) $ do
|
|
| 23 | + interruptProcessGroupOf p
|
|
| 24 | + t <- myThreadId
|
|
| 25 | + -- timeout
|
|
| 26 | + forkIO $ do
|
|
| 27 | + threadDelay 5000000
|
|
| 28 | + putStrLn "Interrupting a Running Process Failed"
|
|
| 29 | + hFlush stdout
|
|
| 30 | + killThread t
|
|
| 31 | + waitForProcess p
|
|
| 32 | + return ()
|
|
| 33 | + |
|
| 21 | 34 | putStrLn "end"
|
| 22 | 35 | return () |