Skip to content

Commit

Permalink
fix: don't use dummy location when inserting debug code (#7482)
Browse files Browse the repository at this point in the history
  • Loading branch information
asterite authored Feb 21, 2025
1 parent fd213f6 commit 87196fe
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions compiler/noirc_frontend/src/debug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ impl DebugInstrumenter {
let func_body = &mut func.body.statements;
let mut statements = take(func_body);

self.walk_scope(&mut statements, func.location.span);
self.walk_scope(&mut statements, func.location);

// walk_scope ensures that the last statement is the return value of the function
let last_stmt = statements.pop().expect("at least one statement after walk_scope");
Expand All @@ -139,7 +139,7 @@ impl DebugInstrumenter {

// Modify a vector of statements in-place, adding instrumentation for sets and drops.
// This function will consume a scope level.
fn walk_scope(&mut self, statements: &mut Vec<ast::Statement>, span: Span) {
fn walk_scope(&mut self, statements: &mut Vec<ast::Statement>, location: Location) {
statements.iter_mut().for_each(|stmt| self.walk_statement(stmt));

// extract and save the return value from the scope if there is one
Expand All @@ -166,8 +166,8 @@ impl DebugInstrumenter {
}
};

let span = Span::empty(span.end());
let location = Location::new(span, FileId::dummy());
let span = Span::empty(location.span.end());
let location = Location::new(span, location.file);

// drop scope variables
let scope_vars = self.scope.pop().unwrap_or_default();
Expand Down Expand Up @@ -384,7 +384,7 @@ impl DebugInstrumenter {
match &mut expr.kind {
ast::ExpressionKind::Block(ast::BlockExpression { ref mut statements, .. }) => {
self.scope.push(HashMap::default());
self.walk_scope(statements, expr.location.span);
self.walk_scope(statements, expr.location);
}
ast::ExpressionKind::Prefix(prefix_expr) => {
self.walk_expr(&mut prefix_expr.rhs);
Expand Down

1 comment on commit 87196fe

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 87196fe Previous: c254c3c Ratio
noir-lang_noir_bigcurve_ 335 s 265 s 1.26

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Please sign in to comment.