Skip to content

Commit 1c1fbff

Browse files
committed
Merge branch 'master' into chained_hash_pipelining
2 parents 4f001b9 + c940a31 commit 1c1fbff

File tree

115 files changed

+1825
-909
lines changed

Some content is hidden

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

115 files changed

+1825
-909
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: 3 additions & 9 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)
@@ -3545,7 +3539,7 @@ function merge_override_effects!(interp::AbstractInterpreter, effects::Effects,
35453539
# N.B.: We'd like deleted_world here, but we can't add an appropriate edge at this point.
35463540
# However, in order to reach here in the first place, ordinary method lookup would have
35473541
# had to add an edge and appropriate invalidation trigger.
3548-
valid_worlds = WorldRange(m.primary_world, typemax(Int))
3542+
valid_worlds = WorldRange(m.primary_world, typemax(UInt))
35493543
if sv.world.this in valid_worlds
35503544
update_valid_age!(sv, valid_worlds)
35513545
else

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: 9 additions & 10 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, "(")

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/typeinfer.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ function adjust_effects(ipo_effects::Effects, def::Method, world::UInt)
475475
valid_worlds = WorldRange(0, typemax(UInt))
476476
if is_effect_overridden(override, :consistent)
477477
# See note on `typemax(Int)` instead of `deleted_world` in adjust_effects!
478-
override_valid_worlds = WorldRange(def.primary_world, typemax(Int))
478+
override_valid_worlds = WorldRange(def.primary_world, typemax(UInt))
479479
if world in override_valid_worlds
480480
ipo_effects = Effects(ipo_effects; consistent=ALWAYS_TRUE)
481481
valid_worlds = override_valid_worlds
@@ -749,7 +749,7 @@ end
749749

750750
# record the backedges
751751
function store_backedges(caller::CodeInstance, edges::SimpleVector)
752-
isa(caller.def.def, Method) || return # don't add backedges to toplevel method instance
752+
isa(get_ci_mi(caller).def, Method) || return # don't add backedges to toplevel method instance
753753

754754
backedges = ForwardToBackedgeIterator(edges)
755755
for (i, (invokesig, item)) in enumerate(backedges)
@@ -1683,7 +1683,8 @@ function typeinf_ext_toplevel(methods::Vector{Any}, worlds::Vector{UInt}, trim_m
16831683
return codeinfos
16841684
end
16851685

1686-
verify_typeinf_trim(codeinfos::Vector{Any}, onlywarn::Bool) = invokelatest(verify_typeinf_trim, stdout, codeinfos, onlywarn)
1686+
const _verify_trim_world_age = RefValue{UInt}(typemax(UInt))
1687+
verify_typeinf_trim(codeinfos::Vector{Any}, onlywarn::Bool) = Core._call_in_world(_verify_trim_world_age[], verify_typeinf_trim, stdout, codeinfos, onlywarn)
16871688

16881689
function return_type(@nospecialize(f), t::DataType) # this method has a special tfunc
16891690
world = tls_world_age()

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: 10 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)

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)