Restore AllocOptPass in the -O1 scalar optimizer pipeline - #281
Open
rbvermaa wants to merge 1 commit into
Open
Conversation
Backport the `else if (O.getSpeedupLevel() >= 1)` branch of buildScalarOptimizerPipeline that upstream added in JuliaLang#52850 ("Add passes to -O1 pipeline to reduce allocations in reinterpret"). That branch was carried to release-1.10 (JuliaLang#57731) and release-1.11 (JuliaLang#57732) on 2025-03-11, but never landed on release-1.12 — it is present on master, release-1.13 and v1.11.9, and absent on release-1.12, backports-release-1.12 and v1.12.6. We could not find a revert or a rationale for the omission. Without AllocOptPass at -O1, a `Ref` holding an immutable value which never escapes and is used only via `pointer_from_objref` is heap-allocated: julia 1.10.11 -O1 @allocated = 0 julia 1.11.9 -O1 @allocated = 0 julia 1.12.6 -O1 @allocated = 32 <-- regression julia 1.12.6 -O2 @allocated = 0 raicode runs its test suite at -O1 and asserts that several hot paths (TypeNormalization's byte-string hashing and fast_reinterpret, among others) allocate nothing, so -O1 no longer gives a usable "this code does not allocate" signal. Production builds run at -O2/-O3 and are unaffected. The added pass list is byte-identical to v1.11.9's. All six passes are already used elsewhere in this file and their headers are already included, so this adds no new dependencies.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Backports the
else if (O.getSpeedupLevel() >= 1)branch ofbuildScalarOptimizerPipelinethat upstream added in JuliaLang/julia#52850 — "Add passes to-O1pipeline to reduce allocations inreinterpret".Why
That branch was backported to release-1.10 (#57731) and release-1.11 (#57732) on 2025-03-11, but never landed on the 1.12 line:
else if (>= 1)blockv1.11.9masterrelease-1.13v1.12.6release-1.12backports-release-1.12We found no revert on master and no stated rationale for the omission.
#52850merged 2025-02-21 andv1.12.0-rc1was tagged 2025-07-12, so a branch cut after the merge should have inherited it.Effect
Without
AllocOptPassat-O1, aRefholding an immutable value which never escapes and is used only viapointer_from_objrefis heap-allocated:-O1-O2Reproduces on stock and
+RAIbuilds, onaarch64-darwinandx86_64-linux. In the IR the box is a real@ijl_gc_small_allocat-O1and absent at-O2.raicode runs its test suite at
-O1(JULIA_COMMON_ARGS) and asserts several hot paths allocate nothing — TypeNormalization's byte-stringhashandfast_reinterpretuse exactly this idiom deliberately to avoid allocating. So-O1currently gives no usable "this code does not allocate" signal. Production builds run at-O2/-O3and are unaffected.Risk
The added pass list is byte-identical to v1.11.9's. All six passes are already used elsewhere in
src/pipeline.cppand their headers are already included, so this adds no new dependencies. The>= 2branch is untouched, so-O2/-O3codegen is unchanged.Not compiled locally (no build tree) — validation is via raicode's
deps.julia.x86_64-linuxbuild plus the-O1allocation assertions that currently fail.