summaryrefslogtreecommitdiff
path: root/compiler/GHC/StgToCmm
diff options
context:
space:
mode:
authorPeter Trommler <ptrommler@acm.org>2020-06-11 08:31:22 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-06-14 15:36:38 -0400
commit01f7052cc182c0ced85522dc775ebc490bf094ce (patch)
tree6168f59ed7c937aca0a713d7bae322ad62c6b30a /compiler/GHC/StgToCmm
parentbd761185561747fe0b3adc22602f75d7b50cd248 (diff)
downloadhaskell-01f7052cc182c0ced85522dc775ebc490bf094ce.tar.gz
FFI: Fix pass small ints in foreign call wrappers
The Haskell calling convention requires integer parameters smaller than wordsize to be promoted to wordsize (where the upper bits are don't care). To access such small integer parameter read a word from the parameter array and then cast that word to the small integer target type. Fixes #15933
Diffstat (limited to 'compiler/GHC/StgToCmm')
-rw-r--r--compiler/GHC/StgToCmm/Foreign.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/GHC/StgToCmm/Foreign.hs b/compiler/GHC/StgToCmm/Foreign.hs
index 72dae672ba..0681d41f96 100644
--- a/compiler/GHC/StgToCmm/Foreign.hs
+++ b/compiler/GHC/StgToCmm/Foreign.hs
@@ -74,6 +74,7 @@ cgForeignCall (CCall (CCallSpec target cconv safety)) typ stg_args res_ty
| otherwise = Nothing
-- ToDo: this might not be correct for 64-bit API
+ -- This is correct for the PowerPC ELF ABI version 1 and 2.
arg_size (arg, _) = max (widthInBytes $ typeWidth $ cmmExprType platform arg)
(platformWordSizeInBytes platform)
; cmm_args <- getFCallArgs stg_args typ
@@ -634,4 +635,3 @@ typeToStgFArgType typ
-- a type in a foreign function signature with a representationally
-- equivalent newtype.
tycon = tyConAppTyCon (unwrapType typ)
-