[GHC] #11792: Optimised unsafe FFI call can get wrong argument

GHC ghc-devs at haskell.org
Wed May 25 01:52:01 UTC 2016


#11792: Optimised unsafe FFI call can get wrong argument
-------------------------------------+-------------------------------------
        Reporter:  Szunti            |                Owner:
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:
       Component:  Compiler          |              Version:  7.10.3
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
 Type of failure:  Incorrect result  |  Unknown/Multiple
  at runtime                         |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by hsyl20):

 I have made a first patch: https://phabricator.haskell.org/D2263

 The result looks better (even if a little bit suboptimal):

 {{{#!nasm
         movq 8(%rbp),%rax
         xorl %ecx,%ecx
         xorl %edx,%edx
         movl $7457,%esi
         movl $255,%edi
         ; inlined code not using %esi/%rsi
         ; ...
         movq %rcx,%rdi ; suboptimal (could be xorq %rdi, %rdi)
         movq %rsi,%rcx ; suboptimal (could be movq %rsi, %rdx directly)
         movq %rbx,%rsi ; suboptimal (could be xorq %rsi, %rsi)
         movq %rcx,%rdx
         movq %rax,%rcx
         subq $8,%rsp
         xorl %eax,%eax
         call third_arg
 }}}

 The patch doesn't handle pushed args yet.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11792#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list