[commit: ghc] master: DriverPipeline: Ensure -globalopt is passed to LLVM opt (b84b5da)

git at git.haskell.org git at git.haskell.org
Thu Mar 13 22:58:06 UTC 2014


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

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

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

commit b84b5da4430aacd5bf8422b06a861cd0584f99cf
Author: Ben Gamari <bgamari.foss at gmail.com>
Date:   Thu Mar 6 21:20:02 2014 +0100

    DriverPipeline: Ensure -globalopt is passed to LLVM opt
    
    While -O1 and -O2 both include -globalopt, the order in which the passes are
    run means that aliases aren't resolved which then causes llc to fall over.
    See GHC bug #8855.
    
    Signed-off-by: Austin Seipp <austin at well-typed.com>


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

b84b5da4430aacd5bf8422b06a861cd0584f99cf
 compiler/main/DriverPipeline.hs |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index f6d9e03..564edd2 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1337,7 +1337,7 @@ runPhase (RealPhase LlvmOpt) input_fn dflags
         -- passes only, so if the user is passing us extra options we assume
         -- they know what they are doing and don't get in the way.
         optFlag  = if null (getOpts dflags opt_lo)
-                       then map SysTools.Option $ words (llvmOpts !! opt_lvl)
+                       then map SysTools.Option $ words (llvmOpts ver !! opt_lvl)
                        else []
         tbaa | ver < 29                 = "" -- no tbaa in 2.8 and earlier
              | gopt Opt_LlvmTBAA dflags = "--enable-tbaa=true"
@@ -1357,7 +1357,11 @@ runPhase (RealPhase LlvmOpt) input_fn dflags
   where 
         -- we always (unless -optlo specified) run Opt since we rely on it to
         -- fix up some pretty big deficiencies in the code we generate
-        llvmOpts = ["-mem2reg -globalopt", "-O1", "-O2"]
+        llvmOpts ver = [ "-mem2reg -globalopt"
+                       , if ver >= 34 then "-O1 -globalopt" else "-O1"
+                         -- LLVM 3.4 -O1 doesn't eliminate aliases reliably (bug #8855)
+                       , "-O2"
+                       ]
 
 -----------------------------------------------------------------------------
 -- LlvmLlc phase



More information about the ghc-commits mailing list