Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
GHC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zubin
GHC
Commits
685ef198
Commit
685ef198
authored
11 years ago
by
Joachim Breitner
Committed by
Joachim Breitner
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add a flag -fnested-cpr-off to conveniently test the effect of nested CPR
parent
1810fe56
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
compiler/basicTypes/Demand.lhs
+18
-9
18 additions, 9 deletions
compiler/basicTypes/Demand.lhs
compiler/main/StaticFlags.hs
+7
-2
7 additions, 2 deletions
compiler/main/StaticFlags.hs
with
25 additions
and
11 deletions
compiler/basicTypes/Demand.lhs
+
18
−
9
View file @
685ef198
...
...
@@ -814,6 +814,7 @@ cprSumRes tag | opt_CprOff = topRes
cprProdRes :: [DmdResult] -> DmdResult
cprProdRes arg_ress
| opt_CprOff = topRes
| opt_NestedCprOff = Converges $ cutCPRResult flatCPRDepth $ RetProd arg_ress
| otherwise = Converges $ cutCPRResult maxCPRDepth $ RetProd arg_ress
getDmdResult :: DmdType -> DmdResult
...
...
@@ -827,6 +828,13 @@ divergeDmdResult r = r `lubDmdResult` botRes
maxCPRDepth :: Int
maxCPRDepth = 3
-- This is the depth we use with -fnested-cpr-off, in order
-- to get precisely the same behaviour as before introduction of nested cpr
-- -fnested-cpr-off can eventually be removed if nested cpr is deemd to be
-- a good thing always.
flatCPRDepth :: Int
flatCPRDepth = 1
-- With nested CPR, DmdResult can be arbitrarily deep; consider
-- data Rec1 = Foo Rec2 Rec2
-- data Rec2 = Bar Rec1 Rec1
...
...
@@ -836,16 +844,17 @@ maxCPRDepth = 3
--
-- So we need to forget information at a certain depth. We do that at all points
-- where we are constructing new RetProd constructors.
cutDmdResult :: Int -> DmdResult -> DmdResult
cutDmdResult 0 _ = topRes
cutDmdResult _ Diverges = Diverges
cutDmdResult n (Converges c) = Converges (cutCPRResult n c)
cutDmdResult n (Dunno c) = Dunno (cutCPRResult n c)
cutCPRResult :: Int -> CPRResult -> CPRResult
cutCPRResult _ NoCPR = NoCPR
cutCPRResult n (RetProd rs) = RetProd (map (cutDmdResult (n-1)) rs)
cutCPRResult _ (RetSum tag) = RetSum tag
cutCPRResult 0 _ = NoCPR
cutCPRResult _ NoCPR = NoCPR
cutCPRResult _ (RetSum tag) = RetSum tag
cutCPRResult n (RetProd rs) = RetProd (map (cutDmdResult (n-1)) rs)
where
cutDmdResult :: Int -> DmdResult -> DmdResult
cutDmdResult 0 _ = topRes
cutDmdResult _ Diverges = Diverges
cutDmdResult n (Converges c) = Converges (cutCPRResult n c)
cutDmdResult n (Dunno c) = Dunno (cutCPRResult n c)
vanillaCprProdRes :: Arity -> DmdResult
vanillaCprProdRes arity = cprProdRes (replicate arity topRes)
...
...
This diff is collapsed.
Click to expand it.
compiler/main/StaticFlags.hs
+
7
−
2
View file @
685ef198
...
...
@@ -27,6 +27,7 @@ module StaticFlags (
-- optimisation opts
opt_NoStateHack
,
opt_CprOff
,
opt_NestedCprOff
,
opt_NoOptCoercion
,
-- For the parser
...
...
@@ -140,7 +141,8 @@ flagsStaticNames :: [String]
flagsStaticNames
=
[
"fno-state-hack"
,
"fno-opt-coercion"
,
"fcpr-off"
"fcpr-off"
,
"fnested-cpr-off"
]
-- We specifically need to discard static flags for clients of the
...
...
@@ -195,10 +197,13 @@ opt_NoDebugOutput = lookUp (fsLit "-dno-debug-output")
opt_NoStateHack
::
Bool
opt_NoStateHack
=
lookUp
(
fsLit
"-fno-state-hack"
)
-- Switch off CPR analysis in the
new
demand analyser
-- Switch off CPR analysis in the demand analyser
opt_CprOff
::
Bool
opt_CprOff
=
lookUp
(
fsLit
"-fcpr-off"
)
opt_NestedCprOff
::
Bool
opt_NestedCprOff
=
lookUp
(
fsLit
"-fnested-cpr-off"
)
opt_NoOptCoercion
::
Bool
opt_NoOptCoercion
=
lookUp
(
fsLit
"-fno-opt-coercion"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment