-
Notifications
You must be signed in to change notification settings - Fork 452
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
Document the RemoveUnusedDeclarations pass. #548
Document the RemoveUnusedDeclarations pass. #548
Conversation
frontends/p4/unusedDeclarations.h
Outdated
class RemoveAllUnusedDeclarations : public PassManager { | ||
public: | ||
explicit RemoveAllUnusedDeclarations(ReferenceMap* refMap, bool warn = false) { | ||
CHECK_NULL(refMap); | ||
std::set<const IR::Node*> *warned = nullptr; | ||
|
||
// TODO: The @warned set is discarded. Is it necessary, or can it be replaced |
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.
The set is not discarded, it is used as an argument for the RemoveUnusedDeclarations below.
It is the same set for all iterations of the PassRepeated, thus it cannot be replaced with a bool.
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.
Oh I see. This avoids issuing multiple warnings for the same unreferenced extern definition, which is the only thing that can both trigger a warning and persist across multiple rounds.
I'll remove the TODO and add a comment to this effect. Thanks for pointing it out.
frontends/p4/unusedDeclarations.h
Outdated
* - IR::Type_StructLike | ||
* | ||
* If @warned is non-null, unused IR::P4Table and IR::Declaration_Instance | ||
* nodes are stored in @warned if they are unused and removed by this pass. |
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.
In addition, a warning message is emitted only if the declaration was not previously in warned
-- that is in fact the main point of warned
-- to suppress duplicate warnings
fbdefe2
to
a9ca136
Compare
Thanks @mbudiu-vmw and @ChrisDodd. I updated the comments to (a) remove the TODO, which was wrong, and (b) clarify the behavior of the warning list. |
a9ca136
to
44a4dfe
Compare
…o make giveWarning() private, since it is only used inside the pass.
…O comment). Based on feedback from @mbudiu-vmw and @ChrisDodd.
44a4dfe
to
1b19336
Compare
No description provided.