Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
10 changed files:
- + changelog.d/T27749
- compiler/GHC/Cmm/DebugBlock.hs
- compiler/GHC/Core/Utils.hs
- compiler/GHC/Driver/GenerateCgIPEStub.hs
- compiler/GHC/Driver/Main/Compile.hs
- compiler/GHC/Stg/Debug.hs
- compiler/GHC/Types/Tickish.hs
- + testsuite/tests/simplCore/should_compile/T27749.hs
- + testsuite/tests/simplCore/should_compile/T27749.stderr
- testsuite/tests/simplCore/should_compile/all.T
Changes:
| 1 | +section: compiler
|
|
| 2 | +issues: #27749
|
|
| 3 | +mrs: !16601
|
|
| 4 | +synopsis:
|
|
| 5 | + Consistently prefer local source note ticks
|
|
| 6 | +description:
|
|
| 7 | + When generating IPE stack frames, we now insist on using a source location
|
|
| 8 | + that is local to the current module. |
| ... | ... | @@ -47,9 +47,8 @@ import GHC.Cmm.Dataflow.Label |
| 47 | 47 | |
| 48 | 48 | import Data.Maybe
|
| 49 | 49 | import Data.List ( nubBy )
|
| 50 | -import Data.List.NonEmpty ( NonEmpty (..), nonEmpty )
|
|
| 50 | +import Data.List.NonEmpty ( NonEmpty (..) )
|
|
| 51 | 51 | import qualified Data.List.NonEmpty as NE
|
| 52 | -import Data.Ord ( comparing )
|
|
| 53 | 52 | import qualified Data.Map as Map
|
| 54 | 53 | import Data.Foldable ( toList )
|
| 55 | 54 | import Data.Either ( partitionEithers )
|
| ... | ... | @@ -152,10 +151,6 @@ cmmDebugGen modLoc decls = map (blocksForScope Nothing) topScopes |
| 152 | 151 | -- from the same source file. Furthermore, dumps take priority
|
| 153 | 152 | -- (if we generated one, we probably want debug information to
|
| 154 | 153 | -- refer to it).
|
| 155 | - bestSrcTick = minimumBy (comparing rangeRating)
|
|
| 156 | - rangeRating (span, _)
|
|
| 157 | - | srcSpanFile span == thisFile = 1
|
|
| 158 | - | otherwise = 2 :: Int
|
|
| 159 | 154 | thisFile = maybe nilFS mkFastString $ ml_hs_file modLoc
|
| 160 | 155 | |
| 161 | 156 | -- Returns block tree for this scope as well as all nested
|
| ... | ... | @@ -189,17 +184,14 @@ cmmDebugGen modLoc decls = map (blocksForScope Nothing) topScopes |
| 189 | 184 | blocks | top = seqList childs childs
|
| 190 | 185 | | otherwise = []
|
| 191 | 186 | |
| 192 | - -- A source tick scopes over all nested blocks. However
|
|
| 193 | - -- their source ticks might take priority.
|
|
| 194 | - isSourceTick (SourceNote span a) = Just (span, a)
|
|
| 195 | - isSourceTick _ = Nothing
|
|
| 196 | 187 | -- Collect ticks from all blocks inside the tick scope.
|
| 197 | 188 | -- We attempt to filter out duplicates while we're at it.
|
| 198 | 189 | ticks = nubBy (flip tickishContains) $
|
| 199 | 190 | bCtxsTicks bctxs ++ ticksToCopy scope
|
| 200 | - stick = case nonEmpty $ mapMaybe isSourceTick ticks of
|
|
| 201 | - Nothing -> cstick
|
|
| 202 | - Just sticks -> Just $! bestSrcTick (sticks `NE.appendList` maybeToList cstick)
|
|
| 191 | + -- A source tick scopes over all nested blocks. However
|
|
| 192 | + -- their source ticks might take priority.
|
|
| 193 | + !stick = bestSourceNote True thisFile $
|
|
| 194 | + ticks ++ map (uncurry SourceNote) (maybeToList cstick)
|
|
| 203 | 195 | |
| 204 | 196 | -- | Build a map of blocks sorted by their tick scopes
|
| 205 | 197 | --
|
| ... | ... | @@ -426,8 +426,10 @@ tickTickedExpr preserve_anf t1 t2s e |
| 426 | 426 | -- combination.
|
| 427 | 427 | -- See Note [Avoiding duplicate ticks] in GHC.Core.Opt.FloatOut
|
| 428 | 428 | -- and Note [Ordering of source notes] in GHC.Types.Tickish.
|
| 429 | - | Just t2s' <- combine_into_stack t2s
|
|
| 430 | - = apply_ticks t2s' e
|
|
| 429 | + | Just combined <- combine_into_stack t1 (NE.toList t2s)
|
|
| 430 | + = case combined of
|
|
| 431 | + DropIncomingTick -> apply_ticks t2s e
|
|
| 432 | + TickOutsideStack t1' t2s' -> Tick t1' (apply_ticks t2s' e)
|
|
| 431 | 433 | |
| 432 | 434 | -- Case 2: 't1' can be commuted past all the ticks in the stack, e.g. because
|
| 433 | 435 | -- it has tighter placement properties than all the ticks in the stack.
|
| ... | ... | @@ -437,22 +439,48 @@ tickTickedExpr preserve_anf t1 t2s e |
| 437 | 439 | |
| 438 | 440 | -- Fallback: keep the new tick on the outside.
|
| 439 | 441 | | otherwise
|
| 440 | - = apply_ticks (t1 NE.:| NE.toList t2s) e
|
|
| 442 | + = Tick t1 (apply_ticks t2s e)
|
|
| 441 | 443 | |
| 442 | 444 | where
|
| 443 | - apply_ticks :: NE.NonEmpty CoreTickish -> CoreExpr -> CoreExpr
|
|
| 445 | + apply_ticks :: Foldable f => f CoreTickish -> CoreExpr -> CoreExpr
|
|
| 444 | 446 | apply_ticks ts e' = foldr Tick e' ts
|
| 447 | + {-# INLINE apply_ticks #-}
|
|
| 445 | 448 | |
| 446 | - -- Try to combine 't1' into a stack of ticks.
|
|
| 447 | - combine_into_stack :: NE.NonEmpty CoreTickish -> Maybe (NE.NonEmpty CoreTickish)
|
|
| 448 | - combine_into_stack (t2 NE.:| rest)
|
|
| 449 | - | Just t2' <- combineTickish_maybe t1 t2
|
|
| 450 | - = Just (t2' NE.:| rest)
|
|
| 451 | - | r_hd : r_tl <- rest
|
|
| 452 | - , Just rest' <- combine_into_stack (r_hd NE.:| r_tl)
|
|
| 453 | - = Just (t2 NE.:| NE.toList rest')
|
|
| 449 | +-- | The result of combining a tick into a stack of ticks.
|
|
| 450 | +data CombineIntoStack
|
|
| 451 | + -- | Drop the incoming tick: it's subsumed by a tick in the stack.
|
|
| 452 | + = DropIncomingTick
|
|
| 453 | + -- | Keep the incoming tick on the outside (possibly merged with an inner tick),
|
|
| 454 | + -- and wrap it around the given stack (from which we removed subsumed ticks).
|
|
| 455 | + | TickOutsideStack !CoreTickish [CoreTickish]
|
|
| 456 | + |
|
| 457 | +-- | Try to combine a tick into a stack of ticks, never re-ordering any ticks.
|
|
| 458 | +--
|
|
| 459 | +-- - If the tick is subsumed by a tick in the stack, drop it.
|
|
| 460 | +-- - Otherwise merge it with the ticks it subsumes and keep the result outside
|
|
| 461 | +-- the whole stack (#27749), discarding the ticks it makes redundant.
|
|
| 462 | +combine_into_stack :: CoreTickish -> [CoreTickish] -> Maybe CombineIntoStack
|
|
| 463 | +combine_into_stack _ [] = Nothing
|
|
| 464 | +combine_into_stack s (t : ts) =
|
|
| 465 | + case combineTickish_maybe s t of
|
|
| 466 | + Just s1
|
|
| 467 | + -- 's1 is redundant: drop it, keeping the stack as it is.
|
|
| 468 | + | s1 == t -> Just DropIncomingTick
|
|
| 469 | + -- 't' is redundant: put 's1' outside the stack.
|
|
| 470 | + -- Carry on, as 's1' may subsume further ticks in the stack.
|
|
| 471 | + | otherwise -> Just $ combine_into_stack s1 ts `orElse` TickOutsideStack s1 ts
|
|
| 472 | + -- Didn't combine: recur, and discard 't' if we end up putting a tick on the
|
|
| 473 | + -- outside that subsumes it.
|
|
| 474 | + Nothing -> retain t <$> combine_into_stack s ts
|
|
| 475 | + where
|
|
| 476 | + retain _ DropIncomingTick = DropIncomingTick -- retains it
|
|
| 477 | + retain t1 res@(TickOutsideStack s1 ss)
|
|
| 478 | + | Just t1' <- combineTickish_maybe s1 t1
|
|
| 479 | + , s1 == t1'
|
|
| 480 | + -- s1 subsumes t1: drop t1
|
|
| 481 | + = res
|
|
| 454 | 482 | | otherwise
|
| 455 | - = Nothing
|
|
| 483 | + = TickOutsideStack s1 (t1 : ss)
|
|
| 456 | 484 | |
| 457 | 485 | {- Note [Pushing SCCs inwards]
|
| 458 | 486 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| ... | ... | @@ -28,7 +28,8 @@ import GHC.StgToCmm.Utils |
| 28 | 28 | import GHC.StgToCmm.CgUtils (CgStream)
|
| 29 | 29 | import GHC.Types.IPE (InfoTableProvMap (provInfoTables), IpeSourceLocation)
|
| 30 | 30 | import GHC.Types.Name.Set (NonCaffySet)
|
| 31 | -import GHC.Types.Tickish (GenTickish (SourceNote))
|
|
| 31 | +import GHC.Data.FastString (FastString)
|
|
| 32 | +import GHC.Types.Tickish (bestSourceNote)
|
|
| 32 | 33 | import GHC.Unit.Types (Module, moduleName)
|
| 33 | 34 | import GHC.Unit.Module (moduleNameString)
|
| 34 | 35 | import qualified GHC.Utils.Logger as Logger
|
| ... | ... | @@ -257,11 +258,12 @@ generateCgIPEStub hsc_env this_mod denv (nonCaffySet, moduleLFInfos, infoTablesW |
| 257 | 258 | -- performance suffered considerably as a result (see #23103).
|
| 258 | 259 | lookupEstimatedTicks
|
| 259 | 260 | :: HscEnv
|
| 261 | + -> FastString -- ^ the source file of the module being compiled
|
|
| 260 | 262 | -> Map CmmInfoTable (Maybe IpeSourceLocation)
|
| 261 | 263 | -> IPEStats
|
| 262 | 264 | -> CmmGroupSRTs
|
| 263 | 265 | -> IO (Map CmmInfoTable (Maybe IpeSourceLocation), IPEStats)
|
| 264 | -lookupEstimatedTicks hsc_env ipes stats cmm_group_srts =
|
|
| 266 | +lookupEstimatedTicks hsc_env this_file ipes stats cmm_group_srts =
|
|
| 265 | 267 | -- Pass 2: Create an entry in the IPE map for every info table listed in
|
| 266 | 268 | -- this CmmGroupSRTs. If the info table is a stack info table and
|
| 267 | 269 | -- -finfo-table-map-with-stack is enabled, look up its estimated source
|
| ... | ... | @@ -286,9 +288,9 @@ lookupEstimatedTicks hsc_env ipes stats cmm_group_srts = |
| 286 | 288 | labelsToSources :: Map CLabel IpeSourceLocation
|
| 287 | 289 | labelsToSources =
|
| 288 | 290 | if platformTablesNextToCode platform then
|
| 289 | - foldl' labelsToSourcesWithTNTC Map.empty cmm_group_srts
|
|
| 291 | + foldl' (labelsToSourcesWithTNTC this_file) Map.empty cmm_group_srts
|
|
| 290 | 292 | else
|
| 291 | - foldl' labelsToSourcesSansTNTC Map.empty cmm_group_srts
|
|
| 293 | + foldl' (labelsToSourcesSansTNTC this_file) Map.empty cmm_group_srts
|
|
| 292 | 294 | |
| 293 | 295 | collectInfoTables
|
| 294 | 296 | :: (Map CmmInfoTable (Maybe IpeSourceLocation), IPEStats)
|
| ... | ... | @@ -331,15 +333,16 @@ lookupEstimatedTicks hsc_env ipes stats cmm_group_srts = |
| 331 | 333 | |
| 332 | 334 | -- | See Note [Stacktraces from Info Table Provenance Entries (IPE based stack unwinding)]
|
| 333 | 335 | labelsToSourcesWithTNTC
|
| 334 | - :: Map CLabel IpeSourceLocation
|
|
| 336 | + :: FastString -- ^ the source file of the module being compiled
|
|
| 337 | + -> Map CLabel IpeSourceLocation
|
|
| 335 | 338 | -> GenCmmDecl RawCmmStatics CmmTopInfo CmmGraph
|
| 336 | 339 | -> Map CLabel IpeSourceLocation
|
| 337 | -labelsToSourcesWithTNTC acc (CmmProc _ _ _ cmm_graph) =
|
|
| 340 | +labelsToSourcesWithTNTC this_file acc (CmmProc _ _ _ cmm_graph) =
|
|
| 338 | 341 | foldl' go acc (toBlockList cmm_graph)
|
| 339 | 342 | where
|
| 340 | 343 | go :: Map CLabel IpeSourceLocation -> CmmBlock -> Map CLabel IpeSourceLocation
|
| 341 | 344 | go acc block =
|
| 342 | - case (,) <$> returnFrameLabel <*> lastTickInBlock of
|
|
| 345 | + case (,) <$> returnFrameLabel <*> nearestTickInBlock of
|
|
| 343 | 346 | Just (clabel, src_loc) -> Map.insert clabel src_loc acc
|
| 344 | 347 | Nothing -> acc
|
| 345 | 348 | where
|
| ... | ... | @@ -351,20 +354,20 @@ labelsToSourcesWithTNTC acc (CmmProc _ _ _ cmm_graph) = |
| 351 | 354 | (CmmCall _ (Just l) _ _ _ _) -> Just $ mkAsmTempLabel l
|
| 352 | 355 | _ -> Nothing
|
| 353 | 356 | |
| 354 | - lastTickInBlock = foldr maybeTick Nothing (blockToList middleBlock)
|
|
| 355 | - |
|
| 356 | - maybeTick :: CmmNode O O -> Maybe IpeSourceLocation -> Maybe IpeSourceLocation
|
|
| 357 | - maybeTick _ s@(Just _) = s
|
|
| 358 | - maybeTick (CmmTick (SourceNote span name)) Nothing = Just (span, name)
|
|
| 359 | - maybeTick _ _ = Nothing
|
|
| 360 | -labelsToSourcesWithTNTC acc _ = acc
|
|
| 357 | + -- The ticks enclosing the call, innermost first.
|
|
| 358 | + -- NB: the innermost tick may not be from the current module, due to inlining.
|
|
| 359 | + nearestTickInBlock =
|
|
| 360 | + bestSourceNote False this_file
|
|
| 361 | + [ t | CmmTick t <- reverse (blockToList middleBlock) ]
|
|
| 362 | +labelsToSourcesWithTNTC _ acc _ = acc
|
|
| 361 | 363 | |
| 362 | 364 | -- | See Note [Stacktraces from Info Table Provenance Entries (IPE based stack unwinding)]
|
| 363 | 365 | labelsToSourcesSansTNTC
|
| 364 | - :: Map CLabel IpeSourceLocation
|
|
| 366 | + :: FastString -- ^ the source file of the module being compiled
|
|
| 367 | + -> Map CLabel IpeSourceLocation
|
|
| 365 | 368 | -> GenCmmDecl RawCmmStatics CmmTopInfo CmmGraph
|
| 366 | 369 | -> Map CLabel IpeSourceLocation
|
| 367 | -labelsToSourcesSansTNTC acc (CmmProc _ _ _ cmm_graph) =
|
|
| 370 | +labelsToSourcesSansTNTC this_file acc (CmmProc _ _ _ cmm_graph) =
|
|
| 368 | 371 | foldl' go acc (toBlockList cmm_graph)
|
| 369 | 372 | where
|
| 370 | 373 | go :: Map CLabel IpeSourceLocation -> CmmBlock -> Map CLabel IpeSourceLocation
|
| ... | ... | @@ -380,7 +383,9 @@ labelsToSourcesSansTNTC acc (CmmProc _ _ _ cmm_graph) = |
| 380 | 383 | case (b, lastTick) of
|
| 381 | 384 | (CmmStore _ (CmmLit (CmmLabel l)) _, Just src_loc) ->
|
| 382 | 385 | (Map.insert l src_loc acc, Nothing)
|
| 383 | - (CmmTick (SourceNote span name), _) ->
|
|
| 384 | - (acc, Just (span, name))
|
|
| 386 | + (CmmTick t, _)
|
|
| 387 | + -- Pick the innermost source note tick from the current file.
|
|
| 388 | + | Just src_loc <- bestSourceNote False this_file [t] ->
|
|
| 389 | + (acc, Just src_loc)
|
|
| 385 | 390 | _ -> (acc, lastTick)
|
| 386 | -labelsToSourcesSansTNTC acc _ = acc |
|
| 391 | +labelsToSourcesSansTNTC _ acc _ = acc |
| ... | ... | @@ -699,7 +699,7 @@ hscGenHardCode hsc_env cgguts mod_loc output_filename = do |
| 699 | 699 | Just _ ->
|
| 700 | 700 | do
|
| 701 | 701 | cmms <- {-# SCC "StgToCmm" #-}
|
| 702 | - doCodeGen hsc_env this_mod denv tycons
|
|
| 702 | + doCodeGen hsc_env this_mod mod_loc denv tycons
|
|
| 703 | 703 | cost_centre_info
|
| 704 | 704 | stg_binds
|
| 705 | 705 | |
| ... | ... | @@ -957,14 +957,14 @@ This reduces residency towards the end of the CodeGen phase significantly |
| 957 | 957 | (5-10%).
|
| 958 | 958 | -}
|
| 959 | 959 | |
| 960 | -doCodeGen :: HscEnv -> Module -> InfoTableProvMap -> [TyCon]
|
|
| 960 | +doCodeGen :: HscEnv -> Module -> ModLocation -> InfoTableProvMap -> [TyCon]
|
|
| 961 | 961 | -> CollectedCCs
|
| 962 | 962 | -> [CgStgTopBinding] -- ^ Bindings come already annotated with fvs
|
| 963 | 963 | -> IO (CgStream CmmGroupSRTs CmmCgInfos)
|
| 964 | 964 | -- Note we produce a 'Stream' of CmmGroups, so that the
|
| 965 | 965 | -- backend can be run incrementally. Otherwise it generates all
|
| 966 | 966 | -- the C-- up front, which has a significant space cost.
|
| 967 | -doCodeGen hsc_env this_mod denv tycons
|
|
| 967 | +doCodeGen hsc_env this_mod mod_loc denv tycons
|
|
| 968 | 968 | cost_centre_info stg_binds_w_fvs = do
|
| 969 | 969 | let dflags = hsc_dflags hsc_env
|
| 970 | 970 | logger = hsc_logger hsc_env
|
| ... | ... | @@ -972,6 +972,7 @@ doCodeGen hsc_env this_mod denv tycons |
| 972 | 972 | tmpfs = hsc_tmpfs hsc_env
|
| 973 | 973 | platform = targetPlatform dflags
|
| 974 | 974 | stg_ppr_opts = (initStgPprOpts dflags)
|
| 975 | + this_file = maybe nilFS mkFastString $ ml_hs_file mod_loc
|
|
| 975 | 976 | |
| 976 | 977 | putDumpFileMaybe logger Opt_D_dump_stg_final "Final STG:" FormatSTG
|
| 977 | 978 | (pprGenStgTopBindings stg_ppr_opts stg_binds_w_fvs)
|
| ... | ... | @@ -1033,7 +1034,7 @@ doCodeGen hsc_env this_mod denv tycons |
| 1033 | 1034 | -- Positions] in GHC.Stg.Debug.
|
| 1034 | 1035 | (ipes', stats') <-
|
| 1035 | 1036 | if (gopt Opt_InfoTableMap dflags) then
|
| 1036 | - liftIO $ lookupEstimatedTicks hsc_env ipes stats cmm_srts
|
|
| 1037 | + liftIO $ lookupEstimatedTicks hsc_env this_file ipes stats cmm_srts
|
|
| 1037 | 1038 | else
|
| 1038 | 1039 | return (ipes, stats)
|
| 1039 | 1040 |
| ... | ... | @@ -135,10 +135,12 @@ collectAlt alt = do e' <- collectExpr $ alt_rhs alt |
| 135 | 135 | -- propagated downwards by 'withSpan'. It's "quick" because it works only using immediate context rather
|
| 136 | 136 | -- than looking at the parent context like 'withSpan'
|
| 137 | 137 | quickSourcePos :: FastString -> StgExpr -> Maybe SpanWithLabel
|
| 138 | -quickSourcePos cur_mod (StgTick (SourceNote ss m) e)
|
|
| 139 | - | srcSpanFile ss == cur_mod = Just (SpanWithLabel ss m)
|
|
| 140 | - | otherwise = quickSourcePos cur_mod e
|
|
| 141 | -quickSourcePos _ _ = Nothing
|
|
| 138 | +quickSourcePos cur_mod e
|
|
| 139 | + = uncurry SpanWithLabel <$> bestSourceNote False cur_mod (head_ticks e)
|
|
| 140 | + where
|
|
| 141 | + -- The ticks at the head of the expression, outermost first.
|
|
| 142 | + head_ticks (StgTick t e') = t : head_ticks e'
|
|
| 143 | + head_ticks _ = []
|
|
| 142 | 144 | |
| 143 | 145 | recordStgIdPosition :: Id -> Maybe SpanWithLabel -> Maybe SpanWithLabel -> M ()
|
| 144 | 146 | recordStgIdPosition id best_span ss = do
|
| ... | ... | @@ -18,6 +18,7 @@ module GHC.Types.Tickish ( |
| 18 | 18 | tickishContains,
|
| 19 | 19 | combineTickish_maybe,
|
| 20 | 20 | tickishCommutable,
|
| 21 | + bestSourceNote,
|
|
| 21 | 22 | |
| 22 | 23 | -- * Breakpoint tick identifiers
|
| 23 | 24 | BreakpointId(..), BreakTickIndex
|
| ... | ... | @@ -32,7 +33,7 @@ import GHC.Core.Type |
| 32 | 33 | import GHC.Unit.Module
|
| 33 | 34 | |
| 34 | 35 | import GHC.Types.CostCentre
|
| 35 | -import GHC.Types.SrcLoc ( RealSrcSpan, containsSpan )
|
|
| 36 | +import GHC.Types.SrcLoc ( RealSrcSpan, containsSpan, srcSpanFile )
|
|
| 36 | 37 | import GHC.Types.Var
|
| 37 | 38 | |
| 38 | 39 | import GHC.Utils.Panic
|
| ... | ... | @@ -40,6 +41,8 @@ import GHC.Utils.Panic |
| 40 | 41 | import Language.Haskell.Syntax.Extension ( NoExtField )
|
| 41 | 42 | |
| 42 | 43 | import Data.Data
|
| 44 | +import Data.List ( partition )
|
|
| 45 | +import Data.Maybe ( listToMaybe, mapMaybe )
|
|
| 43 | 46 | import GHC.Utils.Binary
|
| 44 | 47 | import GHC.Utils.Outputable (Outputable (ppr), text, (<+>))
|
| 45 | 48 | |
| ... | ... | @@ -645,3 +648,25 @@ tickishContains (SourceNote sp1 n1) (SourceNote sp2 n2) |
| 645 | 648 | -- compare the String last
|
| 646 | 649 | tickishContains t1 t2
|
| 647 | 650 | = t1 == t2
|
| 651 | + |
|
| 652 | +-- | Choose the "best" source note in the given candidate list of ticks,
|
|
| 653 | +-- preferring source notes that are local to the source file being consdiered.
|
|
| 654 | +bestSourceNote
|
|
| 655 | + :: Bool
|
|
| 656 | + -- ^ accept a location in another module if there are none in the
|
|
| 657 | + -- current module?
|
|
| 658 | + -> FastString -- ^ the "local" source file
|
|
| 659 | + -> [GenTickish pass] -- ^ candidates (best first)
|
|
| 660 | + -> Maybe (RealSrcSpan, LexicalFastString)
|
|
| 661 | +bestSourceNote accept_outside_loc this_file ticks
|
|
| 662 | + = listToMaybe $
|
|
| 663 | + if accept_outside_loc
|
|
| 664 | + then here ++ elsewhere
|
|
| 665 | + else here
|
|
| 666 | + where
|
|
| 667 | + (here, elsewhere)
|
|
| 668 | + = partition ((this_file ==) . srcSpanFile . fst)
|
|
| 669 | + $ mapMaybe source_location ticks
|
|
| 670 | + |
|
| 671 | + source_location (SourceNote span name) = Just (span, name)
|
|
| 672 | + source_location _ = Nothing |
| 1 | +module T27749 where
|
|
| 2 | + |
|
| 3 | +select :: Maybe Int -> (Int -> Int) -> Int
|
|
| 4 | +select m k = case m of { Nothing -> 0; Just x -> k x }
|
|
| 5 | +{-# INLINE select #-}
|
|
| 6 | + |
|
| 7 | +ordering :: Maybe Int -> Int -> Int
|
|
| 8 | +ordering m b = select m (\x -> x + b)
|
|
| 9 | +{-# OPAQUE ordering #-} |
| 1 | +ordering
|
|
| 2 | + = \ (m :: Maybe Int) (b :: Int) ->
|
|
| 3 | + src<T27749.hs:8:1-37>
|
|
| 4 | + src<T27749.hs:4:1-54> |
| ... | ... | @@ -612,3 +612,9 @@ test('T27296b', [], makefile_test, ['T27296b']) |
| 612 | 612 | test('T27589', [grep_errmsg(r'wombat')], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-uniques'])
|
| 613 | 613 | test('T27590', [grep_errmsg(r'wombat')], compile, ['-O -ddump-simpl -dno-typeable-binds -dsuppress-uniques'])
|
| 614 | 614 | test('T27556', [only_ways('ghci'), extra_hc_opts('-O -fno-unoptimized-core-for-interpreter')], ghci_script, ['T27556.script'])
|
| 615 | + |
|
| 616 | +# Check the stack of source notes at the top of the body of 'ordering'
|
|
| 617 | +# is in the correct order.
|
|
| 618 | +test('T27749',
|
|
| 619 | + multiline_grep_errmsg(r'ordering\n.*\n(\s+src<[^>]*>\n)+'),
|
|
| 620 | + compile, ['-O -g3 -ddump-simpl -dsuppress-uniques']) |