[GHC] #8922: GHC unnecessarily sign/zero-extends C call arguments

#8922: GHC unnecessarily sign/zero-extends C call arguments ----------------------------------+------------------------------------- Reporter: simonmar | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler (NCG) | Version: 7.6.3 Keywords: | Operating System: Unknown/Multiple Architecture: x86_64 (amd64) | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #7684 | ----------------------------------+------------------------------------- Ticket created following discussion in [https://ghc.haskell.org/trac/ghc/ticket/7684#comment:58] It seems the zero/sign-extension that we're doing in the NCG for arguments less than a word in size is unnecessary, since the ABI doesn't specify any extension. There's some clarification of the spec in this thread: [http://gcc.gnu.org/ml/gcc/2013-01/msg00448.html] -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8922 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8922: GHC unnecessarily sign/zero-extends C call arguments -------------------------------------+---------------------------------- Reporter: simonmar | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler (NCG) | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #7684 -------------------------------------+---------------------------------- Comment (by tibbe): Note this exchange in the linked email thread above. I'm not sure if Richard (the editor) is saying that zero extending in the caller is an optimization:
How? You aren't allowed to access the bits outside the specified argument type (which must match on caller and callee side), so you can't observe them, so it's not required to specify their content.
OK, thanks. It's clear now.
The problem is that LLVM assumes that values are extended at a call. GCC does that, but libffi doesn't. So, calls via libffi to LLVM don't work correctly.
It's an optimization to do so to avoid partial register stalls.
-- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8922#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8922: GHC unnecessarily sign/zero-extends C call arguments -------------------------------------+---------------------------------- Reporter: simonmar | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: Compiler (NCG) | Version: 7.6.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: x86_64 (amd64) Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: #7684 -------------------------------------+---------------------------------- Comment (by simonmar): My reading of it was that extending in the caller is not strictly necessary but is done as an optimisation to avoid partial register stalls. Maybe that means we ought to be doing it too - that's not clear to me. I'm sure it's not *always* an optimisation. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8922#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC