
#10062: Codegen on sequential FFI calls is not very good -------------------------------------+------------------------------------- Reporter: chadaustin | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.3 (CodeGen) | Keywords: Resolution: | Architecture: Operating System: Unknown/Multiple | Unknown/Multiple Type of failure: Runtime | Test Case: performance bug | Blocking: Blocked By: | Differential Revisions: Related Tickets: | -------------------------------------+------------------------------------- Comment (by Yuras):
I don't know why rsp is being changed so much.
It is necessary because `ccall` calling convention requires alignment that is different from the one used in `ghc`, see [[https://github.com/ghc/ghc/blob/64678e9e8ff0107cac956f0c7b799a1dd317b963/compiler/nativeGen/X86/CodeGen.hs#L2320|here]] for details. Though all this `addq`/`subq` probably can be combined... IIRC we don't have optimization pass for asm (?)
I also can't explain the assignment to eax before the call
It is required by calling convention [[https://github.com/ghc/ghc/blob/64678e9e8ff0107cac956f0c7b799a1dd317b963/compiler/nativeGen/X86/CodeGen.hs#L2357|too]]. So, the generated code is pretty reasonable, but there definitely is space for improvements. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/10062#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler