[commit: ghc] master: Disable AVX for LLVM 3.2 by default (#9391) (c557f99)

git at git.haskell.org git at git.haskell.org
Tue Nov 18 18:43:23 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/c557f991a9fa6f6afad4850e4f5db6a08fa1cb6c/ghc

>---------------------------------------------------------------

commit c557f991a9fa6f6afad4850e4f5db6a08fa1cb6c
Author: Peter Wortmann <scpmw at leeds.ac.uk>
Date:   Tue Nov 18 12:33:05 2014 -0600

    Disable AVX for LLVM 3.2 by default (#9391)
    
    Due to a bug LLVM generates a C-like frame pointer prelude for functions
    that use AVX instructions. This causes programs using the GHC calling
    convention to crash, therefore we simply disable them. People that want
    to use AVX should consider upgrading to a more current LLVM version.
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>


>---------------------------------------------------------------

c557f991a9fa6f6afad4850e4f5db6a08fa1cb6c
 compiler/main/DriverPipeline.hs | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 66c6e97..ed2e906 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1404,6 +1404,11 @@ runPhase (RealPhase LlvmLlc) input_fn dflags
                         
     output_fn <- phaseOutputFilename next_phase
 
+    -- AVX can cause LLVM 3.2 to generate a C-like frame pointer
+    -- prelude, see #9391
+    when (ver == 32 && isAvxEnabled dflags) $ liftIO $ errorMsg dflags $ text
+      "Note: LLVM 3.2 has known problems with AVX instructions (see trac #9391)"
+
     liftIO $ SysTools.runLlvmLlc dflags
                 ([ SysTools.Option (llvmOpts !! opt_lvl),
                     SysTools.Option $ "-relocation-model=" ++ rmodel,
@@ -1413,7 +1418,7 @@ runPhase (RealPhase LlvmLlc) input_fn dflags
                 ++ map SysTools.Option fpOpts
                 ++ map SysTools.Option abiOpts
                 ++ map SysTools.Option sseOpts
-                ++ map SysTools.Option avxOpts
+                ++ map SysTools.Option (avxOpts ver)
                 ++ map SysTools.Option avx512Opts
                 ++ map SysTools.Option stackAlignOpts)
 
@@ -1449,10 +1454,11 @@ runPhase (RealPhase LlvmLlc) input_fn dflags
                 | isSseEnabled dflags    = ["-mattr=+sse"]
                 | otherwise              = []
 
-        avxOpts | isAvx512fEnabled dflags = ["-mattr=+avx512f"]
-                | isAvx2Enabled dflags    = ["-mattr=+avx2"]
-                | isAvxEnabled dflags     = ["-mattr=+avx"]
-                | otherwise               = []
+        avxOpts ver | isAvx512fEnabled dflags = ["-mattr=+avx512f"]
+                    | isAvx2Enabled dflags    = ["-mattr=+avx2"]
+                    | isAvxEnabled dflags     = ["-mattr=+avx"]
+                    | ver == 32               = ["-mattr=-avx"] -- see #9391
+                    | otherwise               = []
 
         avx512Opts =
           [ "-mattr=+avx512cd" | isAvx512cdEnabled dflags ] ++



More information about the ghc-commits mailing list