[Git][ghc/ghc][master] CmmToC: fix CmmRegOff for 64-bit register on a 32-bit target
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Tue Jan 24 17:12:00 UTC 2023
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
d151546e by Cheng Shao at 2023-01-24T12:11:29-05:00
CmmToC: fix CmmRegOff for 64-bit register on a 32-bit target
We used to print the offset value to a platform word sized integer.
This is incorrect when the offset is negative (e.g. output of cmm
constant folding) and the register is 64-bit but on a 32-bit target,
and may lead to incorrect runtime result (e.g. #22607).
The fix is simple: just treat it as a proper MO_Add, with the correct
width info inferred from the register itself.
Metric Increase:
T12707
T13379
T4801
T5321FD
T5321Fun
- - - - -
1 changed file:
- compiler/GHC/CmmToC.hs
Changes:
=====================================
compiler/GHC/CmmToC.hs
=====================================
@@ -382,8 +382,8 @@ pprExpr platform e = case e of
CmmRegOff reg 0 -> pprCastReg reg
-- CmmRegOff is an alias of MO_Add
- CmmRegOff reg i -> pprCastReg reg <> char '+' <>
- pprHexVal platform (fromIntegral i) (wordWidth platform)
+ CmmRegOff reg i -> pprExpr platform $ CmmMachOp (MO_Add w) [CmmReg reg, CmmLit $ CmmInt (toInteger i) w]
+ where w = cmmRegWidth platform reg
CmmMachOp mop args -> pprMachOpApp platform mop args
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d151546e59a50158f25c3df6728b00d3c27bb4b9
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/d151546e59a50158f25c3df6728b00d3c27bb4b9
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/20230124/9f0466d3/attachment.html>
More information about the ghc-commits
mailing list