-
Notifications
You must be signed in to change notification settings - Fork 457
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
Remove ReferenceMap from top-level frontend passes #4947
Conversation
RemoveRedundantParsers(ReferenceMap *refMap, TypeMap *typeMap, const RemoveUnusedPolicy &policy) | ||
: PassManager{new TypeChecking(refMap, typeMap, true), | ||
RemoveRedundantParsers(TypeMap *typeMap, const RemoveUnusedPolicy &policy) | ||
: PassManager{new TypeChecking(nullptr, typeMap, true), |
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 missed this in the other PRs but passing in nullptr doesn't seem right to me. Any way to make the constructor safe and just use two parameters? I also ran into this with ConstantFolding, which now has an ambiguous constructor.
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.
Yeah, this logic is pretty confusing, as depending whether refmap is passed or not the TypeChecking
also runs ResolveReferences
. And lots of passes rely on this.
But I think now we can add typemap-only constructor. And ensure that refmap is non-null on all other paths.
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.
Thanks for all these changes!
I'm not sure about the changes to evaluator in frontend and inlining. From the comment in inlining, it seems like the pass itself does not need to re-run evaluator, that it is just to update its state for future use. But then the evaluator is not used again if it is not passed into Inlining. Also in the frontend, the evaluator "result" is not used.
As Evaluator
is an inspector, presumably running it does not change anything, do we even need it in Frontend? Or is it because of errors it can produce? There seems to be just one...
p4c/frontends/p4/evaluator/evaluator.cpp
Lines 133 to 134 in 7009f96
::P4::error(ErrorType::ERR_INVALID, "%1%: Cannot evaluate to a compile-time constant", | |
arg->expression); |
Yeah, I was confused as well. And applied the common logic: if something looks incomplete, then probably there is a downstream code that uses / changes this. So, I tried to keep the existing logic as much as possible. The Evaluator itself is a bit special:
The inliner ( I think we'd can just remove it from |
I think I addressed the majority of review comments. @fruffy I'm going to do |
Oh, I missed that inliner runs as |
8f3dce3
to
6df3cde
Compare
@smolkaj Any idea whether the Bazel failures are spurious or require a change? |
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Signed-off-by: Anton Korobeynikov <[email protected]>
Finally, this removes ReferenceMap from top-level frontend passes:
ResolveReferences
CheckShadow
to executeResolveReferences
with shadow check enabled (and with "local" refmap)