#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): Phab:D2263 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Ben Gamari <ben@…>): In [changeset:"b61b7c2462b919de7eb4c373e2e2145c6d78d04c/ghc" b61b7c24/ghc]: {{{ #!CommitTicketReference repository="ghc" revision="b61b7c2462b919de7eb4c373e2e2145c6d78d04c" CodeGen X86: fix unsafe foreign calls wrt inlining Foreign calls (unsafe and safe) interact badly with inlining and register passing ABIs (see #11792 and #12614): the inlined code to compute a parameter of the call may overwrite a register already set to pass a preceding parameter. With this patch, we compute all parameters which are not simple expressions before assigning them to fixed registers required by the ABI. Test Plan: - Add test (test both reg and stack parameters) - Validate Reviewers: osa1, bgamari, austin, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2263 GHC Trac Issues: #11792, #12614 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11792#comment:14> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler