Skip to content

Comments

fix(minifier): inline multiple variable declarations at once#13477

Merged
graphite-app[bot] merged 1 commit intomainfrom
08-31-fix_minifier_inline_multiple_variable_declarations_at_once
Aug 31, 2025
Merged

fix(minifier): inline multiple variable declarations at once#13477
graphite-app[bot] merged 1 commit intomainfrom
08-31-fix_minifier_inline_multiple_variable_declarations_at_once

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Aug 31, 2025

Codes like:

var a1 = 'a1'
var a2 = 'a2'
var a3 = 'a3'
var arr = [
  a1,
  a2,
  a3,
]
console.log(arr)

was not processed at once for DCE because DCE does not join variable declarations.
This PR fixes that.

Copy link
Member Author

sapphi-red commented Aug 31, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-minifier Area - Minifier C-bug Category - Bug labels Aug 31, 2025
@sapphi-red sapphi-red changed the base branch from 08-31-feat_minifier_return_total_iterations_ran_for_dce_as_well to graphite-base/13477 August 31, 2025 13:19
@sapphi-red sapphi-red force-pushed the graphite-base/13477 branch from 7c96301 to 5990f17 Compare August 31, 2025 13:19
@sapphi-red sapphi-red force-pushed the 08-31-fix_minifier_inline_multiple_variable_declarations_at_once branch from ff4180d to ff425d0 Compare August 31, 2025 13:19
@sapphi-red sapphi-red changed the base branch from graphite-base/13477 to main August 31, 2025 13:19
@sapphi-red sapphi-red marked this pull request as ready for review August 31, 2025 13:22
Copilot AI review requested due to automatic review settings August 31, 2025 13:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a dead code elimination (DCE) issue where multiple variable declarations were not inlined in a single pass. The minifier now iteratively processes variable declarations to fully inline multiple unused variables at once, improving the optimization efficiency.

  • Modified the inlining logic to use a loop instead of single-pass processing
  • Added comprehensive test coverage for the multi-iteration DCE scenario
  • Changed return logic to track whether any inlining occurred across iterations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
crates/oxc_minifier/src/peephole/minimize_statements.rs Updated variable inlining logic to process multiple declarations iteratively
crates/oxc_minifier/tests/peephole/dead_code_elimination.rs Added test case with 20 variables to verify multi-iteration DCE behavior

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 31, 2025

CodSpeed Instrumentation Performance Report

Merging #13477 will not alter performance

Comparing 08-31-fix_minifier_inline_multiple_variable_declarations_at_once (946669b) with main (ecf69bb)1

Summary

✅ 37 untouched benchmarks

Footnotes

  1. No successful run was found on main (78dcfc6) during the generation of this report, so ecf69bb was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Aug 31, 2025
Copy link
Member

Boshen commented Aug 31, 2025

Merge activity

Codes like:
```js
var a1 = 'a1'
var a2 = 'a2'
var a3 = 'a3'
var arr = [
  a1,
  a2,
  a3,
]
console.log(arr)
```
was not processes at once for DCE because DCE does not join variable declarations.
This PR fixes that.
@graphite-app graphite-app bot force-pushed the 08-31-fix_minifier_inline_multiple_variable_declarations_at_once branch from ff425d0 to 946669b Compare August 31, 2025 15:09
@graphite-app graphite-app bot merged commit 946669b into main Aug 31, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 08-31-fix_minifier_inline_multiple_variable_declarations_at_once branch August 31, 2025 15:15
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants