diff options
author | Joachim Breitner <mail@joachim-breitner.de> | 2014-01-26 11:36:23 +0000 |
---|---|---|
committer | Joachim Breitner <mail@joachim-breitner.de> | 2014-11-02 19:03:28 +0100 |
commit | c271e32eac65ee95ba1aacc72ed1b24b58ef17ad (patch) | |
tree | fc9ea34e09f44452b4e6328cbe665b30a3e40ee5 /testsuite | |
parent | c001bde73e38904ed161b0b61b240f99a3b6f48d (diff) | |
download | haskell-c271e32eac65ee95ba1aacc72ed1b24b58ef17ad.tar.gz |
Add GHC.Prim.oneShot
to allow the programer to explictitly set the oneShot flag. This helps
with #7994 and will be used in left folds. Also see
https://ghc.haskell.org/trac/ghc/wiki/OneShot
This commit touches libraries/base/GHC/Event/Manager.hs (which used to
have a local definition of the name oneShot) to avoid a shadowing error.
Differential Revision: https://phabricator.haskell.org/D392
Diffstat (limited to 'testsuite')
-rw-r--r-- | testsuite/.gitignore | 1 | ||||
-rw-r--r-- | testsuite/tests/simplCore/prog003/Makefile | 3 | ||||
-rw-r--r-- | testsuite/tests/simplCore/prog003/OneShot1.hs | 21 | ||||
-rw-r--r-- | testsuite/tests/simplCore/prog003/OneShot2.hs | 24 | ||||
-rw-r--r-- | testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr | 21 | ||||
-rw-r--r-- | testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/simplCore/prog003/test.T | 7 |
7 files changed, 78 insertions, 0 deletions
diff --git a/testsuite/.gitignore b/testsuite/.gitignore index ce5c2c266e..231897c101 100644 --- a/testsuite/.gitignore +++ b/testsuite/.gitignore @@ -1368,6 +1368,7 @@ mk/ghcconfig*_inplace_bin_ghc-stage2.exe.mk /tests/safeHaskell/safeLanguage/SafeLang13 /tests/safeHaskell/safeLanguage/SafeLang15 /tests/safeHaskell/unsafeLibs/BadImport02 +/tests/simplCore/prog003/simplCore.oneShot /tests/simplCore/should_compile/T3055.simpl /tests/simplCore/should_compile/T4138.simpl /tests/simplCore/should_compile/T7702plugin/pkg.T7702/ diff --git a/testsuite/tests/simplCore/prog003/Makefile b/testsuite/tests/simplCore/prog003/Makefile new file mode 100644 index 0000000000..9101fbd40a --- /dev/null +++ b/testsuite/tests/simplCore/prog003/Makefile @@ -0,0 +1,3 @@ +TOP=../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk diff --git a/testsuite/tests/simplCore/prog003/OneShot1.hs b/testsuite/tests/simplCore/prog003/OneShot1.hs new file mode 100644 index 0000000000..3f6589acd1 --- /dev/null +++ b/testsuite/tests/simplCore/prog003/OneShot1.hs @@ -0,0 +1,21 @@ +module OneShot1 where + +import GHC.Base + +-- This oneShot is a lie, and together with unsafePerformIO (in the form of +-- trace) in OneShot2, we can observe the difference. + +-- Two modules to ensure that oneShot annotations surive interface files, both +-- in explicits unfoldings (foo) and in unannotated functions (baz) + +foo :: Int -> Int -> Int +foo y = oneShot (\x -> x+y) +{-# INLINE foo #-} + +bar :: Int -> Int -> Int +bar y = (\x -> y+x) +{-# INLINE bar #-} + +baz :: Int -> Int -> Int +baz y = oneShot (\x -> x+y) + diff --git a/testsuite/tests/simplCore/prog003/OneShot2.hs b/testsuite/tests/simplCore/prog003/OneShot2.hs new file mode 100644 index 0000000000..9d2052a1d4 --- /dev/null +++ b/testsuite/tests/simplCore/prog003/OneShot2.hs @@ -0,0 +1,24 @@ +import OneShot1 +import System.Environment +import Debug.Trace + +p n = trace "p evaluated" (n > 0) +{-# NOINLINE p #-} + +summap :: (Int -> Int) -> (Int -> Int) +summap f n = sum $ map f [1..10] +{-# NOINLINE summap #-} + +foo' n = if p n then foo n else foo (n+1) +{-# NOINLINE foo' #-} + +bar' n = if p n then bar n else bar (n+1) +{-# NOINLINE bar' #-} + +baz' n = if p n then baz n else baz (n+1) +{-# NOINLINE baz' #-} + +main = do + n <- length `fmap` getArgs + print $ summap (foo' n) n + summap (bar' n) n + summap (baz' n) n + diff --git a/testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr b/testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr new file mode 100644 index 0000000000..b288d52e93 --- /dev/null +++ b/testsuite/tests/simplCore/prog003/simplCore.oneShot.stderr @@ -0,0 +1,21 @@ +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated +p evaluated diff --git a/testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout b/testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout new file mode 100644 index 0000000000..6bb2f98fb0 --- /dev/null +++ b/testsuite/tests/simplCore/prog003/simplCore.oneShot.stdout @@ -0,0 +1 @@ +195 diff --git a/testsuite/tests/simplCore/prog003/test.T b/testsuite/tests/simplCore/prog003/test.T new file mode 100644 index 0000000000..387bd20508 --- /dev/null +++ b/testsuite/tests/simplCore/prog003/test.T @@ -0,0 +1,7 @@ +test('simplCore.oneShot', + [ only_ways(['optasm']), + extra_clean(['OneShot1.hi', 'OneShot1.o', + 'OneShot2.hi', 'OneShot2.o']), + ], + multimod_compile_and_run, + ['OneShot2', '-v0']) |