diff options
author | Ben Gamari <ben@smart-cactus.org> | 2022-02-03 23:25:13 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2022-04-06 15:24:01 -0400 |
commit | ec4526b5cbb58b93457591e2595c5a66b2a101f9 (patch) | |
tree | e80375c444bbdd5391d45b233417550ce2d557a9 | |
parent | 105a0056afbe6226d849c586f2e76c726fe89c3f (diff) | |
download | haskell-ec4526b5cbb58b93457591e2595c5a66b2a101f9.tar.gz |
Don't assume that labels are 32-bit on Windows
-rw-r--r-- | compiler/GHC/CmmToAsm/X86/CodeGen.hs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/compiler/GHC/CmmToAsm/X86/CodeGen.hs b/compiler/GHC/CmmToAsm/X86/CodeGen.hs index d105453458..3d2a83c984 100644 --- a/compiler/GHC/CmmToAsm/X86/CodeGen.hs +++ b/compiler/GHC/CmmToAsm/X86/CodeGen.hs @@ -1564,20 +1564,27 @@ getRegOrMem e = do return (OpReg reg, code) is32BitLit :: Platform -> CmmLit -> Bool -is32BitLit platform lit - | not (target32Bit platform) = case lit of +is32BitLit platform _lit + | target32Bit platform = True +is32BitLit platform lit = + case lit of CmmInt i W64 -> is32BitInteger i - -- assume that labels are in the range 0-2^31-1: this assumes the - -- small memory model. Note [%rip-relative addressing on x86-64]. - CmmLabel _ -> True + -- Except on Windows, assume that labels are in the range 0-2^31-1: this + -- assumes the small memory model. Note [%rip-relative addressing on + -- x86-64]. + CmmLabel _ -> low_image -- however we can't assume that label offsets are in this range -- (see #15570) - CmmLabelOff _ off -> is32BitInteger (fromIntegral off) - CmmLabelDiffOff _ _ off _ -> is32BitInteger (fromIntegral off) + CmmLabelOff _ off -> low_image && is32BitInteger (fromIntegral off) + CmmLabelDiffOff _ _ off _ -> low_image && is32BitInteger (fromIntegral off) _ -> True -is32BitLit _ _ = True - - + where + -- Is the executable image certain to be located below 4GB? As noted in + -- Note [%rip-relative addressing on x86-64], this is not true on Windows. + low_image = + case platformOS platform of + OSMinGW32 -> False -- See Note [%rip-relative addressing on x86-64] + _ -> True -- Set up a condition code for a conditional branch. |