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

Commits:

17 changed files:

Changes:

  • changelog.d/T27308
    1
    +section: compiler
    
    2
    +synopsis: Drop `preloadClosure` from `UnitState`
    
    3
    +issues: #27308
    
    4
    +mrs: !16108
    
    5
    +
    
    6
    +description: {
    
    7
    +    Drop `preloadClosure` from `UnitState` as it is always set to the empty set.
    
    8
    +    This allows to simplify the `UnitState` and related functions.
    
    9
    +}
    
    10
    +

  • compiler/.hlint.yaml
    ... ... @@ -3,6 +3,8 @@
    3 3
     ##########################
    
    4 4
     
    
    5 5
     - ignore: {}
    
    6
    +- ignore: {name: Use camelCase}
    
    7
    +- ignore: {name: Eta reduce}
    
    6 8
     - warn: {name: Unused LANGUAGE pragma}
    
    7 9
     - warn: {name: Use fewer LANGUAGE pragmas}
    
    8 10
     - warn: {name: Redundant return}
    

  • compiler/GHC/CmmToAsm/RV64/CodeGen.hs
    ... ... @@ -718,7 +718,7 @@ getRegister' config plat expr =
    718 718
                   ( \dst ->
    
    719 719
                       code
    
    720 720
                         `appOL` code_x
    
    721
    -                    `snocOL` annExpr expr (FCVT IntToFloat (OpReg to dst) (OpReg from reg_x)) -- (Signed ConVerT Float)
    
    721
    +                    `snocOL` annExpr expr (FCVT IntToFloat (OpReg to dst) (OpReg from reg_x) Rne) -- (Signed ConVerT Float)
    
    722 722
                   )
    
    723 723
             MO_SF_Round from to ->
    
    724 724
               pure
    
    ... ... @@ -726,7 +726,7 @@ getRegister' config plat expr =
    726 726
                   (floatFormat to)
    
    727 727
                   ( \dst ->
    
    728 728
                       code
    
    729
    -                    `snocOL` annExpr expr (FCVT IntToFloat (OpReg to dst) (OpReg from reg)) -- (Signed ConVerT Float)
    
    729
    +                    `snocOL` annExpr expr (FCVT IntToFloat (OpReg to dst) (OpReg from reg) Rne) -- (Signed ConVerT Float)
    
    730 730
                   )
    
    731 731
             -- TODO: Can this case happen?
    
    732 732
             MO_FS_Truncate from to
    
    ... ... @@ -738,7 +738,7 @@ getRegister' config plat expr =
    738 738
                           code
    
    739 739
                             `snocOL`
    
    740 740
                             -- W32 is the smallest width to convert to. Decrease width afterwards.
    
    741
    -                        annExpr expr (FCVT FloatToInt (OpReg W32 dst) (OpReg from reg))
    
    741
    +                        annExpr expr (FCVT FloatToInt (OpReg W32 dst) (OpReg from reg) Rtz)
    
    742 742
                             `appOL` signExtendAdjustPrecission W32 to dst dst -- (float convert (-> zero) signed)
    
    743 743
                       )
    
    744 744
             MO_FS_Truncate from to ->
    
    ... ... @@ -747,7 +747,7 @@ getRegister' config plat expr =
    747 747
                   (intFormat to)
    
    748 748
                   ( \dst ->
    
    749 749
                       code
    
    750
    -                    `snocOL` annExpr expr (FCVT FloatToInt (OpReg to dst) (OpReg from reg))
    
    750
    +                    `snocOL` annExpr expr (FCVT FloatToInt (OpReg to dst) (OpReg from reg) Rtz)
    
    751 751
                         `appOL` truncateReg from to dst -- (float convert (-> zero) signed)
    
    752 752
                   )
    
    753 753
             MO_UU_Conv from to
    
    ... ... @@ -769,9 +769,18 @@ getRegister' config plat expr =
    769 769
                         `appOL` truncateReg from to dst
    
    770 770
                   )
    
    771 771
             MO_SS_Conv from to -> ss_conv from to reg code
    
    772
    -        MO_FF_Conv from to -> return $ Any (floatFormat to) (\dst -> code `snocOL` annExpr e (FCVT FloatToFloat (OpReg to dst) (OpReg from reg)))
    
    772
    +        MO_FF_Conv from to -> return $ Any (floatFormat to) (\dst -> code `snocOL` annExpr e (FCVT FloatToFloat (OpReg to dst) (OpReg from reg) Rne))
    
    773 773
             MO_WF_Bitcast w    -> return $ Any (floatFormat w)  (\dst -> code `snocOL` MOV (OpReg w dst) (OpReg w reg))
    
    774
    -        MO_FW_Bitcast w    -> return $ Any (intFormat w)    (\dst -> code `snocOL` MOV (OpReg w dst) (OpReg w reg))
    
    774
    +        MO_FW_Bitcast w ->
    
    775
    +          return
    
    776
    +            $ Any
    
    777
    +              (intFormat w)
    
    778
    +              ( \dst ->
    
    779
    +                  code
    
    780
    +                    `snocOL` MOV (OpReg w dst) (OpReg w reg)
    
    781
    +                    -- FMV.X.W sign-extends the value, so truncate the result
    
    782
    +                    `appOL` truncateReg W64 w dst
    
    783
    +              )
    
    775 784
     
    
    776 785
             -- Conversions
    
    777 786
             -- TODO: Duplication with MO_UU_Conv
    

  • compiler/GHC/CmmToAsm/RV64/Instr.hs
    ... ... @@ -106,7 +106,7 @@ regUsageOfInstr platform instr = case instr of
    106 106
       LDR _ dst src -> usage (regOp src, regOp dst)
    
    107 107
       LDRU _ dst src -> usage (regOp src, regOp dst)
    
    108 108
       FENCE _ _ -> usage ([], [])
    
    109
    -  FCVT _variant dst src -> usage (regOp src, regOp dst)
    
    109
    +  FCVT _variant dst src _rm -> usage (regOp src, regOp dst)
    
    110 110
       FABS dst src -> usage (regOp src, regOp dst)
    
    111 111
       FMIN dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst)
    
    112 112
       FMAX dst src1 src2 -> usage (regOp src1 ++ regOp src2, regOp dst)
    
    ... ... @@ -165,6 +165,7 @@ callerSavedRegisters =
    165 165
         ++ map regSingle [t3RegNo .. t6RegNo]
    
    166 166
         ++ map regSingle [ft0RegNo .. ft7RegNo]
    
    167 167
         ++ map regSingle [fa0RegNo .. fa7RegNo]
    
    168
    +    ++ map regSingle [ft8RegNo .. ft11RegNo]
    
    168 169
     
    
    169 170
     -- | Apply a given mapping to all the register references in this instruction.
    
    170 171
     patchRegsOfInstr :: Instr -> (Reg -> Reg) -> Instr
    
    ... ... @@ -205,7 +206,7 @@ patchRegsOfInstr instr env = case instr of
    205 206
       LDR f o1 o2 -> LDR f (patchOp o1) (patchOp o2)
    
    206 207
       LDRU f o1 o2 -> LDRU f (patchOp o1) (patchOp o2)
    
    207 208
       FENCE o1 o2 -> FENCE o1 o2
    
    208
    -  FCVT variant o1 o2 -> FCVT variant (patchOp o1) (patchOp o2)
    
    209
    +  FCVT variant o1 o2 rm -> FCVT variant (patchOp o1) (patchOp o2) rm
    
    209 210
       FABS o1 o2 -> FABS (patchOp o1) (patchOp o2)
    
    210 211
       FMIN o1 o2 o3 -> FMIN (patchOp o1) (patchOp o2) (patchOp o3)
    
    211 212
       FMAX o1 o2 o3 -> FMAX (patchOp o1) (patchOp o2) (patchOp o3)
    
    ... ... @@ -612,7 +613,7 @@ data Instr
    612 613
         -- Memory barrier.
    
    613 614
         FENCE FenceType FenceType
    
    614 615
       | -- | Floating point conversion
    
    615
    -    FCVT FcvtVariant Operand Operand
    
    616
    +    FCVT FcvtVariant Operand Operand RoundingMode
    
    616 617
       | -- | Floating point ABSolute value
    
    617 618
         FABS Operand Operand
    
    618 619
     
    
    ... ... @@ -636,6 +637,21 @@ data FenceType = FenceRead | FenceWrite | FenceReadWrite
    636 637
     -- | Variant of a floating point conversion instruction
    
    637 638
     data FcvtVariant = FloatToFloat | IntToFloat | FloatToInt
    
    638 639
     
    
    640
    +-- | The rounding mode associated with an instruction
    
    641
    +data RoundingMode
    
    642
    +  = -- | Round to nearest, ties to even
    
    643
    +    Rne
    
    644
    +  | -- | Round toward zero
    
    645
    +    Rtz
    
    646
    +  | -- | Round downward (toward negative infinity)
    
    647
    +    Rdn
    
    648
    +  | -- | Round upward (toward positive infinity)
    
    649
    +    Rup
    
    650
    +  | -- | Round to nearest, ties to max magnitude
    
    651
    +    Rmm
    
    652
    +  | -- | Dynamic rounding mode
    
    653
    +    Dyn
    
    654
    +
    
    639 655
     instrCon :: Instr -> String
    
    640 656
     instrCon i =
    
    641 657
       case i of
    

  • compiler/GHC/CmmToAsm/RV64/Ppr.hs
    ... ... @@ -406,6 +406,17 @@ pprReg w r = case r of
    406 406
           -- no support for widths > W64.
    
    407 407
           | otherwise = pprPanic "Unsupported width in register (max is 64)" (ppr w <+> int i)
    
    408 408
     
    
    409
    +-- | Pretty print a rounding mode
    
    410
    +--
    
    411
    +-- If the rounding mode is omitted, 'dyn' will be used.
    
    412
    +pprRm :: IsLine doc => RoundingMode -> doc
    
    413
    +pprRm Rne = text "rne"
    
    414
    +pprRm Rtz = text "rtz"
    
    415
    +pprRm Rdn = text "rdn"
    
    416
    +pprRm Rup = text "rup"
    
    417
    +pprRm Rmm = text "rmm"
    
    418
    +pprRm Dyn = text "dyn"
    
    419
    +
    
    409 420
     -- | Single precission `Operand` (floating-point)
    
    410 421
     isSingleOp :: Operand -> Bool
    
    411 422
     isSingleOp (OpReg W32 _) = True
    
    ... ... @@ -643,25 +654,26 @@ pprInstr platform instr = case instr of
    643 654
       LDRU FF64 o1 o2@(OpAddr (AddrRegImm _ _)) -> op2 (text "\tfld") o1 o2
    
    644 655
       LDRU f o1 o2 -> pprPanic "Unsupported unsigned load" ((text . show) f <+> pprOp platform o1 <+> pprOp platform o2)
    
    645 656
       FENCE r w -> line $ text "\tfence" <+> pprFenceType r <> char ',' <+> pprFenceType w
    
    646
    -  FCVT FloatToFloat o1@(OpReg W32 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.s.d") o1 o2
    
    647
    -  FCVT FloatToFloat o1@(OpReg W64 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.d.s") o1 o2
    
    648
    -  FCVT FloatToFloat o1 o2 ->
    
    657
    +  FCVT FloatToFloat o1@(OpReg W32 _) o2@(OpReg W64 _) rm -> op2rm (text "\tfcvt.s.d") o1 o2 rm
    
    658
    +  -- The assembler seems to be unhappy with explicit rounding mode on fcvt.d.s
    
    659
    +  FCVT FloatToFloat o1@(OpReg W64 _) o2@(OpReg W32 _) _rm -> op2 (text "\tfcvt.d.s") o1 o2
    
    660
    +  FCVT FloatToFloat o1 o2 rm ->
    
    649 661
         pprPanic "RV64.pprInstr - impossible float to float conversion"
    
    650
    -      $ line (pprOp platform o1 <> text "->" <> pprOp platform o2)
    
    651
    -  FCVT IntToFloat o1@(OpReg W32 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.s.w") o1 o2
    
    652
    -  FCVT IntToFloat o1@(OpReg W32 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.s.l") o1 o2
    
    653
    -  FCVT IntToFloat o1@(OpReg W64 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.d.w") o1 o2
    
    654
    -  FCVT IntToFloat o1@(OpReg W64 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.d.l") o1 o2
    
    655
    -  FCVT IntToFloat o1 o2 ->
    
    662
    +      $ line (pprOp platform o1 <> text "->" <> pprOp platform o2 <> text "," <> pprRm rm)
    
    663
    +  FCVT IntToFloat o1@(OpReg W32 _) o2@(OpReg W32 _) rm -> op2rm (text "\tfcvt.s.w") o1 o2 rm
    
    664
    +  FCVT IntToFloat o1@(OpReg W32 _) o2@(OpReg W64 _) rm -> op2rm (text "\tfcvt.s.l") o1 o2 rm
    
    665
    +  FCVT IntToFloat o1@(OpReg W64 _) o2@(OpReg W32 _) rm -> op2rm (text "\tfcvt.d.w") o1 o2 rm
    
    666
    +  FCVT IntToFloat o1@(OpReg W64 _) o2@(OpReg W64 _) rm -> op2rm (text "\tfcvt.d.l") o1 o2 rm
    
    667
    +  FCVT IntToFloat o1 o2 rm ->
    
    656 668
         pprPanic "RV64.pprInstr - impossible integer to float conversion"
    
    657
    -      $ line (pprOp platform o1 <> text "->" <> pprOp platform o2)
    
    658
    -  FCVT FloatToInt o1@(OpReg W32 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.w.s") o1 o2
    
    659
    -  FCVT FloatToInt o1@(OpReg W32 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.w.d") o1 o2
    
    660
    -  FCVT FloatToInt o1@(OpReg W64 _) o2@(OpReg W32 _) -> op2 (text "\tfcvt.l.s") o1 o2
    
    661
    -  FCVT FloatToInt o1@(OpReg W64 _) o2@(OpReg W64 _) -> op2 (text "\tfcvt.l.d") o1 o2
    
    662
    -  FCVT FloatToInt o1 o2 ->
    
    669
    +      $ line (pprOp platform o1 <> text "->" <> pprOp platform o2 <> text "," <> pprRm rm)
    
    670
    +  FCVT FloatToInt o1@(OpReg W32 _) o2@(OpReg W32 _) rm -> op2rm (text "\tfcvt.w.s") o1 o2 rm
    
    671
    +  FCVT FloatToInt o1@(OpReg W32 _) o2@(OpReg W64 _) rm -> op2rm (text "\tfcvt.w.d") o1 o2 rm
    
    672
    +  FCVT FloatToInt o1@(OpReg W64 _) o2@(OpReg W32 _) rm -> op2rm (text "\tfcvt.l.s") o1 o2 rm
    
    673
    +  FCVT FloatToInt o1@(OpReg W64 _) o2@(OpReg W64 _) rm -> op2rm (text "\tfcvt.l.d") o1 o2 rm
    
    674
    +  FCVT FloatToInt o1 o2 rm ->
    
    663 675
         pprPanic "RV64.pprInstr - impossible float to integer conversion"
    
    664
    -      $ line (pprOp platform o1 <> text "->" <> pprOp platform o2)
    
    676
    +      $ line (pprOp platform o1 <> text "->" <> pprOp platform o2 <> text "," <> pprRm rm)
    
    665 677
       FABS o1 o2 | isSingleOp o2 -> op2 (text "\tfabs.s") o1 o2
    
    666 678
       FABS o1 o2 | isDoubleOp o2 -> op2 (text "\tfabs.d") o1 o2
    
    667 679
       FMIN o1 o2 o3 | isSingleOp o1 -> op3 (text "\tfmin.s") o1 o2 o3
    
    ... ... @@ -678,6 +690,8 @@ pprInstr platform instr = case instr of
    678 690
       instr -> panic $ "RV64.pprInstr - Unknown instruction: " ++ instrCon instr
    
    679 691
       where
    
    680 692
         op2 op o1 o2 = line $ op <+> pprOp platform o1 <> comma <+> pprOp platform o2
    
    693
    +    op2rm op o1 o2 Dyn = line $ op <+> pprOp platform o1 <> comma <+> pprOp platform o2
    
    694
    +    op2rm op o1 o2 rm = line $ op <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprRm rm
    
    681 695
         op3 op o1 o2 o3 = line $ op <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3
    
    682 696
         op4 op o1 o2 o3 o4 = line $ op <+> pprOp platform o1 <> comma <+> pprOp platform o2 <> comma <+> pprOp platform o3 <> comma <+> pprOp platform o4
    
    683 697
         pprFenceType FenceRead = text "r"
    

  • compiler/GHC/CmmToAsm/RV64/Regs.hs
    ... ... @@ -53,9 +53,14 @@ d7RegNo, ft7RegNo :: RegNo
    53 53
     d7RegNo = 39
    
    54 54
     ft7RegNo = d7RegNo
    
    55 55
     
    
    56
    +d28RegNo, ft8RegNo :: RegNo
    
    57
    +d28RegNo = 60
    
    58
    +ft8RegNo = d28RegNo
    
    59
    +
    
    56 60
     -- | Last floating point register.
    
    57
    -d31RegNo :: RegNo
    
    61
    +d31RegNo, ft11RegNo :: RegNo
    
    58 62
     d31RegNo = 63
    
    63
    +ft11RegNo = d31RegNo
    
    59 64
     
    
    60 65
     a0RegNo, x10RegNo :: RegNo
    
    61 66
     x10RegNo = 10
    

  • compiler/GHC/Driver/Backpack.hs
    ... ... @@ -242,7 +242,6 @@ withBkpSession cid insts deps session_type do_this = do
    242 242
                 -- Synthesize the flags
    
    243 243
                 , packageFlags = packageFlags dflags ++ map (\(uid0, rn) ->
    
    244 244
                   let uid = unwireUnit unit_state
    
    245
    -                        $ improveUnit unit_state
    
    246 245
                             $ renameHoleUnit unit_state (listToUFM insts) uid0
    
    247 246
                   in ExposePackage
    
    248 247
                     (showSDoc dflags
    
    ... ... @@ -311,19 +310,16 @@ buildUnit session cid insts lunit = do
    311 310
         -- The compilation dependencies are just the appropriately filled
    
    312 311
         -- in unit IDs which must be compiled before we can compile.
    
    313 312
         let hsubst = listToUFM insts
    
    314
    -        deps0 = map (renameHoleUnit (hsc_units hsc_env) hsubst) raw_deps
    
    313
    +        deps = map (renameHoleUnit (hsc_units hsc_env) hsubst) raw_deps
    
    315 314
     
    
    316 315
         -- Build dependencies OR make sure they make sense. BUT NOTE,
    
    317 316
         -- we can only check the ones that are fully filled; the rest
    
    318 317
         -- we have to defer until we've typechecked our local signature.
    
    319 318
         -- TODO: work this into GHC.Driver.Make!!
    
    320
    -    forM_ (zip [1..] deps0) $ \(i, dep) ->
    
    319
    +    forM_ (zip [1..] deps) $ \(i, dep) ->
    
    321 320
             case session of
    
    322 321
                 TcSession -> return ()
    
    323
    -            _ -> compileInclude (length deps0) (i, dep)
    
    324
    -
    
    325
    -    -- IMPROVE IT
    
    326
    -    let deps = map (improveUnit (hsc_units hsc_env)) deps0
    
    322
    +            _ -> compileInclude (length deps) (i, dep)
    
    327 323
     
    
    328 324
         mb_old_eps <- case session of
    
    329 325
                         TcSession -> fmap Just getEpsGhc
    

  • compiler/GHC/Iface/Load.hs
    ... ... @@ -914,13 +914,13 @@ findAndReadIface hsc_env doc_str mod wanted_mod hi_boot_file = do
    914 914
                   && not (isOneShot (ghcMode dflags))
    
    915 915
                 then return (Failed (HomeModError mod loc))
    
    916 916
                 else do
    
    917
    -                r <- read_file hooks logger name_cache unit_state dflags wanted_mod (ml_hi_file loc)
    
    917
    +                r <- read_file hooks logger name_cache dflags wanted_mod (ml_hi_file loc)
    
    918 918
                     case r of
    
    919 919
                       Failed err
    
    920 920
                         -> return (Failed $ BadIfaceFile err)
    
    921 921
                       Succeeded (iface,_fp)
    
    922 922
                         -> do
    
    923
    -                        r2 <- load_dynamic_too_maybe hooks logger name_cache unit_state
    
    923
    +                        r2 <- load_dynamic_too_maybe hooks logger name_cache
    
    924 924
                                                      (setDynamicNow dflags) wanted_mod
    
    925 925
                                                      iface loc
    
    926 926
                             case r2 of
    
    ... ... @@ -936,20 +936,20 @@ findAndReadIface hsc_env doc_str mod wanted_mod hi_boot_file = do
    936 936
                                   err
    
    937 937
     
    
    938 938
     -- | Check if we need to try the dynamic interface for -dynamic-too
    
    939
    -load_dynamic_too_maybe :: Hooks -> Logger -> NameCache -> UnitState -> DynFlags
    
    939
    +load_dynamic_too_maybe :: Hooks -> Logger -> NameCache -> DynFlags
    
    940 940
                            -> Module -> ModIface -> ModLocation
    
    941 941
                            -> IO (MaybeErr MissingInterfaceError ())
    
    942
    -load_dynamic_too_maybe hooks logger name_cache unit_state dflags wanted_mod iface loc
    
    942
    +load_dynamic_too_maybe hooks logger name_cache dflags wanted_mod iface loc
    
    943 943
       -- Indefinite interfaces are ALWAYS non-dynamic.
    
    944 944
       | not (moduleIsDefinite (mi_module iface)) = return (Succeeded ())
    
    945
    -  | gopt Opt_BuildDynamicToo dflags = load_dynamic_too hooks logger name_cache unit_state dflags wanted_mod iface loc
    
    945
    +  | gopt Opt_BuildDynamicToo dflags = load_dynamic_too hooks logger name_cache dflags wanted_mod iface loc
    
    946 946
       | otherwise = return (Succeeded ())
    
    947 947
     
    
    948
    -load_dynamic_too :: Hooks -> Logger -> NameCache -> UnitState -> DynFlags
    
    948
    +load_dynamic_too :: Hooks -> Logger -> NameCache -> DynFlags
    
    949 949
                      -> Module -> ModIface -> ModLocation
    
    950 950
                      -> IO (MaybeErr MissingInterfaceError ())
    
    951
    -load_dynamic_too hooks logger name_cache unit_state dflags wanted_mod iface loc = do
    
    952
    -  read_file hooks logger name_cache unit_state dflags wanted_mod (ml_dyn_hi_file loc) >>= \case
    
    951
    +load_dynamic_too hooks logger name_cache dflags wanted_mod iface loc = do
    
    952
    +  read_file hooks logger name_cache dflags wanted_mod (ml_dyn_hi_file loc) >>= \case
    
    953 953
         Succeeded (dynIface, _)
    
    954 954
          | mi_mod_hash iface == mi_mod_hash dynIface
    
    955 955
          -> return (Succeeded ())
    
    ... ... @@ -963,10 +963,10 @@ load_dynamic_too hooks logger name_cache unit_state dflags wanted_mod iface loc
    963 963
     
    
    964 964
     
    
    965 965
     
    
    966
    -read_file :: Hooks -> Logger -> NameCache -> UnitState -> DynFlags
    
    966
    +read_file :: Hooks -> Logger -> NameCache -> DynFlags
    
    967 967
               -> Module -> FilePath
    
    968 968
               -> IO (MaybeErr ReadInterfaceError (ModIface, FilePath))
    
    969
    -read_file hooks logger name_cache unit_state dflags wanted_mod file_path = do
    
    969
    +read_file hooks logger name_cache dflags wanted_mod file_path = do
    
    970 970
     
    
    971 971
       -- Figure out what is recorded in mi_module.  If this is
    
    972 972
       -- a fully definite interface, it'll match exactly, but
    
    ... ... @@ -975,7 +975,7 @@ read_file hooks logger name_cache unit_state dflags wanted_mod file_path = do
    975 975
             case getModuleInstantiation wanted_mod of
    
    976 976
                 (_, Nothing) -> wanted_mod
    
    977 977
                 (_, Just indef_mod) ->
    
    978
    -              instModuleToModule unit_state
    
    978
    +              instModuleToModule
    
    979 979
                     (uninstantiateInstantiatedModule indef_mod)
    
    980 980
       read_result <- readIface hooks logger dflags name_cache wanted_mod' file_path
    
    981 981
       case read_result of
    

  • compiler/GHC/Iface/Recomp.hs
    ... ... @@ -620,7 +620,7 @@ checkMergedSignatures hsc_env mod_summary self_recomp = do
    620 620
             new_merged = case lookupUniqMap (requirementContext unit_state)
    
    621 621
                               (ms_mod_name mod_summary) of
    
    622 622
                             Nothing -> []
    
    623
    -                        Just r -> sort $ map (instModuleToModule unit_state) r
    
    623
    +                        Just r -> sort $ map instModuleToModule r
    
    624 624
         if old_merged == new_merged
    
    625 625
             then up_to_date logger (text "signatures to merge in unchanged" $$ ppr new_merged)
    
    626 626
             else return $ needsRecompileBecause SigsMergeChanged
    

  • compiler/GHC/Unit.hs
    ... ... @@ -226,8 +226,8 @@ on-the-fly:
    226 226
     A 'VirtUnit' may be indefinite or definite, it depends on whether some holes
    
    227 227
     remain in the instantiated unit OR in the instantiating units (recursively).
    
    228 228
     Having a fully instantiated (i.e. definite) virtual unit can lead to some issues
    
    229
    -if there is a matching compiled unit in the preload closure.  See Note [VirtUnit
    
    230
    -to RealUnit improvement]
    
    229
    +if there is a matching compiled unit in the preload closure.
    
    230
    +See Note [VirtUnit to RealUnit improvement]
    
    231 231
     
    
    232 232
     Unit database and indefinite units
    
    233 233
     ----------------------------------
    
    ... ... @@ -314,7 +314,6 @@ field in the SDocContext to pretty-print.
    314 314
           (i.e. GHC doesn't correctly call `pprWithUnitState` before pretty-printing a
    
    315 315
           UnitId), that's what will be shown to the user so it's no big deal.
    
    316 316
     
    
    317
    -
    
    318 317
     Note [VirtUnit to RealUnit improvement]
    
    319 318
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    320 319
     
    
    ... ... @@ -332,6 +331,8 @@ same type-checking session, their names won't match (e.g. "abc:M.X" vs
    332 331
     As we want them to match we just replace the virtual unit with the installed
    
    333 332
     one: for some reason this is called "improvement".
    
    334 333
     
    
    334
    +HISTORICAL:
    
    335
    +
    
    335 336
     There is one last niggle: improvement based on the unit database means
    
    336 337
     that we might end up developing on a unit that is not transitively
    
    337 338
     depended upon by the units the user specified directly via command line
    
    ... ... @@ -340,6 +341,12 @@ instantiations are out of date. The solution is to only improve a
    340 341
     unit id if the new unit id is part of the 'preloadClosure'; i.e., the
    
    341 342
     closure of all the units which were explicitly specified.
    
    342 343
     
    
    344
    +NOTE:
    
    345
    +
    
    346
    +The 'preloadClosure' was completely unused, thus we removed it without
    
    347
    +changing any of the tests. It doesn't seem to be necessary any more.
    
    348
    +It is unclear at which exact point this became redundant.
    
    349
    +
    
    343 350
     Note [Representation of module/name variables]
    
    344 351
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    345 352
     In our ICFP'16, we use <A> to represent module holes, and {A.T} to represent
    

  • compiler/GHC/Unit/State.hs
    ... ... @@ -7,7 +7,6 @@ module GHC.Unit.State (
    7 7
     
    
    8 8
             -- * Reading the package config, and processing cmdline args
    
    9 9
             UnitState(..),
    
    10
    -        PreloadUnitClosure,
    
    11 10
             UnitDatabase (..),
    
    12 11
             UnitErr (..),
    
    13 12
             emptyUnitState,
    
    ... ... @@ -29,7 +28,6 @@ module GHC.Unit.State (
    29 28
     
    
    30 29
             lookupPackageName,
    
    31 30
             resolvePackageImport,
    
    32
    -        improveUnit,
    
    33 31
             searchPackageId,
    
    34 32
             listVisibleModuleNames,
    
    35 33
             lookupModuleInAllUnits,
    
    ... ... @@ -89,7 +87,6 @@ import GHC.Unit.Home
    89 87
     
    
    90 88
     import GHC.Types.Unique.FM
    
    91 89
     import GHC.Types.Unique.DFM
    
    92
    -import GHC.Types.Unique.Set
    
    93 90
     import GHC.Types.Unique.DSet
    
    94 91
     import GHC.Types.Unique.Map
    
    95 92
     import GHC.Types.Unique
    
    ... ... @@ -268,8 +265,6 @@ originEmpty :: ModuleOrigin -> Bool
    268 265
     originEmpty (ModOrigin Nothing [] [] False) = True
    
    269 266
     originEmpty _ = False
    
    270 267
     
    
    271
    -type PreloadUnitClosure = UniqSet UnitId
    
    272
    -
    
    273 268
     -- | 'UniqFM' map from 'Unit' to a 'UnitVisibility'.
    
    274 269
     type VisibilityMap = UniqMap Unit UnitVisibility
    
    275 270
     
    
    ... ... @@ -432,13 +427,6 @@ data UnitState = UnitState {
    432 427
       -- may have the 'exposed' flag be 'False'.)
    
    433 428
       unitInfoMap :: UnitInfoMap,
    
    434 429
     
    
    435
    -  -- | The set of transitively reachable units according
    
    436
    -  -- to the explicitly provided command line arguments.
    
    437
    -  -- A fully instantiated VirtUnit may only be replaced by a RealUnit from
    
    438
    -  -- this set.
    
    439
    -  -- See Note [VirtUnit to RealUnit improvement]
    
    440
    -  preloadClosure :: PreloadUnitClosure,
    
    441
    -
    
    442 430
       -- | A mapping of 'PackageName' to 'UnitId'. If several units have the same
    
    443 431
       -- package name (e.g. different instantiations), then we return one of them...
    
    444 432
       -- This is used when users refer to packages in Backpack includes.
    
    ... ... @@ -491,7 +479,6 @@ data UnitState = UnitState {
    491 479
     emptyUnitState :: UnitState
    
    492 480
     emptyUnitState = UnitState {
    
    493 481
         unitInfoMap    = emptyUniqMap,
    
    494
    -    preloadClosure = emptyUniqSet,
    
    495 482
         packageNameMap = emptyUFM,
    
    496 483
         wireMap        = emptyUniqMap,
    
    497 484
         unwireMap      = emptyUniqMap,
    
    ... ... @@ -517,7 +504,7 @@ type UnitInfoMap = UniqMap UnitId UnitInfo
    517 504
     
    
    518 505
     -- | Find the unit we know about with the given unit, if any
    
    519 506
     lookupUnit :: UnitState -> Unit -> Maybe UnitInfo
    
    520
    -lookupUnit pkgs = lookupUnit' (allowVirtualUnits pkgs) (unitInfoMap pkgs) (preloadClosure pkgs)
    
    507
    +lookupUnit pkgs = lookupUnit' (allowVirtualUnits pkgs) (unitInfoMap pkgs)
    
    521 508
     
    
    522 509
     -- | A more specialized interface, which doesn't require a 'UnitState' (so it
    
    523 510
     -- can be used while we're initializing 'DynFlags')
    
    ... ... @@ -525,16 +512,15 @@ lookupUnit pkgs = lookupUnit' (allowVirtualUnits pkgs) (unitInfoMap pkgs) (prelo
    525 512
     -- Parameters:
    
    526 513
     --    * a boolean specifying whether or not to look for on-the-fly renamed interfaces
    
    527 514
     --    * a 'UnitInfoMap'
    
    528
    ---    * a 'PreloadUnitClosure'
    
    529
    -lookupUnit' :: Bool -> UnitInfoMap -> PreloadUnitClosure -> Unit -> Maybe UnitInfo
    
    530
    -lookupUnit' allowOnTheFlyInst pkg_map closure u = case u of
    
    515
    +lookupUnit' :: Bool -> UnitInfoMap -> Unit -> Maybe UnitInfo
    
    516
    +lookupUnit' allowOnTheFlyInst pkg_map u = case u of
    
    531 517
        HoleUnit   -> error "Hole unit"
    
    532 518
        RealUnit i -> lookupUniqMap pkg_map (unDefinite i)
    
    533 519
        VirtUnit i
    
    534 520
           | allowOnTheFlyInst
    
    535 521
           -> -- lookup UnitInfo of the indefinite unit to be instantiated and
    
    536 522
              -- instantiate it on-the-fly
    
    537
    -         fmap (renameUnitInfo pkg_map closure (instUnitInsts i))
    
    523
    +         fmap (renameUnitInfo pkg_map (instUnitInsts i))
    
    538 524
                (lookupUniqMap pkg_map (instUnitInstanceOf i))
    
    539 525
     
    
    540 526
           | otherwise
    
    ... ... @@ -908,7 +894,6 @@ applyTrustFlag prec_map unusable pkgs flag =
    908 894
     applyPackageFlag
    
    909 895
        :: UnitPrecedenceMap
    
    910 896
        -> UnitInfoMap
    
    911
    -   -> PreloadUnitClosure
    
    912 897
        -> UnusableUnits
    
    913 898
        -> Bool -- if False, if you expose a package, it implicitly hides
    
    914 899
                -- any previously exposed packages with the same name
    
    ... ... @@ -917,10 +902,10 @@ applyPackageFlag
    917 902
        -> PackageFlag             -- flag to apply
    
    918 903
        -> MaybeErr UnitErr VisibilityMap -- Now exposed
    
    919 904
     
    
    920
    -applyPackageFlag prec_map pkg_map closure unusable no_hide_others pkgs vm flag =
    
    905
    +applyPackageFlag prec_map pkg_map unusable no_hide_others pkgs vm flag =
    
    921 906
       case flag of
    
    922 907
         ExposePackage _ arg (ModRenaming b rns) ->
    
    923
    -       case findPackages prec_map pkg_map closure arg pkgs unusable of
    
    908
    +       case findPackages prec_map pkg_map arg pkgs unusable of
    
    924 909
              Left ps     -> Failed (PackageFlagErr flag ps)
    
    925 910
              Right (p:_) -> Succeeded vm'
    
    926 911
               where
    
    ... ... @@ -984,7 +969,7 @@ applyPackageFlag prec_map pkg_map closure unusable no_hide_others pkgs vm flag =
    984 969
              _ -> panic "applyPackageFlag"
    
    985 970
     
    
    986 971
         HidePackage str ->
    
    987
    -       case findPackages prec_map pkg_map closure (PackageArg str) pkgs unusable of
    
    972
    +       case findPackages prec_map pkg_map (PackageArg str) pkgs unusable of
    
    988 973
              Left ps  -> Failed (PackageFlagErr flag ps)
    
    989 974
              Right ps -> Succeeded $ foldl' delFromUniqMap vm (map mkUnit ps)
    
    990 975
     
    
    ... ... @@ -993,12 +978,11 @@ applyPackageFlag prec_map pkg_map closure unusable no_hide_others pkgs vm flag =
    993 978
     -- if the 'UnitArg' has a renaming associated with it.
    
    994 979
     findPackages :: UnitPrecedenceMap
    
    995 980
                  -> UnitInfoMap
    
    996
    -             -> PreloadUnitClosure
    
    997 981
                  -> PackageArg -> [UnitInfo]
    
    998 982
                  -> UnusableUnits
    
    999 983
                  -> Either [(UnitInfo, UnusableUnitReason)]
    
    1000 984
                     [UnitInfo]
    
    1001
    -findPackages prec_map pkg_map closure arg pkgs unusable
    
    985
    +findPackages prec_map pkg_map arg pkgs unusable
    
    1002 986
       = let ps = mapMaybe (finder arg) pkgs
    
    1003 987
         in if null ps
    
    1004 988
             then Left (mapMaybe (\(x,y) -> finder arg x >>= \x' -> return (x',y))
    
    ... ... @@ -1016,7 +1000,7 @@ findPackages prec_map pkg_map closure arg pkgs unusable
    1016 1000
                 -> Just p
    
    1017 1001
               VirtUnit inst
    
    1018 1002
                 | instUnitInstanceOf inst == unitId p
    
    1019
    -            -> Just (renameUnitInfo pkg_map closure (instUnitInsts inst) p)
    
    1003
    +            -> Just (renameUnitInfo pkg_map (instUnitInsts inst) p)
    
    1020 1004
               _ -> Nothing
    
    1021 1005
     
    
    1022 1006
     selectPackages :: UnitPrecedenceMap -> PackageArg -> [UnitInfo]
    
    ... ... @@ -1031,10 +1015,10 @@ selectPackages prec_map arg pkgs unusable
    1031 1015
             else Right (sortByPreference prec_map ps, rest)
    
    1032 1016
     
    
    1033 1017
     -- | Rename a 'UnitInfo' according to some module instantiation.
    
    1034
    -renameUnitInfo :: UnitInfoMap -> PreloadUnitClosure -> [(ModuleName, Module)] -> UnitInfo -> UnitInfo
    
    1035
    -renameUnitInfo pkg_map closure insts conf =
    
    1018
    +renameUnitInfo :: UnitInfoMap -> [(ModuleName, Module)] -> UnitInfo -> UnitInfo
    
    1019
    +renameUnitInfo pkg_map insts conf =
    
    1036 1020
         let hsubst = listToUFM insts
    
    1037
    -        smod  = renameHoleModule' pkg_map closure hsubst
    
    1021
    +        smod  = renameHoleModule' pkg_map hsubst
    
    1038 1022
             new_insts = map (\(k,v) -> (k,smod v)) (unitInstantiations conf)
    
    1039 1023
         in conf {
    
    1040 1024
             unitInstantiations = new_insts,
    
    ... ... @@ -1632,7 +1616,7 @@ mkUnitState logger cfg = do
    1632 1616
       -- user tries to enable an unusable package, we should let them know.
    
    1633 1617
       --
    
    1634 1618
       vis_map2 <- mayThrowUnitErr
    
    1635
    -                $ foldM (applyPackageFlag prec_map prelim_pkg_db emptyUniqSet unusable
    
    1619
    +                $ foldM (applyPackageFlag prec_map prelim_pkg_db unusable
    
    1636 1620
                             (unitConfigHideAll cfg) pkgs1)
    
    1637 1621
                                 vis_map1 other_flags
    
    1638 1622
     
    
    ... ... @@ -1661,7 +1645,7 @@ mkUnitState logger cfg = do
    1661 1645
                             | otherwise = vis_map2
    
    1662 1646
                     plugin_vis_map2
    
    1663 1647
                         <- mayThrowUnitErr
    
    1664
    -                        $ foldM (applyPackageFlag prec_map prelim_pkg_db emptyUniqSet unusable
    
    1648
    +                        $ foldM (applyPackageFlag prec_map prelim_pkg_db unusable
    
    1665 1649
                                     hide_plugin_pkgs pkgs1)
    
    1666 1650
                                  plugin_vis_map1
    
    1667 1651
                                  (reverse (unitConfigFlagsPlugins cfg))
    
    ... ... @@ -1713,7 +1697,7 @@ mkUnitState logger cfg = do
    1713 1697
                         $ closeUnitDeps pkg_db
    
    1714 1698
                         $ zip (map toUnitId preload3) (repeat Nothing)
    
    1715 1699
     
    
    1716
    -  let mod_map1 = mkModuleNameProvidersMap logger cfg pkg_db emptyUniqSet vis_map
    
    1700
    +  let mod_map1 = mkModuleNameProvidersMap logger cfg pkg_db vis_map
    
    1717 1701
           mod_map2 = mkUnusableModuleNameProvidersMap unusable
    
    1718 1702
           mod_map = mod_map2 `plusUniqMap` mod_map1
    
    1719 1703
     
    
    ... ... @@ -1723,9 +1707,8 @@ mkUnitState logger cfg = do
    1723 1707
              , explicitUnits                = explicit_pkgs
    
    1724 1708
              , homeUnitDepends              = home_unit_deps
    
    1725 1709
              , unitInfoMap                  = pkg_db
    
    1726
    -         , preloadClosure               = emptyUniqSet
    
    1727 1710
              , moduleNameProvidersMap       = mod_map
    
    1728
    -         , pluginModuleNameProvidersMap = mkModuleNameProvidersMap logger cfg pkg_db emptyUniqSet plugin_vis_map
    
    1711
    +         , pluginModuleNameProvidersMap = mkModuleNameProvidersMap logger cfg pkg_db plugin_vis_map
    
    1729 1712
              , packageNameMap               = pkgname_map
    
    1730 1713
              , wireMap                      = wired_map
    
    1731 1714
              , unwireMap                    = listToUniqMap [ (v,k) | (k,v) <- nonDetUniqMapToList wired_map ]
    
    ... ... @@ -1765,10 +1748,9 @@ mkModuleNameProvidersMap
    1765 1748
       :: Logger
    
    1766 1749
       -> UnitConfig
    
    1767 1750
       -> UnitInfoMap
    
    1768
    -  -> PreloadUnitClosure
    
    1769 1751
       -> VisibilityMap
    
    1770 1752
       -> ModuleNameProvidersMap
    
    1771
    -mkModuleNameProvidersMap logger cfg pkg_map closure vis_map =
    
    1753
    +mkModuleNameProvidersMap logger cfg pkg_map vis_map =
    
    1772 1754
         -- What should we fold on?  Both situations are awkward:
    
    1773 1755
         --
    
    1774 1756
         --    * Folding on the visibility map means that we won't create
    
    ... ... @@ -1840,7 +1822,7 @@ mkModuleNameProvidersMap logger cfg pkg_map closure vis_map =
    1840 1822
         hiddens = [(m, mkModMap pk m ModHidden) | m <- hidden_mods]
    
    1841 1823
     
    
    1842 1824
         pk = mkUnit pkg
    
    1843
    -    unit_lookup uid = lookupUnit' (unitConfigAllowVirtual cfg) pkg_map closure uid
    
    1825
    +    unit_lookup uid = lookupUnit' (unitConfigAllowVirtual cfg) pkg_map uid
    
    1844 1826
                             `orElse` pprPanic "unit_lookup" (ppr uid)
    
    1845 1827
     
    
    1846 1828
         exposed_mods = unitExposedModules pkg
    
    ... ... @@ -2191,44 +2173,16 @@ fsPackageName info = fs
    2191 2173
        where
    
    2192 2174
           PackageName fs = unitPackageName info
    
    2193 2175
     
    
    2194
    -
    
    2195
    --- | Given a fully instantiated 'InstantiatedUnit', improve it into a
    
    2196
    --- 'RealUnit' if we can find it in the package database.
    
    2197
    -improveUnit :: UnitState -> Unit -> Unit
    
    2198
    -improveUnit state u = improveUnit' (unitInfoMap state) (preloadClosure state) u
    
    2199
    -
    
    2200
    --- | Given a fully instantiated 'InstantiatedUnit', improve it into a
    
    2201
    --- 'RealUnit' if we can find it in the package database.
    
    2202
    -improveUnit' :: UnitInfoMap -> PreloadUnitClosure -> Unit -> Unit
    
    2203
    -improveUnit' _       _       uid@(RealUnit _) = uid -- short circuit
    
    2204
    -improveUnit' pkg_map closure uid =
    
    2205
    -    -- Do NOT lookup indefinite ones, they won't be useful!
    
    2206
    -    case lookupUnit' False pkg_map closure uid of
    
    2207
    -        Nothing  -> uid
    
    2208
    -        Just pkg ->
    
    2209
    -            -- Do NOT improve if the indefinite unit id is not
    
    2210
    -            -- part of the closure unique set.  See
    
    2211
    -            -- Note [VirtUnit to RealUnit improvement]
    
    2212
    -            if unitId pkg `elementOfUniqSet` closure
    
    2213
    -                then mkUnit pkg
    
    2214
    -                else uid
    
    2215
    -
    
    2216
    --- | Check the database to see if we already have an installed unit that
    
    2217
    --- corresponds to the given 'InstantiatedUnit'.
    
    2218
    ---
    
    2219
    --- Return a `UnitId` which either wraps the `InstantiatedUnit` unchanged or
    
    2220
    --- references a matching installed unit.
    
    2221
    ---
    
    2222
    --- See Note [VirtUnit to RealUnit improvement]
    
    2223
    -instUnitToUnit :: UnitState -> InstantiatedUnit -> Unit
    
    2224
    -instUnitToUnit state iuid =
    
    2176
    +-- | Return a `UnitId` which either wraps the `InstantiatedUnit` unchanged.
    
    2177
    +instUnitToUnit :: InstantiatedUnit -> Unit
    
    2178
    +instUnitToUnit iuid =
    
    2225 2179
         -- NB: suppose that we want to compare the instantiated
    
    2226 2180
         -- unit p[H=impl:H] against p+abcd (where p+abcd
    
    2227 2181
         -- happens to be the existing, installed version of
    
    2228 2182
         -- p[H=impl:H].  If we *only* wrap in p[H=impl:H]
    
    2229 2183
         -- VirtUnit, they won't compare equal; only
    
    2230 2184
         -- after improvement will the equality hold.
    
    2231
    -    improveUnit state $ VirtUnit iuid
    
    2185
    +    VirtUnit iuid
    
    2232 2186
     
    
    2233 2187
     
    
    2234 2188
     -- | Substitution on module variables, mapping module names to module
    
    ... ... @@ -2240,30 +2194,30 @@ type ShHoleSubst = ModuleNameEnv Module
    2240 2194
     -- @p[A=\<A>]:B@ maps to @p[A=q():A]:B@ with @A=q():A@;
    
    2241 2195
     -- similarly, @\<A>@ maps to @q():A@.
    
    2242 2196
     renameHoleModule :: UnitState -> ShHoleSubst -> Module -> Module
    
    2243
    -renameHoleModule state = renameHoleModule' (unitInfoMap state) (preloadClosure state)
    
    2197
    +renameHoleModule state = renameHoleModule' (unitInfoMap state)
    
    2244 2198
     
    
    2245 2199
     -- | Substitutes holes in a 'Unit', suitable for renaming when
    
    2246 2200
     -- an include occurs; see Note [Representation of module/name variables].
    
    2247 2201
     --
    
    2248 2202
     -- @p[A=\<A>]@ maps to @p[A=\<B>]@ with @A=\<B>@.
    
    2249 2203
     renameHoleUnit :: UnitState -> ShHoleSubst -> Unit -> Unit
    
    2250
    -renameHoleUnit state = renameHoleUnit' (unitInfoMap state) (preloadClosure state)
    
    2204
    +renameHoleUnit state = renameHoleUnit' (unitInfoMap state)
    
    2251 2205
     
    
    2252
    --- | Like 'renameHoleModule', but requires only 'ClosureUnitInfoMap'
    
    2206
    +-- | Like 'renameHoleModule', but requires only 'UnitInfoMap'
    
    2253 2207
     -- so it can be used by "GHC.Unit.State".
    
    2254
    -renameHoleModule' :: UnitInfoMap -> PreloadUnitClosure -> ShHoleSubst -> Module -> Module
    
    2255
    -renameHoleModule' pkg_map closure env m
    
    2208
    +renameHoleModule' :: UnitInfoMap -> ShHoleSubst -> Module -> Module
    
    2209
    +renameHoleModule' pkg_map env m
    
    2256 2210
       | not (isHoleModule m) =
    
    2257
    -        let uid = renameHoleUnit' pkg_map closure env (moduleUnit m)
    
    2211
    +        let uid = renameHoleUnit' pkg_map env (moduleUnit m)
    
    2258 2212
             in mkModule uid (moduleName m)
    
    2259 2213
       | Just m' <- lookupUFM env (moduleName m) = m'
    
    2260 2214
       -- NB m = <Blah>, that's what's in scope.
    
    2261 2215
       | otherwise = m
    
    2262 2216
     
    
    2263
    --- | Like 'renameHoleUnit, but requires only 'ClosureUnitInfoMap'
    
    2217
    +-- | Like 'renameHoleUnit', but requires only 'UnitInfoMap'
    
    2264 2218
     -- so it can be used by "GHC.Unit.State".
    
    2265
    -renameHoleUnit' :: UnitInfoMap -> PreloadUnitClosure -> ShHoleSubst -> Unit -> Unit
    
    2266
    -renameHoleUnit' pkg_map closure env uid =
    
    2219
    +renameHoleUnit' :: UnitInfoMap -> ShHoleSubst -> Unit -> Unit
    
    2220
    +renameHoleUnit' pkg_map env uid =
    
    2267 2221
         case uid of
    
    2268 2222
           (VirtUnit
    
    2269 2223
             InstantiatedUnit{ instUnitInstanceOf = cid
    
    ... ... @@ -2271,20 +2225,15 @@ renameHoleUnit' pkg_map closure env uid =
    2271 2225
                             , instUnitHoles      = fh })
    
    2272 2226
               -> if isNullUFM (intersectUFM_C const (udfmToUfm (getUniqDSet fh)) env)
    
    2273 2227
                     then uid
    
    2274
    -                -- Functorially apply the substitution to the instantiation,
    
    2275
    -                -- then check the 'ClosureUnitInfoMap' to see if there is
    
    2276
    -                -- a compiled version of this 'InstantiatedUnit' we can improve to.
    
    2277
    -                -- See Note [VirtUnit to RealUnit improvement]
    
    2278
    -                else improveUnit' pkg_map closure $
    
    2279
    -                        mkVirtUnit cid
    
    2280
    -                            (map (\(k,v) -> (k, renameHoleModule' pkg_map closure env v)) insts)
    
    2228
    +                else mkVirtUnit cid
    
    2229
    +                          (map (\(k,v) -> (k, renameHoleModule' pkg_map env v)) insts)
    
    2281 2230
           _ -> uid
    
    2282 2231
     
    
    2283 2232
     -- | Injects an 'InstantiatedModule' to 'Module' (see also
    
    2284 2233
     -- 'instUnitToUnit'.
    
    2285
    -instModuleToModule :: UnitState -> InstantiatedModule -> Module
    
    2286
    -instModuleToModule pkgstate (Module iuid mod_name) =
    
    2287
    -    mkModule (instUnitToUnit pkgstate iuid) mod_name
    
    2234
    +instModuleToModule :: InstantiatedModule -> Module
    
    2235
    +instModuleToModule (Module iuid mod_name) =
    
    2236
    +    mkModule (instUnitToUnit iuid) mod_name
    
    2288 2237
     
    
    2289 2238
     -- | Print unit-ids with UnitInfo found in the given UnitState
    
    2290 2239
     pprWithUnitState :: UnitState -> SDoc -> SDoc
    

  • compiler/GHC/Unit/Types.hs
    ... ... @@ -250,9 +250,7 @@ data GenUnit uid
    250 250
     --
    
    251 251
     -- This unit may be indefinite or not (i.e. with remaining holes or not). If it
    
    252 252
     -- is definite, we don't know if it has already been compiled and installed in a
    
    253
    --- database. Nevertheless, we have a mechanism called "improvement" to try to
    
    254
    --- match a fully instantiated unit with existing compiled and installed units:
    
    255
    --- see Note [VirtUnit to RealUnit improvement].
    
    253
    +-- database.
    
    256 254
     --
    
    257 255
     -- An indefinite unit identifier pretty-prints to something like
    
    258 256
     -- @p[H=<H>,A=aimpl:A>]@ (@p@ is the 'UnitId', and the
    

  • compiler/Language/Haskell/Syntax/Extension.hs
    ... ... @@ -108,7 +108,7 @@ dataConCantHappen x = case x of {}
    108 108
     -- See Note [XRec and SrcSpans in the AST]
    
    109 109
     type family XRec p a = r | r -> a
    
    110 110
     
    
    111
    -type family Anno a = b -- See Note [XRec and Anno in the AST] in GHC.Parser.Annotation
    
    111
    +type family Anno a -- See Note [XRec and Anno in the AST] in GHC.Parser.Annotation
    
    112 112
     
    
    113 113
     {-
    
    114 114
     Note [XRec and SrcSpans in the AST]
    

  • hadrian/src/Rules/Rts.hs
    ... ... @@ -25,7 +25,7 @@ buildGhcInternalImportDef target = do
    25 25
     
    
    26 26
     buildGhcInternalImportLib :: FilePath -> Action ()
    
    27 27
     buildGhcInternalImportLib target = do
    
    28
    -    let input = dropExtensions target <.> "def" -- the .def file
    
    28
    +    let input = dropExtension (dropExtension target) <.> "def" -- the .def file
    
    29 29
             output = target -- the .dll.a import lib
    
    30 30
         need [input]
    
    31 31
         runBuilder Dlltool ["-d", input, "-l", output] [input] [output]

  • rts/sm/Evac.h
    ... ... @@ -25,7 +25,9 @@
    25 25
     //         registers EAX, EDX, and ECX instead of on the stack. Functions that
    
    26 26
     //         take a variable number of arguments will continue to be passed all of
    
    27 27
     //         their arguments on the stack.
    
    28
    -#if defined(x86_64_HOST_ARCH) || defined(i386_HOST_ARCH)
    
    28
    +// On x86-64 the attribute has no effect (the first argument is already
    
    29
    +// passed in a register) and GCC 16 warns that it is ignored.
    
    30
    +#if defined(i386_HOST_ARCH)
    
    29 31
     #define REGPARM1 __attribute__((regparm(1)))
    
    30 32
     #else
    
    31 33
     #define REGPARM1
    

  • testsuite/tests/codeGen/should_run/T16617.hs
    1 1
     import GHC.Float
    
    2 2
     
    
    3
    +{-# OPAQUE noinline #-}
    
    4
    +noinline :: a -> a
    
    5
    +noinline x = x
    
    6
    +
    
    3 7
     main :: IO ()
    
    4 8
     main = do
    
    5 9
       -- As per #16617, Word32s should be non-negative
    
    6 10
       print $ castFloatToWord32 (-1)
    
    7 11
       print $ toInteger (castFloatToWord32 (-1)) > 0
    
    12
    +  -- Disable constant folding; see #27300
    
    13
    +  print $ castFloatToWord32 (noinline $ -1)
    
    14
    +  print $ toInteger (castFloatToWord32 (noinline $ -1)) > 0
    
    8 15
       -- For completeness, so should Word64s
    
    9 16
       print $ castDoubleToWord64 (-1)
    
    10 17
       print $ toInteger (castDoubleToWord64 (-1)) > 0
    
    18
    +  print $ castDoubleToWord64 (noinline $ -1)
    
    19
    +  print $ toInteger (castDoubleToWord64 (noinline $ -1)) > 0

  • testsuite/tests/codeGen/should_run/T16617.stdout
    1 1
     3212836864
    
    2 2
     True
    
    3
    +3212836864
    
    4
    +True
    
    5
    +13830554455654793216
    
    6
    +True
    
    3 7
     13830554455654793216
    
    4 8
     True