Skip to content

Commit

Permalink
Merge pull request #45677 from JuliaLang/revert-45195-vc/llvm_14.0.2
Browse files Browse the repository at this point in the history
Revert "Upgrade to LLVM 14.0.2"
  • Loading branch information
vchuravy authored Jun 14, 2022
2 parents 75f042f + 243b4d7 commit 6dae654
Show file tree
Hide file tree
Showing 24 changed files with 357 additions and 616 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-14jl
JL_PRIVATE_LIBS-$(USE_SYSTEM_LLVM) += libLLVM libLLVM-13jl
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-14jl", "libLLVM", "LLVM", "libLLVMSupport")
for lib_name in ("libLLVM-13jl", "libLLVM", "LLVM", "libLLVMSupport")
hdl = Libdl.dlopen_e(lib_name)
if hdl != C_NULL
try
Expand Down
6 changes: 1 addition & 5 deletions 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 lld
BB_CXX_EXPANDED_PROJECTS=gmp llvm clang llvm-tools
# These are non-BB source-only deps
NON_BB_PROJECTS=patchelf mozillacert lapack libwhich utf8proc

Expand Down Expand Up @@ -80,12 +80,8 @@ $(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
14 changes: 5 additions & 9 deletions deps/Versions.make
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CSL_JLL_NAME := CompilerSupportLibraries

# Clang (paired with LLVM, only here as a JLL download)
CLANG_JLL_NAME := Clang
CLANG_JLL_VER := 14.0.2+1
CLANG_JLL_VER := 13.0.1+0

# DSFMT
DSFMT_VER := 2.2.4
Expand Down Expand Up @@ -44,18 +44,14 @@ LIBUV_VER := 2
LIBUV_JLL_NAME := LibUV

# LLVM
LLVM_VER := 14.0.2
LLVM_ASSERT_JLL_VER := 14.0.2+1
LLVM_VER := 13.0.1
LLVM_ASSERT_JLL_VER := 13.0.1+0
LLVM_JLL_NAME := libLLVM

# LLVM_tools (downloads LLVM_jll to get things like `lit` and `opt`)
LLVM_TOOLS_JLL_NAME := LLVM
LLVM_TOOLS_JLL_VER := 14.0.2+1
LLVM_TOOLS_ASSERT_JLL_VER := 14.0.2+1

# LLD
LLD_JLL_NAME := LLD
LLD_JLL_VER := 14.0.2+1
LLVM_TOOLS_JLL_VER := 13.0.1+0
LLVM_TOOLS_ASSERT_JLL_VER := 13.0.1+0

# LLVM libunwind
LLVMUNWIND_VER := 12.0.1
Expand Down
174 changes: 58 additions & 116 deletions deps/checksums/clang

Large diffs are not rendered by default.

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

This file was deleted.

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

Large diffs are not rendered by default.

23 changes: 5 additions & 18 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ 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 @@ -288,26 +285,16 @@ 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_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)
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)
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-lld install-clang install-llvm-tools: install-llvm
install-clang install-llvm-tools: install-llvm

endif # USE_BINARYBUILDER_LLVM
4 changes: 2 additions & 2 deletions deps/llvm.version
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
LLVM_BRANCH=julia-14.0.2-1
LLVM_SHA1=julia-14.0.2-1
LLVM_BRANCH=julia-13.0.1-0
LLVM_SHA1=julia-13.0.1-0
7 changes: 2 additions & 5 deletions deps/tools/bb-install.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@ $(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)$$($(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
$(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

$$(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 @@ -127,7 +127,7 @@ else
ifeq ($(OS), Darwin)
CG_LLVMLINK += $(LLVM_LDFLAGS) -lLLVM
else
CG_LLVMLINK += $(LLVM_LDFLAGS) -lLLVM-14jl
CG_LLVMLINK += $(LLVM_LDFLAGS) -lLLVM-13jl
endif
endif
endif
Expand Down
40 changes: 16 additions & 24 deletions src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,19 +631,7 @@ 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 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)
;
auto simplifyCFGOptions = SimplifyCFGOptions().hoistCommonInsts(true);
#ifdef JL_DEBUG_BUILD
PM->add(createGCInvariantVerifierPass(true));
PM->add(createVerifierPass());
Expand All @@ -658,7 +646,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level,
if (opt_level == 1)
PM->add(createInstSimplifyLegacyPass());
}
PM->add(createCFGSimplificationPass(basicSimplifyCFGOptions));
PM->add(createCFGSimplificationPass(simplifyCFGOptions));
if (opt_level == 1) {
PM->add(createSROAPass());
PM->add(createInstructionCombiningPass());
Expand Down Expand Up @@ -688,7 +676,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(basicSimplifyCFGOptions));
PM->add(createCFGSimplificationPass(simplifyCFGOptions));
}
}
#if defined(_COMPILER_ASAN_ENABLED_)
Expand All @@ -709,7 +697,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level,
PM->add(createBasicAAWrapperPass());
}

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

