summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2018-07-30 13:43:56 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2018-07-31 13:19:43 +0100
commit2110738b280543698407924a16ac92b6d804dc36 (patch)
treef5a5bbb377b4554e99eae18a146894908d88f9d5 /testsuite
parent56590db07a776ce81eb89d4a4d86bd0f953fb44e (diff)
downloadhaskell-2110738b280543698407924a16ac92b6d804dc36.tar.gz
Don't inline functions with RULES too early
Trac #15445 showed that a function with an automatically generated specialisation RULE coudl be inlined before the RULE had a chance to fire. This patch attaches a NOINLINE[2] activation to the Id, to stop this happening.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/simplCore/should_compile/T15445.hs8
-rw-r--r--testsuite/tests/simplCore/should_compile/T15445.stderr13
-rw-r--r--testsuite/tests/simplCore/should_compile/T15445a.hs10
-rw-r--r--testsuite/tests/simplCore/should_compile/all.T1
4 files changed, 32 insertions, 0 deletions
diff --git a/testsuite/tests/simplCore/should_compile/T15445.hs b/testsuite/tests/simplCore/should_compile/T15445.hs
new file mode 100644
index 0000000000..36bf61dbbb
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T15445.hs
@@ -0,0 +1,8 @@
+module T15445 where
+
+import T15445a
+
+
+foo :: IO ()
+foo = do { print (plusTwoRec [1..10 :: Int])
+ ; print (plusTwoRec' [1..20 :: Int]) }
diff --git a/testsuite/tests/simplCore/should_compile/T15445.stderr b/testsuite/tests/simplCore/should_compile/T15445.stderr
new file mode 100644
index 0000000000..d5deac5a59
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T15445.stderr
@@ -0,0 +1,13 @@
+Rule fired: Class op + (BUILTIN)
+Rule fired: Class op fromInteger (BUILTIN)
+Rule fired: integerToInt (BUILTIN)
+Rule fired: SPEC plusTwoRec (T15445a)
+Rule fired: SPEC $fShow[] (GHC.Show)
+Rule fired: Class op >> (BUILTIN)
+Rule fired: Class op show (BUILTIN)
+Rule fired: SPEC plusTwoRec (T15445a)
+Rule fired: Class op enumFromTo (BUILTIN)
+Rule fired: Class op show (BUILTIN)
+Rule fired: Class op enumFromTo (BUILTIN)
+Rule fired: eftIntList (GHC.Enum)
+Rule fired: eftIntList (GHC.Enum)
diff --git a/testsuite/tests/simplCore/should_compile/T15445a.hs b/testsuite/tests/simplCore/should_compile/T15445a.hs
new file mode 100644
index 0000000000..02e5baceb5
--- /dev/null
+++ b/testsuite/tests/simplCore/should_compile/T15445a.hs
@@ -0,0 +1,10 @@
+module T15445a where
+
+{-# SPECIALIZE plusTwoRec :: [Int] -> [Int] #-}
+plusTwoRec :: Num a => [a] -> [a]
+plusTwoRec [] = []
+plusTwoRec (x:xs) = x+2:plusTwoRec xs
+
+plusTwoRec' :: Num a => [a] -> [a]
+plusTwoRec' [] = []
+plusTwoRec' (x:xs) = x+2:plusTwoRec' xs
diff --git a/testsuite/tests/simplCore/should_compile/all.T b/testsuite/tests/simplCore/should_compile/all.T
index d4eaf196df..1275012bf4 100644
--- a/testsuite/tests/simplCore/should_compile/all.T
+++ b/testsuite/tests/simplCore/should_compile/all.T
@@ -317,3 +317,4 @@ test('T15005', normal, compile, ['-O'])
test('T15056', [extra_files(['T15056a.hs']), omit_ways(['profasm'])], multimod_compile, ['T15056', '-O -v0 -ddump-rule-firings'])
test('T15186', normal, multimod_compile, ['T15186', '-v0'])
test('T15453', normal, compile, ['-dcore-lint -O1'])
+test('T15445', normal, multimod_compile, ['T15445', '-v0 -O -ddump-rule-firings'])