Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backports for 1.0.3 #30010

Merged
merged 68 commits into from
Dec 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
dff0f81
Avoid slow fallback Matrix constructor when converting Q from QR, (#2…
andreasnoack Nov 2, 2018
f3f7951
Typo (#29899)
mschauer Nov 2, 2018
de8c260
avoid expensive runtime div in parse (#29892)
KristofferC Nov 2, 2018
3d45b69
Fix #29713 (ldiv! overwrites arguments) (#29715)
gragusa Nov 4, 2018
8e88a68
Update old reference to Base.REPL (#29910)
christopher-dG Nov 4, 2018
fc5df26
Make median! type stable for small float types (#29902)
andreasnoack Nov 5, 2018
1ef201a
Avoid reading inactive rowvals when computing the rank of a QRSparse …
andreasnoack Nov 5, 2018
cd62dc8
Add missing devdoc pages to make.jl (#29948)
mortenpi Nov 7, 2018
861c9db
Add missing backslashes in LaTeX syntax in the document of binomial f…
machakann Nov 7, 2018
e5862ce
Add backticks around som JL_* words in the manual to protect them fro…
fredrikekre Nov 8, 2018
6c4827f
Deploy docs to JuliaLang/docs.julialang.org:gh-pages instead of Julia…
fredrikekre Nov 9, 2018
cfcae77
mkpath should always return the path [fix #29989] (#29990)
StefanKarpinski Nov 10, 2018
9ae1530
file creation tests: check path existence before & after (#29994)
StefanKarpinski Nov 10, 2018
2d4ef03
Use SYSTEMROOT env variable for powershell detection (#29803)
musm Nov 7, 2018
f501a26
Faster findall for bitarrays (#29888)
maxbennedich Nov 10, 2018
fc9cb3e
Use at-DIR instead of Sys.BINDIR to find UnicodeData.txt in doc build…
fredrikekre Nov 14, 2018
cb9ff82
Include stdlib tarballs in light-source-dist. (#30000)
fredrikekre Nov 14, 2018
3bcd3f8
Move docs about Markdown from the Documentation section to the Markdo…
fredrikekre Nov 15, 2018
3af42db
Added note to highlight that some environment variables can't be set …
IanButterworth Nov 16, 2018
59d5de0
fix #29955, intersection bugs involving triangular constraints (#29986)
JeffBezanson Nov 16, 2018
9855dc8
Work around a llvm-config bug by creating a versioned symlink to libL…
maleadt Nov 14, 2018
841539a
clean up generated code for rational (#30036)
KristofferC Nov 16, 2018
49b839f
Fix backtrace line numbers following macros
tkluck Nov 12, 2018
29f13f3
Define text/latex printing of HorizontalRule with the latex function,…
fredrikekre Nov 13, 2018
1475f70
Also prepend a version number in source tarballs
mortenpi Oct 20, 2018
78b7137
Take 2: use symlinks
mortenpi Oct 20, 2018
4751af0
Remove status from exit calls
mortenpi Oct 26, 2018
8e8c93f
Split into separate commands
mortenpi Oct 27, 2018
33a5d6a
fix #30048, lowering gc_preserve of closure variables (#30051)
JeffBezanson Nov 19, 2018
ef19ed2
stdlib/SparseArrays: add rmul! and lmul! of sparse matrix with Diagon…
dkarrasch Sep 29, 2018
040ede8
Update the Regex section of strings.md. (#29921)
lewisl Nov 19, 2018
0ec67e7
Update arrays.md for element-wise assignment
anders-dc Sep 13, 2018
3890b97
Fix RoundNearestTiesAway (#29700)
simonbyrne Nov 19, 2018
e7eeb05
Make `broadcast_axes` inferrable even if axes are of different types
timholy Nov 18, 2018
a9f8753
Clarify the role of pivoting in QR factorization (#29976)
mzaffalon Nov 21, 2018
4d73211
error msg typo: "delcaration" -> "declaration" (#30106)
cormullion Nov 21, 2018
14b3aaf
Install `ccache` on OSX Travis (#30111)
staticfloat Nov 21, 2018
a9d68f4
Fix deadlock caused by REPL blinking
Keno Nov 21, 2018
5166c26
varinfo() is moved to `InteractiveUtils` (#30130)
YonghyunRyu Nov 23, 2018
91eaae5
document tab completion for dictionary keys (#30147)
bjarthur Nov 26, 2018
29749f2
[AllocOpt] Track deleted instructions
Keno Nov 23, 2018
5a773a5
Put boxed arguments in llvmcall into the correct addrspace
Keno Nov 19, 2018
8302431
Add test for llvmcall Function* interface
Keno Nov 20, 2018
8664908
fix #30030, assignment expr as named tuple element value (#30045)
JeffBezanson Nov 20, 2018
fd1e60f
Fix indexing with Union{} array (#30146)
simonbyrne Nov 25, 2018
459bd3e
inference: set limited flag on entire cycle
vtjnash Oct 24, 2018
711dce0
inference: improve method caching
vtjnash Oct 23, 2018
58d22f0
partially address #29293
vtjnash Oct 23, 2018
6682281
interpreter: fix pref regression from #29795 (#29873)
vtjnash Nov 2, 2018
5b67f8c
Fix indexing with Union{} array (#30146)
simonbyrne Nov 25, 2018
34fd056
stdlib-git: improve integration with git-external (#30075)
vtjnash Nov 26, 2018
65227b6
Fix issue with Git Credential Manager for Windows (#30195)
omus Nov 29, 2018
8f2eb31
Two documentation updates (#30049)
fingolfin Nov 30, 2018
393cd59
fix typo (#30209)
inkydragon Nov 30, 2018
d4e5c5d
Initialize the union selector of undefined upsilon nodes
Keno Sep 12, 2018
c5371af
Remove incorrect return in load_path_expand (#30224)
fredrikekre Dec 3, 2018
3164cfb
Update libosxunwind to v0.0.5 (#30231)
ararslan Dec 3, 2018
6505797
doc: fix typo for named regex capture group (#30237)
stev47 Dec 4, 2018
19d7763
speed up (de)serialization of Base bits types in abstract containers …
JeffBezanson Dec 4, 2018
9894c94
fix formatting in bullets for simdloop (#30261)
KristofferC Dec 4, 2018
db48467
fix #30234, don't resolve bindings when tab-completing `using` (#30254)
JeffBezanson Dec 5, 2018
751e981
fix #30122, bad type intersection involving NTuple and Vararg (#30265)
JeffBezanson Dec 5, 2018
23dc84b
avoid jl_arrayunset in dicts with bitstypes; add some more @inbounds
chethega Nov 21, 2018
1e03743
also skip jl_arrayunset for isbitsunion
chethega Nov 21, 2018
83afc97
amend typo
chethega Nov 22, 2018
22d6ba1
`isdeprecated` does not resolve binding (#29962)
pfitzseb Nov 9, 2018
800c0b7
Create new sparse matrix for R factor in sparse least square solve (#…
andreasnoack Dec 7, 2018
457d8c8
Bump Pkg to 1.0.3.
fredrikekre Dec 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ before_install:
contrib/travis_fastfail.sh || exit 1;
brew tap staticfloat/julia > /dev/null;
brew rm --force $(brew deps --HEAD julia);
brew install -v gcc gmp mpfr pcre2 staticfloat/julia/openblas-julia staticfloat/julia/suite-sparse-julia staticfloat/juliadeps/libgfortran;
brew install -v ccache gcc gmp mpfr pcre2 staticfloat/julia/openblas-julia staticfloat/julia/suite-sparse-julia staticfloat/juliadeps/libgfortran;
BUILDOPTS="-j3 USECLANG=1 USECCACHE=1 BINARYBUILDER_TRIPLET=x86_64-apple-darwin14 BINARYBUILDER_LLVM_ASSERTS=1";
BUILDOPTS="$BUILDOPTS USE_BINARYBUILDER_LLVM=1 LLVM_CONFIG=$TRAVIS_BUILD_DIR/usr/tools/llvm-config LLVM_SIZE=$TRAVIS_BUILD_DIR/usr/tools/llvm-size";
BUILDOPTS="$BUILDOPTS VERBOSE=1 USE_BLAS64=0 SUITESPARSE_INC=-I$(brew --prefix suite-sparse-julia)/include FORCE_ASSERTIONS=1";
Expand Down
16 changes: 9 additions & 7 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1177,22 +1177,24 @@ $(subst /,\\,$(subst $(shell $(2) pwd),$(shell $(2) cmd //C cd),$(abspath $(1)))
endef
endif

define symlink_target
CLEAN_TARGETS += clean-$(2)/$(3)
define symlink_target # (from, to-dir, to-name)
CLEAN_TARGETS += clean-$$(abspath $(2)/$(3))
clean-$$(abspath $(2)/$(3)):
ifeq ($(BUILD_OS), WINNT)
@-cmd //C rmdir $$(call mingw_to_dos,$(2)/$(3),cd $(2) &&)
-cmd //C rmdir $$(call mingw_to_dos,$(2)/$(3),cd $(2) &&)
else
@-rm $$(abspath $(2)/$(3))
-rm -r $$(abspath $(2)/$(3))
endif
$$(subst $$(abspath $(JULIAHOME))/,,$$(abspath $(2)/$(3))): $$(abspath $(2)/$(3))
$$(abspath $(2)/$(3)): | $$(abspath $(2))
ifeq ($(BUILD_OS), WINNT)
ifeq ($$(BUILD_OS), WINNT)
@cmd //C mklink //J $$(call mingw_to_dos,$(2)/$(3),cd $(2) &&) $$(call mingw_to_dos,$(1),)
else ifneq (,$(findstring CYGWIN,$(BUILD_OS)))
else ifneq (,$$(findstring CYGWIN,$$(BUILD_OS)))
@cmd /C mklink /J $$(call cygpath_w,$(2)/$(3)) $$(call cygpath_w,$(1))
else ifdef JULIA_VAGRANT_BUILD
@cp -R $$(abspath $(1)) $$@
@rm -r $$@
@cp -R $$(abspath $(1)) [email protected]
@mv [email protected] $$@
else
@ln -sf $$(abspath $(1)) $$@
endif
Expand Down
59 changes: 36 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ configure:
endif

$(foreach dir,$(DIRS),$(eval $(call dir_target,$(dir))))
$(foreach link,base $(JULIAHOME)/test,$(eval $(call symlink_target,$(link),$(build_datarootdir)/julia,$(notdir $(link)))))
$(foreach link,base $(JULIAHOME)/test,$(eval $(call symlink_target,$(link),$$(build_datarootdir)/julia,$(notdir $(link)))))

julia_flisp.boot.inc.phony: julia-deps
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src julia_flisp.boot.inc.phony
Expand Down Expand Up @@ -65,6 +65,9 @@ julia-base: julia-deps $(build_sysconfdir)/julia/startup.jl $(build_man1dir)/jul
julia-libccalltest: julia-deps
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src libccalltest

julia-libllvmcalltest: julia-deps
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src libllvmcalltest

julia-src-release julia-src-debug : julia-src-% : julia-deps julia_flisp.boot.inc.phony
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT)/src libjulia-$*

Expand All @@ -80,7 +83,7 @@ julia-sysimg-release : julia-stdlib julia-sysimg julia-ui-release
julia-sysimg-debug : julia-stdlib julia-sysimg julia-ui-debug
@$(MAKE) $(QUIET_MAKE) -C $(BUILDROOT) $(build_private_libdir)/sys-debug.$(SHLIB_EXT)

julia-debug julia-release : julia-% : julia-ui-% julia-sysimg-% julia-symlink julia-libccalltest julia-base-cache
julia-debug julia-release : julia-% : julia-ui-% julia-sysimg-% julia-symlink julia-libccalltest julia-libllvmcalltest julia-base-cache

debug release : % : julia-%

Expand Down Expand Up @@ -180,10 +183,8 @@ COMPILER_SRCS := $(addprefix $(JULIAHOME)/, \
COMPILER_SRCS += $(shell find $(JULIAHOME)/base/compiler -name \*.jl)
# sort these to remove duplicates
BASE_SRCS := $(sort $(shell find $(JULIAHOME)/base -name \*.jl -and -not -name sysimg.jl) \
$(shell find $(BUILDROOT)/base -name \*.jl -and -not -name sysimg.jl)) \
$(shell find $(JULIAHOME)/stdlib/Base64/src -name \*.jl)
STDLIB_SRCS := $(JULIAHOME)/base/sysimg.jl $(shell find $(JULIAHOME)/stdlib/*/src -name \*.jl)
STDLIB_PKGS := $(shell cd $(JULIAHOME)/stdlib && ls)
$(shell find $(BUILDROOT)/base -name \*.jl -and -not -name sysimg.jl))
STDLIB_SRCS := $(JULIAHOME)/base/sysimg.jl $(shell find $(build_datarootdir)/julia/stdlib/$(VERSDIR)/*/src -name \*.jl)
RELBUILDROOT := $(shell $(JULIAHOME)/contrib/relative_path.sh "$(JULIAHOME)/base" "$(BUILDROOT)/base/")

$(build_private_libdir)/corecompiler.ji: $(COMPILER_SRCS) | $(build_private_libdir)
Expand Down Expand Up @@ -230,7 +231,7 @@ JL_TARGETS += julia-debug
endif

# private libraries, that are installed in $(prefix)/lib/julia
JL_PRIVATE_LIBS-0 := libccalltest
JL_PRIVATE_LIBS-0 := libccalltest libllvmcalltest
ifeq ($(USE_GPL_LIBS), 1)
JL_PRIVATE_LIBS-0 += libsuitesparse_wrapper
JL_PRIVATE_LIBS-$(USE_SYSTEM_SUITESPARSE) += libamd libcamd libccolamd libcholmod libcolamd libumfpack libspqr libsuitesparseconfig
Expand Down Expand Up @@ -381,6 +382,10 @@ endif
# Remove various files which should not be installed
-rm -f $(DESTDIR)$(datarootdir)/julia/base/version_git.sh
-rm -f $(DESTDIR)$(datarootdir)/julia/test/Makefile
-rm -f $(DESTDIR)$(datarootdir)/julia/stdlib/$(VERSDIR)/*/source-extracted
-rm -f $(DESTDIR)$(datarootdir)/julia/stdlib/$(VERSDIR)/*/build-configured
-rm -f $(DESTDIR)$(datarootdir)/julia/stdlib/$(VERSDIR)/*/build-compiled
-rm -f $(DESTDIR)$(datarootdir)/julia/stdlib/$(VERSDIR)/*/build-checked
# Copy in beautiful new man page
$(INSTALL_F) $(build_man1dir)/julia.1 $(DESTDIR)$(man1dir)/
# Copy icon and .desktop file
Expand Down Expand Up @@ -431,12 +436,9 @@ endif
mkdir -p $(DESTDIR)$(sysconfdir)
cp -R $(build_sysconfdir)/julia $(DESTDIR)$(sysconfdir)/

distclean dist-clean:
distclean:
-rm -fr $(BUILDROOT)/julia-*.tar.gz $(BUILDROOT)/julia*.exe $(BUILDROOT)/julia-*.7z $(BUILDROOT)/julia-$(JULIA_COMMIT)

dist:
@echo \'dist\' target is deprecated: use \'binary-dist\' instead.

binary-dist: distclean
ifeq ($(USE_SYSTEM_BLAS),0)
ifeq ($(ISX86),1)
Expand Down Expand Up @@ -511,16 +513,24 @@ endif

# Create file light-source-dist.tmp to hold all the filenames that go into the tarball
echo "base/version_git.jl" > light-source-dist.tmp

# Download all stdlibs and include the tarball filenames in light-source-dist.tmp
@$(MAKE) -C stdlib getall NO_GIT=1
-ls stdlib/srccache/*.tar.gz >> light-source-dist.tmp

# Exclude git, github and CI config files
git ls-files | sed -E -e '/^\..+/d' -e '/\/\..+/d' -e '/appveyor.yml/d' >> light-source-dist.tmp
find doc/_build/html >> light-source-dist.tmp

# Make tarball with only Julia code
# Make tarball with only Julia code + stdlib tarballs
light-source-dist: light-source-dist.tmp
# Prefix everything with the current directory name (usually "julia"), then create tarball
DIRNAME=$$(basename $$(pwd)); \
sed -e "s_.*_$$DIRNAME/&_" light-source-dist.tmp > light-source-dist.tmp1; \
cd ../ && tar -cz --no-recursion -T $$DIRNAME/light-source-dist.tmp1 -f $$DIRNAME/julia-$(JULIA_VERSION)_$(JULIA_COMMIT).tar.gz
# Prefix everything with "julia-$(commit-sha)/" or "julia-$(version)/" and then create tarball
# To achieve prefixing, we temporarily create a symlink in the source directory that points back
# to the source directory.
sed -e "s_.*_julia-${JULIA_COMMIT}/&_" light-source-dist.tmp > light-source-dist.tmp1
ln -s . julia-${JULIA_COMMIT}
tar -cz --no-recursion -T light-source-dist.tmp1 -f julia-$(JULIA_VERSION)_$(JULIA_COMMIT).tar.gz
rm julia-${JULIA_COMMIT}

source-dist:
@echo \'source-dist\' target is deprecated: use \'full-source-dist\' instead.
Expand All @@ -529,24 +539,26 @@ source-dist:
full-source-dist: light-source-dist.tmp
# Get all the dependencies downloaded
@$(MAKE) -C deps getall NO_GIT=1
@$(MAKE) -C stdlib getall

# Create file full-source-dist.tmp to hold all the filenames that go into the tarball
cp light-source-dist.tmp full-source-dist.tmp
-ls deps/srccache/*.tar.gz deps/srccache/*.tar.bz2 deps/srccache/*.tar.xz deps/srccache/*.tgz deps/srccache/*.zip deps/srccache/*.pem stdlib/srccache/*.tar.gz >> full-source-dist.tmp
-ls deps/srccache/*.tar.gz deps/srccache/*.tar.bz2 deps/srccache/*.tar.xz deps/srccache/*.tgz deps/srccache/*.zip deps/srccache/*.pem >> full-source-dist.tmp

# Prefix everything with the current directory name (usually "julia"), then create tarball
DIRNAME=$$(basename $$(pwd)); \
sed -e "s_.*_$$DIRNAME/&_" full-source-dist.tmp > full-source-dist.tmp1; \
cd ../ && tar -cz --no-recursion -T $$DIRNAME/full-source-dist.tmp1 -f $$DIRNAME/julia-$(JULIA_VERSION)_$(JULIA_COMMIT)-full.tar.gz
# Prefix everything with "julia-$(commit-sha)/" or "julia-$(version)/" and then create tarball
# To achieve prefixing, we temporarily create a symlink in the source directory that points back
# to the source directory.
sed -e "s_.*_julia-${JULIA_COMMIT}/&_" full-source-dist.tmp > full-source-dist.tmp1
ln -s . julia-${JULIA_COMMIT}
tar -cz --no-recursion -T full-source-dist.tmp1 -f julia-$(JULIA_VERSION)_$(JULIA_COMMIT)-full.tar.gz
rm julia-${JULIA_COMMIT}

clean: | $(CLEAN_TARGETS)
@-$(MAKE) -C $(BUILDROOT)/base clean
@-$(MAKE) -C $(BUILDROOT)/doc clean
@-$(MAKE) -C $(BUILDROOT)/src clean
@-$(MAKE) -C $(BUILDROOT)/ui clean
@-$(MAKE) -C $(BUILDROOT)/test clean
@-$(MAKE) -C $(BUILDROOT)/stdlib clean-pkg
@-$(MAKE) -C $(BUILDROOT)/stdlib clean
-rm -f $(BUILDROOT)/julia
-rm -f $(BUILDROOT)/*.tar.gz
-rm -f $(build_depsbindir)/stringreplace \
Expand All @@ -562,6 +574,7 @@ cleanall: clean
-rm -fr $(build_prefix) $(build_staging)

distcleanall: cleanall
@-$(MAKE) -C $(BUILDROOT)/stdlib distclean
@-$(MAKE) -C $(BUILDROOT)/deps distcleanall
@-$(MAKE) -C $(BUILDROOT)/doc cleanall

Expand Down
83 changes: 58 additions & 25 deletions base/bitarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1510,37 +1510,70 @@ function findprev(testf::Function, B::BitArray, start::Integer)
end
#findlast(testf::Function, B::BitArray) = findprev(testf, B, 1) ## defined in array.jl

# findall helper functions
# Generic case (>2 dimensions)
function allindices!(I, B::BitArray)
ind = first(keys(B))
for k = 1:length(B)
I[k] = ind
ind = nextind(B, ind)
end
end

# Optimized case for vector
function allindices!(I, B::BitVector)
I[:] .= 1:length(B)
end

# Optimized case for matrix
function allindices!(I, B::BitMatrix)
k = 1
for c = 1:size(B,2), r = 1:size(B,1)
I[k] = CartesianIndex(r, c)
k += 1
end
end

@inline _overflowind(i1, irest::Tuple{}, size) = (i1, irest)
@inline function _overflowind(i1, irest, size)
i2 = irest[1]
while i1 > size[1]
i1 -= size[1]
i2 += 1
end
i2, irest = _overflowind(i2, tail(irest), tail(size))
return (i1, (i2, irest...))
end

@inline _toind(i1, irest::Tuple{}) = i1
@inline _toind(i1, irest) = CartesianIndex(i1, irest...)

function findall(B::BitArray)
l = length(B)
nnzB = count(B)
ind = first(keys(B))
I = Vector{typeof(ind)}(undef, nnzB)
I = Vector{eltype(keys(B))}(undef, nnzB)
nnzB == 0 && return I
nnzB == length(B) && (allindices!(I, B); return I)
Bc = B.chunks
Icount = 1
for i = 1:length(Bc)-1
u = UInt64(1)
c = Bc[i]
for j = 1:64
if c & u != 0
I[Icount] = ind
Icount += 1
end
ind = nextind(B, ind)
u <<= 1
end
end
u = UInt64(1)
c = Bc[end]
for j = 0:_mod64(l-1)
if c & u != 0
I[Icount] = ind
Icount += 1
Bs = size(B)
Bi = i1 = i = 1
irest = ntuple(one, ndims(B) - 1)
c = Bc[1]
@inbounds while true
while c == 0
Bi == length(Bc) && return I
i1 += 64
Bi += 1
c = Bc[Bi]
end
ind = nextind(B, ind)
u <<= 1

tz = trailing_zeros(c)
c = _blsr(c)

i1, irest = _overflowind(i1 + tz, irest, Bs)
I[i] = _toind(i1, irest)
i += 1
i1 -= tz
end
return I
end

# For performance
Expand Down
10 changes: 9 additions & 1 deletion base/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,19 @@ end
_bcs1(a::Integer, b::Integer) = a == 1 ? b : (b == 1 ? a : (a == b ? a : throw(DimensionMismatch("arrays could not be broadcast to a common size"))))
_bcs1(a::Integer, b) = a == 1 ? b : (first(b) == 1 && last(b) == a ? b : throw(DimensionMismatch("arrays could not be broadcast to a common size")))
_bcs1(a, b::Integer) = _bcs1(b, a)
_bcs1(a, b) = _bcsm(b, a) ? b : (_bcsm(a, b) ? a : throw(DimensionMismatch("arrays could not be broadcast to a common size")))
_bcs1(a, b) = _bcsm(b, a) ? _sametype(b, a) : (_bcsm(a, b) ? _sametype(a, b) : throw(DimensionMismatch("arrays could not be broadcast to a common size")))
# _bcsm tests whether the second index is consistent with the first
_bcsm(a, b) = a == b || length(b) == 1
_bcsm(a, b::Number) = b == 1
_bcsm(a::Number, b::Number) = a == b || b == 1
# Ensure inferrability when dealing with axes of different AbstractUnitRange types
# (We may not want to define general promotion rules between, say, OneTo and Slice, but if
# we get here we know the axes are at least consistent)
_sametype(a::T, b::T) where T = a
_sametype(a::OneTo, b::OneTo) = OneTo{Int}(a)
_sametype(a::OneTo, b) = OneTo{Int}(a)
_sametype(a, b::OneTo) = OneTo{Int}(a)
_sametype(a, b) = UnitRange{Int}(a)

## Check that all arguments are broadcast compatible with shape
# comparing one input against a shape
Expand Down
45 changes: 43 additions & 2 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const _REF_NAME = Ref.body.name
# logic #
#########

# see if the inference result might affect the final answer
call_result_unused(frame::InferenceState, pc::LineNum=frame.currpc) =
isexpr(frame.src.code[frame.currpc], :call) && isempty(frame.ssavalue_uses[pc])

function abstract_call_gf_by_type(@nospecialize(f), argtypes::Vector{Any}, @nospecialize(atype), sv::InferenceState)
atype_params = unwrap_unionall(atype).parameters
ft = unwrap_unionall(atype_params[1]) # TODO: ccall jl_first_argument_datatype here
Expand Down Expand Up @@ -95,6 +99,7 @@ function abstract_call_gf_by_type(@nospecialize(f), argtypes::Vector{Any}, @nosp
rettype === Any && break
end
# try constant propagation if only 1 method is inferred to non-Bottom
# this is in preparation for inlining, or improving the return result
if nonbot > 0 && seen == napplicable && !edgecycle && isa(rettype, Type) && sv.params.ipo_constant_propagation
# if there's a possibility we could constant-propagate a better result
# (hopefully without doing too much work), try to do that now
Expand All @@ -105,6 +110,15 @@ function abstract_call_gf_by_type(@nospecialize(f), argtypes::Vector{Any}, @nosp
rettype = const_rettype
end
end
if call_result_unused(sv) && !(rettype === Bottom)
# We're mainly only here because the optimizer might want this code,
# but we ourselves locally don't typically care about it locally
# (beyond checking if it always throws).
# So avoid adding an edge, since we don't want to bother attempting
# to improve our result even if it does change (to always throw),
# and avoid keeping track of a more complex result type.
rettype = Any
end
if !(rettype === Any) # adding a new method couldn't refine (widen) this type
for edge in edges
add_backedge!(edge::MethodInstance, sv)
Expand Down Expand Up @@ -232,6 +246,13 @@ function abstract_call_method(method::Method, @nospecialize(sig), sparams::Simpl
if infstate.linfo.specTypes == sig
# avoid widening when detecting self-recursion
# TODO: merge call cycle and return right away
if call_result_unused(sv)
# since we don't use the result (typically),
# we have a self-cycle in the call-graph, but not in the inference graph (typically):
# break this edge now (before we record it) by returning early
# (non-typically, this means that we lose the ability to detect a guaranteed StackOverflow in some cases)
return Any, false, nothing
end
topmost = nothing
edgecycle = true
break
Expand Down Expand Up @@ -299,9 +320,27 @@ function abstract_call_method(method::Method, @nospecialize(sig), sparams::Simpl
if newsig !== sig
# continue inference, but note that we've limited parameter complexity
# on this call (to ensure convergence), so that we don't cache this result
if call_result_unused(sv)
# if we don't (typically) actually care about this result,
# don't bother trying to examine some complex abstract signature
# since it's very unlikely that we'll try to inline this,
# or want make an invoke edge to its calling convention return type.
# (non-typically, this means that we lose the ability to detect a guaranteed StackOverflow in some cases)
return Any, false, nothing
end
infstate = sv
topmost = topmost::InferenceState
while !(infstate.parent === topmost.parent)
while !(infstate === topmost.parent)
if call_result_unused(infstate)
# If we won't propagate the result any further (since it's typically unused),
# it's OK that we keep and cache the "limited" result in the parents
# (non-typically, this means that we lose the ability to detect a guaranteed StackOverflow in some cases)
# TODO: we might be able to halt progress much more strongly here,
# since now we know we won't be able to keep anything much that we learned.
# We were mainly only here to compute the calling convention return type,
# but in most situations now, we are unlikely to be able to use that information.
break
end
infstate.limited = true
for infstate_cycle in infstate.callers_in_cycle
infstate_cycle.limited = true
Expand Down Expand Up @@ -1080,7 +1119,9 @@ function typeinf_local(frame::InferenceState)
frame.bestguess = tmerge(frame.bestguess, rt)
for (caller, caller_pc) in frame.cycle_backedges
# notify backedges of updated type information
if caller.stmt_types[caller_pc] !== ()
typeassert(caller.stmt_types[caller_pc], VarTable) # we must have visited this statement before
if !(caller.src.ssavaluetypes[caller_pc] === Any)
# no reason to revisit if that call-site doesn't affect the final result
if caller_pc < caller.pc´´
caller.pc´´ = caller_pc
end
Expand Down
Loading