[commit: ghc] wip/T11295-part1: use passes found in the file instead (58221e4)

git at git.haskell.org git at git.haskell.org
Tue May 15 19:04:13 UTC 2018


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

On branch  : wip/T11295-part1
Link       : http://ghc.haskell.org/trac/ghc/changeset/58221e4bae7c4c563a8f55c7e1e9252e54ccdae9/ghc

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

commit 58221e4bae7c4c563a8f55c7e1e9252e54ccdae9
Author: Kavon Farvardin <kavon at farvard.in>
Date:   Tue May 15 14:03:53 2018 -0500

    use passes found in the file instead


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

58221e4bae7c4c563a8f55c7e1e9252e54ccdae9
 compiler/main/DriverPipeline.hs | 10 ++++++----
 llvm-passes                     |  6 +++++-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
index 0ed65d3..74aef51 100644
--- a/compiler/main/DriverPipeline.hs
+++ b/compiler/main/DriverPipeline.hs
@@ -1474,10 +1474,12 @@ 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 = case optLevel dflags of
-          0 -> "-mem2reg -globalopt"
-          1 -> "-O1 -globalopt"
-          _ -> "-O2"
+        optIdx = min 2 $ max 0 $ optLevel dflags  -- ensure we're in [0,2]
+        llvmOpts = case lookup optIdx $ llvmPasses dflags of
+                    Just passes -> passes
+                    Nothing -> panic ("runPhase LlvmOpt: llvm-passes file "
+                                      ++ "is missing passes for level "
+                                      ++ show optIdx)
 
         -- don't specify anything if user has specified commands. We do this
         -- for opt but not llc since opt is very specifically for optimisation
diff --git a/llvm-passes b/llvm-passes
index fe51488..5183c9f 100644
--- a/llvm-passes
+++ b/llvm-passes
@@ -1 +1,5 @@
-[]
+[
+(0, "-mem2reg -globalopt"),
+(1, "-O1 -globalopt"),
+(2, "-O2")
+]



More information about the ghc-commits mailing list