diff options
author | Luite Stegeman <stegeman@gmail.com> | 2021-03-30 04:06:59 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2021-05-29 05:04:39 -0400 |
commit | 28e0dca2e93dabee88f28ce38282dbcb8c62ab99 (patch) | |
tree | 1bfb0bfd0478315c0366b252d273d25d170f85ff /compiler/GHC/Cmm | |
parent | 5ae070f168ba7f9679b045ea4b8f30917f47f800 (diff) | |
download | haskell-28e0dca2e93dabee88f28ce38282dbcb8c62ab99.tar.gz |
Work around LLVM backend overlapping register limitations
The stg_ctoi_t and stg_ret_t procedures which convert unboxed
tuples between the bytecode an native calling convention were
causing a panic when using the LLVM backend.
Fixes #19591
Diffstat (limited to 'compiler/GHC/Cmm')
-rw-r--r-- | compiler/GHC/Cmm/CallConv.hs | 14 | ||||
-rw-r--r-- | compiler/GHC/Cmm/Parser.y | 3 |
2 files changed, 16 insertions, 1 deletions
diff --git a/compiler/GHC/Cmm/CallConv.hs b/compiler/GHC/Cmm/CallConv.hs index f4b46a03f2..f376e598bf 100644 --- a/compiler/GHC/Cmm/CallConv.hs +++ b/compiler/GHC/Cmm/CallConv.hs @@ -2,10 +2,12 @@ module GHC.Cmm.CallConv ( ParamLocation(..), assignArgumentsPos, assignStack, - realArgRegsCover + realArgRegsCover, + tupleRegsCover ) where import GHC.Prelude +import Data.List (nub) import GHC.Cmm.Expr import GHC.Runtime.Heap.Layout @@ -219,3 +221,13 @@ realArgRegsCover platform realDoubleRegs platform ++ realLongRegs platform -- we don't save XMM registers if they are not used for parameter passing + +-- Like realArgRegsCover but always includes the node. This covers the real +-- and virtual registers used for unboxed tuples. +-- +-- Note: if anything changes in how registers for unboxed tuples overlap, +-- make sure to also update GHC.StgToByteCode.layoutTuple. + +tupleRegsCover :: Platform -> [GlobalReg] +tupleRegsCover platform = + nub (VanillaReg 1 VGcPtr : realArgRegsCover platform) diff --git a/compiler/GHC/Cmm/Parser.y b/compiler/GHC/Cmm/Parser.y index d182a6f714..490a3c4976 100644 --- a/compiler/GHC/Cmm/Parser.y +++ b/compiler/GHC/Cmm/Parser.y @@ -1151,6 +1151,9 @@ stmtMacros = listToUFM [ ( fsLit "SAVE_REGS", \[] -> emitSaveRegs ), ( fsLit "RESTORE_REGS", \[] -> emitRestoreRegs ), + ( fsLit "PUSH_TUPLE_REGS", \[live_regs] -> emitPushTupleRegs live_regs ), + ( fsLit "POP_TUPLE_REGS", \[live_regs] -> emitPopTupleRegs live_regs ), + ( fsLit "LDV_ENTER", \[e] -> ldvEnter e ), ( fsLit "LDV_RECORD_CREATE", \[e] -> ldvRecordCreate e ), |