Expand All @@ -723,7 +711,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, int opt_level,
PM->add(createAllocOptPass());
// consider AggressiveInstCombinePass at optlevel > 2
PM->add(createInstructionCombiningPass());
PM->add(createCFGSimplificationPass(basicSimplifyCFGOptions));
PM->add(createCFGSimplificationPass(simplifyCFGOptions));
if (dump_native)
PM->add(createMultiVersioningPass(external_use));
PM->add(createCPUFeaturesPass());
Expand Down Expand Up @@ -793,23 +781,27 @@ 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
aggressiveSimplifyCFGOptions
SimplifyCFGOptions()
.forwardSwitchCondToPhi(true)
.convertSwitchToLookupTable(true)
.needCanonicalLoops(false)
.hoistCommonInsts(true)
// .sinkCommonInsts(true) // FIXME: Causes assertion in llvm-late-lowering
));
PM->add(createSLPVectorizerPass());
// might need this after LLVM 11:
Expand All @@ -820,7 +812,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-executed. Prevent this by inserting a barrier.
// pass pipeline being re-exectuted. Prevent this by inserting a barrier.
PM->add(createBarrierNoopPass());
PM->add(createLowerExcHandlersPass());
PM->add(createGCInvariantVerifierPass(false));
Expand Down
4 changes: 1 addition & 3 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2090,14 +2090,12 @@ 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
1 change: 0 additions & 1 deletion src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3762,7 +3762,6 @@ 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
5 changes: 0 additions & 5 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,8 @@ 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);
#endif
*stack_hi = 0;
*stack_lo = 0;
#endif
}

Expand Down
2 changes: 1 addition & 1 deletion src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ static jl_cgval_t generic_cast(
// rounding first instead of carrying around incorrect low bits.
Value *jlfloattemp_var = emit_static_alloca(ctx, from->getType());
ctx.builder.CreateStore(from, jlfloattemp_var);
from = ctx.builder.CreateLoad(from->getType(), jlfloattemp_var, /*force this to load from the stack*/true);
from = ctx.builder.CreateLoad(jlfloattemp_var, /*force this to load from the stack*/true);
#endif
}
Value *ans = ctx.builder.CreateCast(Op, from, to);
Expand Down
26 changes: 11 additions & 15 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1459,21 +1459,17 @@ TargetIRAnalysis JuliaOJIT::getTargetIRAnalysis() const {
static void jl_decorate_module(Module &M) {
#if defined(_CPU_X86_64_) && defined(_OS_WINDOWS_)
// Add special values used by debuginfo to build the UnwindData table registration for Win64
// This used to be GV, but with https://reviews.llvm.org/D100944 we no longer can emit GV into `.text`
// TODO: The data is set in debuginfo.cpp but it should be okay to actually emit it here.
M.appendModuleInlineAsm("\
.section .text \n\
.type __UnwindData,@object \n\
.p2align 2, 0x90 \n\
__UnwindData: \n\
.zero 12 \n\
.size __UnwindData, 12 \n\
\n\
.type __catchjmp,@object \n\
.p2align 2, 0x90 \n\
__catchjmp: \n\
.zero 12 \n\
.size __catchjmp, 12");
ArrayType *atype = ArrayType::get(Type::getInt32Ty(M.getContext()), 3); // want 4-byte alignment of 12-bytes of data
GlobalVariable *gvs[2] = {
new GlobalVariable(M, atype,
false, GlobalVariable::InternalLinkage,
ConstantAggregateZero::get(atype), "__UnwindData"),
new GlobalVariable(M, atype,
false, GlobalVariable::InternalLinkage,
ConstantAggregateZero::get(atype), "__catchjmp") };
gvs[0]->setSection(".text");
gvs[1]->setSection(".text");
appendToCompilerUsed(M, makeArrayRef((GlobalValue**)gvs, 2));
#endif
}

Expand Down
5 changes: 2 additions & 3 deletions src/llvm-muladd.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#undef DEBUG
#include "llvm-version.h"
#include "passes.h"

Expand All @@ -19,13 +20,11 @@
#include <llvm/IR/Verifier.h>
#include <llvm/Pass.h>
#include <llvm/Support/Debug.h>
#define DEBUG_TYPE "combine_muladd"

#include "julia.h"
#include "julia_assert.h"

#define DEBUG_TYPE "combine_muladd"
#undef DEBUG

using namespace llvm;
STATISTIC(TotalContracted, "Total number of multiplies marked for FMA");

Expand Down
6 changes: 3 additions & 3 deletions src/llvm-multiversioning.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

// Function multi-versioning
#define DEBUG_TYPE "julia_multiversioning"
#undef DEBUG

// LLVM pass to clone function for different archs

#include "llvm-version.h"
Expand Down Expand Up @@ -38,9 +41,6 @@
#include "codegen_shared.h"
#include "julia_assert.h"

#define DEBUG_TYPE "julia_multiversioning"
#undef DEBUG

using namespace llvm;

extern Optional<bool> always_have_fma(Function&);
Expand Down
7 changes: 4 additions & 3 deletions src/llvm-ptls.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// This file is a part of Julia. License is MIT: https://julialang.org/license

#define DEBUG_TYPE "lower_ptls"
#undef DEBUG

// LLVM pass to lower TLS access and remove references to julia intrinsics

#include "llvm-version.h"
Expand All @@ -25,9 +29,6 @@
#include "codegen_shared.h"
#include "julia_assert.h"

#define DEBUG_TYPE "lower_ptls"
#undef DEBUG

using namespace llvm;

typedef Instruction TerminatorInst;
Expand Down
Loading

4 comments on commit 6dae654

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@vtjnash
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

Please sign in to comment.