[GHC] #12134: PowerPC 64-bit: Foreign functions with more than 8 float parameters broken
#12134: PowerPC 64-bit: Foreign functions with more than 8 float parameters broken -------------------------------------+------------------------------------- Reporter: trommler | Owner: trommler Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 (NCG) | Keywords: ccall | Operating System: Linux Architecture: powerpc64 | Type of failure: Incorrect result | at runtime Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider the following: {{{#!c void many_floats(float f1, float f2, float f3, float f4, float f5, float f6, float f7, float f8, float f9, float f10, float f11, float f12, float f13, float f14) { printf("%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n%f\n", f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14); } }}} and {{{#!hs foreign import ccall "many_floats" many :: CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> CFloat -> IO () main = many 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5 9.5 10.5 11.5 12.5 13.5 14.5 }}} gives {{{ 1.500000 2.500000 3.500000 4.500000 5.500000 6.500000 7.500000 8.500000 0.000000 0.000000 3.000000 14.500000 13.500000 0.000000 }}} on PowerPC 64-bit Linux. According to the ABI for PowerPC 64-bit ELF v1.9 and ELF v2.0 the first 13 floating or double parameters are passed in floating point registers. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12134> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12134: PowerPC 64-bit: Foreign functions with more than 8 float parameters broken -------------------------------------+------------------------------------- Reporter: trommler | Owner: trommler Type: bug | Status: patch Priority: normal | Milestone: 8.0.2 Component: Compiler (NCG) | Version: 8.0.1 Resolution: | Keywords: ccall Operating System: Linux | Architecture: powerpc64 Type of failure: Incorrect result | Test Case: at runtime | ffi/should_run/T12134 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2327 Wiki Page: | -------------------------------------+------------------------------------- Changes (by trommler): * status: new => patch * testcase: => ffi/should_run/T12134 * differential: => Phab:D2327 * milestone: => 8.0.2 Comment: The patch in Phab:D2327 fixes it and adds a regression test. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12134#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12134: PowerPC 64-bit: Foreign functions with more than 8 float parameters broken -------------------------------------+------------------------------------- Reporter: trommler | Owner: trommler Type: bug | Status: patch Priority: normal | Milestone: 8.0.2 Component: Compiler (NCG) | Version: 8.0.1 Resolution: | Keywords: ccall Operating System: Linux | Architecture: powerpc64 Type of failure: Incorrect result | Test Case: at runtime | ffi/should_run/T12134 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2327 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"2897be77123bf31cad1c60dd5560eba7f2f021ce/ghc" 2897be7/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="2897be77123bf31cad1c60dd5560eba7f2f021ce" PPC NCG: Fix float parameter passing on 64-bit. On Linux 64-bit PowerPC the first 13 floating point parameters are passed in registers. We only passed the first 8 floating point params. The alignment of a floating point single precision value in ELF v1.9 is the second word of a doubleword. For ELF v2 we support only little endian and the least significant word of a doubleword is the first word, so no special handling is required. Add a regression test. Test Plan: validate on powerpc Linux and AIX Reviewers: erikd, hvr, austin, simonmar, bgamari Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2327 GHC Trac Issues: #12134 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12134#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12134: PowerPC 64-bit: Foreign functions with more than 8 float parameters broken -------------------------------------+------------------------------------- Reporter: trommler | Owner: trommler Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler (NCG) | Version: 8.0.1 Resolution: | Keywords: ccall Operating System: Linux | Architecture: powerpc64 Type of failure: Incorrect result | Test Case: at runtime | ffi/should_run/T12134 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2327 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge Comment: This should likely go into 8.0.2. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12134#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12134: PowerPC 64-bit: Foreign functions with more than 8 float parameters broken -------------------------------------+------------------------------------- Reporter: trommler | Owner: trommler Type: bug | Status: merge Priority: normal | Milestone: 8.0.2 Component: Compiler (NCG) | Version: 8.0.1 Resolution: | Keywords: ccall Operating System: Linux | Architecture: powerpc64 Type of failure: Incorrect result | Test Case: at runtime | ffi/should_run/T12134 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2327 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"7f373fb1b9aea45db94f04267427c5629b73f25c/ghc" 7f373fb1/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="7f373fb1b9aea45db94f04267427c5629b73f25c" PPC NCG: Fix float parameter passing on 64-bit. On Linux 64-bit PowerPC the first 13 floating point parameters are passed in registers. We only passed the first 8 floating point params. The alignment of a floating point single precision value in ELF v1.9 is the second word of a doubleword. For ELF v2 we support only little endian and the least significant word of a doubleword is the first word, so no special handling is required. Add a regression test. Test Plan: validate on powerpc Linux and AIX Reviewers: erikd, hvr, austin, simonmar, bgamari Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2327 GHC Trac Issues: #12134 (cherry picked from commit 2897be77123bf31cad1c60dd5560eba7f2f021ce) }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12134#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#12134: PowerPC 64-bit: Foreign functions with more than 8 float parameters broken -------------------------------------+------------------------------------- Reporter: trommler | Owner: trommler Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler (NCG) | Version: 8.0.1 Resolution: fixed | Keywords: ccall Operating System: Linux | Architecture: powerpc64 Type of failure: Incorrect result | Test Case: at runtime | ffi/should_run/T12134 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2327 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12134#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC