Skip to content

Commit b6bc64d

Browse files
authored
Merge branch 'master' into windows-shell-support
2 parents 1f2cca7 + 925d504 commit b6bc64d

File tree

163 files changed

+2169
-989
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+2169
-989
lines changed

Compiler/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Compiler"
22
uuid = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"
3-
version = "0.0.0"
3+
version = "0.1.0"
44

55
[compat]
66
julia = "1.10"

Compiler/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ your `Project.toml` as follows:
1616
Compiler = "807dbc54-b67e-4c79-8afb-eafe4df6f2e1"
1717

1818
[compat]
19-
Compiler = "0"
19+
Compiler = "0.1"
2020
```
2121

22-
With the setup above, [the special placeholder version (v0.0.0)](https://github.com/JuliaLang/BaseCompiler.jl)
22+
With the setup above, [the special placeholder version (v0.1.0)](https://github.com/JuliaLang/BaseCompiler.jl)
2323
will be installed by default.[^1]
2424

25-
[^1]: Currently, only version v0.0.0 is registered in the [General](https://github.com/JuliaRegistries/General) registry.
25+
[^1]: Currently, only version v0.1.0 is registered in the [General](https://github.com/JuliaRegistries/General) registry.
2626

2727
If needed, you can switch to a custom implementation of the `Compiler` module by running
2828
```julia-repl

Compiler/src/Compiler.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ using Base: @_foldable_meta, @_gc_preserve_begin, @_gc_preserve_end, @nospeciali
6565
structdiff, tls_world_age, unconstrain_vararg_length, unionlen, uniontype_layout,
6666
uniontypes, unsafe_convert, unwrap_unionall, unwrapva, vect, widen_diagonal,
6767
_uncompressed_ir, maybe_add_binding_backedge!, datatype_min_ninitialized,
68-
partialstruct_init_undefs, fieldcount_noerror, _eval_import, _eval_using
68+
partialstruct_init_undefs, fieldcount_noerror, _eval_import, _eval_using,
69+
get_ci_mi
70+
6971
using Base.Order
7072

7173
import Base: ==, _topmod, append!, convert, copy, copy!, findall, first, get, get!,

