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

Fix for issue #270 #271

Merged
merged 7 commits into from
Feb 2, 2017
Merged

Fix for issue #270 #271

merged 7 commits into from
Feb 2, 2017

Conversation

mihaibudiu
Copy link
Contributor

This is reworking an older fix which proved to be incomplete; this code does some copy propagation only in the control which does checksum updates. It takes advantage of the fact that we only allow very restricted code in this control - the only method that can be called is the checksum.get() method.

The code can now handle multiple checksum units. It is not foolproof; some hand-written code patterns can trip it - the foolproof solution should probably use an extern in the BMv2 simulator for checksum calculations.

(I really don't know why the changes to the tableKeyNames.cpp file are in this PR; I should have done a rebase.)

auto result = new VariableDefinitions();
result->writers = writers;
return result;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems cleaner to use the copy ctor here, so the body would be just

return new VariableDefinitions(*this);

auto result = clone();
for (auto e : other->writers)
result->writers.emplace(e);
return result;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If e.first (the string) already has an entry in writers, then this won't actually do anything -- shouldn't it be unioning the sets in this case? Or can it never happen (should probably add a BUG_CHECK if so)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bug, I will submit a patch.

// analysis is run. We take advantage that some more complex code
// patterns have already been eliminated.
class Accesses : public Inspector {
PathSubstitutions* substitutions;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ControlFlowVisitor here would make the special handling of IfStatement (and other control flow constructs) below unnecessary. Using P4WriteContext would obviate the need for the special handling of assignments, as well as make the code (potentially) work for out params of method calls.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right about this; however, we only have 1 example using P4WriteContext in the compiler, and it is currently not working correctly - this is issue #242. So I have resorted to using a more explicit approach.

I am also relying on the fact that on this architecture you cannot call methods with out arguments in the checksum verification stage.

if (prev == writers.end())
result->writers[e.first] = e.second;
else
result->writers[e.first] = prev->second->join(e.second);
Copy link
Contributor

@ChrisDodd ChrisDodd Feb 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be just

auto &prev = result->writers[e.first];
prev = prev ? prev->join(e.second) : e.second;

could be even simpler if you didn't have the (unnecessary?) extra level of pointer in the map

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants