Skip to content

Commit

Permalink
Merge branch 'master' into build-rm-Versions.make
Browse files Browse the repository at this point in the history
  • Loading branch information
inkydragon committed Jun 18, 2022
1 parent 1850865 commit 15f31d5
Show file tree
Hide file tree
Showing 37 changed files with 829 additions and 477 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ else
JL_PRIVATE_LIBS-$(USE_SYSTEM_ZLIB) += libz
endif
ifeq ($(USE_LLVM_SHLIB),1)
JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM libLLVM-13jl
JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM libLLVM-14jl
endif
JL_PRIVATE_LIBS-$(USE_SYSTEM_LIBUNWIND) += libunwind

Expand Down
2 changes: 1 addition & 1 deletion base/binaryplatforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ function detect_cxxstring_abi()
end

function open_libllvm(f::Function)
for lib_name in ("libLLVM-13jl", "libLLVM", "LLVM", "libLLVMSupport")
for lib_name in ("libLLVM-14jl", "libLLVM", "LLVM", "libLLVMSupport")
hdl = Libdl.dlopen_e(lib_name)
if hdl != C_NULL
try
Expand Down
6 changes: 5 additions & 1 deletion contrib/refresh_checksums.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ NON_CLANG_TRIPLETS=$(filter-out %-darwin %-freebsd,$(TRIPLETS))
# These are the projects currently using BinaryBuilder; both GCC-expanded and non-GCC-expanded:
BB_PROJECTS=mbedtls libssh2 nghttp2 mpfr curl libgit2 pcre libuv unwind llvmunwind dsfmt objconv p7zip zlib libsuitesparse openlibm blastrampoline
BB_GCC_EXPANDED_PROJECTS=openblas csl
BB_CXX_EXPANDED_PROJECTS=gmp llvm clang llvm-tools
BB_CXX_EXPANDED_PROJECTS=gmp llvm clang llvm-tools lld
# These are non-BB source-only deps
NON_BB_PROJECTS=patchelf mozillacert lapack libwhich utf8proc