Compiler/src/abstractinterpretation.jl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,18 +2215,12 @@ function abstract_call_unionall(interp::AbstractInterpreter, argtypes::Vector{An
22152215
return CallMeta(ret, Any, Effects(EFFECTS_TOTAL; nothrow), call.info)
22162216
end
22172217

2218-
function ci_abi(ci::CodeInstance)
2218+
function get_ci_abi(ci::CodeInstance)
22192219
def = ci.def
22202220
isa(def, ABIOverride) && return def.abi
22212221
(def::MethodInstance).specTypes
22222222
end
22232223

2224-
function get_ci_mi(ci::CodeInstance)
2225-
def = ci.def
2226-
isa(def, ABIOverride) && return def.def
2227-
return def::MethodInstance
2228-
end
2229-
22302224
function abstract_invoke(interp::AbstractInterpreter, arginfo::ArgInfo, si::StmtInfo, sv::AbsIntState)
22312225
argtypes = arginfo.argtypes
22322226
ft′ = argtype_by_index(argtypes, 2)
@@ -2238,7 +2232,7 @@ function abstract_invoke(interp::AbstractInterpreter, arginfo::ArgInfo, si::Stmt
22382232
if isa(method_or_ci, CodeInstance)
22392233
our_world = sv.world.this
22402234
argtype = argtypes_to_type(pushfirst!(argtype_tail(argtypes, 4), ft))
2241-
specsig = ci_abi(method_or_ci)
2235+
specsig = get_ci_abi(method_or_ci)
22422236
defdef = get_ci_mi(method_or_ci).def
22432237
exct = method_or_ci.exctype
22442238
if !hasintersect(argtype, specsig)

Compiler/src/abstractlattice.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,10 @@ that should be forwarded along with constant propagation.
227227
end
228228
@nospecializeinfer function is_const_prop_profitable_arg(𝕃::ConstsLattice, @nospecialize t)
229229
if isa(t, Const)
230-
# don't consider mutable values useful constants
230+
# don't consider mutable values useful constants unless they have const fields
231231
val = t.val
232-
return isa(val, Symbol) || isa(val, Type) || isa(val, Method) || isa(val, CodeInstance) || !ismutable(val)
232+
return isa(val, Symbol) || isa(val, Type) || isa(val, Method) || isa(val, CodeInstance) ||
233+
!ismutable(val) || (typeof(val).name.constfields != C_NULL)
233234
end
234235
isa(t, PartialTypeVar) && return false # this isn't forwardable
235236
return is_const_prop_profitable_arg(widenlattice(𝕃), t)

Compiler/src/ssair/ir.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ end
609609
elseif isa(stmt, EnterNode)
610610
op == 1 || throw(BoundsError())
611611
stmt = EnterNode(stmt.catch_dest, v)
612-
elseif isa(stmt, Union{AnySSAValue, GlobalRef})
612+
elseif isa(stmt, Union{AnySSAValue, Argument, GlobalRef})
613613
op == 1 || throw(BoundsError())
614614
stmt = v
615615
elseif isa(stmt, UpsilonNode)
@@ -640,7 +640,7 @@ end
640640
function userefs(@nospecialize(x))
641641
relevant = (isa(x, Expr) && is_relevant_expr(x)) ||
642642
isa(x, GotoIfNot) || isa(x, ReturnNode) || isa(x, SSAValue) || isa(x, OldSSAValue) || isa(x, NewSSAValue) ||
643-
isa(x, PiNode) || isa(x, PhiNode) || isa(x, PhiCNode) || isa(x, UpsilonNode) || isa(x, EnterNode)
643+
isa(x, PiNode) || isa(x, PhiNode) || isa(x, PhiCNode) || isa(x, UpsilonNode) || isa(x, EnterNode) || isa(x, Argument)
644644
return UseRefIterator(x, relevant)
645645
end
646646

@@ -810,7 +810,7 @@ end
810810
types(ir::Union{IRCode, IncrementalCompact}) = TypesView(ir)
811811

812812
function getindex(compact::IncrementalCompact, ssa::SSAValue)
813-
(1 ssa.id compact.result_idx) || throw(InvalidIRError())
813+
(1 ssa.id < compact.result_idx) || throw(InvalidIRError())
814814
return compact.result[ssa.id]
815815
end
816816

Compiler/src/ssair/passes.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ end
99
function is_known_invoke_or_call(@nospecialize(x), @nospecialize(func), ir::Union{IRCode,IncrementalCompact})
1010
isinvoke = isexpr(x, :invoke)
1111
(isinvoke || isexpr(x, :call)) || return false
12-
ft = argextype(x.args[isinvoke ? 2 : 1], ir)
12+
narg = isinvoke ? 2 : 1
13+
length(x.args) < narg && return false
14+
ft = argextype(x.args[narg], ir)
1315
return singleton_type(ft) === func
1416
end
1517

Compiler/src/ssair/show.jl

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ using .Compiler: ALWAYS_FALSE, ALWAYS_TRUE, argextype, BasicBlock, block_for_ins
1212
CachedMethodTable, CFG, compute_basic_blocks, DebugInfoStream, Effects,
1313
EMPTY_SPTYPES, getdebugidx, IncrementalCompact, InferenceResult, InferenceState,
1414
InvalidIRError, IRCode, LimitedAccuracy, NativeInterpreter, scan_ssa_use!,
15-
singleton_type, sptypes_from_meth_instance, StmtRange, Timings, VarState, widenconst
15+
singleton_type, sptypes_from_meth_instance, StmtRange, Timings, VarState, widenconst,
16+
get_ci_mi, get_ci_abi
1617

1718
@nospecialize
1819

@@ -95,16 +96,14 @@ function print_stmt(io::IO, idx::Int, @nospecialize(stmt), code::Union{IRCode,Co
9596
elseif isexpr(stmt, :invoke) && length(stmt.args) >= 2 && isa(stmt.args[1], Union{MethodInstance,CodeInstance})
9697
stmt = stmt::Expr
9798
# TODO: why is this here, and not in Base.show_unquoted
98-
printstyled(io, " invoke "; color = :light_black)
99-
mi = stmt.args[1]
100-
if !(mi isa Core.MethodInstance)
101-
mi = (mi::Core.CodeInstance).def
102-
end
103-
if isa(mi, Core.ABIOverride)
104-
abi = mi.abi
105-
mi = mi.def
99+
ci = stmt.args[1]
100+
if ci isa Core.CodeInstance
101+
printstyled(io, " invoke "; color = :light_black)
102+
mi = get_ci_mi(ci)
103+
abi = get_ci_abi(ci)
106104
else
107-
abi = mi.specTypes
105+
printstyled(io, "dynamic invoke "; color = :yellow)
106+
abi = (ci::Core.MethodInstance).specTypes
108107
end
109108
show_unquoted(io, stmt.args[2], indent)
110109
print(io, "(")
@@ -329,7 +328,7 @@ function compute_ir_line_annotations(code::IRCode)
329328
loc_method = string(" "^printing_depth, loc_method)
330329
last_stack = stack
331330
end
332-
push!(loc_annotations, String(take!(buf)))
331+
push!(loc_annotations, takestring!(buf))
333332
push!(loc_lineno, (lineno != 0 && lineno != last_lineno) ? string(lineno) : "")
334333
push!(loc_methods, loc_method)
335334
(lineno != 0) && (last_lineno = lineno)

Compiler/src/ssair/verify.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ function check_op(ir::IRCode, domtree::DomTree, @nospecialize(op), use_bb::Int,
3232
if isa(op, SSAValue)
3333
op.id > 0 || @verify_error "Def ($(op.id)) is invalid in final IR"
3434
if op.id > length(ir.stmts)
35+
if op.id - length(ir.stmts) > length(ir.new_nodes.info)
36+
@verify_error "Def ($(op.id)) points to non-existent new node"
37+
raise_error()
38+
end
3539
def_bb = block_for_inst(ir.cfg, ir.new_nodes.info[op.id - length(ir.stmts)].pos)
3640
else
3741
def_bb = block_for_inst(ir.cfg, op.id)

Compiler/src/validation.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ const VALID_EXPR_HEADS = IdDict{Symbol,UnitRange{Int}}(
3535
:aliasscope => 0:0,
3636
:popaliasscope => 0:0,
3737
:new_opaque_closure => 5:typemax(Int),
38-
:import => 1:typemax(Int),
39-
:using => 1:typemax(Int),
4038
:export => 1:typemax(Int),
4139
:public => 1:typemax(Int),
4240
:latestworld => 0:0,
@@ -72,11 +70,13 @@ function maybe_validate_code(mi::MethodInstance, src::CodeInfo, kind::String)
7270
if !isempty(errors)
7371
for e in errors
7472
if mi.def isa Method
75-
println(stderr, "WARNING: Encountered invalid ", kind, " code for method ",
76-
mi.def, ": ", e)
73+
println(Core.stderr,
74+
"WARNING: Encountered invalid ", kind,
75+
" code for method ", mi.def, ": ", e)
7776
else
78-
println(stderr, "WARNING: Encountered invalid ", kind, " code for top level expression in ",
79-
mi.def, ": ", e)
77+
println(Core.stderr,
78+
"WARNING: Encountered invalid ", kind,
79+
" code for top level expression in ", mi.def, ": ", e)
8080
end
8181
end
8282
error("")

Compiler/test/codegen.jl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,16 @@ for (T, StructName) in ((Int128, :Issue55558), (UInt128, :UIssue55558))
951951
end
952952
end
953953

954+
# Issue #42326
955+
primitive type PadAfter64_42326 448 end
956+
mutable struct CheckPadAfter64_42326
957+
a::UInt64
958+
pad::PadAfter64_42326
959+
b::UInt64
960+
end
961+
@test fieldoffset(CheckPadAfter64_42326, 3) == 80
962+
@test sizeof(CheckPadAfter64_42326) == 96
963+
954964
@noinline Base.@nospecializeinfer f55768(@nospecialize z::UnionAll) = z === Vector
955965
@test f55768(Vector)
956966
@test f55768(Vector{T} where T)
@@ -1037,3 +1047,25 @@ f57872() = (Core.isdefinedglobal(@__MODULE__, Base.compilerbarrier(:const, :x578
10371047
@noinline f_mutateany(@nospecialize x) = x[] = 1
10381048
g_mutateany() = (y = Ref(0); f_mutateany(y); y[])
10391049
@test g_mutateany() === 1
1050+
1051+
# 58470 tbaa for unionselbyte of heap allocated mutables
1052+
mutable struct Wrapper58470
1053+
x::Union{Nothing,Int}
1054+
end
1055+
1056+
function findsomething58470(dict, inds)
1057+
default = Wrapper58470(nothing)
1058+
for i in inds
1059+
x = get(dict, i, default).x
1060+
if !isnothing(x)
1061+
return x
1062+
end
1063+
end
1064+
return nothing
1065+
end
1066+
1067+
let io = IOBuffer()
1068+
code_llvm(io, findsomething58470, Tuple{Dict{Int64, Wrapper58470}, Vector{Int}}, dump_module=true, raw=true, optimize=false)
1069+
str = String(take!(io))
1070+
@test !occursin("jtbaa_unionselbyte", str)
1071+
end

Compiler/test/irpasses.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,3 +2111,13 @@ let src = code_typed1(()) do
21112111
end
21122112
@test count(iscall((src, isdefined)), src.code) == 0
21132113
end
2114+
# We should successfully fold the default values of a ScopedValue
2115+
const svalconstprop = ScopedValue(1)
2116+
foosvalconstprop() = svalconstprop[]
2117+
2118+
let src = code_typed1(foosvalconstprop, ())
2119+
function is_constfield_load(expr)
2120+
iscall((src, getfield))(expr) && expr.args[3] in (:(:has_default), :(:default))
2121+
end
2122+
@test count(is_constfield_load, src.code) == 0
2123+
end

Compiler/test/ssair.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ let
459459
@test stmt.cond === v
460460
elseif isa(stmt, ReturnNode) || isa(stmt, UpsilonNode)
461461
@test stmt.val === v
462-
elseif isa(stmt, SSAValue) || isa(stmt, NewSSAValue)
462+
elseif isa(stmt, SSAValue) || isa(stmt, NewSSAValue) || isa(stmt, Argument)
463463
@test stmt === v
464464
elseif isa(stmt, PiNode)
465465
@test stmt.val === v && stmt.typ === typeof(stmt)
@@ -508,6 +508,7 @@ let
508508
GotoNode(5),
509509
SSAValue(7),
510510
NewSSAValue(9),
511+
Argument(1),
511512
ReturnNode(SSAValue(11)),
512513
]
513514

Make.inc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ USE_SYSTEM_LIBGIT2:=0
5959
USE_SYSTEM_PATCHELF:=0
6060
USE_SYSTEM_LIBWHICH:=0
6161
USE_SYSTEM_ZLIB:=0
62+
USE_SYSTEM_ZSTD:=0
6263
USE_SYSTEM_P7ZIP:=0
6364
USE_SYSTEM_LLD:=0
6465

@@ -373,11 +374,15 @@ $(1)_rel_eval = $(call rel_path,$(2),$($(1)))
373374
$(1)_rel = $$(call hit_cache,$(1)_rel_eval)
374375
endef
375376
$(foreach D,libdir private_libdir datarootdir libexecdir private_libexecdir docdir sysconfdir includedir,$(eval $(call cache_rel_path,$(D),$(bindir))))
376-
$(foreach D,build_libdir build_private_libdir,$(eval $(call cache_rel_path,$(D),$(build_bindir))))
377+
$(foreach D,build_libdir build_private_libdir ,$(eval $(call cache_rel_path,$(D),$(build_bindir))))
377378

378379
# Save a special one: reverse_private_libdir_rel: usually just `../`, but good to be general:
379380
reverse_private_libdir_rel_eval = $(call rel_path,$(private_libdir),$(libdir))
380381
reverse_private_libdir_rel = $(call hit_cache,reverse_private_libdir_rel_eval)
382+
reverse_private_libexecdir_rel_eval = $(call rel_path,$(private_libexecdir),$(private_libdir))
383+
reverse_private_libexecdir_rel = $(call hit_cache,reverse_private_libexecdir_rel_eval)
384+
reverse_build_private_libexecdir_rel_eval = $(call rel_path,$(build_private_libexecdir),$(build_libdir))
385+
reverse_build_private_libexecdir_rel = $(call hit_cache,reverse_build_private_libexecdir_rel_eval)
381386

382387
INSTALL_F := $(JULIAHOME)/contrib/install.sh 644
383388
INSTALL_M := $(JULIAHOME)/contrib/install.sh 755
@@ -1417,7 +1422,7 @@ CSL_NEXT_GLIBCXX_VERSION=GLIBCXX_3\.4\.34|GLIBCXX_3\.5\.|GLIBCXX_4\.
14171422
# Note: we explicitly _do not_ define `CSL` here, since it requires some more
14181423
# advanced techniques to decide whether it should be installed from a BB source
14191424
# or not. See `deps/csl.mk` for more detail.
1420-
BB_PROJECTS := BLASTRAMPOLINE OPENBLAS LLVM LIBSUITESPARSE OPENLIBM GMP OPENSSL LIBSSH2 NGHTTP2 MPFR CURL LIBGIT2 PCRE LIBUV LIBUNWIND DSFMT OBJCONV ZLIB P7ZIP LLD LIBTRACYCLIENT BOLT
1425+
BB_PROJECTS := BLASTRAMPOLINE OPENBLAS LLVM LIBSUITESPARSE OPENLIBM GMP OPENSSL LIBSSH2 NGHTTP2 MPFR CURL LIBGIT2 PCRE LIBUV LIBUNWIND DSFMT OBJCONV ZLIB ZSTD P7ZIP LLD LIBTRACYCLIENT BOLT
14211426

14221427
ifeq (${USE_THIRD_PARTY_GC},mmtk)
14231428
BB_PROJECTS += MMTK_JULIA

0 commit comments

Comments
 (0)