diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-06-19 19:57:28 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-07-02 10:47:08 -0400 |
commit | 3cdd8d69f5c1d63137b9b56992bb9b74a6785459 (patch) | |
tree | d98f944154a7d26ae6c2a43181b402c9715cdbc5 /testsuite | |
parent | 23e4e04700f840e3c4e75ccb2085aea05bfb5318 (diff) | |
download | haskell-3cdd8d69f5c1d63137b9b56992bb9b74a6785459.tar.gz |
NCG: correctly handle addresses with huge offsets (#15570)
Before this patch we could generate addresses of this form:
movzbl cP0_str+-9223372036854775808,%eax
The linker can't handle them because the offset is too large:
ld.lld: error: Main.o:(.text+0xB3): relocation R_X86_64_32S out of range: -9223372036852653050 is not in [-2147483648, 2147483647]
With this patch we detect those cases and generate:
movq $-9223372036854775808,%rax
addq $cP0_str,%rax
movzbl (%rax),%eax
I've also refactored `getAmode` a little bit to make it easier to
understand and to trace.
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/tests/codeGen/should_compile/T15570.hs | 5 | ||||
-rw-r--r-- | testsuite/tests/codeGen/should_compile/all.T | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/testsuite/tests/codeGen/should_compile/T15570.hs b/testsuite/tests/codeGen/should_compile/T15570.hs new file mode 100644 index 0000000000..34164cf896 --- /dev/null +++ b/testsuite/tests/codeGen/should_compile/T15570.hs @@ -0,0 +1,5 @@ +{-# LANGUAGE MagicHash #-} +import GHC.Exts + +main :: IO () +main = print $ C# (indexCharOffAddr# "foo"# -9223372036854775808#) diff --git a/testsuite/tests/codeGen/should_compile/all.T b/testsuite/tests/codeGen/should_compile/all.T index f30123f07d..73c80e786e 100644 --- a/testsuite/tests/codeGen/should_compile/all.T +++ b/testsuite/tests/codeGen/should_compile/all.T @@ -91,3 +91,8 @@ test('T17648', normal, makefile_test, []) test('T17904', normal, compile, ['-O']) test('T18227A', normal, compile, ['']) test('T18227B', normal, compile, ['']) +test('T15570', + when(unregisterised(), skip), + compile, ['-Wno-overflowed-literals']) + # skipped with CmmToC because it generates a warning: + # warning: integer constant is so large that it is unsigned |