| ... |
... |
@@ -653,9 +653,7 @@ specProgram guts@(ModGuts { mg_module = this_mod |
|
653
|
653
|
-- Easiest thing is to do it all at once, as if all the top-level
|
|
654
|
654
|
-- decls were mutually recursive
|
|
655
|
655
|
; let top_env = SE { se_subst = Core.mkEmptySubst $
|
|
656
|
|
- mkInScopeSetBndrs binds
|
|
657
|
|
- -- mkInScopeSetList $
|
|
658
|
|
- -- bindersOfBinds binds
|
|
|
656
|
+ mkInScopeSetBndrs binds
|
|
659
|
657
|
, se_module = this_mod
|
|
660
|
658
|
, se_rules = rule_env
|
|
661
|
659
|
, se_dflags = dflags }
|
| ... |
... |
@@ -804,24 +802,24 @@ spec_imports :: SpecEnv -- Passed in so that all top-level Ids are in s |
|
804
|
802
|
, [CoreBind] ) -- Specialised bindings
|
|
805
|
803
|
spec_imports env callers dict_binds calls
|
|
806
|
804
|
= do { let import_calls = dVarEnvElts calls
|
|
807
|
|
--- ; debugTraceMsg (text "specImports {" <+>
|
|
808
|
|
--- vcat [ text "calls:" <+> ppr import_calls
|
|
809
|
|
--- , text "dict_binds:" <+> ppr dict_binds ])
|
|
|
805
|
+ ; debugTraceMsg (text "specImports {" <+>
|
|
|
806
|
+ vcat [ text "calls:" <+> ppr import_calls
|
|
|
807
|
+ , text "dict_binds:" <+> ppr dict_binds ])
|
|
810
|
808
|
; (env, rules, spec_binds) <- go env import_calls
|
|
811
|
|
--- ; debugTraceMsg (text "End specImports }" <+> ppr import_calls)
|
|
812
|
|
---
|
|
|
809
|
+ ; debugTraceMsg (text "End specImports }" <+> ppr import_calls)
|
|
|
810
|
+
|
|
813
|
811
|
; return (env, rules, spec_binds) }
|
|
814
|
812
|
where
|
|
815
|
813
|
go :: SpecEnv -> [CallInfoSet] -> CoreM (SpecEnv, [CoreRule], [CoreBind])
|
|
816
|
814
|
go env [] = return (env, [], [])
|
|
817
|
815
|
go env (cis : other_calls)
|
|
818
|
816
|
= do {
|
|
819
|
|
--- debugTraceMsg (text "specImport {" <+> vcat [ ppr cis
|
|
820
|
|
--- , text "callers" <+> ppr callers
|
|
821
|
|
--- , text "dict_binds" <+> ppr dict_binds ])
|
|
|
817
|
+ debugTraceMsg (text "specImport {" <+> vcat [ ppr cis
|
|
|
818
|
+ , text "callers" <+> ppr callers
|
|
|
819
|
+ , text "dict_binds" <+> ppr dict_binds ])
|
|
822
|
820
|
; (env, rules1, spec_binds1) <- spec_import env callers dict_binds cis
|
|
823
|
|
--- ; debugTraceMsg (text "specImport }" <+> ppr cis)
|
|
824
|
|
---
|
|
|
821
|
+ ; debugTraceMsg (text "specImport }" <+> ppr cis)
|
|
|
822
|
+
|
|
825
|
823
|
; (env, rules2, spec_binds2) <- go env other_calls
|
|
826
|
824
|
; return (env, rules1 ++ rules2, spec_binds1 ++ spec_binds2) }
|
|
827
|
825
|
|
| ... |
... |
@@ -837,7 +835,7 @@ spec_import :: SpecEnv -- Passed in so that all top-level Ids are |
|
837
|
835
|
, [CoreBind] ) -- Specialised bindings
|
|
838
|
836
|
spec_import env callers dict_binds cis@(CIS fn _)
|
|
839
|
837
|
| isIn "specImport" fn callers
|
|
840
|
|
- = do { -- debugTraceMsg (text "specImport1-bad" <+> (ppr fn $$ text "callers" <+> ppr callers))
|
|
|
838
|
+ = do { debugTraceMsg (text "specImport1-bad" <+> (ppr fn $$ text "callers" <+> ppr callers))
|
|
841
|
839
|
; return (env, [], []) }
|
|
842
|
840
|
-- No warning. This actually happens all the time
|
|
843
|
841
|
-- when specialising a recursive function, because
|
| ... |
... |
@@ -845,7 +843,7 @@ spec_import env callers dict_binds cis@(CIS fn _) |
|
845
|
843
|
-- call to the original function
|
|
846
|
844
|
|
|
847
|
845
|
| null good_calls
|
|
848
|
|
- = do { -- debugTraceMsg (text "specImport1-no-good" <+> (ppr cis $$ text "dict_binds" <+> ppr dict_binds))
|
|
|
846
|
+ = do { debugTraceMsg (text "specImport1-no-good" <+> (ppr cis $$ text "dict_binds" <+> ppr dict_binds))
|
|
849
|
847
|
; return (env, [], []) }
|
|
850
|
848
|
|
|
851
|
849
|
| Just rhs <- canSpecImport dflags fn
|
| ... |
... |
@@ -855,12 +853,12 @@ spec_import env callers dict_binds cis@(CIS fn _) |
|
855
|
853
|
; eps_rules <- getExternalRuleBase
|
|
856
|
854
|
; let rule_env = se_rules env `updExternalPackageRules` eps_rules
|
|
857
|
855
|
|
|
858
|
|
--- ; debugTraceMsg (text "specImport1" <+> vcat
|
|
859
|
|
--- [ text "function:" <+> ppr fn
|
|
860
|
|
--- , text "good calls:" <+> ppr good_calls
|
|
861
|
|
--- , text "existing rules:" <+> ppr (getRules rule_env fn)
|
|
862
|
|
--- , text "rhs:" <+> ppr rhs
|
|
863
|
|
--- , text "dict_binds:" <+> ppr dict_binds ])
|
|
|
856
|
+ ; debugTraceMsg (text "specImport1" <+> vcat
|
|
|
857
|
+ [ text "function:" <+> ppr fn
|
|
|
858
|
+ , text "good calls:" <+> ppr good_calls
|
|
|
859
|
+ , text "existing rules:" <+> ppr (getRules rule_env fn)
|
|
|
860
|
+ , text "rhs:" <+> ppr rhs
|
|
|
861
|
+ , text "dict_binds:" <+> ppr dict_binds ])
|
|
864
|
862
|
|
|
865
|
863
|
; (rules1, spec_pairs, MkUD { ud_binds = dict_binds1, ud_calls = new_calls })
|
|
866
|
864
|
<- runSpecM $ specCalls True env (getRules rule_env fn) good_calls fn rhs
|
| ... |
... |
@@ -877,12 +875,12 @@ spec_import env callers dict_binds cis@(CIS fn _) |
|
877
|
875
|
`bringFloatedDictsIntoScope` dict_binds1
|
|
878
|
876
|
|
|
879
|
877
|
-- Now specialise any cascaded calls
|
|
880
|
|
--- ; debugTraceMsg (text "specImport 2" <+> vcat
|
|
881
|
|
--- [ text "function:" <+> ppr fn
|
|
882
|
|
--- , text "rules1:" <+> ppr rules1
|
|
883
|
|
--- , text "spec_binds1" <+> ppr spec_binds1
|
|
884
|
|
--- , text "dict_binds1" <+> ppr dict_binds1
|
|
885
|
|
--- , text "new_calls" <+> ppr new_calls ])
|
|
|
878
|
+ ; debugTraceMsg (text "specImport 2" <+> vcat
|
|
|
879
|
+ [ text "function:" <+> ppr fn
|
|
|
880
|
+ , text "rules1:" <+> ppr rules1
|
|
|
881
|
+ , text "spec_binds1" <+> ppr spec_binds1
|
|
|
882
|
+ , text "dict_binds1" <+> ppr dict_binds1
|
|
|
883
|
+ , text "new_calls" <+> ppr new_calls ])
|
|
886
|
884
|
|
|
887
|
885
|
; (env, rules2, spec_binds2)
|
|
888
|
886
|
<- spec_imports new_env (fn:callers)
|
| ... |
... |
@@ -896,8 +894,8 @@ spec_import env callers dict_binds cis@(CIS fn _) |
|
896
|
894
|
|
|
897
|
895
|
| otherwise
|
|
898
|
896
|
= do {
|
|
899
|
|
--- debugTraceMsg (hang (text "specImport1-missed")
|
|
900
|
|
--- 2 (vcat [ppr cis, text "can-spec" <+> ppr (canSpecImport dflags fn)]))
|
|
|
897
|
+ debugTraceMsg (hang (text "specImport1-missed")
|
|
|
898
|
+ 2 (vcat [ppr cis, text "can-spec" <+> ppr (canSpecImport dflags fn)]))
|
|
901
|
899
|
; tryWarnMissingSpecs dflags callers fn good_calls
|
|
902
|
900
|
; return (env, [], [])}
|
|
903
|
901
|
|