llvm-general 3.4.3.1 → 3.4.4.0
raw patch · 10 files changed
+127/−24 lines, 10 filesdep ~llvm-generaldep ~llvm-general-pure
Dependency ranges changed: llvm-general, llvm-general-pure
Files
- llvm-general.cabal +9/−6
- src/LLVM/General/Internal/FFI/PassManager.hs +6/−0
- src/LLVM/General/Internal/FFI/PassManagerC.cpp +27/−7
- src/LLVM/General/Internal/FFI/Threading.hs +17/−0
- src/LLVM/General/Internal/FFI/Transforms.hs +2/−0
- src/LLVM/General/Internal/PassManager.hs +16/−9
- src/LLVM/General/Internal/Threading.hs +33/−0
- src/LLVM/General/Threading.hs +7/−0
- src/LLVM/General/Transforms.hs +9/−1
- test/LLVM/General/Test/Optimization.hs +1/−1
llvm-general.cabal view
@@ -1,5 +1,5 @@ name: llvm-general-version: 3.4.3.1+version: 3.4.4.0 license: BSD3 license-file: LICENSE author: Benjamin S.Scarlet <fgthb0@greynode.net>@@ -16,7 +16,7 @@ handles almost all of the stateful complexities of using the LLVM API to build IR; and it supports moving IR not only from Haskell into LLVM C++ objects, but the other direction - from LLVM C++ into Haskell. .- For haddock, see <http://bscarlet.github.io/llvm-general/3.4.3.1/doc/html/llvm-general/index.html>.+ For haddock, see <http://bscarlet.github.io/llvm-general/3.4.4.0/doc/html/llvm-general/index.html>. extra-source-files: src/LLVM/General/Internal/FFI/Analysis.h src/LLVM/General/Internal/FFI/BinaryOperator.h@@ -40,7 +40,7 @@ type: git location: git://github.com/bscarlet/llvm-general.git branch: llvm-3.4- tag: v3.4.3.1+ tag: v3.4.4.0 flag shared-llvm description: link against llvm shared rather than static library@@ -64,7 +64,7 @@ parsec >= 3.1.3, array >= 0.4.0.0, setenv >= 0.1.0,- llvm-general-pure == 3.4.3.1+ llvm-general-pure == 3.4.4.0 extra-libraries: stdc++ hs-source-dirs: src extensions:@@ -90,6 +90,7 @@ LLVM.General.Target LLVM.General.Target.LibraryFunction LLVM.General.Target.Options+ LLVM.General.Threading LLVM.General.Transforms other-modules:@@ -128,6 +129,7 @@ LLVM.General.Internal.RMWOperation LLVM.General.Internal.String LLVM.General.Internal.Target+ LLVM.General.Internal.Threading LLVM.General.Internal.Type LLVM.General.Internal.Value LLVM.General.Internal.FFI.Analysis@@ -160,6 +162,7 @@ LLVM.General.Internal.FFI.RawOStream LLVM.General.Internal.FFI.SMDiagnostic LLVM.General.Internal.FFI.Target+ LLVM.General.Internal.FFI.Threading LLVM.General.Internal.FFI.Transforms LLVM.General.Internal.FFI.Type LLVM.General.Internal.FFI.User@@ -199,8 +202,8 @@ HUnit >= 1.2.4.2, test-framework-quickcheck2 >= 0.3.0.1, QuickCheck >= 2.5.1.1,- llvm-general == 3.4.3.1,- llvm-general-pure == 3.4.3.1,+ llvm-general == 3.4.4.0,+ llvm-general-pure == 3.4.4.0, containers >= 0.4.2.1, mtl >= 2.0.1.0 hs-source-dirs: test
src/LLVM/General/Internal/FFI/PassManager.hs view
@@ -129,3 +129,9 @@ foreign import ccall unsafe "LLVM_General_PassManagerBuilderSetLibraryInfo" passManagerBuilderSetLibraryInfo :: Ptr PassManagerBuilder -> Ptr TargetLibraryInfo -> IO ()++foreign import ccall unsafe "LLVM_General_PassManagerBuilderSetLoopVectorize" passManagerBuilderSetLoopVectorize ::+ Ptr PassManagerBuilder -> LLVMBool -> IO ()++foreign import ccall unsafe "LLVM_General_PassManagerBuilderSetSuperwordLevelParallelismVectorize" passManagerBuilderSetSuperwordLevelParallelismVectorize ::+ Ptr PassManagerBuilder -> LLVMBool -> IO ()
src/LLVM/General/Internal/FFI/PassManagerC.cpp view
@@ -246,14 +246,34 @@ unwrap(PM)->add(createDebugIRPass()); } -void-LLVM_General_PassManagerBuilderSetLibraryInfo(- LLVMPassManagerBuilderRef PMB,- LLVMTargetLibraryInfoRef l+void LLVM_General_AddLoopVectorizePass(+ LLVMPassManagerRef PM,+ LLVMBool noUnrolling ) {- // The PassManager frees the TargetLibraryInfo when done,- // but we also free our ref, so give it a new copy.- unwrap(PMB)->LibraryInfo = new TargetLibraryInfo(*unwrap(l));+ unwrap(PM)->add(createLoopVectorizePass(noUnrolling));+}++void LLVM_General_PassManagerBuilderSetLibraryInfo(+ LLVMPassManagerBuilderRef PMB,+ LLVMTargetLibraryInfoRef l+) {+ // The PassManager frees the TargetLibraryInfo when done,+ // but we also free our ref, so give it a new copy.+ unwrap(PMB)->LibraryInfo = new TargetLibraryInfo(*unwrap(l));+}++void LLVM_General_PassManagerBuilderSetLoopVectorize(+ LLVMPassManagerBuilderRef PMB,+ LLVMBool runLoopVectorization+) {+ unwrap(PMB)->LoopVectorize = runLoopVectorization;+}++void LLVM_General_PassManagerBuilderSetSuperwordLevelParallelismVectorize(+ LLVMPassManagerBuilderRef PMB,+ LLVMBool runSLPVectorization+) {+ unwrap(PMB)->SLPVectorize = runSLPVectorization; } }
+ src/LLVM/General/Internal/FFI/Threading.hs view
@@ -0,0 +1,17 @@+{-# LANGUAGE+ ForeignFunctionInterface+ #-}+module LLVM.General.Internal.FFI.Threading where++import Foreign.C++import LLVM.General.Internal.FFI.LLVMCTypes++foreign import ccall unsafe "LLVMStartMultithreaded" startMultithreaded ::+ IO LLVMBool++foreign import ccall unsafe "LLVMStopMultithreaded" stopMultithreaded ::+ IO ()++foreign import ccall unsafe "LLVMIsMultithreaded" isMultithreaded ::+ IO LLVMBool
src/LLVM/General/Internal/FFI/Transforms.hs view
@@ -33,6 +33,7 @@ "OldScalarReplacementOfAggregates" -> "ScalarReplAggregates" "SimplifyControlFlowGraph" -> "CFGSimplification" "SparseConditionalConstantPropagation" -> "SCCP"+ "SuperwordLevelParallelismVectorize" -> "SLPVectorize" h -> h patchImpls = [ "AddressSanitizer",@@ -54,6 +55,7 @@ "LoopClosedSingleStaticAssignment", "LoopInstructionSimplify", "LoopStrengthReduce",+ "LoopVectorize", "LowerAtomic", "LowerInvoke", "LowerSwitch",
src/LLVM/General/Internal/PassManager.hs view
@@ -54,8 +54,12 @@ sizeLevel :: Maybe Word, unitAtATime :: Maybe Bool, simplifyLibCalls :: Maybe Bool,+ loopVectorize :: Maybe Bool,+ superwordLevelParallelismVectorize :: Maybe Bool, useInlinerWithThreshold :: Maybe Word,- curatedTargetLibraryInfo :: Maybe TargetLibraryInfo+ dataLayout :: Maybe DataLayout,+ targetLibraryInfo :: Maybe TargetLibraryInfo,+ targetMachine :: Maybe TargetMachine } -- | Helper to make a curated 'PassSetSpec'@@ -64,8 +68,12 @@ sizeLevel = Nothing, unitAtATime = Nothing, simplifyLibCalls = Nothing,+ loopVectorize = Nothing,+ superwordLevelParallelismVectorize = Nothing, useInlinerWithThreshold = Nothing,- curatedTargetLibraryInfo = Nothing+ dataLayout = Nothing,+ targetLibraryInfo = Nothing,+ targetMachine = Nothing } -- | an empty 'PassSetSpec'@@ -82,6 +90,10 @@ createPassManager :: PassSetSpec -> IO (Ptr FFI.PassManager) createPassManager pss = flip runAnyContT return $ do pm <- liftIO $ FFI.createPassManager+ forM_ (dataLayout pss) $ \dl -> liftIO $ withFFIDataLayout dl $ FFI.addDataLayoutPass pm + forM_ (targetLibraryInfo pss) $ \(TargetLibraryInfo tli) -> do+ liftIO $ FFI.addTargetLibraryInfoPass pm tli+ forM_ (targetMachine pss) $ \(TargetMachine tm) -> liftIO $ FFI.addAnalysisPasses tm pm case pss of s@CuratedPassSetSpec {} -> liftIO $ do bracket FFI.passManagerBuilderCreate FFI.passManagerBuilderDispose $ \b -> do@@ -91,16 +103,11 @@ handleOption FFI.passManagerBuilderSetDisableUnitAtATime (liftM not . unitAtATime) handleOption FFI.passManagerBuilderSetDisableSimplifyLibCalls (liftM not . simplifyLibCalls) handleOption FFI.passManagerBuilderUseInlinerWithThreshold useInlinerWithThreshold- case (curatedTargetLibraryInfo s) of- (Just (TargetLibraryInfo tl)) -> FFI.passManagerBuilderSetLibraryInfo b tl- Nothing -> return ()+ handleOption FFI.passManagerBuilderSetLoopVectorize loopVectorize+ handleOption FFI.passManagerBuilderSetSuperwordLevelParallelismVectorize superwordLevelParallelismVectorize FFI.passManagerBuilderPopulateModulePassManager b pm PassSetSpec ps dl tli tm' -> do let tm = maybe nullPtr (\(TargetMachine tm) -> tm) tm'- forM_ tli $ \(TargetLibraryInfo tli) -> do- liftIO $ FFI.addTargetLibraryInfoPass pm tli- forM_ dl $ \dl -> liftIO $ withFFIDataLayout dl $ FFI.addDataLayoutPass pm - forM_ tm' $ \(TargetMachine tm) -> liftIO $ FFI.addAnalysisPasses tm pm forM_ ps $ \p -> $( do TH.TyConI (TH.DataD _ _ _ cons _) <- TH.reify ''Pass
+ src/LLVM/General/Internal/Threading.hs view
@@ -0,0 +1,33 @@+module LLVM.General.Internal.Threading (+ setMultithreaded,+ isMultithreaded+ ) where++import Control.Concurrent.MVar+import System.IO.Unsafe+import Control.Monad++import qualified LLVM.General.Internal.FFI.Threading as FFI++import LLVM.General.Internal.Coding++lock :: MVar ()+{-# NOINLINE lock #-}+lock = unsafePerformIO $ newMVar ()++-- | Set the multithreading mode of LLVM. If it is disabled (as by default) locks are not enforced.+setMultithreaded :: Bool -> IO ()+setMultithreaded s = do+ takeMVar lock+ multi <- isMultithreaded+ case (s,multi) of+ (True,False) -> do+ success <- decodeM =<< FFI.startMultithreaded+ when (not success) $ error "setMultithreaded: LLVM not built with threading support"+ (False,True) -> FFI.stopMultithreaded+ _ -> return ()+ putMVar lock ()++-- | Check if multithreading is enabled in LLVM+isMultithreaded :: IO Bool+isMultithreaded = FFI.isMultithreaded >>= decodeM
+ src/LLVM/General/Threading.hs view
@@ -0,0 +1,7 @@+-- | functionality necessary when running LLVM in multiple threads at the same time.+module LLVM.General.Threading (+ setMultithreaded,+ isMultithreaded+ ) where++import LLVM.General.Internal.Threading
src/LLVM/General/Transforms.hs view
@@ -104,7 +104,10 @@ noMemoryOperationBoost :: Bool, fastDependencyAnalysis :: Bool }- | LoopVectorize+ | LoopVectorize {+ noUnrolling :: Bool+ }+ | SuperwordLevelParallelismVectorize -- here begin the instrumentation passes | GCOVProfiler {@@ -143,6 +146,11 @@ } | DebugExistingIR deriving (Eq, Ord, Read, Show, Typeable, Data)++-- | Defaults for the 'LoopVectorize' pass+defaultLoopVectorize = LoopVectorize {+ noUnrolling = False+ } -- | Defaults for the 'BasicBlockVectorize' pass - copied from the C++ code to keep these defaults -- constant. (The C++ defaults are modifiable through global objects used for command-line processing,
test/LLVM/General/Test/Optimization.hs view
@@ -251,7 +251,7 @@ withTargetOptions $ \targetOptions -> do withTargetMachine target triple "" Set.empty targetOptions R.Default CM.Default CGO.Default $ \tm -> do optimize (defaultPassSetSpec { - transforms = [ LoopVectorize ],+ transforms = [ defaultLoopVectorize ], dataLayout = moduleDataLayout mIn, targetMachine = Just tm }) mIn