Pass LocalizeAllActions neglects to prepend a "." to @name annotations that do not have one when it adds global actions into controls #4969
Labels
bug
This behavior is unintended and should be fixed.
control-plane
Topics related to the control-plane or P4Runtime.
When there is an action defined at the top level used in one or more controls, pass LocalizeAllActions creates one copy of this top level action in each control that uses it, and then removes the top level one, in the IR.
When it does this, if the action does not have a @name annotation, it creates one with a "." at the beginning, e.g.
action foo ...
at the top level will become@name(".foo") action foo ...
in each control it is copied into. When P4Runtime API files are generated, the name "foo" will thus be at the top level, not a hierarchical name in each of the controls, e.g. "mycontrol1.foo", "mycontrol2.foo", etc. That is good, and as it should be.However, if the action does have a @name annotation, and that name does not begin with a ".", e.g.
@name("bar") action foo ...
is declared at the top level, then localizeAllActions will create a copy of the action in each control where it is used, but leave the @name unchanged. Later, if P4Runtime API files are generated, this results in one action being created for each copy with hierarchical names, e.g. "mycontrol1.bar", "mycontrol2.bar", etc. This is entirely due to an implementation detail of the LocalizeAllActions pass, and is NOT something the user asked for in their @name annotations.I believe that instead, LocalizeAllActions should prepend a "." to any @name annotation string that does not already have one, when it creates copies of top-level actions within controls.
The text was updated successfully, but these errors were encountered: