Skip to content

Commit

Permalink
Upgrade to LLVM 14.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Jun 14, 2022
1 parent 6dae654 commit a12c2f0
Show file tree
Hide file tree
Showing 19 changed files with 560 additions and 326 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
14 changes: 9 additions & 5 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 := 13.0.1+0
CLANG_JLL_VER := 14.0.2+1

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

# LLVM
LLVM_VER := 13.0.1
LLVM_ASSERT_JLL_VER := 13.0.1+0
LLVM_VER := 14.0.2
LLVM_ASSERT_JLL_VER := 14.0.2+1
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 := 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

# LLD
LLD_JLL_NAME := LLD
LLD_JLL_VER := 14.0.2+1

# LLVM libunwind
LLVMUNWIND_VER := 12.0.1
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.

23 changes: 18 additions & 5 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,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 @@ -285,16 +288,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
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-13.0.1-0
LLVM_SHA1=julia-13.0.1-0
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 @@ -26,10 +26,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 @@ -127,7 +127,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
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
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(jlfloattemp_var, /*force this to load from the stack*/true);
from = ctx.builder.CreateLoad(from->getType(), jlfloattemp_var, /*force this to load from the stack*/true);
#endif
}
Value *ans = ctx.builder.CreateCast(Op, from, to);
Expand Down
5 changes: 3 additions & 2 deletions src/llvm-muladd.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// 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 @@ -20,11 +19,13 @@
#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,9 +1,6 @@
// 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 @@ -41,6 +38,9 @@
#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: 3 additions & 4 deletions src/llvm-ptls.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
// 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 @@ -29,6 +25,9 @@
#include "codegen_shared.h"
#include "julia_assert.h"

#define DEBUG_TYPE "lower_ptls"
#undef DEBUG

using namespace llvm;

typedef Instruction TerminatorInst;
Expand Down
4 changes: 2 additions & 2 deletions src/llvm-simdloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "llvm-version.h"
#include "passes.h"

#define DEBUG_TYPE "lower_simd_loop"

// This file defines a LLVM pass that:
// 1. Set's loop information in form of metadata
// 2. If the metadata contains `julia.simdloop` finds reduction chains and marks
Expand All @@ -30,6 +28,8 @@

#include "julia_assert.h"

#define DEBUG_TYPE "lower_simd_loop"

using namespace llvm;

STATISTIC(TotalMarkedLoops, "Total number of loops marked with simdloop");
Expand Down
2 changes: 1 addition & 1 deletion stdlib/libLLVM_jll/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "libLLVM_jll"
uuid = "8f36deef-c2a5-5394-99ed-8e07531fb29a"
version = "13.0.1+0"
version = "14.0.2+1"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Expand Down
4 changes: 2 additions & 2 deletions stdlib/libLLVM_jll/src/libLLVM_jll.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ libLLVM_handle = C_NULL
libLLVM_path = ""

if Sys.iswindows()
const libLLVM = "libLLVM-13jl.dll"
const libLLVM = "libLLVM-14jl.dll"
elseif Sys.isapple()
const libLLVM = "@rpath/libLLVM.dylib"
else
const libLLVM = "libLLVM-13jl.so"
const libLLVM = "libLLVM-14jl.so"
end

function __init__()
Expand Down

0 comments on commit a12c2f0

Please sign in to comment.