From 1a9c95ce0568fa348015c178a1c738704a1ec8b7 Mon Sep 17 00:00:00 2001 From: d0cd Date: Fri, 14 Oct 2022 22:07:03 -0400 Subject: [PATCH] Fix SSA pass --- .../rename_statement.rs | 38 +++++++------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/compiler/passes/src/static_single_assignment/rename_statement.rs b/compiler/passes/src/static_single_assignment/rename_statement.rs index 7f5d59aec7..269935166d 100644 --- a/compiler/passes/src/static_single_assignment/rename_statement.rs +++ b/compiler/passes/src/static_single_assignment/rename_statement.rs @@ -297,30 +297,6 @@ impl StatementConsumer for StaticSingleAssigner<'_> { statements } - /// Consumes the expressions associated with the `FinalizeStatement`, returning the simplified `FinalizeStatement`. - fn consume_finalize(&mut self, input: FinalizeStatement) -> Self::Output { - let mut statements = Vec::new(); - - // Process the arguments, accumulating any statements produced. - let arguments = input - .arguments - .into_iter() - .map(|argument| { - let (argument, stmts) = self.consume_expression(argument); - statements.extend(stmts); - argument - }) - .collect(); - - // Construct and accumulate a simplified finalize statement. - statements.push(Statement::Finalize(FinalizeStatement { - arguments, - span: input.span, - })); - - statements - } - /// Consumes the expressions associated with the `IncrementStatement`, returning a simplified `IncrementStatement`. fn consume_increment(&mut self, input: IncrementStatement) -> Self::Output { // First consume the expression associated with the amount. @@ -351,9 +327,23 @@ impl StatementConsumer for StaticSingleAssigner<'_> { // Consume the return expression. let (expression, mut statements) = self.consume_expression(input.expression); + // Consume the finalize arguments if they exist. + // Process the arguments, accumulating any statements produced. + let finalize_args = input.finalize_args.map(|arguments| { + arguments + .into_iter() + .map(|argument| { + let (argument, stmts) = self.consume_expression(argument); + statements.extend(stmts); + argument + }) + .collect() + }); + // Add the simplified return statement to the list of produced statements. statements.push(Statement::Return(ReturnStatement { expression, + finalize_args, span: input.span, }));