Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass LocalizeAllActions neglects to prepend a "." to @name annotations that do not have one when it adds global actions into controls #4969

Open
jafingerhut opened this issue Oct 21, 2024 · 0 comments
Assignees
Labels
bug This behavior is unintended and should be fixed. control-plane Topics related to the control-plane or P4Runtime.

Comments

@jafingerhut
Copy link
Contributor

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.

@jafingerhut jafingerhut self-assigned this Oct 21, 2024
@jafingerhut jafingerhut added bug This behavior is unintended and should be fixed. control-plane Topics related to the control-plane or P4Runtime. labels Oct 21, 2024
jafingerhut added a commit to jafingerhut/p4c that referenced this issue Oct 21, 2024
so that it prepends a "." to @name annotations of global actions, if
they do not have one already.

Signed-off-by: Andy Fingerhut <andy_fingerhut@alum.wustl.edu>
@jafingerhut jafingerhut changed the title Pass LocalizeAllActions neglects to prepend a "." to @name annotations that do not have one when it adds actions to controls Pass LocalizeAllActions neglects to prepend a "." to @name annotations that do not have one when it adds global actions into controls Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed. control-plane Topics related to the control-plane or P4Runtime.
Projects
None yet
Development

No branches or pull requests

1 participant