[Git][ghc/ghc][wip/zap-void-StgOpApp-args] filter out voidrep args in collectStgFArgTypes

Matthew Craven (@clyring) gitlab at gitlab.haskell.org
Tue Apr 18 03:08:54 UTC 2023



Matthew Craven pushed to branch wip/zap-void-StgOpApp-args at Glasgow Haskell Compiler / GHC


Commits:
745b3f7e by Matthew Craven at 2023-04-17T23:08:21-04:00
filter out voidrep args in collectStgFArgTypes

- - - - -


1 changed file:

- compiler/GHC/StgToCmm/Foreign.hs


Changes:

=====================================
compiler/GHC/StgToCmm/Foreign.hs
=====================================
@@ -720,20 +720,23 @@ collectStgFArgTypes = go []
     go  _ (CastTy{}) = panic "myCollectTypeArgs: CastTy"
     go  _ (CoercionTy{}) = panic "myCollectTypeArgs: CoercionTy"
     go bs (FunTy {ft_arg = arg, ft_res=res}) =
-      go (typeToStgFArgType arg:bs) res
+      case typeToStgFArgType arg of
+        Just b  -> go (b : bs) res
+        Nothing -> go bs res
 
 -- Choose the offset based on the type. For anything other
 -- than an unlifted boxed type, there is no offset.
 -- See Note [Unlifted boxed arguments to foreign calls]
-typeToStgFArgType :: Type -> StgFArgType
+typeToStgFArgType :: Type -> Maybe StgFArgType
 typeToStgFArgType typ
-  | tycon == arrayPrimTyCon = StgArrayType
-  | tycon == mutableArrayPrimTyCon = StgArrayType
-  | tycon == smallArrayPrimTyCon = StgSmallArrayType
-  | tycon == smallMutableArrayPrimTyCon = StgSmallArrayType
-  | tycon == byteArrayPrimTyCon = StgByteArrayType
-  | tycon == mutableByteArrayPrimTyCon = StgByteArrayType
-  | otherwise = StgPlainType
+  | tycon == arrayPrimTyCon = Just StgArrayType
+  | tycon == mutableArrayPrimTyCon = Just StgArrayType
+  | tycon == smallArrayPrimTyCon = Just StgSmallArrayType
+  | tycon == smallMutableArrayPrimTyCon = Just StgSmallArrayType
+  | tycon == byteArrayPrimTyCon = Just StgByteArrayType
+  | tycon == mutableByteArrayPrimTyCon = Just StgByteArrayType
+  | isZeroBitTy typ = Nothing
+  | otherwise = Just StgPlainType
   where
   -- Should be a tycon app, since this is a foreign call. We look
   -- through newtypes so the offset does not change if a user replaces



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/745b3f7e502c0ffd1410f46524d317cb97c5daf8

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/745b3f7e502c0ffd1410f46524d317cb97c5daf8
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/20230417/5f573dad/attachment-0001.html>


More information about the ghc-commits mailing list