[GHC] #11138: Kill the terrible LLVM Mangler
#11138: Kill the terrible LLVM Mangler -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Other Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Since its introduction the LLVM backend has had a mangler which transforms assembler produced by LLVM. In the past this mangler was responsible for shuffling around code to make tables-next-to-code work, but the need for this has past with the resolution of #4213. At this point the only reason it exists is to mangle AVX instructions to 1. rewriting all symbols of type `@function` to `@object` to prevent symbol references from going through the PLT, which would be bad due to tables-next-to-code. 2. On x86_64, rewrite AVX instructions that require alignment to their unaligned counterparts, since the stack is only 16-byte aligned but these instructions require 32-byte alignment. While it's unclear that we will ever be able to discharge (1), it would be nice to investigate whether we can at least do something about (2) (there may even be performance to be gained!). -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11138> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11138: Kill the terrible LLVM Mangler -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dobenour): (1) is probably an LLVM bug, since GHC now uses LLVM's prefix data support. LLVM should be responsible for ensuring that the prefix data is properly handled by the assembler and linker. (2) can be solved by either 32-byte aligning the stack or disabling AVX instructions. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11138#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11138: Kill the terrible LLVM Mangler -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by thomie): * component: Compiler => Compiler (LLVM) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11138#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11138: Kill the terrible LLVM Mangler -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * type: bug => task -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11138#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11138: Kill the terrible LLVM Mangler -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by angerman): - According to majnemer_ we might not need the avx trick in the Mangler when using `-mstackalign` (which is supposedly available in 3.9) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11138#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11138: Kill the terrible LLVM Mangler -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: task | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by dobenour): LLVM 3.8 (and presumably later) has the `-stack-alignment` option, which we could use. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11138#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11138: Kill the terrible LLVM Mangler -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by angerman): When compiling with avx, e.g. `-mavx2`, we already add `-stack- alignment=32` to the `llc` invocation. This begs the question if we need (2) anymore after all? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11138#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11138: Kill the terrible LLVM Mangler -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: task | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by angerman): * cc: gmainland (added) Comment: This was added already in 2013. afdb2fc3d2013ced6c136853f4e24e84b6f150e9 \\ Author: Geoffrey Mainland <mainland@cs.drexel.edu> \\ AuthorDate: Thu Feb 14 21:25:54 2013 +0000 \\ Commit: Geoffrey Mainland <mainland@cs.drexel.edu> \\ CommitDate: Sun Sep 22 22:33:59 2013 -0400 **Set LLVM option -stack-alignment=32 when compiling AVX instructions.** ---- Then mangler code however was created earlier in 2011. f8c51678b0e60aad8ee1e4c57af746fa792a3546\\ Author: Geoffrey Mainland <mainland@cs.drexel.edu>\\ AuthorDate: Sat Nov 26 12:45:23 2011 +0000\\ Commit: Geoffrey Mainland <mainland@cs.drexel.edu>\\ CommitDate: Sun Sep 22 22:33:59 2013 -0400 **Fixup stack spills when generating AVX instructions.** LLVM uses aligned AVX moves to spill values onto the stack, which requires 32-bye aligned stacks. Since the stack in only 16-byte aligned, LLVM inserts extra instructions that munge the stack pointer. This is very very bad for the GHC calling convention, so we tell LLVM to assume the stack is 32-byte aligned. This patch rewrites the spill instructions that LLVM generates so they do not require an aligned stack. ---- Could it be that the Mangler code is some ancient relict? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11138#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11138: Kill the terrible LLVM Mangler -------------------------------------+------------------------------------- Reporter: bgamari | Owner: angerman Type: task | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by angerman): * owner: (none) => angerman Comment: I'll assign this to me for the time being. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11138#comment:8> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#11138: Kill the terrible LLVM Mangler -------------------------------------+------------------------------------- Reporter: bgamari | Owner: angerman Type: task | Status: new Priority: normal | Milestone: Component: Compiler (LLVM) | Version: 7.11 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Other | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by michalt): * cc: michalt (added) -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11138#comment:9> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC