Skip to content

Commit

Permalink
Merge branch 'master' into test_undoc
Browse files Browse the repository at this point in the history
  • Loading branch information
LilithHafner authored Jan 14, 2024
2 parents 91e465d + 4d670fb commit f286d44
Show file tree
Hide file tree
Showing 76 changed files with 1,655 additions and 799 deletions.
2 changes: 1 addition & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ JCPPFLAGS_COMMON := -fasynchronous-unwind-tables
JCPPFLAGS_CLANG := $(JCPPFLAGS_COMMON) -mllvm -enable-tail-merge=0
JCPPFLAGS_GCC := $(JCPPFLAGS_COMMON) -fno-tree-tail-merge

JCXXFLAGS_COMMON := -pipe $(fPIC) -fno-rtti -std=c++14
JCXXFLAGS_COMMON := -pipe $(fPIC) -fno-rtti -std=c++17
JCXXFLAGS_CLANG := $(JCXXFLAGS_COMMON) -pedantic
JCXXFLAGS_GCC := $(JCXXFLAGS_COMMON) -fno-gnu-unique

Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ Standard library changes
* There is now a specialized dispatch for `eigvals/eigen(::Hermitian{<:Tridiagonal})` which performs a similarity transformation to create a real symmetrix triagonal matrix, and solve that using the LAPACK routines ([#49546]).
* Structured matrices now retain either the axes of the parent (for `Symmetric`/`Hermitian`/`AbstractTriangular`/`UpperHessenberg`), or that of the principal diagonal (for banded matrices) ([#52480]).
* `bunchkaufman` and `bunchkaufman!` now work for any `AbstractFloat`, `Rational` and their complex variants. `bunchkaufman` now supports `Integer` types, by making an internal conversion to `Rational{BigInt}`. Added new function `inertia` that computes the inertia of the diagonal factor given by the `BunchKaufman` factorization object of a real symmetric or Hermitian matrix. For complex symmetric matrices, `inertia` only computes the number of zero eigenvalues of the diagonal factor ([#51487]).
* Packages that specialize matrix-matrix `mul!` with a method signature of the form `mul!(::AbstractMatrix, ::MyMatrix, ::AbstractMatrix, ::Number, ::Number)` no longer encounter method ambiguities when interacting with `LinearAlgebra`. Previously, ambiguities used to arise when multiplying a `MyMatrix` with a structured matrix type provided by LinearAlgebra, such as `AbstractTriangular`, which used to necessitate additional methods to resolve such ambiguities. Similar sources of ambiguities have also been removed for matrix-vector `mul!` operations ([#52837]).

#### Logging
* New `@create_log_macro` macro for creating new log macros like `@info`, `@warn` etc. For instance
Expand Down
17 changes: 9 additions & 8 deletions base/binaryplatforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -661,18 +661,12 @@ const libstdcxx_version_mapping = Dict{String,String}(
"libstdcxx" => "-libstdcxx\\d+",
)

"""
parse(::Type{Platform}, triplet::AbstractString)
Parses a string platform triplet back into a `Platform` object.
"""
function Base.parse(::Type{Platform}, triplet::String; validate_strict::Bool = false)
const triplet_regex = let
# Helper function to collapse dictionary of mappings down into a regex of
# named capture groups joined by "|" operators
c(mapping) = string("(",join(["(?<$k>$v)" for (k, v) in mapping], "|"), ")")

# We're going to build a mondo regex here to parse everything:
triplet_regex = Regex(string(
Regex(string(
"^",
# First, the core triplet; arch/os/libc/call_abi
c(arch_mapping),
Expand All @@ -687,7 +681,14 @@ function Base.parse(::Type{Platform}, triplet::String; validate_strict::Bool = f
"(?<tags>(?:-[^-]+\\+[^-]+)*)?",
"\$",
))
end

"""
parse(::Type{Platform}, triplet::AbstractString)
Parses a string platform triplet back into a `Platform` object.
"""
function Base.parse(::Type{Platform}, triplet::String; validate_strict::Bool = false)
m = match(triplet_regex, triplet)
if m !== nothing
# Helper function to find the single named field within the giant regex
Expand Down
32 changes: 20 additions & 12 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2119,8 +2119,14 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
abstract_call_gf_by_type(interp, f, ArgInfo(nothing, T), si, atype, sv, max_methods)
end
pT = typevar_tfunc(𝕃ᵢ, n, lb_var, ub_var)
effects = builtin_effects(𝕃ᵢ, Core._typevar, Any[n, lb_var, ub_var], pT)
return CallMeta(pT, Any, effects, call.info)
typevar_argtypes = Any[n, lb_var, ub_var]
effects = builtin_effects(𝕃ᵢ, Core._typevar, typevar_argtypes, pT)
if effects.nothrow
exct = Union{}
else
exct = builtin_exct(𝕃ᵢ, Core._typevar, typevar_argtypes, pT)
end
return CallMeta(pT, exct, effects, call.info)
elseif f === UnionAll
call = abstract_call_gf_by_type(interp, f, ArgInfo(nothing, Any[Const(UnionAll), Any, Any]), si, Tuple{Type{UnionAll}, Any, Any}, sv, max_methods)
return abstract_call_unionall(interp, argtypes, call)
Expand Down Expand Up @@ -2310,11 +2316,7 @@ function abstract_eval_cfunction(interp::AbstractInterpreter, e::Expr, vtypes::U
end

function abstract_eval_special_value(interp::AbstractInterpreter, @nospecialize(e), vtypes::Union{VarTable,Nothing}, sv::AbsIntState)
if isa(e, QuoteNode)
effects = Effects(EFFECTS_TOTAL;
inaccessiblememonly = is_mutation_free_argtype(typeof(e.value)) ? ALWAYS_TRUE : ALWAYS_FALSE)
return RTEffects(Const(e.value), Union{}, effects)
elseif isa(e, SSAValue)
if isa(e, SSAValue)
return RTEffects(abstract_eval_ssavalue(e, sv), Union{}, EFFECTS_TOTAL)
elseif isa(e, SlotNumber)
if vtypes !== nothing
Expand All @@ -2335,8 +2337,12 @@ function abstract_eval_special_value(interp::AbstractInterpreter, @nospecialize(
elseif isa(e, GlobalRef)
return abstract_eval_globalref(interp, e, sv)
end

return RTEffects(Const(e), Union{}, EFFECTS_TOTAL)
if isa(e, QuoteNode)
e = e.value
end
effects = Effects(EFFECTS_TOTAL;
inaccessiblememonly = is_mutation_free_argtype(typeof(e)) ? ALWAYS_TRUE : ALWAYS_FALSE)
return RTEffects(Const(e), Union{}, effects)
end

function abstract_eval_value_expr(interp::AbstractInterpreter, e::Expr, sv::AbsIntState)
Expand Down Expand Up @@ -3288,10 +3294,12 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
# Process non control-flow statements
(; changes, rt, exct) = abstract_eval_basic_statement(interp,
stmt, currstate, frame)
if exct !== Union{}
update_exc_bestguess!(interp, exct, frame)
end
if !has_curr_ssaflag(frame, IR_FLAG_NOTHROW)
if exct !== Union{}
update_exc_bestguess!(interp, exct, frame)
# TODO: assert that these conditions match. For now, we assume the `nothrow` flag
# to be correct, but allow the exct to be an over-approximation.
end
propagate_to_error_handler!(currstate, frame, 𝕃ᵢ)
end
if rt === Bottom
Expand Down
24 changes: 19 additions & 5 deletions base/compiler/ssair/ir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1340,8 +1340,8 @@ function kill_edge!(compact::IncrementalCompact, active_bb::Int, from::Int, to::
else
stmts = compact.ir.cfg.blocks[to].stmts
for stmt in CompactPeekIterator(compact, first(stmts), last(stmts))
stmt === nothing && continue
isa(stmt, PhiNode) || break
is_valid_phiblock_stmt(stmt) || break
isa(stmt, PhiNode) || continue
i = findfirst(x::Int32->x==from, stmt.edges)
if i !== nothing
deleteat!(stmt.edges, i)
Expand Down Expand Up @@ -1684,13 +1684,27 @@ struct CompactPeekIterator
compact::IncrementalCompact
start_idx::Int
end_idx::Int
include_stmts_before_start::Bool
end
CompactPeekIterator(compact::IncrementalCompact, start_idx::Int, end_idx::Int) =
CompactPeekIterator(compact, start_idx, end_idx, false)


function CompactPeekIterator(compact::IncrementalCompact, start_idx::Int)
return CompactPeekIterator(compact, start_idx, 0)
end

entry_at_idx(entry::NewNodeInfo, idx::Int) = entry.attach_after ? entry.pos == idx - 1 : entry.pos == idx
function entry_at_idx(entry::NewNodeInfo, idx::Int, start_idx::Int, include_stmts_before_start::Bool)
if entry.attach_after
if !include_stmts_before_start
entry.pos >= start_idx || return false
end
return entry.pos == idx - 1
else
return entry.pos == idx
end
end

function iterate(it::CompactPeekIterator, (idx, aidx, bidx)::NTuple{3, Int}=(it.start_idx, it.compact.new_nodes_idx, 1))
if it.end_idx > 0 && idx > it.end_idx
return nothing
Expand All @@ -1702,15 +1716,15 @@ function iterate(it::CompactPeekIterator, (idx, aidx, bidx)::NTuple{3, Int}=(it.
if compact.new_nodes_idx <= length(compact.perm)
new_nodes = compact.ir.new_nodes
for eidx in aidx:length(compact.perm)
if entry_at_idx(new_nodes.info[compact.perm[eidx]], idx)
if entry_at_idx(new_nodes.info[compact.perm[eidx]], idx, it.start_idx, it.include_stmts_before_start)
entry = new_nodes.stmts[compact.perm[eidx]]
return (entry[:stmt], (idx, eidx+1, bidx))
end
end
end
if !isempty(compact.pending_perm)
for eidx in bidx:length(compact.pending_perm)
if entry_at_idx(compact.pending_nodes.info[compact.pending_perm[eidx]], idx)
if entry_at_idx(compact.pending_nodes.info[compact.pending_perm[eidx]], idx, it.start_idx, it.include_stmts_before_start)
entry = compact.pending_nodes.stmts[compact.pending_perm[eidx]]
return (entry[:stmt], (idx, aidx, eidx+1))
end
Expand Down
33 changes: 25 additions & 8 deletions base/compiler/ssair/passes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,18 @@ function (this::IntermediaryCollector)(@nospecialize(pi), @nospecialize(ssa))
end

function update_scope_mapping!(scope_mapping, bb, val)
@assert (scope_mapping[bb] in (val, SSAValue(0)))
current_mapping = scope_mapping[bb]
if current_mapping != SSAValue(0)
if val == SSAValue(0)
# Unreachable bbs will have SSAValue(0), but can branch into
# try/catch regions. We could validate with the domtree, but that's
# quite expensive for a debug check, so simply allow this without
# making any changes to mapping.
return
end
@assert current_mapping == val
return
end
scope_mapping[bb] = val
end

Expand Down Expand Up @@ -1392,7 +1403,7 @@ function sroa_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
(lifted_val, nest) = perform_lifting!(compact,
visited_philikes, field, result_t, lifted_leaves, val, lazydomtree)

node_was_deleted = false
should_delete_node = false
line = compact[SSAValue(idx)][:line]
if lifted_val !== nothing && !(𝕃ₒ, compact[SSAValue(idx)][:type], result_t)
compact[idx] = lifted_val === nothing ? nothing : lifted_val.val
Expand All @@ -1401,9 +1412,8 @@ function sroa_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
# Save some work in a later compaction, by inserting this into the renamer now,
# but only do this if we didn't set the REFINED flag, to save work for irinterp
# in revisiting only the renamings that came through *this* idx.
delete_inst_here!(compact)
compact.ssa_rename[old_idx] = lifted_val === nothing ? nothing : lifted_val.val
node_was_deleted = true
should_delete_node = true
else
compact[idx] = lifted_val === nothing ? nothing : lifted_val.val
end
Expand All @@ -1424,17 +1434,24 @@ function sroa_pass!(ir::IRCode, inlining::Union{Nothing,InliningState}=nothing)
def_val = (def_val::LiftedValue).val
finish_phi_nest!(compact, nest)
end
ni = NewInstruction(
Expr(:throw_undef_if_not, Symbol("##getfield##"), def_val), Nothing, line)
if node_was_deleted
insert_node_here!(compact, ni, true)
throw_expr = Expr(:throw_undef_if_not, Symbol("##getfield##"), def_val)
if should_delete_node
# Replace the node we already have rather than deleting/re-inserting.
# This way it is easier to handle BB boundary corner cases.
compact[SSAValue(idx)] = throw_expr
compact[SSAValue(idx)][:type] = Nothing
compact[SSAValue(idx)][:flag] = IR_FLAG_EFFECT_FREE | IR_FLAG_CONSISTENT | IR_FLAG_NOUB
should_delete_node = false
else
ni = NewInstruction(throw_expr, Nothing, line)
insert_node!(compact, SSAValue(idx), ni)
end
else
# val must be defined
@assert lifted_val !== nothing
end

should_delete_node && delete_inst_here!(compact)
end

non_dce_finish!(compact)
Expand Down
3 changes: 2 additions & 1 deletion base/compiler/ssair/verify.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

function maybe_show_ir(ir::IRCode)
if isdefined(Core, :Main)
invokelatest(Core.Main.Base.display, ir)
# ensure we use I/O that does not yield, as this gets called during compilation
invokelatest(Core.Main.Base.show, Core.stdout, "text/plain", ir)
end
end

Expand Down
2 changes: 1 addition & 1 deletion base/compiler/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ end

function is_valid_rvalue(@nospecialize(x))
is_valid_argument(x) && return true
if isa(x, Expr) && x.head in (:new, :splatnew, :the_exception, :isdefined, :call, :invoke, :invoke_modify, :foreigncall, :cfunction, :gc_preserve_begin, :copyast)
if isa(x, Expr) && x.head in (:new, :splatnew, :the_exception, :isdefined, :call, :invoke, :invoke_modify, :foreigncall, :cfunction, :gc_preserve_begin, :copyast, :new_opaque_closure)
return true
end
return false
Expand Down
2 changes: 1 addition & 1 deletion base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ end
"""
cis(x)
More efficient method for `exp(im*x)` by using Euler's formula: ``cos(x) + i sin(x) = \\exp(i x)``.
More efficient method for `exp(im*x)` by using Euler's formula: ``\\cos(x) + i \\sin(x) = \\exp(i x)``.
See also [`cispi`](@ref), [`sincos`](@ref), [`exp`](@ref), [`angle`](@ref).
Expand Down
10 changes: 9 additions & 1 deletion base/docs/basedocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3312,7 +3312,7 @@ kw"atomic"
This function prevents dead-code elimination (DCE) of itself and any arguments
passed to it, but is otherwise the lightest barrier possible. In particular,
it is not a GC safepoint, does model an observable heap effect, does not expand
it is not a GC safepoint, does not model an observable heap effect, does not expand
to any code itself and may be re-ordered with respect to other side effects
(though the total number of executions may not change).
Expand All @@ -3330,6 +3330,14 @@ unused and delete the entire benchmark code).
`donotdelete(1+1)`, no add instruction needs to be executed at runtime and
the code is semantically equivalent to `donotdelete(2).`
!!! note
This intrinsic does not affect the semantics of code that is dead because it is
*unreachable*. For example, the body of the function `f(x) = false && donotdelete(x)`
may be deleted in its entirety. The semantics of this intrinsic only guarantee that
*if* the intrinsic is semantically executed, then there is some program state at
which the value of the arguments of this intrinsic were available (in a register,
in memory, etc.).
# Examples
```julia
Expand Down
9 changes: 7 additions & 2 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1033,8 +1033,13 @@ function cache_file_entry(pkg::PkgId)
uuid === nothing ? pkg.name : package_slug(uuid)
end

# for use during running the REPL precompilation subprocess script, given we don't
# want it to pick up caches that already exist for other optimization levels
const ignore_compiled_cache = PkgId[]

function find_all_in_cache_path(pkg::PkgId)
paths = String[]
pkg in ignore_compiled_cache && return paths
entrypath, entryfile = cache_file_entry(pkg)
for path in joinpath.(DEPOT_PATH, entrypath)
isdir(path) || continue
Expand Down Expand Up @@ -1212,13 +1217,13 @@ function run_module_init(mod::Module, i::Int=1)
cumulative_compile_timing(false);
comp_time, recomp_time = (cumulative_compile_time_ns() .- compile_elapsedtimes) ./ 1e6

print(round(elapsedtime, digits=1), " ms $mod.__init__() ")
print("$(round(elapsedtime, digits=1)) ms $mod.__init__() ")
if comp_time > 0
printstyled(Ryu.writefixed(Float64(100 * comp_time / elapsedtime), 2), "% compilation time", color = Base.info_color())
end
if recomp_time > 0
perc = Float64(100 * recomp_time / comp_time)
printstyled(" (", perc < 1 ? "<1" : Ryu.writefixed(perc, 0), "% recompilation)", color = Base.warn_color())
printstyled(" ($(perc < 1 ? "<1" : Ryu.writefixed(perc, 0))% recompilation)", color = Base.warn_color())
end
println()
end
Expand Down
2 changes: 1 addition & 1 deletion base/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ end
"""
names(x::Module; all::Bool = false, imported::Bool = false)

Get an array of the public names of a `Module`, excluding deprecated names.
Get a vector of the public names of a `Module`, excluding deprecated names.
If `all` is true, then the list also includes non-public names defined in the module,
deprecated names, and compiler-generated names.
If `imported` is true, then names explicitly imported from other modules
Expand Down
2 changes: 1 addition & 1 deletion base/uuid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ let groupings = [36:-1:25; 23:-1:20; 18:-1:15; 13:-1:10; 8:-1:1]
end

print(io::IO, u::UUID) = print(io, string(u))
show(io::IO, u::UUID) = print(io, "UUID(\"", u, "\")")
show(io::IO, u::UUID) = print(io, UUID, "(\"", u, "\")")

isless(a::UUID, b::UUID) = isless(a.value, b.value)

Expand Down
6 changes: 6 additions & 0 deletions contrib/generate_precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ precompile(Tuple{typeof(Base.hashindex), String, Int64})
precompile(Tuple{typeof(Base.write), Base.GenericIOBuffer{Array{UInt8, 1}}, String})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Nothing, Int64}, Int64})
precompile(Tuple{typeof(Base.indexed_iterate), Tuple{Nothing, Int64}, Int64, Int64})
precompile(Tuple{typeof(Base._typeddict), Base.Dict{String, Any}, Base.Dict{String, Any}, Vararg{Base.Dict{String, Any}}})
precompile(Tuple{typeof(Base.promoteK), Type, Base.Dict{String, Any}, Base.Dict{String, Any}})
precompile(Tuple{typeof(Base.promoteK), Type, Base.Dict{String, Any}})
precompile(Tuple{typeof(Base.promoteV), Type, Base.Dict{String, Any}, Base.Dict{String, Any}})
precompile(Tuple{typeof(Base.eval_user_input), Base.PipeEndpoint, Any, Bool})
precompile(Tuple{typeof(Base.get), Base.PipeEndpoint, Symbol, Bool})

# used by Revise.jl
precompile(Tuple{typeof(Base.parse_cache_header), String})
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
97bb33510fadec7f4cc4c718c739e9a0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a362aaf762f42deebb8632a7a7980cd22b2777e8c4dc629e418580269e24a64217ad846d61acad70438cfdc190e47ba2ff7716edd4e04d8d10c1d765efce604d
Loading

0 comments on commit f286d44

Please sign in to comment.