Set LLVM option -stack-alignment=32 when compiling AVX instructions.
authorGeoffrey Mainland <gmainlan@microsoft.com>
Thu, 14 Feb 2013 21:25:54 +0000 (21:25 +0000)
committerGeoffrey Mainland <gmainlan@microsoft.com>
Mon, 23 Sep 2013 02:33:59 +0000 (22:33 -0400)
compiler/main/DriverPipeline.hs

index a123564..76f6186 100644 (file)
@@ -1381,7 +1381,8 @@ 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
+                ++ map SysTools.Option stackAlignOpts)
 
     return (RealPhase next_phase, output_fn)
   where
@@ -1418,6 +1419,11 @@ runPhase (RealPhase LlvmLlc) input_fn dflags
                 | isAvxEnabled dflags    = ["-mattr=+avx"]
                 | otherwise              = []
 
+        stackAlignOpts =
+            case platformArch (targetPlatform dflags) of
+              ArchX86_64 | isAvxEnabled dflags -> ["-stack-alignment=32"]
+              _                                -> []
+
 -----------------------------------------------------------------------------
 -- LlvmMangle phase