Expand Down Expand Up @@ -80,8 +80,12 @@ $(foreach project,$(BB_CXX_EXPANDED_PROJECTS),$(foreach triplet,$(CLANG_TRIPLETS

# Special libLLVM_asserts_jll/LLVM_assert_jll targets
$(foreach triplet,$(NON_CLANG_TRIPLETS),$(foreach cxxstring_abi,cxx11 cxx03,$(eval $(call checksum_dep,llvm,$(triplet)-$(cxxstring_abi),assert))))
$(foreach triplet,$(NON_CLANG_TRIPLETS),$(foreach cxxstring_abi,cxx11 cxx03,$(eval $(call checksum_dep,clang,$(triplet)-$(cxxstring_abi),assert))))
$(foreach triplet,$(NON_CLANG_TRIPLETS),$(foreach cxxstring_abi,cxx11 cxx03,$(eval $(call checksum_dep,lld,$(triplet)-$(cxxstring_abi),assert))))
$(foreach triplet,$(NON_CLANG_TRIPLETS),$(foreach cxxstring_abi,cxx11 cxx03,$(eval $(call checksum_dep,llvm-tools,$(triplet)-$(cxxstring_abi),assert))))
$(foreach triplet,$(CLANG_TRIPLETS),$(eval $(call checksum_dep,llvm,$(triplet),assert)))
$(foreach triplet,$(CLANG_TRIPLETS),$(eval $(call checksum_dep,clang,$(triplet),assert)))
$(foreach triplet,$(CLANG_TRIPLETS),$(eval $(call checksum_dep,lld,$(triplet),assert)))
$(foreach triplet,$(CLANG_TRIPLETS),$(eval $(call checksum_dep,llvm-tools,$(triplet),assert)))

# External stdlibs
Expand Down
174 changes: 116 additions & 58 deletions deps/checksums/clang

Large diffs are not rendered by default.

116 changes: 116 additions & 0 deletions deps/checksums/lld

Large diffs are not rendered by default.

502 changes: 268 additions & 234 deletions deps/checksums/llvm

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deps/clang.version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## jll artifact
# Clang (paired with LLVM, only here as a JLL download)
CLANG_JLL_NAME := Clang
CLANG_JLL_VER := 13.0.1+0
CLANG_JLL_VER := 14.0.2+1
3 changes: 3 additions & 0 deletions deps/lld.version
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## jll artifact
LLD_JLL_NAME := LLD
LLD_JLL_VER := 14.0.2+1
4 changes: 2 additions & 2 deletions deps/llvm-tools.version
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## jll artifact
# LLVM_tools (downloads LLVM_jll to get things like `lit` and `opt`)
LLVM_TOOLS_JLL_NAME := LLVM
LLVM_TOOLS_JLL_VER := 13.0.1+0
LLVM_TOOLS_ASSERT_JLL_VER := 13.0.1+0
LLVM_TOOLS_JLL_VER := 14.0.2+1
LLVM_TOOLS_ASSERT_JLL_VER := 14.0.2+1
23 changes: 18 additions & 5 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ LLVM_CMAKE += -DLLVM_EXTERNAL_RV_SOURCE_DIR=$(LLVM_MONOSRC_DIR)/rv
LLVM_CMAKE += -DLLVM_CXX_STD=c++14
endif

# Otherwise LLVM will translate \\ to / on mingw
LLVM_CMAKE += -DLLVM_WINDOWS_PREFER_FORWARD_SLASH=False

# Allow adding LLVM specific flags
LLVM_CFLAGS += $(CFLAGS)
LLVM_CXXFLAGS += $(CXXFLAGS)
Expand Down Expand Up @@ -286,16 +289,26 @@ else # USE_BINARYBUILDER_LLVM

# We provide a way to subversively swap out which LLVM JLL we pull artifacts from
ifeq ($(LLVM_ASSERTIONS), 1)
LLVM_JLL_DOWNLOAD_NAME := libLLVM_assert
LLVM_JLL_VER := $(LLVM_ASSERT_JLL_VER)
LLVM_TOOLS_JLL_DOWNLOAD_NAME := LLVM_assert
LLVM_TOOLS_JLL_VER := $(LLVM_TOOLS_ASSERT_JLL_VER)
# LLVM_JLL_DOWNLOAD_NAME := libLLVM_assert
# LLVM_JLL_VER := $(LLVM_ASSERT_JLL_VER)
# LLVM_TOOLS_JLL_DOWNLOAD_NAME := LLVM_assert
# LLVM_TOOLS_JLL_VER := $(LLVM_TOOLS_ASSERT_JLL_VER)
LLVM_JLL_TAGS := -llvm_version+$(LLVM_VER_MAJ).asserts
CLANG_JLL_TAGS := -llvm_version+$(LLVM_VER_MAJ).asserts
LLD_JLL_TAGS := -llvm_version+$(LLVM_VER_MAJ).asserts
LLVM_TOOLS_JLL_TAGS := -llvm_version+$(LLVM_VER_MAJ).asserts
else
LLVM_JLL_TAGS := -llvm_version+$(LLVM_VER_MAJ)
CLANG_JLL_TAGS := -llvm_version+$(LLVM_VER_MAJ)
LLD_JLL_TAGS := -llvm_version+$(LLVM_VER_MAJ)
LLVM_TOOLS_JLL_TAGS := -llvm_version+$(LLVM_VER_MAJ)
endif

$(eval $(call bb-install,llvm,LLVM,false,true))
$(eval $(call bb-install,clang,CLANG,false,true))
$(eval $(call bb-install,lld,LLD,false,true))
$(eval $(call bb-install,llvm-tools,LLVM_TOOLS,false,true))

install-clang install-llvm-tools: install-llvm
install-lld install-clang install-llvm-tools: install-llvm

endif # USE_BINARYBUILDER_LLVM
8 changes: 4 additions & 4 deletions deps/llvm.version
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
## jll artifact
LLVM_JLL_NAME := libLLVM
LLVM_ASSERT_JLL_VER := 13.0.1+0
LLVM_ASSERT_JLL_VER := 14.0.2+1

## source build
LLVM_VER := 13.0.1
LLVM_BRANCH=julia-13.0.1-0
LLVM_SHA1=julia-13.0.1-0
LLVM_VER := 14.0.2
LLVM_BRANCH=julia-14.0.2-1
LLVM_SHA1=julia-14.0.2-1
7 changes: 5 additions & 2 deletions deps/tools/bb-install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ $(2)_JLL_VER ?= $$(shell [ -f $$($(2)_STDLIB_PATH)/Project.toml ] && grep "^vers
# Allow things to override which JLL we pull from, e.g. libLLVM_jll vs. libLLVM_assert_jll
$(2)_JLL_DOWNLOAD_NAME ?= $$($(2)_JLL_NAME)

# Allow things to provide platform tags
$(2)_JLL_TAGS ?=

$(2)_BB_TRIPLET := $$($$(TRIPLET_VAR))
$(2)_JLL_VER_NOPLUS := $$(firstword $$(subst +,$(SPACE),$$($(2)_JLL_VER)))
$(2)_JLL_BASENAME := $$($(2)_JLL_DOWNLOAD_NAME).v$$($(2)_JLL_VER).$$($(2)_BB_TRIPLET).tar.gz
$(2)_BB_URL := https://github.com/JuliaBinaryWrappers/$$($(2)_JLL_DOWNLOAD_NAME)_jll.jl/releases/download/$$($(2)_JLL_DOWNLOAD_NAME)-v$$($(2)_JLL_VER)/$$($(2)_JLL_DOWNLOAD_NAME).v$$($(2)_JLL_VER_NOPLUS).$$($(2)_BB_TRIPLET).tar.gz
$(2)_JLL_BASENAME := $$($(2)_JLL_DOWNLOAD_NAME).v$$($(2)_JLL_VER).$$($(2)_BB_TRIPLET)$$($(2)_JLL_TAGS).tar.gz
$(2)_BB_URL := https://github.com/JuliaBinaryWrappers/$$($(2)_JLL_DOWNLOAD_NAME)_jll.jl/releases/download/$$($(2)_JLL_DOWNLOAD_NAME)-v$$($(2)_JLL_VER)/$$($(2)_JLL_DOWNLOAD_NAME).v$$($(2)_JLL_VER_NOPLUS).$$($(2)_BB_TRIPLET)$$($(2)_JLL_TAGS).tar.gz

$$(SRCCACHE)/$$($(2)_JLL_BASENAME): | $$(SRCCACHE)
$$(JLDOWNLOAD) $$@ $$($(2)_BB_URL)
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ else
ifeq ($(OS), Darwin)
CG_LLVMLINK += $(LLVM_LDFLAGS) -lLLVM
else
CG_LLVMLINK += $(LLVM_LDFLAGS) -lLLVM-13jl
CG_LLVMLINK += $(LLVM_LDFLAGS) -lLLVM-14jl
endif
endif
endif
Expand Down
40 changes: 24 additions & 16 deletions src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,19 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level,
// to merge allocations and sometimes eliminate them,
// since AllocOpt does not handle PhiNodes.
// Enable this instruction hoisting because of this and Union benchmarks.
auto simplifyCFGOptions = SimplifyCFGOptions().hoistCommonInsts(true);
auto basicSimplifyCFGOptions = SimplifyCFGOptions()
.convertSwitchRangeToICmp(true)
.convertSwitchToLookupTable(true)
.forwardSwitchCondToPhi(true);
auto aggressiveSimplifyCFGOptions = SimplifyCFGOptions()
.convertSwitchRangeToICmp(true)
.convertSwitchToLookupTable(true)
.forwardSwitchCondToPhi(true)
//These mess with loop rotation, so only do them after that
.hoistCommonInsts(true)
// Causes an SRET assertion error in late-gc-lowering
// .sinkCommonInsts(true)
;
#ifdef JL_DEBUG_BUILD
PM->add(createGCInvariantVerifierPass(true));
PM->add(createVerifierPass());
Expand All @@ -646,7 +658,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level,
if (opt_level == 1)
PM->add(createInstSimplifyLegacyPass());
}
PM->add(createCFGSimplificationPass(simplifyCFGOptions));
PM->add(createCFGSimplificationPass(basicSimplifyCFGOptions));
if (opt_level == 1) {
PM->add(createSROAPass());
PM->add(createInstructionCombiningPass());
Expand Down Expand Up @@ -676,7 +688,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level,
// minimal clean-up to get rid of CPU feature checks
if (opt_level == 1) {
PM->add(createInstSimplifyLegacyPass());
PM->add(createCFGSimplificationPass(simplifyCFGOptions));
PM->add(createCFGSimplificationPass(basicSimplifyCFGOptions));
}
}
#if defined(_COMPILER_ASAN_ENABLED_)
Expand All @@ -697,7 +709,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level,
PM->add(createBasicAAWrapperPass());
}

PM->add(createCFGSimplificationPass(simplifyCFGOptions));
PM->add(createCFGSimplificationPass(basicSimplifyCFGOptions));
PM->add(createDeadCodeEliminationPass());
PM->add(createSROAPass());

Expand All @@ -711,7 +723,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level,
PM->add(createAllocOptPass());
// consider AggressiveInstCombinePass at optlevel > 2
PM->add(createInstructionCombiningPass());
PM->add(createCFGSimplificationPass(simplifyCFGOptions));
PM->add(createCFGSimplificationPass(basicSimplifyCFGOptions));
if (dump_native)
PM->add(createMultiVersioningPass(external_use));
PM->add(createCPUFeaturesPass());
Expand Down Expand Up @@ -781,27 +793,23 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level,
PM->add(createGVNPass()); // Must come after JumpThreading and before LoopVectorize
}
PM->add(createDeadStoreEliminationPass());
// see if all of the constant folding has exposed more loops
// to simplification and deletion
// this helps significantly with cleaning up iteration
PM->add(createCFGSimplificationPass(aggressiveSimplifyCFGOptions));

// More dead allocation (store) deletion before loop optimization
// consider removing this:
// Moving this after aggressive CFG simplification helps deallocate when allocations are hoisted
PM->add(createAllocOptPass());
// see if all of the constant folding has exposed more loops
// to simplification and deletion
// this helps significantly with cleaning up iteration
PM->add(createCFGSimplificationPass()); // See note above, don't hoist instructions before LV
PM->add(createLoopDeletionPass());
PM->add(createInstructionCombiningPass());
PM->add(createLoopVectorizePass());
PM->add(createLoopLoadEliminationPass());
// Cleanup after LV pass
PM->add(createInstructionCombiningPass());
PM->add(createCFGSimplificationPass( // Aggressive CFG simplification
SimplifyCFGOptions()
.forwardSwitchCondToPhi(true)
.convertSwitchToLookupTable(true)
.needCanonicalLoops(false)
.hoistCommonInsts(true)
// .sinkCommonInsts(true) // FIXME: Causes assertion in llvm-late-lowering
aggressiveSimplifyCFGOptions
));
PM->add(createSLPVectorizerPass());
// might need this after LLVM 11:
Expand All @@ -812,7 +820,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level,
if (lower_intrinsics) {
// LowerPTLS removes an indirect call. As a result, it is likely to trigger
// LLVM's devirtualization heuristics, which would result in the entire
// pass pipeline being re-exectuted. Prevent this by inserting a barrier.
// pass pipeline being re-executed. Prevent this by inserting a barrier.
PM->add(createBarrierNoopPass());
PM->add(createLowerExcHandlersPass());
PM->add(createGCInvariantVerifierPass(false));
Expand Down
2 changes: 1 addition & 1 deletion src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ static Type *bitstype_to_llvm(jl_value_t *bt, LLVMContext &ctxt, bool llvmcall =
{
assert(jl_is_primitivetype(bt));
if (bt == (jl_value_t*)jl_bool_type)
return getInt8Ty(ctxt);
return llvmcall ? getInt1Ty(ctxt) : getInt8Ty(ctxt);
if (bt == (jl_value_t*)jl_int32_type)
return getInt32Ty(ctxt);
if (bt == (jl_value_t*)jl_int64_type)
Expand Down
4 changes: 3 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2090,12 +2090,14 @@ static void jl_init_function(Function *F)
// i686 Windows (which uses a 4-byte-aligned stack)
#if JL_LLVM_VERSION >= 140000
AttrBuilder attr(F->getContext());
attr.addStackAlignmentAttr(16);
F->addFnAttrs(attr);
#else
AttrBuilder attr;
#endif
attr.addStackAlignmentAttr(16);
F->addAttributes(AttributeList::FunctionIndex, attr);
#endif
#endif
#if defined(_OS_WINDOWS_) && defined(_CPU_X86_64_)
F->setHasUWTable(); // force NeedsWinEH
#endif
Expand Down
20 changes: 3 additions & 17 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,22 +190,7 @@ NOINLINE uintptr_t gc_get_stack_ptr(void)

#define should_timeout() 0

static void jl_gc_wait_for_the_world(void)
{
if (jl_n_threads > 1)
jl_wake_libuv();
for (int i = 0; i < jl_n_threads; i++) {
jl_ptls_t ptls2 = jl_all_tls_states[i];
// This acquire load pairs with the release stores
// in the signal handler of safepoint so we are sure that
// all the stores on those threads are visible.
// We're currently also using atomic store release in mutator threads
// (in jl_gc_state_set), but we may want to use signals to flush the
// memory operations on those threads lazily instead.
while (!jl_atomic_load_relaxed(&ptls2->gc_state) || !jl_atomic_load_acquire(&ptls2->gc_state))
jl_cpu_pause(); // yield?
}
}
void jl_gc_wait_for_the_world(void);

// malloc wrappers, aligned allocation

Expand Down Expand Up @@ -3258,7 +3243,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)

_report_gc_finished(pause, gc_num.freed, sweep_full, recollect);

gc_final_pause_end(t0, gc_end_time);
gc_final_pause_end(gc_start_time, gc_end_time);
gc_time_sweep_pause(gc_end_time, actual_allocd, live_bytes,
estimate_freed, sweep_full);
gc_num.full_sweep += sweep_full;
Expand Down Expand Up @@ -3762,6 +3747,7 @@ static void *gc_perm_alloc_large(size_t sz, int zero, unsigned align, unsigned o
#endif
errno = last_errno;
jl_may_leak(base);
assert(align > 0);
unsigned diff = (offset - base) % align;
return (void*)(base + diff);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static jl_method_instance_t *jl_specializations_get_linfo_(jl_method_t *m JL_PRO
for (int locked = 0; ; locked++) {
jl_array_t *speckeyset = jl_atomic_load_acquire(&m->speckeyset);
jl_svec_t *specializations = jl_atomic_load_relaxed(&m->specializations);
size_t i, cl = jl_svec_len(specializations);
size_t i = -1, cl = jl_svec_len(specializations);
if (hv) {
ssize_t idx = jl_smallintset_lookup(speckeyset, speccache_eq, type, specializations, hv);
if (idx != -1) {
Expand Down
6 changes: 6 additions & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,14 @@ void jl_init_stack_limits(int ismaster, void **stack_lo, void **stack_hi)
struct rlimit rl;
getrlimit(RLIMIT_STACK, &rl);
size_t stacksize = rl.rlim_cur;
// We intentionally leak a stack address here core.StackAddressEscape
# ifndef __clang_analyzer__
*stack_hi = (void*)&stacksize;
*stack_lo = (void*)((char*)*stack_hi - stacksize);
# else
*stack_hi = 0;
*stack_lo = 0;
# endif
#endif
}

Expand Down
Loading

0 comments on commit 15f31d5

Please sign in to comment.