GHC generates bad code for pointer manipulations from .cmm
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
movq $-8,%rax
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.
Trac metadata
Trac field | Value |
---|---|
Version | 6.8.2 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |