Skip to content

Commit

Permalink
out parameters checked in the right context; fixes p4lang#2175
Browse files Browse the repository at this point in the history
  • Loading branch information
Mihai Budiu committed Mar 18, 2020
1 parent c120950 commit 307cfe4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions frontends/p4/def_use.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ class Definitions : public IHasDbPrint {
/// Set of program points that have written last to each location
/// (conservative approximation).
std::map<const BaseLocation*, const ProgramPoints*> definitions;
/// If true the current program point is actually unreachable and
/// it's definitions should not matter.
/// If true the current program point is actually unreachable.
bool unreachable;

public:
Expand All @@ -357,7 +356,6 @@ class Definitions : public IHasDbPrint {
void dbprint(std::ostream& out) const {
if (unreachable) {
out << " Unreachable";
return;
}
if (definitions.empty())
out << " Empty definitions";
Expand Down Expand Up @@ -414,6 +412,7 @@ class AllDefinitions : public IHasDbPrint {
* @pre Must be executed after variable initializers have been removed.
*
*/

class ComputeWriteSet : public Inspector {
protected:
AllDefinitions* allDefinitions; /// Result computed by this pass.
Expand Down
6 changes: 5 additions & 1 deletion frontends/p4/simplifyDefUse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,14 @@ class FindUninitialized : public Inspector {
BUG_CHECK(findContext<IR::P4Program>() == nullptr, "Unexpected function");
LOG3("FU Visiting function " << func->name << "[" << func->id << "]");
LOG5(func);
auto callingContext = currentPoint;
currentPoint = ProgramPoint(func);
visit(func->body);
bool checkReturn = !func->type->returnType->is<IR::Type_Void>();
checkOutParameters(func, func->type->parameters, getCurrentDefinitions(), checkReturn);
currentPoint = callingContext; // We want the definitions after the function has completed,
// not after the last statement.
auto current = getCurrentDefinitions();
checkOutParameters(func, func->type->parameters, current, checkReturn);
return false;
}

Expand Down

0 comments on commit 307cfe4

Please sign in to comment.