Commit d0faaa6f authored by tibbe's avatar tibbe Committed by dterei
Browse files

Fix segfault in array copy primops on 32-bit



The second argument to C's memset was passed as a W8 while memset
expects an int.
Signed-off-by: dterei's avatarDavid Terei <davidterei@gmail.com>
parent f31e9349
...@@ -733,7 +733,7 @@ emitCloneArray info_p res_r src0 src_off0 n0 live = do ...@@ -733,7 +733,7 @@ emitCloneArray info_p res_r src0 src_off0 n0 live = do
emitMemcpyCall dst_p src_p (n `cmmMulWord` wordSize) live emitMemcpyCall dst_p src_p (n `cmmMulWord` wordSize) live
emitMemsetCall (cmmOffsetExprW dst_p n) emitMemsetCall (cmmOffsetExprW dst_p n)
(CmmLit (CmmInt (toInteger (1 :: Int)) W8)) (CmmLit (mkIntCLit 1))
(card_words `cmmMulWord` wordSize) (card_words `cmmMulWord` wordSize)
live live
stmtC $ CmmAssign (CmmLocal res_r) arr stmtC $ CmmAssign (CmmLocal res_r) arr
...@@ -751,7 +751,7 @@ emitSetCards :: CmmExpr -> CmmExpr -> CmmExpr -> StgLiveVars -> Code ...@@ -751,7 +751,7 @@ emitSetCards :: CmmExpr -> CmmExpr -> CmmExpr -> StgLiveVars -> Code
emitSetCards dst_start dst_cards_start n live = do emitSetCards dst_start dst_cards_start n live = do
start_card <- assignTemp $ card dst_start start_card <- assignTemp $ card dst_start
emitMemsetCall (dst_cards_start `cmmAddWord` start_card) emitMemsetCall (dst_cards_start `cmmAddWord` start_card)
(CmmLit (CmmInt (toInteger (1 :: Int)) W8)) (CmmLit (mkIntCLit 1))
((card (dst_start `cmmAddWord` n) `cmmSubWord` start_card) ((card (dst_start `cmmAddWord` n) `cmmSubWord` start_card)
`cmmAddWord` CmmLit (mkIntCLit 1)) `cmmAddWord` CmmLit (mkIntCLit 1))
live live
...@@ -795,8 +795,8 @@ emitMemmoveCall dst src n live = do ...@@ -795,8 +795,8 @@ emitMemmoveCall dst src n live = do
memmove = CmmLit (CmmLabel (mkForeignLabel (fsLit "memmove") Nothing memmove = CmmLit (CmmLabel (mkForeignLabel (fsLit "memmove") Nothing
ForeignLabelInExternalPackage IsFunction)) ForeignLabelInExternalPackage IsFunction))
-- | Emit a call to @memset@. The second argument must be of type -- | Emit a call to @memset@. The second argument must fit inside an
-- 'W8'. -- unsigned char.
emitMemsetCall :: CmmExpr -> CmmExpr -> CmmExpr -> StgLiveVars -> Code emitMemsetCall :: CmmExpr -> CmmExpr -> CmmExpr -> StgLiveVars -> Code
emitMemsetCall dst c n live = do emitMemsetCall dst c n live = do
vols <- getVolatileRegs live vols <- getVolatileRegs live
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment