Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure all unused elements are removed during applyDCEGraphRemovals. NFC #21840

Merged
merged 1 commit into from Apr 30, 2024

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Apr 26, 2024

There were bugs in applyDCEGraphRemovals that were preventing it from finding certain unused exports in certain cases.

This change cleanup up the pass and adds assertions that all unused imports and exports are actually located and removed, thus preventing these types of bugs from sneaking in again.

The test we had for applyDCEGraphRemovals were worked, but they were writing in a slightly different style to the current emscripten output. In particular the export name and JS name were matching, even though the actual compiler output produces JS names that contain a leading underscore. I also updates the tests to match this style for consistency.

I believe the effects of this bug were not captured by our code size tests because they all run closure compiler afterwards which was removing the unused exports itself.

@sbc100 sbc100 requested a review from kripken April 26, 2024 17:56
@sbc100 sbc100 force-pushed the applyDCEGraphRemovals branch 4 times, most recently from c2e4b15 to 6698bc6 Compare April 27, 2024 08:50
tools/acorn-optimizer.mjs Outdated Show resolved Hide resolved
tools/acorn-optimizer.mjs Outdated Show resolved Hide resolved
tools/extract_metadata.py Outdated Show resolved Hide resolved
@sbc100 sbc100 force-pushed the applyDCEGraphRemovals branch 3 times, most recently from 8e901f1 to e458f10 Compare April 29, 2024 23:52
There were bugs in `applyDCEGraphRemovals` that were preventing it from
finding certain unused exports in certain cases.

This change cleanup up the pass and adds assertions that all unused
imports and exports are actually located and removed, thus preventing
these types of bugs from sneaking in again.

The test we had for `applyDCEGraphRemovals` were worked, but they were
writing in a slightly different style to the current emscripten output.
In particular the export name and JS name were matching, even though
the actual compiler output produces JS names that contain a leading
underscore.  I also updates the tests to match this style for
consistency.

I believe the effects of this bug were not captured by our code size
tests because they all run closure compiler afterwards which was
removing the unused exports itself.
@sbc100 sbc100 enabled auto-merge (squash) April 30, 2024 01:08
@sbc100 sbc100 merged commit 63c648f into emscripten-core:main Apr 30, 2024
29 checks passed
@sbc100 sbc100 deleted the applyDCEGraphRemovals branch April 30, 2024 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants