@@ -15,6 +15,7 @@ import LLVM.General.AST
15import LLVM.General.AST.AddrSpace
15import LLVM.General.AST.AddrSpace
16import LLVM.General.Target
16import LLVM.General.Target
17import LLVM.General.AST.DataLayout
17import LLVM.General.AST.DataLayout
18+import LLVM.General.PassManager
18import qualified LLVM.General.Module as M
19import qualified LLVM.General.Module as M
19import qualified LLVM.General.AST.IntegerPredicate as IPred
20import qualified LLVM.General.AST.IntegerPredicate as IPred
20import qualified LLVM.General.AST.Linkage as L
21import qualified LLVM.General.AST.Linkage as L
@@ -64,7 +65,14 @@ codegenLLVM defs file outty = withContext $ \context -> do
64 withTargetMachine target triple cpu features options R.Default CM.Default CGO.Default $ \tm ->
65 withTargetMachine target triple cpu features options R.Default CM.Default CGO.Default $ \tm ->
65 do layout <- getTargetMachineDataLayout tm
66 do layout <- getTargetMachineDataLayout tm
66 let ast = codegen (Target triple layout) (map snd defs)
67 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
71+ , simplifyLibCalls = Just True
72+ , useInlinerWithThreshold = Just 225
74+ withPassManager opts $ \pm -> runPassManager pm m
75+ outputModule tm file outty m
68 case result of
76 case result of
69 Right _ -> return ()
77 Right _ -> return ()
70 Left msg -> ierror msg
78 Left msg -> ierror msg