Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
jberryman
GHC
Commits
af7428e8
Commit
af7428e8
authored
Feb 18, 2014
by
Joachim Breitner
Browse files
Call Arity refactoring: fakeBoringCalls
parent
ba4616b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
compiler/simplCore/CallArity.hs
View file @
af7428e8
...
...
@@ -396,21 +396,16 @@ interestingBinds bind =
where
go
(
v
,
e
)
=
exprArity
e
<
length
(
typeArity
(
idType
v
))
boringBinds
::
CoreBind
->
[
Var
]
boringBinds
bind
=
map
fst
$
filter
go
$
case
bind
of
(
NonRec
v
e
)
->
[(
v
,
e
)]
(
Rec
ves
)
->
ves
where
go
(
v
,
e
)
=
exprArity
e
>=
length
(
typeArity
(
idType
v
))
addInterestingBinds
::
VarSet
->
CoreBind
->
VarSet
addInterestingBinds
int
bind
=
int
`
delVarSetList
`
bindersOf
bind
-- Possible shadowing
`
extendVarSetList
`
interestingBinds
bind
addBoringCalls
::
CallArityEnv
->
CoreBind
->
CallArityEnv
addBoringCalls
ae
bind
=
ae
`
lubEnv
`
(
mkVarEnv
$
zip
(
boringBinds
bind
)
(
repeat
topCallCount
))
-- This function pretens a (Many 0) call for every variable bound in the binder
-- that is not interesting, as calls to these are not reported by the analysis.
fakeBoringCalls
::
VarSet
->
CoreBind
->
CallArityEnv
fakeBoringCalls
int
bind
=
mkVarEnv
[
(
v
,
topCallCount
)
|
v
<-
bindersOf
bind
,
not
(
v
`
elemVarSet
`
int
)
]
-- Used for both local and top-level binds
-- First argument is the demand from the body
...
...
@@ -433,7 +428,7 @@ callArityBind ae_body int b@(Rec binds)
where
int_body
=
int
`
addInterestingBinds
`
b
-- We are ignoring calls to boring binds, so we need to pretend them here!
ae_body'
=
ae_body
`
addBoringCalls
`
b
ae_body'
=
ae_body
`
lubEnv
`
(
fakeBoringCalls
int_body
b
)
(
ae_rhs
,
binds'
)
=
callArityFix
ae_body'
int_body
[(
i
,
Nothing
,
e
)
|
(
i
,
e
)
<-
binds
]
final_ae
=
ae_rhs
`
delVarEnvList
`
interestingBinds
b
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment