Skip to content

Commit 47038ea

Browse files
authored
Merge pull request #30607 from JuliaLang/backport-1.1.0
Backports for 1.1.0-rc2
2 parents ecf9911 + 05a8951 commit 47038ea

File tree

110 files changed

+463
-68
lines changed

Some content is hidden

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

110 files changed

+463
-68
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ matrix:
4040
- gfortran-5
4141
- os: osx
4242
env: ARCH="x86_64"
43-
osx_image: xcode8
43+
osx_image: xcode8.3
4444
cache: ccache
4545
branches:
4646
only:
@@ -76,8 +76,8 @@ before_install:
7676
brew tap staticfloat/julia > /dev/null;
7777
brew rm --force $(brew deps --HEAD julia);
7878
brew install -v ccache gcc gmp mpfr pcre2 staticfloat/julia/openblas-julia staticfloat/julia/suite-sparse-julia staticfloat/juliadeps/libgfortran;
79-
BUILDOPTS="-j3 USECLANG=1 USECCACHE=1 BINARYBUILDER_TRIPLET=x86_64-apple-darwin14 BINARYBUILDER_LLVM_ASSERTS=1";
80-
BUILDOPTS="$BUILDOPTS USE_BINARYBUILDER_LLVM=1 LLVM_CONFIG=$TRAVIS_BUILD_DIR/usr/tools/llvm-config LLVM_SIZE=$TRAVIS_BUILD_DIR/usr/tools/llvm-size";
79+
BUILDOPTS="-j3 USECLANG=1 USECCACHE=1 USE_BINARYBUILDER_LLVM=1 USE_BINARYBUILDER_OPENBLAS=1 BINARYBUILDER_LLVM_ASSERTS=1";
80+
BUILDOPTS="$BUILDOPTS LLVM_CONFIG=$TRAVIS_BUILD_DIR/usr/tools/llvm-config LLVM_SIZE=$TRAVIS_BUILD_DIR/usr/tools/llvm-size";
8181
BUILDOPTS="$BUILDOPTS VERBOSE=1 USE_BLAS64=0 SUITESPARSE_INC=-I$(brew --prefix suite-sparse-julia)/include FORCE_ASSERTIONS=1";
8282
BUILDOPTS="$BUILDOPTS LIBBLAS=-lopenblas LIBBLASNAME=libopenblas LIBLAPACK=-lopenblas LIBLAPACKNAME=libopenblas";
8383
for lib in SUITESPARSE BLAS LAPACK GMP MPFR LIBUNWIND; do

Make.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,10 @@ INSTALL_F := $(JULIAHOME)/contrib/install.sh 644
232232
INSTALL_M := $(JULIAHOME)/contrib/install.sh 755
233233

234234
# BinaryBuilder options
235-
# TODO: Autodiscover triplet
235+
USE_BINARYBUILDER_OPENBLAS := 0
236236
USE_BINARYBUILDER_LLVM := 0
237237
# Use the Assertions build
238238
BINARYBUILDER_LLVM_ASSERTS := 0
239-
BINARYBUILDER_TRIPLET :=
240239

241240
# LLVM Options
242241
LLVMROOT := $(build_prefix)

base/array.jl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ offset `do`. Return `dest`.
267267
"""
268268
function copyto!(dest::Array{T}, doffs::Integer, src::Array{T}, soffs::Integer, n::Integer) where T
269269
n == 0 && return dest
270-
n > 0 || _throw_argerror(n)
270+
n > 0 || _throw_argerror()
271271
if soffs < 1 || doffs < 1 || soffs+n-1 > length(src) || doffs+n-1 > length(dest)
272272
throw(BoundsError())
273273
end
@@ -276,10 +276,11 @@ function copyto!(dest::Array{T}, doffs::Integer, src::Array{T}, soffs::Integer,
276276
end
277277

278278
# Outlining this because otherwise a catastrophic inference slowdown
279-
# occurs, see discussion in #27874
280-
function _throw_argerror(n)
279+
# occurs, see discussion in #27874.
280+
# It is also mitigated by using a constant string.
281+
function _throw_argerror()
281282
@_noinline_meta
282-
throw(ArgumentError(string("tried to copy n=", n, " elements, but n should be nonnegative")))
283+
throw(ArgumentError("Number of elements to copy must be nonnegative."))
283284
end
284285

285286
copyto!(dest::Array{T}, src::Array{T}) where {T} = copyto!(dest, 1, src, 1, length(src))

base/checked.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function checked_neg(x::T) where T<:Integer
8787
checked_sub(T(0), x)
8888
end
8989
throw_overflowerr_negation(x) = (@_noinline_meta;
90-
throw(OverflowError("checked arithmetic: cannot compute -x for x = $x::$(typeof(x))")))
90+
throw(OverflowError(Base.invokelatest(string, "checked arithmetic: cannot compute -x for x = ", x, "::", typeof(x)))))
9191
if BrokenSignedInt != Union{}
9292
function checked_neg(x::BrokenSignedInt)
9393
r = -x
@@ -151,7 +151,7 @@ end
151151

152152

153153
throw_overflowerr_binaryop(op, x, y) = (@_noinline_meta;
154-
throw(OverflowError("$x $op $y overflowed for type $(typeof(x))")))
154+
throw(OverflowError(Base.invokelatest(string, x, " ", op, "y", " overflowed for type ", typeof(x)))))
155155

156156
"""
157157
Base.checked_add(x, y)

base/compiler/abstractinterpretation.jl

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,27 @@ function precise_container_type(@nospecialize(typ), vtypes::VarTable, sv::Infere
405405
end
406406
end
407407
return result
408-
elseif isa(tti0, DataType) && tti0 <: Tuple
409-
if isvatuple(tti0) && length(tti0.parameters) == 1
410-
return Any[Vararg{unwrapva(tti0.parameters[1])}]
408+
elseif tti0 <: Tuple
409+
if isa(tti0, DataType)
410+
if isvatuple(tti0) && length(tti0.parameters) == 1
411+
return Any[Vararg{unwrapva(tti0.parameters[1])}]
412+
else
413+
return Any[ p for p in tti0.parameters ]
414+
end
415+
elseif !isa(tti, DataType)
416+
return Any[Vararg{Any}]
411417
else
412-
return Any[ p for p in tti0.parameters ]
418+
len = length(tti.parameters)
419+
last = tti.parameters[len]
420+
va = isvarargtype(last)
421+
elts = Any[ fieldtype(tti0, i) for i = 1:len ]
422+
if va
423+
elts[len] = Vararg{elts[len]}
424+
end
425+
return elts
413426
end
427+
elseif tti0 === SimpleVector || tti0 === Any
428+
return Any[Vararg{Any}]
414429
elseif tti0 <: Array
415430
return Any[Vararg{eltype(tti0)}]
416431
else

base/compiler/ssair/passes.jl

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function simple_walk(compact::IncrementalCompact, @nospecialize(defssa#=::AnySSA
130130
return defssa
131131
end
132132
if isa(def.val, SSAValue)
133-
if isa(defssa, OldSSAValue) && !already_inserted(compact, defssa)
133+
if is_old(compact, defssa)
134134
defssa = OldSSAValue(def.val.id)
135135
else
136136
defssa = def.val
@@ -191,7 +191,7 @@ function walk_to_defs(compact::IncrementalCompact, @nospecialize(defssa), @nospe
191191
collect(Iterators.filter(1:length(def.edges)) do n
192192
isassigned(def.values, n) || return false
193193
val = def.values[n]
194-
if isa(defssa, OldSSAValue) && isa(val, SSAValue)
194+
if is_old(compact, defssa) && isa(val, SSAValue)
195195
val = OldSSAValue(val.id)
196196
end
197197
edge_typ = widenconst(compact_exprtype(compact, val))
@@ -201,7 +201,7 @@ function walk_to_defs(compact::IncrementalCompact, @nospecialize(defssa), @nospe
201201
for n in possible_predecessors
202202
pred = def.edges[n]
203203
val = def.values[n]
204-
if isa(defssa, OldSSAValue) && isa(val, SSAValue)
204+
if is_old(compact, defssa) && isa(val, SSAValue)
205205
val = OldSSAValue(val.id)
206206
end
207207
if isa(val, AnySSAValue)
@@ -281,7 +281,7 @@ function lift_leaves(compact::IncrementalCompact, @nospecialize(stmt),
281281
end
282282
if is_tuple_call(compact, def) && isa(field, Int) && 1 <= field < length(def.args)
283283
lifted = def.args[1+field]
284-
if isa(leaf, OldSSAValue) && isa(lifted, SSAValue)
284+
if is_old(compact, leaf) && isa(lifted, SSAValue)
285285
lifted = OldSSAValue(lifted.id)
286286
end
287287
if isa(lifted, GlobalRef) || isa(lifted, Expr)
@@ -320,7 +320,7 @@ function lift_leaves(compact::IncrementalCompact, @nospecialize(stmt),
320320
compact[leaf] = def
321321
end
322322
lifted = def.args[1+field]
323-
if isa(leaf, OldSSAValue) && isa(lifted, SSAValue)
323+
if is_old(compact, leaf) && isa(lifted, SSAValue)
324324
lifted = OldSSAValue(lifted.id)
325325
end
326326
if isa(lifted, GlobalRef) || isa(lifted, Expr)
@@ -339,7 +339,7 @@ function lift_leaves(compact::IncrementalCompact, @nospecialize(stmt),
339339
# N.B.: This can be a bit dangerous because it can lead to
340340
# infinite loops if we accidentally insert a node just ahead
341341
# of where we are
342-
if isa(leaf, OldSSAValue) && (isa(field, Int) || isa(field, Symbol))
342+
if is_old(compact, leaf) && (isa(field, Int) || isa(field, Symbol))
343343
(isa(typ, DataType) && (!typ.abstract)) || return nothing
344344
@assert !typ.mutable
345345
# If there's the potential for an undefref error on access, we cannot insert a getfield
@@ -425,6 +425,12 @@ struct LiftedPhi
425425
need_argupdate::Bool
426426
end
427427

428+
function is_old(compact, @nospecialize(old_node_ssa))
429+
isa(old_node_ssa, OldSSAValue) &&
430+
!is_pending(compact, old_node_ssa) &&
431+
!already_inserted(compact, old_node_ssa)
432+
end
433+
428434
function perform_lifting!(compact::IncrementalCompact,
429435
visited_phinodes::Vector{Any}, @nospecialize(cache_key),
430436
lifting_cache::IdDict{Pair{AnySSAValue, Any}, AnySSAValue},
@@ -455,7 +461,7 @@ function perform_lifting!(compact::IncrementalCompact,
455461
isassigned(old_node.values, i) || continue
456462
val = old_node.values[i]
457463
orig_val = val
458-
if isa(old_node_ssa, OldSSAValue) && !is_pending(compact, old_node_ssa) && !already_inserted(compact, old_node_ssa) && isa(val, SSAValue)
464+
if is_old(compact, old_node_ssa) && isa(val, SSAValue)
459465
val = OldSSAValue(val.id)
460466
end
461467
if isa(val, Union{NewSSAValue, SSAValue, OldSSAValue})
@@ -688,10 +694,14 @@ function getfield_elim_pass!(ir::IRCode, domtree::DomTree)
688694
compact[idx] = val === nothing ? nothing : val.x
689695
end
690696

691-
# Copy the use count, `finish` may modify it and for our predicate
692-
# below we need it consistent with the state of the IR here.
697+
698+
non_dce_finish!(compact)
699+
# Copy the use count, `simple_dce!` may modify it and for our predicate
700+
# below we need it consistent with the state of the IR here (after tracking
701+
# phi node arguments, but before dce).
693702
used_ssas = copy(compact.used_ssas)
694-
ir = finish(compact)
703+
simple_dce!(compact)
704+
ir = complete(compact)
695705
# Now go through any mutable structs and see which ones we can eliminate
696706
for (idx, (intermediaries, defuse)) in defuses
697707
intermediaries = collect(intermediaries)

base/compiler/typeinfer.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,12 @@ end
633633

634634

635635
function return_type(@nospecialize(f), @nospecialize(t))
636-
params = Params(ccall(:jl_get_tls_world_age, UInt, ()))
636+
world = ccall(:jl_get_tls_world_age, UInt, ())
637+
return ccall(:jl_call_in_typeinf_world, Any, (Ptr{Ptr{Cvoid}}, Cint), Any[_return_type, f, t, world], 4)
638+
end
639+
640+
function _return_type(@nospecialize(f), @nospecialize(t), world)
641+
params = Params(world)
637642
rt = Union{}
638643
if isa(f, Builtin)
639644
rt = builtin_tfunction(f, Any[t.parameters...], nothing, params)

base/show.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,14 +455,14 @@ function show_type_name(io::IO, tn::Core.TypeName)
455455
globname = isdefined(tn, :mt) ? tn.mt.name : nothing
456456
globfunc = false
457457
if globname !== nothing
458-
globname_str = string(globname)
458+
globname_str = string(globname::Symbol)
459459
if ('#' globname_str && '@' globname_str && isdefined(tn, :module) &&
460460
isbindingresolved(tn.module, globname) && isdefined(tn.module, globname) &&
461461
isconcretetype(tn.wrapper) && isa(getfield(tn.module, globname), tn.wrapper))
462462
globfunc = true
463463
end
464464
end
465-
sym = globfunc ? globname : tn.name
465+
sym = (globfunc ? globname : tn.name)::Symbol
466466
if get(io, :compact, false)
467467
if globfunc
468468
return print(io, "typeof(", sym, ")")

base/strings/io.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ end
105105

106106
tostr_sizehint(x) = 8
107107
tostr_sizehint(x::AbstractString) = lastindex(x)
108+
tostr_sizehint(x::Union{String,SubString{String}}) = sizeof(x)
108109
tostr_sizehint(x::Float64) = 20
109110
tostr_sizehint(x::Float32) = 12
110111

base/subarray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ check_parent_index_match(parent, ::NTuple{N, Bool}) where {N} =
4242
# are inlined
4343
@inline Base.throw_boundserror(A::SubArray, I) =
4444
__subarray_throw_boundserror(typeof(A), A.parent, A.indices, A.offset1, A.stride1, I)
45-
@noinline __subarray_throw_boundserror(T, parent, indices, offset1, stride1, I) =
45+
@noinline __subarray_throw_boundserror(::Type{T}, parent, indices, offset1, stride1, I) where {T} =
4646
throw(BoundsError(T(parent, indices, offset1, stride1), I))
4747

4848
# This computes the linear indexing compatibility for a given tuple of indices

contrib/fixup-libgfortran.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# This file is a part of Julia. License is MIT: https://julialang.org/license
33

44
# Run as: fixup-libgfortran.sh [--verbose] <$private_libdir>
5+
FC=${FC:-gfortran}
56

67
# If we're invoked with "--verbose", create a `debug` function that prints stuff out
78
if [ "$1" = "--verbose" ] || [ "$1" = "-v" ]; then
@@ -22,7 +23,7 @@ if [ "$UNAME" = "Linux" ]; then
2223
elif [ "$UNAME" = "Darwin" ]; then
2324
SHLIB_EXT="dylib"
2425
else
25-
echo "WARNING: Could not autodetect platform type ('uname -s' == $UNAME); assuming Linux" >&2
26+
echo "WARNING: Could not autodetect platform type ('uname -s' = $UNAME); assuming Linux" >&2
2627
UNAME="Linux"
2728
SHLIB_EXT="so"
2829
fi
@@ -41,6 +42,20 @@ find_shlib()
4142
fi
4243
}
4344

45+
find_shlib_dir()
46+
{
47+
# Usually, on platforms like OSX we get full paths when linking. However,
48+
# if we are inspecting, say, BinaryBuilder-built OpenBLAS libraries, we will
49+
# only get something like `@rpath/libgfortran.5.dylib` when inspecting the
50+
# libraries. We can, as a last resort, ask `$FC` directly what the full
51+
# filepath for this library is, but only if we don't have a direct path to it:
52+
if [ $(dirname "$1") = "@rpath" ]; then
53+
dirname "$($FC -print-file-name="$(basename "$1")" 2>/dev/null)"
54+
else
55+
dirname "$1" 2>/dev/null
56+
fi
57+
}
58+
4459
# First, discover all the places where libgfortran/libgcc is, as well as their true SONAMES
4560
for lib in lapack blas openblas; do
4661
for private_libname in ${private_libdir}/lib$lib*.$SHLIB_EXT*; do
@@ -51,10 +66,11 @@ for lib in lapack blas openblas; do
5166
LIBQUADMATH_PATH=$(find_shlib "$private_libname" libquadmath)
5267

5368
# Take the directories, add them onto LIBGFORTRAN_DIRS, which we use to
54-
# search for these libraries in the future.
55-
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(dirname $LIBGFORTRAN_PATH 2>/dev/null)"
56-
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(dirname $LIBGCC_PATH 2>/dev/null)"
57-
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(dirname $LIBQUADMATH_PATH 2>/dev/null)"
69+
# search for these libraries in the future. If there is no directory, try
70+
# asking `$FC` where such a file could be found.
71+
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(find_shlib_dir $LIBGFORTRAN_PATH)"
72+
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(find_shlib_dir $LIBGCC_PATH)"
73+
LIBGFORTRAN_DIRS="$LIBGFORTRAN_DIRS $(find_shlib_dir $LIBQUADMATH_PATH)"
5874

5975
# Save the SONAMES
6076
LIBGFORTRAN_SONAMES="$LIBGFORTRAN_SONAMES $(basename "$LIBGFORTRAN_PATH")"

0 commit comments

Comments
 (0)