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

Bump LLVM to v17 #53070

Merged
merged 86 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from 78 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
d1f8917
Update LLVM to v17
mofeing Jan 26, 2024
1f40bf1
Update checksums for `clang`, `lld`, `llvm`
mofeing Jan 26, 2024
83a0c79
Fix path to `Triple.h` header
mofeing Jan 26, 2024
2f0e470
Replace count[Leading/Trailing][Zeros/Ones] functions for new methods
mofeing Jan 26, 2024
6ffc4aa
Replace `Module.getGlobalList().push_back(...)` for `Module.insertGlo…
mofeing Jan 26, 2024
7777e3f
Replace `Module.getAliasList().push_back(...)` for `Module.insertAlia…
mofeing Jan 26, 2024
e16b932
Fix access to operand of `MCInstrDesc`
mofeing Jan 26, 2024
d20b16b
Replace `JITEvaluatedSymbol` with `ExecutorSymbolDef`
mofeing Jan 26, 2024
c5f3378
Fix namespace of `ExecutorSymbolDef`
mofeing Jan 26, 2024
c6085ec
Refactor return type of `findSymbol` and `findUnmangledSymbol`
mofeing Jan 26, 2024
fdbe35d
Fix pointer dereference of `Expected<ExecutorSymbolDef>` class
mofeing Jan 26, 2024
c04791c
Fix `cantFail` call
mofeing Jan 26, 2024
1cdf5ed
Fix deprecated header `llvm/Support/Host.h`
mofeing Jan 27, 2024
168e401
Fix `getWithSamePointeeType` deprecation
mofeing Jan 27, 2024
baa48dc
Fix `isOpaquePointer` deprecation
mofeing Jan 27, 2024
7b2e7af
Move value on `cantFail` with `Expected`
mofeing Jan 27, 2024
a24c765
Convert `ExecutorAddr` to `uint64_t` on `JuliaOJIT` addresses
mofeing Jan 27, 2024
ed8c4cd
Remove deprecated `isOpaqueOrPointeeTypeMatches` calls
mofeing Jan 27, 2024
910d275
Remove deprecated `PointerType.isOpaque` calls
mofeing Jan 27, 2024
f4b1d3e
Link to `libLLVMTargetParser`
mofeing Jan 28, 2024
6230acc
Fix `StandardInstrumentations.registerCallbacks` call
mofeing Jan 28, 2024
ea1d29f
Format `NewPM::run`
mofeing Jan 28, 2024
d563d40
Fix deprecated `hasSamaElementTypeAs` calls
mofeing Jan 28, 2024
8fa5700
Fix `supportsTypedPointers`, `getNonOpaquePointerElementType` depreca…
mofeing Jan 28, 2024
07326f6
Fix deprecated `setOpaquePointers` calls
mofeing Jan 28, 2024
50c1235
Refactor dead `GetElementPtr` instruction in `AddrspaceRemoveValueMat…
mofeing Jan 28, 2024
790d11e
Fix unused variables warning but used by `assert`
mofeing Jan 28, 2024
11f0f4c
Remove dead code
mofeing Jan 28, 2024
a96b045
Remove definition of `JL_LLVM_OPAQUE_POINTERS`
mofeing Jan 28, 2024
faaa0ff
Fix missing stdlib headers
mofeing Jan 28, 2024
90d5bd2
Add missing checksums
mofeing Jan 28, 2024
f572587
Try to fix checksums
giordano Jan 28, 2024
7ffcbea
Fix LLVM checksums
mofeing Jan 28, 2024
980f4bd
Fix Clang checksums
giordano Jan 28, 2024
db3ec24
[libLLVM_jll] Fix test
giordano Jan 28, 2024
6cda10a
Fix LLVM checksums take 3
giordano Jan 29, 2024
1596a75
Fix `ExecutorSymbolDef` evaluation to `bool`
mofeing Jan 29, 2024
75be37a
Fix assertion
mofeing Jan 29, 2024
f0942cc
Make code compatible with LLVM 15 again
mofeing Jan 29, 2024
b7e7739
Fix code
mofeing Jan 30, 2024
c2d66ff
Fix Makefile conditional linking
mofeing Jan 30, 2024
2a5d28f
Fix header inclusion
mofeing Jan 30, 2024
4424ad1
Fix LLVM version requirement for `libLLVMTargetParser` link
mofeing Jan 30, 2024
ef70f1b
Fix typo
mofeing Jan 30, 2024
71051f5
Fix header inclusion
mofeing Jan 30, 2024
e335cb6
Fix C++ header on C code
mofeing Jan 30, 2024
ce972fd
Fix header inclusion after rebase
mofeing Jan 30, 2024
8e28ca9
Try fix for `is_trivially_copy/move_constructible`
mofeing Jan 30, 2024
63db41f
Add missing header
mofeing Jan 30, 2024
88aaec5
Try fix assertion crash in `ConstantExpr::getWithOperands`
mofeing Jan 31, 2024
14712d8
Replace LLVM version guard for comment
mofeing Feb 1, 2024
db07d8e
Remove legacy `-enable-new-pm` flag from llvmpasses
mofeing Feb 1, 2024
414db35
Fix undefined identifier on LLVM 17
mofeing Feb 1, 2024
54c2421
Revert "Fix undefined identifier on LLVM 17"
mofeing Feb 1, 2024
1cfa764
Revert "Replace LLVM version guard for comment"
mofeing Feb 1, 2024
33ecff3
Remove `--opaque-pointers` flags on llvmpasses
mofeing Feb 1, 2024
515af75
Fix missing `RUN` statement
mofeing Feb 1, 2024
85817e9
Merge branch 'master' into bump-llvm17
mofeing Feb 18, 2024
9a725cf
Merge branch 'master' into bump-llvm17
gbaraldi Feb 21, 2024
f14c212
Merge branch 'master' into bump-llvm17
mofeing Mar 4, 2024
908935c
Refresh checksums
mofeing Mar 6, 2024
25c866d
Log debug info from lib loading
mofeing Mar 14, 2024
46dca35
Merge branch 'master' into bump-llvm17
gbaraldi Apr 11, 2024
b1d87b9
Merge branch 'master' into bump-llvm17
gbaraldi Apr 11, 2024
194b8f6
Add runpath to libjulia
gbaraldi Apr 11, 2024
2c6f7a6
Patch libclang to have the correct rpath
gbaraldi Apr 11, 2024
757b560
Do it in the right place
gbaraldi Apr 11, 2024
9e7cc43
Simplify
gbaraldi Apr 11, 2024
8a2c672
Try something different
gbaraldi Apr 12, 2024
f4453fa
Install patchelf
gbaraldi Apr 12, 2024
0e3738f
Moar dollars
gbaraldi Apr 12, 2024
bca6a80
Even more dollars
gbaraldi Apr 12, 2024
86f1429
Add patchelf override to the makefile
gbaraldi Apr 12, 2024
13a077a
Add BigPIC
gbaraldi Apr 15, 2024
8e99206
Merge branch 'master' into bump-llvm17
gbaraldi Apr 17, 2024
58ceb2e
Merge branch 'master' into bump-llvm17
gbaraldi Apr 17, 2024
f047289
Apply suggestions from code review
giordano Apr 17, 2024
3b51ab6
Merge branch 'master' into bump-llvm17
mofeing Apr 21, 2024
9e7bb2e
Fix call to removed `getWithSamePointeeType`
mofeing Apr 21, 2024
48cc025
Merge branch 'master' into bump-llvm17
mofeing Apr 22, 2024
1b5ee47
Remove legacy flags `enable-new-pm`,`opaque-pointers` in LLVM passes …
mofeing Apr 22, 2024
64289ec
Update LLVM to 17.0.6+2
gbaraldi Apr 23, 2024
1546fcd
Also update lld checksums
gbaraldi Apr 23, 2024
b5a8598
Bump LLVM to 17.0.6+3
gbaraldi Apr 29, 2024
3c28753
Remove TYPED checks from llvmpasses
gbaraldi Apr 29, 2024
73ef4c6
Merge branch 'master' into bump-llvm17
giordano Apr 30, 2024
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
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ endif
ifeq ($(OS), Linux)
-$(PATCHELF) $(PATCHELF_SET_RPATH_ARG) '$$ORIGIN' $(DESTDIR)$(private_shlibdir)/libLLVM.$(SHLIB_EXT)
endif

ifneq ($(LOADER_BUILD_DEP_LIBS),$(LOADER_INSTALL_DEP_LIBS))
# Next, overwrite relative path to libjulia-internal in our loader if $$(LOADER_BUILD_DEP_LIBS) != $$(LOADER_INSTALL_DEP_LIBS)
ifeq ($(JULIA_BUILD_MODE),release)
Expand Down
216 changes: 108 additions & 108 deletions deps/checksums/clang

Large diffs are not rendered by default.

216 changes: 108 additions & 108 deletions deps/checksums/lld

Large diffs are not rendered by default.

436 changes: 218 additions & 218 deletions deps/checksums/llvm

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion deps/clang.version
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- makefile -*-

## jll artifact
giordano marked this conversation as resolved.
Show resolved Hide resolved
# Clang (paired with LLVM, only here as a JLL download)
CLANG_JLL_NAME := Clang
CLANG_JLL_VER := 16.0.6+4
CLANG_JLL_VER := 17.0.6+1
4 changes: 3 additions & 1 deletion deps/lld.version
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- makefile -*-

## jll artifact
giordano marked this conversation as resolved.
Show resolved Hide resolved
LLD_JLL_NAME := LLD
LLD_JLL_VER := 16.0.6+4
LLD_JLL_VER := 17.0.6+1
6 changes: 4 additions & 2 deletions deps/llvm-tools.version
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- makefile -*-

## jll artifact
giordano marked this conversation as resolved.
Show resolved Hide resolved
# LLVM_tools (downloads LLVM_jll to get things like `lit` and `opt`)
LLVM_TOOLS_JLL_NAME := LLVM
LLVM_TOOLS_JLL_VER := 16.0.6+4
LLVM_TOOLS_ASSERT_JLL_VER := 16.0.6+4
LLVM_TOOLS_JLL_VER := 17.0.6+1
LLVM_TOOLS_ASSERT_JLL_VER := 17.0.6+1
12 changes: 6 additions & 6 deletions deps/llvm.version
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

## jll artifact
LLVM_JLL_NAME := libLLVM
LLVM_ASSERT_JLL_VER := 16.0.6+4
LLVM_ASSERT_JLL_VER := 17.0.6+1
## source build
# Version number of LLVM
LLVM_VER := 16.0.6
LLVM_VER := 17.0.6
# Git branch name in `LLVM_GIT_URL` repository
LLVM_BRANCH=julia-16.0.6-2
LLVM_BRANCH=julia-17.0.6-1
# Git ref in `LLVM_GIT_URL` repository
LLVM_SHA1=julia-16.0.6-2
LLVM_SHA1=julia-17.0.6-1

## Following options are used to automatically fetch patchset from Julia's fork. This is
## useful if you want to build an external LLVM while still applying Julia's patches.
Expand All @@ -18,6 +18,6 @@ LLVM_APPLY_JULIA_PATCHES := 0
# GitHub repository to use for fetching the Julia patches to apply to LLVM source code.
LLVM_JULIA_DIFF_GITHUB_REPO := https://github.com/llvm/llvm-project
# Base GitHub ref for generating the diff.
LLVM_BASE_REF := llvm:llvmorg-16.0.6
LLVM_BASE_REF := llvm:llvmorg-17.0.6
# Julia fork's GitHub ref for generating the diff.
LLVM_JULIA_REF := JuliaLang:julia-16.0.6-0
LLVM_JULIA_REF := JuliaLang:julia-17.0.6-1
2 changes: 1 addition & 1 deletion deps/sanitizers.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ install-sanitizers: $$(addprefix $$(build_libdir)/, $$(notdir $$(call pathsearch
$$(addprefix $$(build_shlibdir)/,$(2)): $$(addprefix $$(SANITIZER_LIB_PATH)/,$(2)) | $$(build_shlibdir)
-cp $$< $$@
$(if $(filter $(OS), Linux), \
-$(PATCHELF) $(PATCHELF_SET_RPATH_ARG) '$$$$ORIGIN' $$@ , 0)
-$(PATCHELF) $(PATCHELF_SET_RPATH_ARG) '$$$$ORIGIN' $$@ , 0)
endef

ifeq ($(USECLANG),1)
Expand Down
54 changes: 54 additions & 0 deletions src/APInt-C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,27 @@
memcpy(pr, pa, onumbytes);
}

#if JL_LLVM_VERSION >= 170000
extern "C" JL_DLLEXPORT
unsigned countr_zero_8(uint8_t Val) {

Check warning on line 480 in src/APInt-C.cpp

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "countr" should be "counter or contour or country or county".
return countr_zero(Val);

Check warning on line 481 in src/APInt-C.cpp

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "countr" should be "counter or contour or country or county".
}

extern "C" JL_DLLEXPORT
unsigned countr_zero_16(uint16_t Val) {

Check warning on line 485 in src/APInt-C.cpp

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "countr" should be "counter or contour or country or county".
return countr_zero(Val);

Check warning on line 486 in src/APInt-C.cpp

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "countr" should be "counter or contour or country or county".
}

extern "C" JL_DLLEXPORT
unsigned countr_zero_32(uint32_t Val) {

Check warning on line 490 in src/APInt-C.cpp

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "countr" should be "counter or contour or country or county".
return countr_zero(Val);

Check warning on line 491 in src/APInt-C.cpp

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "countr" should be "counter or contour or country or county".
}

extern "C" JL_DLLEXPORT
unsigned countr_zero_64(uint64_t Val) {

Check warning on line 495 in src/APInt-C.cpp

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "countr" should be "counter or contour or country or county".
return countr_zero(Val);

Check warning on line 496 in src/APInt-C.cpp

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "countr" should be "counter or contour or country or county".
}
#else
extern "C" JL_DLLEXPORT
unsigned countTrailingZeros_8(uint8_t Val) {
return countTrailingZeros(Val);
Expand All @@ -494,6 +515,7 @@
unsigned countTrailingZeros_64(uint64_t Val) {
return countTrailingZeros(Val);
}
#endif

extern "C" JL_DLLEXPORT
void jl_LLVMSMod(unsigned numbits, integerPart *pa, integerPart *pb, integerPart *pr) {
Expand Down Expand Up @@ -523,6 +545,37 @@
memcpy(pr, pa, numbytes);
}

#if JL_LLVM_VERSION >= 170000
extern "C" JL_DLLEXPORT
unsigned LLVMPopcount(unsigned numbits, integerPart *pa) {
CREATE(a)
return a.popcount();
}

extern "C" JL_DLLEXPORT
unsigned LLVMCountr_one(unsigned numbits, integerPart *pa) {

Check warning on line 556 in src/APInt-C.cpp

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "Countr" should be "Counter or Contour or Country or County".
CREATE(a)
return a.countr_one();

Check warning on line 558 in src/APInt-C.cpp

View workflow job for this annotation

GitHub Actions / Check for new typos

perhaps "countr" should be "counter or contour or country or county".
}

extern "C" JL_DLLEXPORT
unsigned LLVMCountr_zero(unsigned numbits, integerPart *pa) {
CREATE(a)
return a.countr_zero();
}

extern "C" JL_DLLEXPORT
unsigned LLVMCountl_one(unsigned numbits, integerPart *pa) {
CREATE(a)
return a.countl_one();
}

extern "C" JL_DLLEXPORT
unsigned LLVMCountl_zero(unsigned numbits, integerPart *pa) {
CREATE(a)
return a.countl_zero();
}
#else
extern "C" JL_DLLEXPORT
unsigned LLVMCountPopulation(unsigned numbits, integerPart *pa) {
CREATE(a)
Expand Down Expand Up @@ -552,3 +605,4 @@
CREATE(a)
return a.countLeadingZeros();
}
#endif
18 changes: 17 additions & 1 deletion src/APInt-C.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@

#include "julia.h"
#include "dtypes.h"
#include "llvm-version.h"

#ifdef __cplusplus
extern "C" {
#endif

#ifdef LLVM_VERSION_MAJOR
#if defined(__cplusplus) && defined(LLVM_VERSION_MAJOR)
using integerPart = llvm::APInt::WordType;
#else
typedef void integerPart;
Expand Down Expand Up @@ -53,11 +54,19 @@ JL_DLLEXPORT int LLVMDiv_uov(unsigned numbits, integerPart *pa, integerPart *pb,
JL_DLLEXPORT int LLVMRem_sov(unsigned numbits, integerPart *pa, integerPart *pb, integerPart *pr);
JL_DLLEXPORT int LLVMRem_uov(unsigned numbits, integerPart *pa, integerPart *pb, integerPart *pr);

#if JL_LLVM_VERSION >= 170000
JL_DLLEXPORT unsigned LLVMPopcount(unsigned numbits, integerPart *pa);
JL_DLLEXPORT unsigned LLVMCountr_one(unsigned numbits, integerPart *pa);
JL_DLLEXPORT unsigned LLVMCountr_zero(unsigned numbits, integerPart *pa);
JL_DLLEXPORT unsigned LLVMCountl_one(unsigned numbits, integerPart *pa);
JL_DLLEXPORT unsigned LLVMCountl_zero(unsigned numbits, integerPart *pa);
#else
JL_DLLEXPORT unsigned LLVMCountPopulation(unsigned numbits, integerPart *pa);
JL_DLLEXPORT unsigned LLVMCountTrailingOnes(unsigned numbits, integerPart *pa);
JL_DLLEXPORT unsigned LLVMCountTrailingZeros(unsigned numbits, integerPart *pa);
JL_DLLEXPORT unsigned LLVMCountLeadingOnes(unsigned numbits, integerPart *pa);
JL_DLLEXPORT unsigned LLVMCountLeadingZeros(unsigned numbits, integerPart *pa);
#endif

JL_DLLEXPORT void LLVMFPtoSI(jl_datatype_t *ty, integerPart *pa, jl_datatype_t *oty, integerPart *pr);
JL_DLLEXPORT void LLVMFPtoUI(jl_datatype_t *ty, integerPart *pa, jl_datatype_t *oty, integerPart *pr);
Expand All @@ -73,10 +82,17 @@ JL_DLLEXPORT int LLVMFPtoUI_exact(jl_datatype_t *ty, integerPart *pa, jl_datatyp
JL_DLLEXPORT void jl_LLVMSMod(unsigned numbits, integerPart *pa, integerPart *pb, integerPart *pr);
JL_DLLEXPORT void jl_LLVMFlipSign(unsigned numbits, integerPart *pa, integerPart *pb, integerPart *pr);

#if JL_LLVM_VERSION >= 170000
JL_DLLEXPORT unsigned countr_zero_8(uint8_t Val);
JL_DLLEXPORT unsigned countr_zero_16(uint16_t Val);
JL_DLLEXPORT unsigned countr_zero_32(uint32_t Val);
JL_DLLEXPORT unsigned countr_zero_64(uint64_t Val);
#else
JL_DLLEXPORT unsigned countTrailingZeros_8(uint8_t Val);
JL_DLLEXPORT unsigned countTrailingZeros_16(uint16_t Val);
JL_DLLEXPORT unsigned countTrailingZeros_32(uint32_t Val);
JL_DLLEXPORT unsigned countTrailingZeros_64(uint64_t Val);
#endif

//uint8_t getSwappedBytes_8(uint8_t Value); // no-op
//uint16_t getSwappedBytes_16(uint16_t Value);
Expand Down
7 changes: 4 additions & 3 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ else
# JULIACODEGEN != LLVM
endif

RT_LLVM_LIBS := support # for APMath and some other useful ADT
ifneq ($(LLVM_VER_MAJ),15)
RT_LLVM_LIBS += targetparser # for getHostCPUName on LLVM 16+
RT_LLVM_LIBS := support

ifeq ($(shell test $(LLVM_VER_MAJ) -ge 16 && echo true),true)
RT_LLVM_LIBS += targetparser
endif

ifeq ($(OS),WINNT)
Expand Down
21 changes: 20 additions & 1 deletion src/aotcompile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
#include "platform.h"

// target support
#include "llvm/Support/CodeGen.h"
#if JL_LLVM_VERSION >= 170000
#include <llvm/TargetParser/Triple.h>
#else
#include <llvm/ADT/Triple.h>
#endif
#include "llvm/Support/CodeGen.h"
#include <llvm/ADT/Statistic.h>
#include <llvm/Analysis/TargetLibraryInfo.h>
#include <llvm/Analysis/TargetTransformInfo.h>
Expand Down Expand Up @@ -696,7 +700,11 @@ static FunctionInfo getFunctionWeight(const Function &F)
auto val = F.getFnAttribute("julia.mv.clones").getValueAsString();
// base16, so must be at most 4 * length bits long
// popcount gives number of clones
#if JL_LLVM_VERSION >= 170000
info.clones = APInt(val.size() * 4, val, 16).popcount() + 1;
#else
info.clones = APInt(val.size() * 4, val, 16).countPopulation() + 1;
#endif
}
info.weight += info.insts;
// more basic blocks = more complex than just sum of insts,
Expand Down Expand Up @@ -1439,7 +1447,9 @@ static SmallVector<AOTOutputs, 16> add_output(Module &M, TargetMachine &TM, Stri
for (unsigned i = 0; i < threads; i++) {
std::function<void()> func = [&, i]() {
LLVMContext ctx;
#if JL_LLVM_VERSION < 170000
SetOpaquePointer(ctx);
#endif
// Lazily deserialize the entire module
timers[i].deserialize.startTimer();
auto EM = getLazyBitcodeModule(MemoryBufferRef(StringRef(serialized.data(), serialized.size()), "Optimized"), ctx);
Expand Down Expand Up @@ -1643,7 +1653,9 @@ void jl_dump_native_impl(void *native_code,
if (z) {
JL_TIMING(NATIVE_AOT, NATIVE_Sysimg);
LLVMContext Context;
#if JL_LLVM_VERSION < 170000
SetOpaquePointer(Context);
#endif
Module sysimgM("sysimg", Context);
sysimgM.setTargetTriple(TheTriple.str());
sysimgM.setDataLayout(DL);
Expand Down Expand Up @@ -1690,6 +1702,7 @@ void jl_dump_native_impl(void *native_code,
JL_TIMING(NATIVE_AOT, NATIVE_Setup);
dataM.setTargetTriple(TheTriple.str());
dataM.setDataLayout(DL);
dataM.setPICLevel(PICLevel::BigPIC);
gbaraldi marked this conversation as resolved.
Show resolved Hide resolved
auto &Context = dataM.getContext();

Type *T_psize = dataM.getDataLayout().getIntPtrType(Context)->getPointerTo();
Expand Down Expand Up @@ -1786,7 +1799,9 @@ void jl_dump_native_impl(void *native_code,
{
JL_TIMING(NATIVE_AOT, NATIVE_Metadata);
LLVMContext Context;
#if JL_LLVM_VERSION < 170000
SetOpaquePointer(Context);
#endif
Module metadataM("metadata", Context);
metadataM.setTargetTriple(TheTriple.str());
metadataM.setDataLayout(DL);
Expand Down Expand Up @@ -2036,12 +2051,16 @@ void jl_get_llvmf_defn_impl(jl_llvmf_dump_t* dump, jl_method_instance_t *mi, siz
global.second->setLinkage(GlobalValue::ExternalLinkage);
} else {
auto p = literal_static_pointer_val(global.first, global.second->getValueType());
#if JL_LLVM_VERSION >= 170000
Type *elty = PointerType::get(output.getContext(), 0);
#else
Type *elty;
if (p->getType()->isOpaquePointerTy()) {
elty = PointerType::get(output.getContext(), 0);
} else {
elty = p->getType()->getNonOpaquePointerElementType();
}
#endif
// For pretty printing, when LLVM inlines the global initializer into its loads
auto alias = GlobalAlias::create(elty, 0, GlobalValue::PrivateLinkage, global.second->getName() + ".jit", p, global.second->getParent());
global.second->setInitializer(ConstantExpr::getBitCast(alias, global.second->getValueType()));
Expand Down
2 changes: 2 additions & 0 deletions src/ccall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,9 @@ static GlobalVariable *emit_plt_thunk(
SmallVector<Value*, 16> args;
for (auto &arg : plt->args())
args.push_back(&arg);
#if JL_LLVM_VERSION < 170000
assert(cast<PointerType>(ptr->getType())->isOpaqueOrPointeeTypeMatches(functype));
#endif
CallInst *ret = irbuilder.CreateCall(
functype,
ptr, ArrayRef<Value*>(args));
Expand Down
Loading