summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wortmann <scpmw@leeds.ac.uk>2014-11-18 12:33:05 -0600
committerAustin Seipp <austin@well-typed.com>2014-11-18 12:33:05 -0600
commitc557f991a9fa6f6afad4850e4f5db6a08fa1cb6c (patch)
tree46fe432cceeb284cc50de9725d827d3fe0f2c4c4
parent21f9bc434c12e928005d59c494e4f48c242b0613 (diff)
downloadhaskell-c557f991a9fa6f6afad4850e4f5db6a08fa1cb6c.tar.gz
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@well-typed.com>
-rw-r--r--compiler/main/DriverPipeline.hs16
1 files changed, 11 insertions, 5 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 66c6e97d0c..ed2e906676 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 ] ++