summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Schulze Frielinghaus <stefansf@linux.ibm.com>2021-02-02 16:36:44 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-02-05 19:12:39 -0500
commit792191e44f18130031a272c53459f91dea21bbd0 (patch)
tree8eac52378811cd1d6f3bd1f534a4945ed3cb5ea3
parentfe789978453bfd4e5ff456a6be57fc8041664d75 (diff)
downloadhaskell-792191e44f18130031a272c53459f91dea21bbd0.tar.gz
FFI: Revisit fix pass small ints in foreign call wrappers
Since commit be5d74ca small ints/words are passed according to their natural size which obsoletes fix from commit 01f7052cc1. Reverted 01f7052cc1 but kept the introduced test case.
-rw-r--r--compiler/GHC/HsToCore/Foreign/Decl.hs31
1 files changed, 5 insertions, 26 deletions
diff --git a/compiler/GHC/HsToCore/Foreign/Decl.hs b/compiler/GHC/HsToCore/Foreign/Decl.hs
index 7f618eb77c..f6de90de64 100644
--- a/compiler/GHC/HsToCore/Foreign/Decl.hs
+++ b/compiler/GHC/HsToCore/Foreign/Decl.hs
@@ -541,36 +541,15 @@ mkFExportCBits dflags c_nm maybe_target arg_htys res_hty is_IO_res_ty cc
SDoc, -- C type
Type, -- Haskell type
CmmType)] -- the CmmType
- arg_info = [ let stg_type = showStgType ty
- cmm_type = typeCmmType platform (getPrimTyOf ty)
- stack_type
- = if int_promote (typeTyCon ty)
- then text "HsWord"
- else stg_type
- in
- (arg_cname n stg_type stack_type,
+ arg_info = [ let stg_type = showStgType ty in
+ (arg_cname n stg_type,
stg_type,
ty,
- cmm_type)
+ typeCmmType platform (getPrimTyOf ty))
| (ty,n) <- zip arg_htys [1::Int ..] ]
- int_promote ty_con
- | ty_con `hasKey` int8TyConKey = True
- | ty_con `hasKey` int16TyConKey = True
- | ty_con `hasKey` int32TyConKey
- , platformWordSizeInBytes platform > 4
- = True
- | ty_con `hasKey` word8TyConKey = True
- | ty_con `hasKey` word16TyConKey = True
- | ty_con `hasKey` word32TyConKey
- , platformWordSizeInBytes platform > 4
- = True
- | otherwise = False
-
-
- arg_cname n stg_ty stack_ty
- | libffi = parens (stg_ty) <> char '*' <>
- parens (stack_ty <> char '*') <>
+ arg_cname n stg_ty
+ | libffi = char '*' <> parens (stg_ty <> char '*') <>
text "args" <> brackets (int (n-1))
| otherwise = text ('a':show n)