Backports for 1.13.0-beta2#60614
Merged
KristofferC merged 34 commits intorelease-1.13from Feb 3, 2026
Merged
Conversation
(cherry picked from commit 8101956)
(cherry picked from commit 42ad41c)
(cherry picked from commit d1b898d)
Moving out closures into separate functions, using `@lock` instead of `lock() do`. (cherry picked from commit 915a892)
(cherry picked from commit f20e754)
…60615) Co-authored-by: KristofferC <1282691+KristofferC@users.noreply.github.com>
04dbf3f to
3fb442e
Compare
…#60700) Stdlib: SparseArrays URL: https://github.com/JuliaSparse/SparseArrays.jl.git Stdlib branch: release-1.13 Julia branch: backports-release-1.13 Old commit: 26c80c8 New commit: 6b7e9ef Julia version: 1.13.0-beta1 SparseArrays version: 1.13.0 Bump invoked by: @dkarrasch Powered by: [BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl) Diff: JuliaSparse/SparseArrays.jl@26c80c8...6b7e9ef ``` $ git log --oneline 26c80c8..6b7e9ef 6b7e9ef Backports to release v1.13 (#665) 0a37c0c Update CI workflow for Julia and checkout action (#659) 1216e80 Separate out tests for the GPL build and do not run them when GPL libs are not present (#658) 0f0cd32 Remove more bounds checks (#661) d53ae09 Fix generic sparse-dense multiplication (#663) ``` Co-authored-by: dkarrasch <26658441+dkarrasch@users.noreply.github.com>
(cherry picked from commit 657273a)
We store the previous scope in the eh_state and thus hide it from GC. This means we need to manually preserve that scope across the `try ... catch`, instead fo the new scope that we switch to. --------- Co-authored-by: Nathan Daly <nathan.daly@relational.ai> Co-authored-by: Keno Fischer <keno@juliacomputing.com> (cherry picked from commit f22ae77)
## Summary This PR fixes the performance regression where `@fastmath x^2` for `Float32` was not being inlined to efficient LLVM code, unlike `Float64`. ## Problem As reported in #60639, `@fastmath x^2` for `Float32` was falling back to `power_by_squaring` instead of using the LLVM `powi` intrinsic. This resulted in: - Unnecessary function calls instead of inline multiplication - Potential type promotion to `Float64` - Suboptimal generated code compared to `Float64` Before this fix, `@code_llvm @fastmath Float32(1.5)^2` would show calls to `power_by_squaring`, while `Float64` correctly used the `llvm.powi` intrinsic. ## Solution Added the missing `pow_fast` methods for `Float32` and `Float16`: - `pow_fast(::Float32, ::Int32)` - uses `llvm.powi.f32.i32` intrinsic directly - `pow_fast(::Float32, ::Integer)` - wrapper that converts to `Int32` when safe, matching the `Float64` pattern - `pow_fast(::Float16, ::Integer)` - converts to `Float32`, computes, and converts back This mirrors the existing implementation for `Float64` which already used `llvm.powi.f64.i32`. ## Testing Added a regression test that verifies `@fastmath x^2` generates inline `fmul` instructions (not `power_by_squaring` calls) for `Float16`, `Float32`, and `Float64`. Fixes #60639 --------- Co-authored-by: Oscar Smith <oscardssmith@gmail.com> (cherry picked from commit f34d5f2)
This gets rid of the following JET warnings (present on julia 1.13.0-beta1 with JET aviatesk/JET.jl@377fa53 (see aviatesk/JET.jl#796 why I did not use a released version), no longer present with this patch applied onto julia 1.13.0-beta1) ```julia julia> @report_call Base.process_backtrace(Base.stacktrace(Base.backtrace())) [ Info: tracking Base ┌ Warning: skipping var"#sprint#423"(context, sizehint::Integer, ::typeof(sprint), f::Function, args...) @ Base strings/io.jl:102 to avoid parsing too much code └ @ Revise ~/.julia/packages/Revise/icvyF/src/packagedef.jl:1344 ═════ 3 possible errors found ═════ ┌ process_backtrace(t::Vector{Base.StackTraces.StackFrame}) @ Base ./errorshow.jl:1094 │┌ process_backtrace(tracecount::Vector{Any}) @ Base ./errorshow.jl:1100 ││┌ _backtrace_collapse_repeated_locations!(trace::Vector{Any}) @ Base ./errorshow.jl:1048 │││┌ sprint(f::typeof(show), args::Base.StackTraces.StackFrame) @ Base ./strings/io.jl:102 ││││┌ sprint(f::typeof(show), args::Base.StackTraces.StackFrame; context::Nothing, sizehint::Int64) @ Base ./strings/io.jl:109 │││││┌ show(io::IOBuffer, frame::Base.StackTraces.StackFrame) @ Base.StackTraces ./stacktraces.jl:331 ││││││┌ show_spec_linfo(io::IOBuffer, frame::Base.StackTraces.StackFrame) @ Base.StackTraces ./stacktraces.jl:282 │││││││┌ show_custom_spec_sig(io::IOBuffer, owner::Any, linfo::Core.CodeInstance, frame::Base.StackTraces.StackFrame) @ Base.StackTraces ./stacktraces.jl:298 ││││││││ no matching method found `show_spec_sig(::IOBuffer, ::Module, ::Any)` (1/2 union split): Base.StackTraces.show_spec_sig(io::IOBuffer, mi.def::Union{Method, Module}, mi.specTypes::Any) │││││││└──────────────────── ││││││┌ show_spec_linfo(io::IOBuffer, frame::Base.StackTraces.StackFrame) @ Base.StackTraces ./stacktraces.jl:286 │││││││┌ getproperty(x::Nothing, f::Symbol) @ Base ./Base_compiler.jl:57 ││││││││ invalid builtin function call: getfield(x::Nothing, f::Symbol) │││││││└──────────────────── ││││││┌ show_spec_linfo(io::IOBuffer, frame::Base.StackTraces.StackFrame) @ Base.StackTraces ./stacktraces.jl:286 │││││││ no matching method found `show_spec_sig(::IOBuffer, ::Nothing, ::Any)` (1/2 union split): Base.StackTraces.show_spec_sig(io::IOBuffer, def::Union{Nothing, Method}, (Base.StackTraces.frame_mi(frame::Base.StackTraces.StackFrame)::Union{Nothing, Core.MethodInstance}).specTypes::Any) ││││││└──────────────────── ``` It would be great to get this backported to 1.12 and 1.13. cc @fingolfin (cherry picked from commit 57d5fb1)
This might cause double frees/use after frees. Found on the mimalloc PR (cherry picked from commit 06def89)
Since this task's stack or scope field could have been modified after it was marked by an incremental collection (and not just for copy stacks), move the barrier back unconditionally here. --------- Co-authored-by: Valentin Churavy <v.churavy@gmail.com> Co-authored-by: Jeff Bezanson <jeff.bezanson@gmail.com> (cherry picked from commit 14ca1ab)
…60720) We're currently excepting callers of `addExternalModule` to provide modules with a DL that contains NI tags: ``` ERROR: LoadError: LLVM error: Added modules have incompatible data layouts: e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32 (module) vs e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-n32:64-S128-Fn32-ni:10:11:12:13 (jit) ``` Doing so is invalid and asserts later during compilation: ``` Assertion failed: (Target.isCompatibleDataLayout(getDataLayout()) && "Can't create a MachineFunction using a Module with a " "Target-incompatible DataLayout attached\n"), function init, file /workspace/srcdir/llvm-project/llvm/lib/CodeGen/MachineFunction.cpp, line 248. ``` The NI tags are stripped during optimization, and modules passed to `addExternalModule` are expected to be optimized as they are passed straight to the JIT (as opposed to `addModule`), so we should make sure to use the correct data layout. (cherry picked from commit 3a884a7)
(cherry picked from commit 23a98ff)
Inherit alignment from the original GC allocation with JL_SMALL_BYTE_ALIGNMENT as the minimum. Use alignment-sized integer chunks for the alloca type (matching emit_static_alloca) so SROA splits allocations into aligned pieces for better performance and vectorization. Also adds the missing setAlignment call in splitOnStack. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> (cherry picked from commit 54fde7e)
~~(I wrote this with assistance from Gemini since I'm not very used to writing LLVM IR)~~ No longer using that code This is an attempt to fix #60441. After bumbling around a bit, it seems that the problem is that `invoke(f, ::CodeInstance, args...)` calls are not turned into `Expr(:invoke` statements in the IR, but remains as `:call`s to the `invoke` builtin which ends up going through the runtime. ~~There's probably a better way to do this, but the way I found was to just detect these builtin calls in the LLVM IR, and send them to `emit_invoke`.~~ I'm now detecting `InvokeCICallInfo`s in the inlining step of the optimizer and turning those into `Expr(:invoke`s. It appears to resolve the issue: ```julia using BenchmarkTools mysin(x::Float64) = sin(x) @Assert mysin(1.0) == sin(1.0) const mysin_ci = Base.specialize_method(Base._which(Tuple{typeof(mysin), Float64})).cache ``` Before this PR: ```julia julia> @Btime invoke(mysin, mysin_ci, x) setup=(x=rand()) 24.952 ns (2 allocations: 32 bytes) 0.7024964043721993 ``` After this PR: ```julia julia> @Btime invoke(mysin, mysin_ci, x) setup=(x=rand()) 4.748 ns (0 allocations: 0 bytes) 0.32283046823183426 ``` (cherry picked from commit e1dda38)
We were missing handling for the case where the binding that we're using is ambiguous. There are two possible behaviors: 1. The ambiguous binding gets ignored for the purpose of resolution 2. The ambiguity poisons and the imported binding is also ambiguous Current behavior between these two depends on resolution order (which is bad and part of what the assert was complaining about). This decides that case #2 is the correct behavior and fixes #60659. (cherry picked from commit 0f275e3)
During incremental compaction a forwarded NewSSAValue with a negative id was treated like an SSAValue, producing SSAValue(-n) and tripping `renumber_ssa2` bounds checks. Only convert NewSSAValue to SSAValue when the id is positive, so new_new_nodes references remain valid. Fixes #57827.
Found by claude-code debugging a random zygote issue: SciML/NeuralPDE.jl#1020 (comment). `spvals` just doesn't exist within this function. This issue has apparently existed since Julia 1.6
`MustAlias` has `has_extended_unionsplit(::MustAliasLattice) === true` so it is treated as a target for union split, but `uniontypes` does not handle `MustAlias` specially, causing union split to fail for `MustAlias`. This issue is addressed by always applying `uniontypes` to the result of `widenconst(x)`. External custom lattice implementations could previously provide their own `uniontypes`, but it would be cleaner interface design if they just overload `widenconst` for their custom lattice elements so that it returns `Union`-type.
(cherry picked from commit 2db36c1)
That is, if it is called twice (e.g. because precompilation is disabled) with identical arguments, then this should not trigger an assertion. This should resolve oscar-system/GAP.jl#1314 (cherry picked from commit 1708d99)
(cherry picked from commit 99a8a7a)
Because `TOML` is used in the tests: https://github.com/JuliaLang/julia/blob/b51d41ac753f46a3529f47fe3c6638895cf97c6d/stdlib/Artifacts/test/runtests.jl#L6-L6 Noticed in PkgEval ([log](https://s3.amazonaws.com/julialang-reports/nanosoldier/pkgeval/by_hash/a6a3237_vs_63406df/Artifacts.primary.log)) (cherry picked from commit ed71c10)
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.
Backported PRs:
Core.Boxin stdlibs and Base. #60490Core.Boxin Base. #60515Core.Boxin Base (and Compiler) #60547Core.Boxin Base and SharedArrays #60599@fastmath x^2inlining regression forFloat32andFloat16#60640show(::IOBuffer, ::StackFrame)#60645invoke(f, ::CodeInstance, args...)#60442usingan ambiguous binding #60804Need manual backport:
remove-argument-side-effectswith keyword call #60195yin parsingx' = y#60246parse_brackets#60403parse_brackets()#60476emit_static_rootsfor "allroots" case #60656jl_method_lookup_by_ttfor custom method tables. #60718Contains multiple commits, manual intervention needed:
convertto aSymbolorString#60366full_nameafter precompiling extension #60456Non-merged PRs with backport label:
@invokelatest#60727firstindexbefore by values (like vectors) #60565inline_cost_threshold == typemax(Int)#60121Core._apply_iterate#60062