-
Notifications
You must be signed in to change notification settings - Fork 447
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
warn on unused controls/parsers #4440
Conversation
@@ -1,4 +1,7 @@ | |||
issue3379-1.p4(14): [--Wwarn=unused] warning: t4: unused instance | |||
mypackaget<bit>(MyParser1()) t4; | |||
^^ | |||
issue3379-1.p4(3): [--Wwarn=unused] warning: Parser MyParser1 is not used; removing | |||
parser MyParser1(in bit tt) { | |||
^^^^^^^^^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@grg Do you know why Myparser1 is considered unused in this test program?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that is because there is no main
declaration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one question about a warning message for one of the test programs, but if there is a good explanation for that one, the rest all looks good to me.
@jafingerhut / @fruffy: Any thoughts on whether these warnings should be added? I opened a ticket (#4439) to get feedback on this. My opinion is that the extra warnings should be added for consistency. |
I do not have any strong opinions but I think your change makes sense. But what about multi-pipe programs? Do the warnings work correctly here? I guess they should since the parser/control is also removed. |
It works as expected with multi-pipe programs: a warning is emitted only if a control/parser is never used in any of the pipes. If it's used in at least one pipe then no warning is emitted. |
Add warnings for unused P4Control and P4Parser objects to match P4Table warnings. Addresses issue #4439.
Call externalName() to get the control/parser block name without "control"/"parser" prepended to the front.
bfad107
to
9c0fcd1
Compare
@asl / @ChrisDodd Is this proposed change likely to impact either of you negatively? |
I believe we are ok. Cross-checking with @kfcripps |
I see 3 approvals on this. Are we waiting for explicit approval from @ChrisDodd ? |
I've added it to the merge queue. This was put on the back burner last week while I was working on upstreaming the midend def-use pass from Tofino. |
Add warnings for unused P4Control and P4Parser objects to match P4Table warnings. Addresses issue #4439.