[GHC] #11651: Allow plugins to define built-in rules

#11651: Allow plugins to define built-in rules -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Conal Eliot has an application in which he wants a plugin to add some new `BuiltinRules` to the `mg_rules` of the `ModGuts` of the module being compiled. He needs a built-in rule (which runs some custom code) rather than a vanilla `CoreRule` (which pattern-matches the argument). But then he got a GHC panic {{{ get a GHC panic: “No match in record selector ru_args”. }}} Turns out it comes from these lines in `OccAnal` {{{ imp_rule_edges = foldr (plusVarEnv_C unionVarSet) emptyVarEnv [ mapVarEnv (const maps_to) (exprFreeIds arg `delVarSetList` ru_bndrs imp_rule) | imp_rule <- imp_rules , let maps_to = exprFreeIds (ru_rhs imp_rule) `delVarSetList` ru_bndrs imp_rule , arg <- ru_args imp_rule ] }}} This code is just working out what locally-defined variables should be kept alive by the `mg_rules` for imported Ids. But `BuiltinRules` don't have any `ru_args`. Easy fix: just don't traverse builtin rules in this scan. In Conal's case, the rules that his plugin adds certainly don't mention locally- defined Ids. I'll do this shortly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11651 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11651: Allow plugins to define built-in rules -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: new Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * priority: normal => highest * milestone: => 8.0.1 Comment: Making high priority for 8.0 because it's a one-line, low-risk change. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11651#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11651: Allow plugins to define built-in rules
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner:
Type: bug | Status: new
Priority: highest | Milestone: 8.0.1
Component: Compiler | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Simon Peyton Jones

#11651: Allow plugins to define built-in rules -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: merge Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by simonpj): * status: new => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11651#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11651: Allow plugins to define built-in rules -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: merge Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- @@ -1,2 +1,2 @@ - Conal Eliot has an application in which he wants a plugin to add some new - `BuiltinRules` to the `mg_rules` of the `ModGuts` of the module being + Conal Elliott has an application in which he wants a plugin to add some + new `BuiltinRules` to the `mg_rules` of the `ModGuts` of the module being New description: Conal Elliott has an application in which he wants a plugin to add some new `BuiltinRules` to the `mg_rules` of the `ModGuts` of the module being compiled. He needs a built-in rule (which runs some custom code) rather than a vanilla `CoreRule` (which pattern-matches the argument). But then he got a GHC panic {{{ get a GHC panic: “No match in record selector ru_args”. }}} Turns out it comes from these lines in `OccAnal` {{{ imp_rule_edges = foldr (plusVarEnv_C unionVarSet) emptyVarEnv [ mapVarEnv (const maps_to) (exprFreeIds arg `delVarSetList` ru_bndrs imp_rule) | imp_rule <- imp_rules , let maps_to = exprFreeIds (ru_rhs imp_rule) `delVarSetList` ru_bndrs imp_rule , arg <- ru_args imp_rule ] }}} This code is just working out what locally-defined variables should be kept alive by the `mg_rules` for imported Ids. But `BuiltinRules` don't have any `ru_args`. Easy fix: just don't traverse builtin rules in this scan. In Conal's case, the rules that his plugin adds certainly don't mention locally- defined Ids. I'll do this shortly. -- Comment (by conal): Fixed spelling of my last name. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11651#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11651: Allow plugins to define built-in rules -------------------------------------+------------------------------------- Reporter: simonpj | Owner: Type: bug | Status: closed Priority: highest | Milestone: 8.0.1 Component: Compiler | Version: 7.10.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged as 934022c088778303fcfac9c63d8c2fd4a4f1fdc2. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11651#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC