Ticket #2016 (closed bug: duplicate)
GHC generates bad code for pointer manipulations from .cmm
|Reported by:||wb.kloke||Owned by:|
|Operating System:||FreeBSD||Architecture:||x86_64 (amd64)|
|Type of failure:||Difficulty:||Unknown|
|Test Case:||Blocked By:|
In files rts/StgStdThunks.cmm (and rts/StgMiscClosures.cmm also) a natively booted x86_64 compiler generates the following wrong assembler output:
.text .align 8 .quad 0 .quad 34 .globl stg_sel_ret_0_upd_info stg_sel_ret_0_upd_info: movl $4294967288,%eax movq %rbx,%rcx andq %rax,%rcx movq 8(%rcx),%rbx addq $8,%rbp ...
The correct code for the movl line is
The real output from a correct compiler (such as the stage1 compiler crosscompiled from i386) is slightly different due to optimisation, but equivalent to my correction.
I checked this bug with different compilation flags in the stage1 and stage2 creation phase (with -fasm or -fvia-C). I am not sure whether the bug is present in other x86_64 OSs, which are supported for longer than FreeBSD. But it is easy to check. Just compile the file with -S with a stage2 compiler.