Merged
Conversation
Member
alii
commented
Apr 7, 2026
…threads Replace the single llvm.Object with a PartitionSet of N parallel Builders. Each Nav is assigned to one shard via hash(nav.fqn)%N (with the InternPool nav index appended to disambiguate non-unique fqns). updateFunc/updateNav route to the owning shard under a per-shard mutex; separate_thread is enabled for stage2_llvm so IR construction overlaps Sema and runs N-wide. Each shard emits its own object via parallel toBitcode + opt + emit, and the linkers consume N partition objects (MachO/ELF self-hosted, Lld ELF). Cross-shard linkage: owned navs become external+hidden definitions, others emit matching declarations. Anonymous constants are linkonce_odr so comptime pointer identity is preserved across generic instantiations in different shards. Singletons (error name table, lt_errors_len, module asm) live in shard 0; exports become aliases so cross-shard fqn references stay valid. Extern declarations are deduped by name since genDecl's collision-replace only runs in the owning shard. zig_llvm.cpp: factor the optimization pipeline into runOptimizationPipeline and split the unoptimised module before opt+emit so the existing SplitModule path runs N-wide on the partitions instead of after a serial whole-module opt pass. Hoist target registration before the emit fanout. InternPool: fix three latent races/encodings exposed by Sema running on non-main tids — (1) the cancel/re-acquire pattern in get() for slice ptr_type/ptr/aggregate didn't re-check .existing after re-locking; (2) Key.Func.zir_body_inst_extra_index is borrowed from the generic owner but was indexed via the instance's tid; add zir_body_inst_tid; (3) CaptureValue.idx:u30 cannot hold a Nav.Index encoded with tid_shift_32; repack nav_val/nav_ref via tid_shift_30. Also adds the scaffolding to spawn .analyze_func to worker threads under a recursive sema_lock with per-AnalUnit claims (gated on ZIG_PARALLEL_SEMA; currently serialized pending the WipNamespaceType publish-before-finish window), --llvm-shard-stats, ZIG_JOB_STATS profiling, and -Dllvm-has-polly for linking against an LLVM built with Polly.
…Date/ensure*AnalysisQueued
…ed refs + tls_aip + atomic ns generation
The parallel-sema fast-path in ensureMemoizedStateUpToDate probed .Type/.panic/.assembly, which are written before the rest of their stage, so a thread could observe the stage as 'done' while later entries were still .none. Probe the last entry of each stage instead and pair an acquire load with release stores in analyzeMemoizedState. In zirStructDecl/zirUnionDecl/zirOpaqueDecl and the reify equivalents, wip_ty.finish now runs before remaining failable operations, but the errdefer cancel/destroyNamespace were still active and would tear down an already-published type on a later error. Gate them on a 'published' flag set immediately after finish.
Member
Author
|
@coderabbitai off |
…PerThread: aipRemove on errdefer
…s_mutex, inline_ref_mutex, claim-before-lock)
…all ensure*UpToDate" This reverts commit 23ef5ba.
…r/Align/Init) — bughunt #1
…uard + zirTypeInfo .none retry (FieldEnum)
…ernPool 256 shards" This reverts commit 846b231.
…tiveFailed); phaseTiming hooks
…Struct/UnionInner; outdated_mutex
… IP writes); gate removeDependenciesForDepender
…ling cross-shard undefs)
…ld_new rejects r_extern relocs to local-range symbols)
…s (Apple ld_new rejects r_extern relocs to local-range syms)
|
Caution Review failedPull request was closed or merged during review WalkthroughThis PR introduces LLVM backend partitioning for parallel codegen through a new Changes
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
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.