ZAM fix for inlining bug when a local is assigned to a function parameter

This commit is contained in:
Vern Paxson 2023-09-27 14:03:45 -07:00
parent 8f92e0d39b
commit cbc3d9c739
2 changed files with 7 additions and 6 deletions

View file

@ -304,11 +304,11 @@ public:
// True if this expression can be the RHS for a field assignment. // True if this expression can be the RHS for a field assignment.
bool IsFieldAssignable(const Expr* e) const; bool IsFieldAssignable(const Expr* e) const;
// True if the expression will transform to one of another type // True if the expression will transform to one of another AST node
// upon reduction, for non-constant operands. "Transform" means // (perhaps of the same type) upon reduction, for non-constant
// something beyond assignment to a temporary. Necessary so that // operands. "Transform" means something beyond assignment to a
// we know to fully reduce such expressions if they're the RHS // temporary. Necessary so that we know to fully reduce such
// of an assignment. // expressions if they're the RHS of an assignment.
virtual bool WillTransform(Reducer* c) const { return false; } virtual bool WillTransform(Reducer* c) const { return false; }
// The same, but for the expression when used in a conditional context. // The same, but for the expression when used in a conditional context.

View file

@ -1812,8 +1812,9 @@ ExprPtr AssignExpr::Reduce(Reducer* c, StmtPtr& red_stmt)
if ( op2->WillTransform(c) ) if ( op2->WillTransform(c) )
{ {
StmtPtr xform_stmt; StmtPtr xform_stmt;
StmtPtr lhs_stmt = lhs_ref->ReduceToLHS(c);
op2 = op2->ReduceToSingleton(c, xform_stmt); op2 = op2->ReduceToSingleton(c, xform_stmt);
red_stmt = MergeStmts(rhs_reduce, xform_stmt); red_stmt = MergeStmts(lhs_stmt, rhs_reduce, xform_stmt);
return ThisPtr(); return ThisPtr();
} }