diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2021-06-10 23:14:35 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2021-07-21 22:51:41 +0000 |
commit | e8f7734d8a052f99b03e1123466dc9f47b48c311 (patch) | |
tree | fda662d428a825c69d24b204a9777d4f70235acd /compiler/GHC/CmmToC.hs | |
parent | 10124b16538091806953d732e24ca485a0664895 (diff) | |
download | haskell-e8f7734d8a052f99b03e1123466dc9f47b48c311.tar.gz |
Fix #19931
The issue was the renderer for x86 addressing modes assumes native size
registers, but we were passing in a possibly-smaller index in
conjunction with a native-sized base pointer.
The easist thing to do is just extend the register first.
I also changed the other NGC backends implementing jump tables
accordingly. On one hand, I think PowerPC and Sparc don't have the small
sub-registers anyways so there is less to worry about. On the other
hand, to the extent that's true the zero extension can become a no-op.
I should give credit where it's due: @hsyl20 really did all the work for
me in
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4717#note_355874,
but I was daft and missed the "Oops" and so ended up spending a silly
amount of time putting it all back together myself.
The unregisterised backend change is a bit different, because here we
are translating the actual case not a jump table, and the fix is to
handle right-sized literals not addressing modes. But it makes sense to
include here too because it's the same change in the subsequent commit
that exposes both bugs.
Diffstat (limited to 'compiler/GHC/CmmToC.hs')
-rw-r--r-- | compiler/GHC/CmmToC.hs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/GHC/CmmToC.hs b/compiler/GHC/CmmToC.hs index 8349393f0d..f662f7d996 100644 --- a/compiler/GHC/CmmToC.hs +++ b/compiler/GHC/CmmToC.hs @@ -341,15 +341,17 @@ pprSwitch platform e ids where (pairs, mbdef) = switchTargetsFallThrough ids + rep = typeWidth (cmmExprType platform e) + -- fall through case caseify (ix:ixs, ident) = vcat (map do_fallthrough ixs) $$ final_branch ix where do_fallthrough ix = - hsep [ text "case" , pprHexVal platform ix (wordWidth platform) <> colon , + hsep [ text "case" , pprHexVal platform ix rep <> colon , text "/* fall through */" ] final_branch ix = - hsep [ text "case" , pprHexVal platform ix (wordWidth platform) <> colon , + hsep [ text "case" , pprHexVal platform ix rep <> colon , text "goto" , (pprBlockId ident) <> semi ] caseify (_ , _ ) = panic "pprSwitch: switch with no cases!" |