build: disable LLVM unroll-add-parallel-reductions on Apple targets#51848
Merged
Conversation
jkleinsc
approved these changes
Jun 2, 2026
|
Release Notes Persisted
|
This was referenced Jun 2, 2026
Contributor
|
I have automatically backported this PR to "42-x-y", please check out #51849 |
Contributor
|
I have automatically backported this PR to "43-x-y", please check out #51850 |
Contributor
|
I have automatically backported this PR to "41-x-y", please check out #51851 |
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.
LLVM's loop unroller miscompiles sub-form reductions when introducing parallel reduction phis (llvm/llvm-project#201065): the partial accumulators are recombined with alternating signs instead of being summed. Under ThinLTO + PGO this miscompiles simdutf's arm64
utf8_length_from_latin1in darwin-arm64/mas-arm64 release builds, undercounting UTF-8 lengths for Latin-1 strings.On Apple Silicon this manifests as (shipped in v42.3.1):
Buffer.byteLength()returning values 2 bytes short for one-byte strings >= 64 chars containing U+0080-U+00FF characters at affected offsetsBuffer.from(string)/TextEncoder.encode()resultsnode::Utf8Value(e.g.fs.writeFileSyncwith such strings >= ~1KB)LLVM only enables the parallel-reduction unrolling for Apple M-like CPUs (
getAppleRuntimeUnrollPreferences), so only Apple targets are affected; linux-arm64 and win-arm64 target generic CPUs and cannot hit this. The flag is applied at link time, where ThinLTO backend codegen runs, and is inert on branches without macOS ThinLTO.Validated on a local release build with the exact CI configuration (ThinLTO + Electron PGO profile): the crash and corruption repros disappear with the flag, the affected loop remains unrolled (single accumulator), and Speedometer 3.1 is unchanged (-0.84%, p=0.48, interleaved A/B).
This patch can be removed once the upstream fix (llvm/llvm-project#201066) ships in the bundled clang.
Notes: Fixed silent data truncation in
Buffer/TextEncoderAPIs and a crash infs.writeFileSyncwith non-ASCII strings on Apple Silicon.