@@ -15,6 +15,7 @@ import LLVM.General.AST
1515import LLVM.General.AST.AddrSpace
1616import LLVM.General.Target
1717import LLVM.General.AST.DataLayout
18+import LLVM.General.PassManager
1819import qualified LLVM.General.Module as M
1920import qualified LLVM.General.AST.IntegerPredicate as IPred
2021import qualified LLVM.General.AST.Linkage as L
@@ -64,7 +65,14 @@ codegenLLVM defs file outty = withContext $ \context -> do
6465 withTargetMachine target triple cpu features options R.Default CM.Default CGO.Default $ \tm ->
6566 do layout <- getTargetMachineDataLayout tm
6667 let ast = codegen (Target triple layout) (map snd defs)
67− result <- runErrorT $ M.withModuleFromAST context ast (outputModule tm file outty)
68+ result <- runErrorT . M.withModuleFromAST context ast $ \m ->
69+ do let opts = defaultCuratedPassSetSpec
70+ { optLevel = Just 3
71+ , simplifyLibCalls = Just True
72+ , useInlinerWithThreshold = Just 225
73+ }
74+ withPassManager opts $ \pm -> runPassManager pm m
75+ outputModule tm file outty m
6876 case result of
6977 Right _ -> return ()
7078 Left msg -> ierror msg