[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 6 commits: NCG: remove useless .align directive (#20758)

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Mon May 22 18:53:07 UTC 2023



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


Commits:
b56d7379 by Sylvain Henry at 2023-05-22T14:21:22-04:00
NCG: remove useless .align directive (#20758)

- - - - -
15b93d2f by Simon Peyton Jones at 2023-05-22T14:21:58-04:00
Add test for #23156

This program had exponential typechecking time in GHC 9.4 and 9.6

- - - - -
15f95381 by Greg Steuck at 2023-05-22T14:52:58-04:00
Revert "Change hostSupportsRPaths to report False on OpenBSD"

This reverts commit 1e0d8fdb55a38ece34fa6cf214e1d2d46f5f5bf2.

- - - - -
e8e72195 by Greg Steuck at 2023-05-22T14:52:58-04:00
Disable T17414 on OpenBSD

Like on other systems it's not guaranteed that there's sufficient
space in /tmp to write 2G out.

- - - - -
c4304564 by Greg Steuck at 2023-05-22T14:52:58-04:00
Bring back getExecutablePath to getBaseDir on OpenBSD

Fix #18173

- - - - -
8c2e0594 by Krzysztof Gogolewski at 2023-05-22T14:52:58-04:00
Add an error origin for impedance matching (#23427)

- - - - -


13 changed files:

- compiler/GHC/CmmToAsm/AArch64/Ppr.hs
- compiler/GHC/CmmToAsm/X86/Ppr.hs
- compiler/GHC/Tc/Gen/Bind.hs
- compiler/GHC/Tc/Types/Origin.hs
- hadrian/src/Oracles/Setting.hs
- libraries/base/tests/IO/all.T
- libraries/ghc-boot/GHC/BaseDir.hs
- + testsuite/tests/typecheck/should_compile/T23156.hs
- + testsuite/tests/typecheck/should_compile/T23156.stderr
- testsuite/tests/typecheck/should_compile/all.T
- + testsuite/tests/typecheck/should_fail/T23427.hs
- + testsuite/tests/typecheck/should_fail/T23427.stderr
- testsuite/tests/typecheck/should_fail/all.T


Changes:

=====================================
compiler/GHC/CmmToAsm/AArch64/Ppr.hs
=====================================
@@ -18,7 +18,6 @@ import GHC.CmmToAsm.Utils
 import GHC.Cmm hiding (topInfoTable)
 import GHC.Cmm.Dataflow.Collections
 import GHC.Cmm.Dataflow.Label
-import GHC.Types.Basic (Alignment, mkAlignment, alignmentBytes)
 
 import GHC.Cmm.BlockId
 import GHC.Cmm.CLabel
@@ -29,18 +28,12 @@ import GHC.Utils.Outputable
 
 import GHC.Utils.Panic
 
-pprProcAlignment :: IsDoc doc => NCGConfig -> doc
-pprProcAlignment config = maybe empty (pprAlign platform . mkAlignment) (ncgProcAlignment config)
-   where
-      platform = ncgPlatform config
-
 pprNatCmmDecl :: IsDoc doc => NCGConfig -> NatCmmDecl RawCmmStatics Instr -> doc
 pprNatCmmDecl config (CmmData section dats) =
   pprSectionAlign config section $$ pprDatas config dats
 
 pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) =
   let platform = ncgPlatform config in
-  pprProcAlignment config $$
   case topInfoTable proc of
     Nothing ->
         -- special case for code without info table:
@@ -80,10 +73,6 @@ pprLabel platform lbl =
    $$ pprTypeDecl platform lbl
    $$ line (pprAsmLabel platform lbl <> char ':')
 
-pprAlign :: IsDoc doc => Platform -> Alignment -> doc
-pprAlign _platform alignment
-        = line $ text "\t.balign " <> int (alignmentBytes alignment)
-
 -- | Print appropriate alignment for the given section type.
 pprAlignForSection :: IsDoc doc => Platform -> SectionType -> doc
 pprAlignForSection _platform _seg


=====================================
compiler/GHC/CmmToAsm/X86/Ppr.hs
=====================================
@@ -74,7 +74,6 @@ pprNatCmmDecl config (CmmData section dats) =
 
 pprNatCmmDecl config proc@(CmmProc top_info lbl _ (ListGraph blocks)) =
   let platform = ncgPlatform config in
-  pprProcAlignment config $$
   case topInfoTable proc of
     Nothing ->
         -- special case for code without info table:


=====================================
compiler/GHC/Tc/Gen/Bind.hs
=====================================
@@ -899,7 +899,7 @@ mkExport prag_fn residual insoluble qtvs theta
                   then return idHsWrapper  -- Fast path; also avoids complaint when we infer
                                            -- an ambiguous type and have AllowAmbiguousType
                                            -- e..g infer  x :: forall a. F a -> Int
-                  else tcSubTypeSigma (Shouldn'tHappenOrigin "mkExport")
+                  else tcSubTypeSigma (ImpedanceMatching poly_id)
                                       sig_ctxt sel_poly_ty poly_ty
                        -- See Note [Impedance matching]
 
@@ -1254,11 +1254,9 @@ Then we want to check that
      forall qtvs. theta => f_mono_ty   is more polymorphic than   f's polytype
 and the proof is the impedance matcher.
 
-Notice that the impedance matcher may do defaulting.  See #7173.
-
-If we've gotten the constraints right during inference (and we assume we have),
-this sub-type check should never fail. It's not really a check -- it's more of
-a procedure to produce the right wrapper.
+The impedance matcher can do defaulting: in the above example, we default
+to Integer because of Num. See #7173. If we're dealing with a nondefaultable
+class, impedance matching can fail. See #23427.
 
 Note [SPECIALISE pragmas]
 ~~~~~~~~~~~~~~~~~~~~~~~~~


=====================================
compiler/GHC/Tc/Types/Origin.hs
=====================================
@@ -591,6 +591,7 @@ data CtOrigin
   | IfThenElseOrigin    -- An if-then-else expression
   | BracketOrigin       -- An overloaded quotation bracket
   | StaticOrigin        -- A static form
+  | ImpedanceMatching Id   -- See Note [Impedance matching] in GHC.Tc.Gen.Bind
   | Shouldn'tHappenOrigin String  -- The user should never see this one
 
   -- | Testing whether the constraint associated with an instance declaration
@@ -826,6 +827,10 @@ pprCtOrigin (InstProvidedOrigin mod cls_inst)
          , ppr cls_inst
          , text "is provided by" <+> quotes (ppr mod)]
 
+pprCtOrigin (ImpedanceMatching x)
+  = vcat [ text "arising when matching required constraints"
+         , text "in a recursive group involving" <+> quotes (ppr x)]
+
 pprCtOrigin (CycleBreakerOrigin orig)
   = pprCtOrigin orig
 
@@ -921,6 +926,8 @@ pprCtO (FRROrigin {})               = text "a representation-polymorphism check"
 pprCtO (WantedSuperclassOrigin {})  = text "a superclass constraint"
 pprCtO (InstanceSigOrigin {})       = text "a type signature in an instance"
 pprCtO (AmbiguityCheckOrigin {})    = text "a type ambiguity check"
+pprCtO (ImpedanceMatching {})       = text "combining required constraints"
+
 
 {- *********************************************************************
 *                                                                      *


=====================================
hadrian/src/Oracles/Setting.hs
=====================================
@@ -291,10 +291,7 @@ isElfTarget = anyTargetOs elfOSes
 -- TODO: Windows supports lazy binding (but GHC doesn't currently support
 --       dynamic way on Windows anyways).
 hostSupportsRPaths :: Action Bool
-hostSupportsRPaths = do
-  -- https://gitlab.haskell.org/ghc/ghc/-/issues/23011
-  isOpenBSD <- anyHostOs ["openbsd"]
-  if not isOpenBSD then anyHostOs (elfOSes ++ machoOSes) else pure False
+hostSupportsRPaths = anyHostOs (elfOSes ++ machoOSes)
 
 -- | Check whether the target supports GHCi.
 ghcWithInterpreter :: Action Bool


=====================================
libraries/base/tests/IO/all.T
=====================================
@@ -155,6 +155,7 @@ test('T17414',
       # distributions. This test needs to create a large file which will exceed the
       # size of this filesystem consequently we must skip it (see #17459).
       when(opsys('linux'), skip),
+      when(opsys('openbsd'), skip),
       high_memory_usage],
      compile_and_run, [''])
 test('T17510', expect_broken(17510), compile_and_run, [''])


=====================================
libraries/ghc-boot/GHC/BaseDir.hs
=====================================
@@ -24,7 +24,7 @@ import Data.List (stripPrefix)
 import Data.Maybe (listToMaybe)
 import System.FilePath
 
-#if MIN_VERSION_base(4,17,0)
+#if MIN_VERSION_base(4,17,0) && !defined(openbsd_HOST_OS)
 import System.Environment (executablePath)
 #else
 import System.Environment (getExecutablePath)
@@ -45,8 +45,10 @@ expandPathVar var value str
 expandPathVar var value (x:xs) = x : expandPathVar var value xs
 expandPathVar _ _ [] = []
 
-#if !MIN_VERSION_base(4,17,0)
--- Polyfill for base-4.17 executablePath
+#if !MIN_VERSION_base(4,17,0) || defined(openbsd_HOST_OS)
+-- Polyfill for base-4.17 executablePath and OpenBSD which doesn't
+-- have executablePath. The best it can do is use argv[0] which is
+-- good enough for most uses of getBaseDir.
 executablePath :: Maybe (IO (Maybe FilePath))
 executablePath = Just (Just <$> getExecutablePath)
 #elif !MIN_VERSION_base(4,18,0) && defined(js_HOST_ARCH)


=====================================
testsuite/tests/typecheck/should_compile/T23156.hs
=====================================
@@ -0,0 +1,59 @@
+{-# LANGUAGE DataKinds, TypeFamilies, PartialTypeSignatures #-}
+{-# OPTIONS_GHC -fdefer-type-errors #-}
+module T23156 where
+
+import Prelude
+import GHC.TypeLits
+import Data.Kind
+
+type BooleanOf2 :: Type -> Type
+type family BooleanOf2 a
+
+type instance BooleanOf2 Double = Double
+
+-- Needs to be a type family, changing this to a datatype makes it fast
+type TensorOf2 :: Nat -> Type -> Type
+type family TensorOf2 k a
+
+type instance TensorOf2 n Double = Double
+
+
+-- With GHC 9.4 and 9.6, typechecking was
+-- exponential in the size of this tuple
+type ADReady r =
+  (  BooleanOf2 r ~ BooleanOf2 (TensorOf2 1 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 2 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 3 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 4 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 5 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 6 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 7 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 8 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 9 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 10 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 11 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 12 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 13 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 14 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 15 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 16 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 17 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 18 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 19 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 20 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 21 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 22 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 23 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 24 r)
+    , BooleanOf2 r ~ BooleanOf2 (TensorOf2 25 r)
+  )
+
+f :: forall r . (ADReady r) => ()
+f = undefined
+
+-- This uses a lot of memory
+g :: _ => ()
+g = f
+
+-- This is fine
+g' = f @Double


=====================================
testsuite/tests/typecheck/should_compile/T23156.stderr
=====================================
@@ -0,0 +1,25 @@
+
+T23156.hs:51:6: warning: [GHC-05617] [-Wdeferred-type-errors (in -Wdefault)]
+    • Could not deduce ‘BooleanOf2 (TensorOf2 1 r0) ~ BooleanOf2 r0’
+      from the context: ADReady r
+        bound by the type signature for:
+                   f :: forall r. ADReady r => ()
+        at T23156.hs:51:6-33
+      NB: ‘BooleanOf2’ is a non-injective type family
+      The type variables ‘r0’, ‘r0’ are ambiguous
+    • In the ambiguity check for ‘f’
+      To defer the ambiguity check to use sites, enable AllowAmbiguousTypes
+      In the type signature: f :: forall r. (ADReady r) => ()
+
+T23156.hs:55:6: warning: [GHC-88464] [-Wpartial-type-signatures (in -Wdefault)]
+    • Found extra-constraints wildcard standing for ‘() :: Constraint’
+    • In the type signature: g :: _ => ()
+
+T23156.hs:56:5: warning: [GHC-18872] [-Wdeferred-type-errors (in -Wdefault)]
+    • Couldn't match type: BooleanOf2 (TensorOf2 1 r0)
+                     with: BooleanOf2 r0
+        arising from a use of ‘f’
+      NB: ‘BooleanOf2’ is a non-injective type family
+      The type variables ‘r0’, ‘r0’ are ambiguous
+    • In the expression: f
+      In an equation for ‘g’: g = f


=====================================
testsuite/tests/typecheck/should_compile/all.T
=====================================
@@ -874,3 +874,4 @@ test('QualifiedRecordUpdate',
 test('T23171', normal, compile, [''])
 test('T23192', normal, compile, [''])
 test('T23199', normal, compile, [''])
+test('T23156', normal, compile, [''])


=====================================
testsuite/tests/typecheck/should_fail/T23427.hs
=====================================
@@ -0,0 +1,10 @@
+module T23427 where
+
+class C a where
+    f :: a -> a
+
+indent :: C a => a -> a
+indent n = doText n
+    where
+      doText x = const (f x) doTail
+      doTail _ = const n doText


=====================================
testsuite/tests/typecheck/should_fail/T23427.stderr
=====================================
@@ -0,0 +1,16 @@
+
+T23427.hs:9:7: error: [GHC-39999]
+    • Could not deduce ‘C a0’
+        arising when matching required constraints
+        in a recursive group involving ‘doTail’
+      from the context: C a
+        bound by the type signature for:
+                   indent :: forall a. C a => a -> a
+        at T23427.hs:6:1-23
+      The type variable ‘a0’ is ambiguous
+    • In an equation for ‘indent’:
+          indent n
+            = doText n
+            where
+                doText x = const (f x) doTail
+                doTail _ = const n doText


=====================================
testsuite/tests/typecheck/should_fail/all.T
=====================================
@@ -683,3 +683,4 @@ test('TyfamsDisabled', normal, compile_fail, [''])
 test('CommonFieldResultTypeMismatch', normal, compile_fail, [''])
 test('CommonFieldTypeMismatch', normal, compile_fail, [''])
 test('T17284', normal, compile_fail, [''])
+test('T23427', normal, compile_fail, [''])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a94db291bc8deb3c25bf077c5d656bbd6ffd9473...8c2e0594e18a4bb966197fd579c5c129945d7a53

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/a94db291bc8deb3c25bf077c5d656bbd6ffd9473...8c2e0594e18a4bb966197fd579c5c129945d7a53
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/20230522/3b32430f/attachment-0001.html>


More information about the ghc-commits mailing list