[arch-commits] Commit in julia/trunk (63303980.patch PKGBUILD julia-llvm13.patch)

Antonio Rojas arojas at gemini.archlinux.org
Tue Jan 4 20:24:04 UTC 2022


    Date: Tuesday, January 4, 2022 @ 20:24:04
  Author: arojas
Revision: 1093052

Update LLVM 13 patches

Added:
  julia/trunk/63303980.patch
Modified:
  julia/trunk/PKGBUILD
Deleted:
  julia/trunk/julia-llvm13.patch

--------------------+
 63303980.patch     |  683 +++++++++++++++++++++++++++++++++++++++++++++++++++
 PKGBUILD           |   15 -
 julia-llvm13.patch |  372 ---------------------------
 3 files changed, 693 insertions(+), 377 deletions(-)

Added: 63303980.patch
===================================================================
--- 63303980.patch	                        (rev 0)
+++ 63303980.patch	2022-01-04 20:24:04 UTC (rev 1093052)
@@ -0,0 +1,683 @@
+From 111d0c8f78266a1ee7fa4ca2b4025748fc8d3dca Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <v.churavy at gmail.com>
+Date: Tue, 12 Oct 2021 11:56:19 -0400
+Subject: [PATCH 1/9] Add Type to ByVal attribute
+
+---
+ src/abi_aarch64.cpp |  2 +-
+ src/abi_arm.cpp     |  2 +-
+ src/abi_llvm.cpp    |  2 +-
+ src/abi_ppc64le.cpp |  6 +++++-
+ src/abi_win32.cpp   |  6 +++++-
+ src/abi_win64.cpp   |  9 +++++++--
+ src/abi_x86.cpp     |  8 ++++++--
+ src/abi_x86_64.cpp  | 11 ++++++++++-
+ src/ccall.cpp       |  4 ++--
+ 9 files changed, 38 insertions(+), 12 deletions(-)
+
+diff --git a/src/abi_aarch64.cpp b/src/abi_aarch64.cpp
+index 3e6b995f07b1..1a3f160329c6 100644
+--- a/src/abi_aarch64.cpp
++++ b/src/abi_aarch64.cpp
+@@ -187,7 +187,7 @@ Type *isHFAorHVA(jl_datatype_t *dt, size_t &nele, LLVMContext &ctx) const
+     return NULL;
+ }
+ 
+-bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
++bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
+ {
+     // B.2
+     //   If the argument type is an HFA or an HVA, then the argument is used
+diff --git a/src/abi_arm.cpp b/src/abi_arm.cpp
+index 032943abd45f..4987d07657ae 100644
+--- a/src/abi_arm.cpp
++++ b/src/abi_arm.cpp
+@@ -23,7 +23,7 @@
+ 
+ struct ABI_ARMLayout : AbiLayout {
+ 
+-bool needPassByRef(jl_datatype_t *dt, AttrBuilder &abi, LLVMContext &ctx) override
++bool needPassByRef(jl_datatype_t *dt, AttrBuilder &abi, LLVMContext &ctx, Type *Ty) override
+ {
+     return false;
+ }
+diff --git a/src/abi_llvm.cpp b/src/abi_llvm.cpp
+index f21edeadee03..181b05ef7997 100644
+--- a/src/abi_llvm.cpp
++++ b/src/abi_llvm.cpp
+@@ -45,7 +45,7 @@ bool use_sret(jl_datatype_t *ty, LLVMContext &ctx) override
+     return false;
+ }
+ 
+-bool needPassByRef(jl_datatype_t *ty, AttrBuilder &ab, LLVMContext &ctx) override
++bool needPassByRef(jl_datatype_t *ty, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
+ {
+     return false;
+ }
+diff --git a/src/abi_ppc64le.cpp b/src/abi_ppc64le.cpp
+index da1d8484a082..a35223c8dde3 100644
+--- a/src/abi_ppc64le.cpp
++++ b/src/abi_ppc64le.cpp
+@@ -101,12 +101,16 @@ bool use_sret(jl_datatype_t *dt, LLVMContext &ctx) override
+     return false;
+ }
+ 
+-bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
++bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
+ {
+     jl_datatype_t *ty0 = NULL;
+     bool hva = false;
+     if (jl_datatype_size(dt) > 64 && isHFA(dt, &ty0, &hva) > 8) {
++#if JL_LLVM_VERSION < 120000
+         ab.addAttribute(Attribute::ByVal);
++#else
++        ab.addByValAttr(Ty);
++#endif
+         return true;
+     }
+     return false;
+diff --git a/src/abi_win32.cpp b/src/abi_win32.cpp
+index a25fcaec9b82..fa1cfe222542 100644
+--- a/src/abi_win32.cpp
++++ b/src/abi_win32.cpp
+@@ -49,11 +49,15 @@ bool use_sret(jl_datatype_t *dt, LLVMContext &ctx) override
+     return true;
+ }
+ 
+-bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
++bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
+ {
+     // Use pass by reference for all structs
+     if (dt->layout->nfields > 0) {
++#if JL_LLVM_VERSION < 120000
+         ab.addAttribute(Attribute::ByVal);
++#else
++        ab.addByValAttr(Ty);
++#endif
+         return true;
+     }
+     return false;
+diff --git a/src/abi_win64.cpp b/src/abi_win64.cpp
+index 6f6d407cfc10..c87e3434f1c1 100644
+--- a/src/abi_win64.cpp
++++ b/src/abi_win64.cpp
+@@ -56,14 +56,19 @@ bool use_sret(jl_datatype_t *dt, LLVMContext &ctx) override
+     return true;
+ }
+ 
+-bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
++bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
+ {
+     nargs++;
+     size_t size = jl_datatype_size(dt);
+     if (win64_reg_size(size))
+         return false;
+-    if (nargs <= 4)
++    if (nargs <= 4) {
++#if JL_LLVM_VERSION < 120000
+         ab.addAttribute(Attribute::ByVal);
++#else
++        ab.addByValAttr(Ty);
++#endif
++    }
+     return true;
+ }
+ 
+diff --git a/src/abi_x86.cpp b/src/abi_x86.cpp
+index c68e657695f3..3c4617c5a3c1 100644
+--- a/src/abi_x86.cpp
++++ b/src/abi_x86.cpp
+@@ -67,12 +67,16 @@ bool use_sret(jl_datatype_t *dt, LLVMContext &ctx) override
+     return true;
+ }
+ 
+-bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
++bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
+ {
+     size_t size = jl_datatype_size(dt);
+     if (is_complex64(dt) || is_complex128(dt) || (jl_is_primitivetype(dt) && size <= 8))
+         return false;
+-    ab.addAttribute(Attribute::ByVal);
++#if JL_LLVM_VERSION < 120000
++        ab.addAttribute(Attribute::ByVal);
++#else
++        ab.addByValAttr(Ty);
++#endif
+     return true;
+ }
+ 
+diff --git a/src/abi_x86_64.cpp b/src/abi_x86_64.cpp
+index 898e98dfcc26..e5beffce39b0 100644
+--- a/src/abi_x86_64.cpp
++++ b/src/abi_x86_64.cpp
+@@ -178,11 +178,15 @@ bool use_sret(jl_datatype_t *dt, LLVMContext &ctx) override
+     return sret;
+ }
+ 
+-bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) override
++bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx, Type *Ty) override
+ {
+     Classification cl = classify(dt);
+     if (cl.isMemory) {
++#if JL_LLVM_VERSION < 120000
+         ab.addAttribute(Attribute::ByVal);
++#else
++        ab.addByValAttr(Ty);
++#endif
+         return true;
+     }
+ 
+@@ -202,7 +206,12 @@ bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, LLVMContext &ctx) overrid
+     else if (jl_is_structtype(dt)) {
+         // spill to memory even though we would ordinarily pass
+         // it in registers
++#if JL_LLVM_VERSION < 120000
+         ab.addAttribute(Attribute::ByVal);
++#else
++        Type* Ty = preferred_llvm_type(dt, false, ctx);
++        ab.addByValAttr(Ty);
++#endif
+         return true;
+     }
+     return false;
+diff --git a/src/ccall.cpp b/src/ccall.cpp
+index 426abf6b7dcb..fb70e53e2814 100644
+--- a/src/ccall.cpp
++++ b/src/ccall.cpp
+@@ -288,7 +288,7 @@ class AbiLayout {
+ public:
+     virtual ~AbiLayout() {}
+     virtual bool use_sret(jl_datatype_t *ty, LLVMContext &ctx) = 0;
+-    virtual bool needPassByRef(jl_datatype_t *ty, AttrBuilder&, LLVMContext &ctx) = 0;
++    virtual bool needPassByRef(jl_datatype_t *ty, AttrBuilder&, LLVMContext &ctx, Type* llvm_t) = 0;
+     virtual Type *preferred_llvm_type(jl_datatype_t *ty, bool isret, LLVMContext &ctx) const = 0;
+ };
+ 
+@@ -1086,7 +1086,7 @@ std::string generate_func_sig(const char *fname)
+         }
+ 
+         // Whether or not LLVM wants us to emit a pointer to the data
+-        bool byRef = abi->needPassByRef((jl_datatype_t*)tti, ab, jl_LLVMContext);
++        bool byRef = abi->needPassByRef((jl_datatype_t*)tti, ab, jl_LLVMContext, t);
+ 
+         if (jl_is_cpointer_type(tti)) {
+             pat = t;
+
+From e7620d0e3c5b13a3e6ac21385784dc917c682969 Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <v.churavy at gmail.com>
+Date: Thu, 21 Oct 2021 20:32:39 -0400
+Subject: [PATCH 2/9] [LLVM/Win32] Force stack alignment on module
+
+---
+ src/aotcompile.cpp |  3 +++
+ src/ccall.cpp      |  3 +++
+ src/codegen.cpp    | 11 ++++++++++-
+ 3 files changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp
+index e18b40240cb2..fc4dbe8decd3 100644
+--- a/src/aotcompile.cpp
++++ b/src/aotcompile.cpp
+@@ -550,6 +550,9 @@ void jl_dump_native_impl(void *native_code,
+     std::unique_ptr<Module> sysimage(new Module("sysimage", Context));
+     sysimage->setTargetTriple(data->M->getTargetTriple());
+     sysimage->setDataLayout(data->M->getDataLayout());
++#if JL_LLVM_VERSION >= 130000
++    sysimage->setOverrideStackAlignment(data->M->getOverrideStackAlignment());
++#endif
+     data->M.reset(); // free memory for data->M
+ 
+     if (sysimg_data) {
+diff --git a/src/ccall.cpp b/src/ccall.cpp
+index fb70e53e2814..dd7626c918d0 100644
+--- a/src/ccall.cpp
++++ b/src/ccall.cpp
+@@ -891,6 +891,9 @@ static jl_cgval_t emit_llvmcall(jl_codectx_t &ctx, jl_value_t **args, size_t nar
+     // copy module properties that should always match
+     Mod->setTargetTriple(jl_Module->getTargetTriple());
+     Mod->setDataLayout(jl_Module->getDataLayout());
++#if JL_LLVM_VERSION >= 130000
++    Mod->setOverrideStackAlignment(jl_Module->getOverrideStackAlignment());
++#endif
+ 
+     // verify the definition
+     Function *def = Mod->getFunction(ir_name);
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index 2ed36f21fa1e..fc2e27d29116 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -1707,6 +1707,14 @@ static void jl_setup_module(Module *m, const jl_cgparams_t *params = &jl_default
+             llvm::DEBUG_METADATA_VERSION);
+     m->setDataLayout(jl_data_layout);
+     m->setTargetTriple(jl_TargetMachine->getTargetTriple().str());
++
++#if defined(_OS_WINDOWS_) && !defined(_CPU_X86_64_) && JL_LLVM_VERSION >= 130000
++    // tell Win32 to assume the stack is always 16-byte aligned,
++    // and to ensure that it is 16-byte aligned for out-going calls,
++    // to ensure compatibility with GCC codes
++    m->setOverrideStackAlignment(16);
++#endif
++
+ }
+ 
+ Module *jl_create_llvm_module(StringRef name)
+@@ -8033,10 +8041,11 @@ extern "C" void jl_init_llvm(void)
+ 
+     TargetOptions options = TargetOptions();
+     //options.PrintMachineCode = true; //Print machine code produced during JIT compiling
+-#if defined(_OS_WINDOWS_) && !defined(_CPU_X86_64_)
++#if defined(_OS_WINDOWS_) && !defined(_CPU_X86_64_) && JL_LLVM_VERSION < 130000
+     // tell Win32 to assume the stack is always 16-byte aligned,
+     // and to ensure that it is 16-byte aligned for out-going calls,
+     // to ensure compatibility with GCC codes
++    // In LLVM 13 and onwards this has turned into a module option
+     options.StackAlignmentOverride = 16;
+ #endif
+ #ifdef JL_DEBUG_BUILD
+
+From 689e52cf3e83eff51a9928d19735bf635fa8c525 Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <v.churavy at gmail.com>
+Date: Fri, 22 Oct 2021 15:35:38 -0400
+Subject: [PATCH 3/9] StackProtector is now a module flag
+
+---
+ src/aotcompile.cpp | 1 +
+ src/ccall.cpp      | 1 +
+ src/codegen.cpp    | 6 ++++--
+ 3 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp
+index fc4dbe8decd3..ad705e96b0da 100644
+--- a/src/aotcompile.cpp
++++ b/src/aotcompile.cpp
+@@ -551,6 +551,7 @@ void jl_dump_native_impl(void *native_code,
+     sysimage->setTargetTriple(data->M->getTargetTriple());
+     sysimage->setDataLayout(data->M->getDataLayout());
+ #if JL_LLVM_VERSION >= 130000
++    sysimage->setStackProtectorGuard(data->M->getStackProtectorGuard());
+     sysimage->setOverrideStackAlignment(data->M->getOverrideStackAlignment());
+ #endif
+     data->M.reset(); // free memory for data->M
+diff --git a/src/ccall.cpp b/src/ccall.cpp
+index dd7626c918d0..647735edb37d 100644
+--- a/src/ccall.cpp
++++ b/src/ccall.cpp
+@@ -892,6 +892,7 @@ static jl_cgval_t emit_llvmcall(jl_codectx_t &ctx, jl_value_t **args, size_t nar
+     Mod->setTargetTriple(jl_Module->getTargetTriple());
+     Mod->setDataLayout(jl_Module->getDataLayout());
+ #if JL_LLVM_VERSION >= 130000
++    Mod->setStackProtectorGuard(jl_Module->getStackProtectorGuard());
+     Mod->setOverrideStackAlignment(jl_Module->getOverrideStackAlignment());
+ #endif
+ 
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index fc2e27d29116..f55446e38c0d 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -1714,7 +1714,9 @@ static void jl_setup_module(Module *m, const jl_cgparams_t *params = &jl_default
+     // to ensure compatibility with GCC codes
+     m->setOverrideStackAlignment(16);
+ #endif
+-
++#if defined(JL_DEBUG_BUILD) && JL_LLVM_VERSION >= 130000
++    m->setStackProtectorGuard("global");
++#endif
+ }
+ 
+ Module *jl_create_llvm_module(StringRef name)
+@@ -8048,7 +8050,7 @@ extern "C" void jl_init_llvm(void)
+     // In LLVM 13 and onwards this has turned into a module option
+     options.StackAlignmentOverride = 16;
+ #endif
+-#ifdef JL_DEBUG_BUILD
++#if defined(JL_DEBUG_BUILD) && JL_LLVM_VERSION < 130000
+     // LLVM defaults to tls stack guard, which causes issues with Julia's tls implementation
+     options.StackProtectorGuard = StackProtectorGuards::Global;
+ #endif
+
+From 45dee34f83ed4900173ed4c6d5632bd86d95b47d Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <v.churavy at gmail.com>
+Date: Sun, 24 Oct 2021 15:18:23 -0400
+Subject: [PATCH 4/9] Cleanup MachineObjectFileInfo handling in disassembly
+
+---
+ src/disasm.cpp | 18 +++++++++---------
+ 1 file changed, 9 insertions(+), 9 deletions(-)
+
+diff --git a/src/disasm.cpp b/src/disasm.cpp
+index 73b394b77d0b..25e7841bde85 100644
+--- a/src/disasm.cpp
++++ b/src/disasm.cpp
+@@ -860,21 +860,21 @@ static void jl_dump_asm_internal(
+     std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TheTriple.str()));
+     assert(MRI && "Unable to create target register info!");
+ 
+-    std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
+-#if JL_LLVM_VERSION >= 130000
+-    MCSubtargetInfo *MSTI = TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features);
+-    assert(MSTI && "Unable to create subtarget info!");
++    std::unique_ptr<llvm::MCSubtargetInfo> STI(
++      TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features));
++    assert(STI && "Unable to create subtarget info!");
+ 
+-    MCContext Ctx(TheTriple, MAI.get(), MRI.get(), MSTI, &SrcMgr);
+-    MOFI->initMCObjectFileInfo(Ctx, /* PIC */ false, /* LargeCodeModel */ false);
++#if JL_LLVM_VERSION >= 130000
++    MCContext Ctx(TheTriple, MAI.get(), MRI.get(), STI.get(), &SrcMgr);
++    std::unique_ptr<MCObjectFileInfo> MOFI(
++      TheTarget->createMCObjectFileInfo(Ctx, /*PIC=*/false, /*LargeCodeModel=*/ false));
++    Ctx.setObjectFileInfo(MOFI.get());
+ #else
++    std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
+     MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
+     MOFI->InitMCObjectFileInfo(TheTriple, /* PIC */ false, Ctx);
+ #endif
+ 
+-    // Set up Subtarget and Disassembler
+-    std::unique_ptr<MCSubtargetInfo>
+-        STI(TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features));
+     std::unique_ptr<MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI, Ctx));
+     if (!DisAsm) {
+         rstream << "ERROR: no disassembler for target " << TheTriple.str();
+
+From 349870e4f190a406c6f338a33c9369299b7befea Mon Sep 17 00:00:00 2001
+From: Jameson Nash <vtjnash at gmail.com>
+Date: Mon, 15 Nov 2021 17:56:52 -0500
+Subject: [PATCH 6/9] [LateLowerGCFrame] handle undef values from a shuffle
+ vector mask
+
+The same as how we handle them if they were undef in the shuffle vector operand.
+---
+ src/llvm-late-gc-lowering.cpp | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/src/llvm-late-gc-lowering.cpp b/src/llvm-late-gc-lowering.cpp
+index ed5fe7c43a59..b142aeaee373 100644
+--- a/src/llvm-late-gc-lowering.cpp
++++ b/src/llvm-late-gc-lowering.cpp
+@@ -616,7 +616,7 @@ std::vector<Value*> LateLowerGCFrame::MaybeExtractVector(State &S, Value *BaseVe
+     std::vector<Value*> V{Numbers.size()};
+     Value *V_rnull = ConstantPointerNull::get(cast<PointerType>(T_prjlvalue));
+     for (unsigned i = 0; i < V.size(); ++i) {
+-        if (Numbers[i] >= 0)
++        if (Numbers[i] >= 0) // ignores undef and poison values
+             V[i] = GetPtrForNumber(S, Numbers[i], InsertBefore);
+         else
+             V[i] = V_rnull;
+@@ -860,8 +860,9 @@ std::vector<int> LateLowerGCFrame::NumberAllBase(State &S, Value *CurrentV) {
+         std::vector<int> Numbers2 = NumberAll(S, SVI->getOperand(1));
+         auto Mask = SVI->getShuffleMask();
+         for (auto idx : Mask) {
+-            assert(idx != -1 && "Undef tracked value is invalid");
+-            if ((unsigned)idx < Numbers1.size()) {
++            if (idx == -1) {
++                Numbers.push_back(-1);
++            } else if ((unsigned)idx < Numbers1.size()) {
+                 Numbers.push_back(Numbers1.at(idx));
+             } else {
+                 Numbers.push_back(Numbers2.at(idx - Numbers1.size()));
+@@ -966,8 +967,9 @@ std::vector<int> LateLowerGCFrame::NumberAll(State &S, Value *V) {
+             Number = Numbers[CurrentV.second]; // only needed a subset of the values
+             Numbers.resize(tracked.count, Number);
+         }
+-        else
++        else {
+             assert(!isa<PointerType>(V->getType()));
++        }
+     }
+     if (CurrentV.first != V) {
+         if (isa<PointerType>(V->getType())) {
+
+From af07387c6c82f54c8b3fd1578e3a42f18ca9e7f4 Mon Sep 17 00:00:00 2001
+From: Jameson Nash <vtjnash at gmail.com>
+Date: Tue, 16 Nov 2021 13:49:05 -0500
+Subject: [PATCH 7/9] fix tbaa_make_child use errors in our llvm passes
+
+now caught by the verifier
+---
+ src/codegen.cpp                  |  6 +++---
+ src/codegen_shared.h             |  9 +++------
+ src/llvm-late-gc-lowering.cpp    |  2 +-
+ src/llvm-multiversioning.cpp     |  7 +------
+ src/llvm-pass-helpers.cpp        | 20 ++++++++++++--------
+ src/llvm-ptls.cpp                |  5 +----
+ test/llvmpasses/late-lower-gc.ll | 14 ++++++--------
+ 7 files changed, 27 insertions(+), 36 deletions(-)
+
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index f55446e38c0d..249a761d1ef0 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -144,7 +144,7 @@ extern JITEventListener *CreateJuliaJITEventListener();
+ bool imaging_mode = false;
+ 
+ // shared llvm state
+-JL_DLLEXPORT LLVMContext &jl_LLVMContext = *(new LLVMContext());
++static LLVMContext &jl_LLVMContext = *(new LLVMContext());
+ TargetMachine *jl_TargetMachine;
+ static DataLayout &jl_data_layout = *(new DataLayout(""));
+ #define jl_Module ctx.f->getParent()
+@@ -4790,7 +4790,7 @@ static Value *get_current_task(jl_codectx_t &ctx)
+ // Get PTLS through current task.
+ static Value *get_current_ptls(jl_codectx_t &ctx)
+ {
+-    return get_current_ptls_from_task(ctx.builder, get_current_task(ctx));
++    return get_current_ptls_from_task(ctx.builder, get_current_task(ctx), tbaa_gcframe);
+ }
+ 
+ // Store world age at the entry block of the function. This function should be
+@@ -7689,7 +7689,7 @@ void jl_compile_workqueue(
+ 
+ // --- initialization ---
+ 
+-std::pair<MDNode*,MDNode*> tbaa_make_child(const char *name, MDNode *parent=nullptr, bool isConstant=false)
++static std::pair<MDNode*,MDNode*> tbaa_make_child(const char *name, MDNode *parent=nullptr, bool isConstant=false)
+ {
+     MDBuilder mbuilder(jl_LLVMContext);
+     if (tbaa_root == nullptr) {
+diff --git a/src/codegen_shared.h b/src/codegen_shared.h
+index 93c913fd7a76..883d804a2091 100644
+--- a/src/codegen_shared.h
++++ b/src/codegen_shared.h
+@@ -99,9 +99,6 @@ static inline std::pair<llvm::MDNode*,llvm::MDNode*> tbaa_make_child_with_contex
+     return std::make_pair(n, scalar);
+ }
+ 
+-static inline llvm::MDNode *get_tbaa_gcframe(llvm::LLVMContext &ctxt) {
+-    return tbaa_make_child_with_context(ctxt, "jtbaa_gcframe").first;
+-}
+ static inline llvm::MDNode *get_tbaa_const(llvm::LLVMContext &ctxt) {
+     return tbaa_make_child_with_context(ctxt, "jtbaa_const", nullptr, true).first;
+ }
+@@ -132,7 +129,7 @@ static inline llvm::Value *emit_bitcast_with_builder(llvm::IRBuilder<> &builder,
+ }
+ 
+ // Get PTLS through current task.
+-static inline llvm::Value *get_current_ptls_from_task(llvm::IRBuilder<> &builder, llvm::Value *current_task)
++static inline llvm::Value *get_current_ptls_from_task(llvm::IRBuilder<> &builder, llvm::Value *current_task, llvm::MDNode *tbaa)
+ {
+     using namespace llvm;
+     auto T_ppjlvalue = JuliaType::get_ppjlvalue_ty(builder.getContext());
+@@ -145,9 +142,9 @@ static inline llvm::Value *get_current_ptls_from_task(llvm::IRBuilder<> &builder
+     LoadInst *ptls_load = builder.CreateAlignedLoad(
+         emit_bitcast_with_builder(builder, pptls, T_ppjlvalue), Align(sizeof(void *)), "ptls_load");
+     // Note: Corresponding store (`t->ptls = ptls`) happens in `ctx_switch` of tasks.c.
+-    tbaa_decorate(get_tbaa_gcframe(builder.getContext()), ptls_load);
++    tbaa_decorate(tbaa, ptls_load);
+     // Using `CastInst::Create` to get an `Instruction*` without explicit cast:
+     auto ptls = CastInst::Create(Instruction::BitCast, ptls_load, T_ppjlvalue, "ptls");
+     builder.Insert(ptls);
+     return ptls;
+-}
+\ No newline at end of file
++}
+diff --git a/src/llvm-late-gc-lowering.cpp b/src/llvm-late-gc-lowering.cpp
+index b142aeaee373..533ea8f5b145 100644
+--- a/src/llvm-late-gc-lowering.cpp
++++ b/src/llvm-late-gc-lowering.cpp
+@@ -2298,7 +2298,7 @@ bool LateLowerGCFrame::CleanupIR(Function &F, State *S) {
+                 // Create a call to the `julia.gc_alloc_bytes` intrinsic, which is like
+                 // `julia.gc_alloc_obj` except it doesn't set the tag.
+                 auto allocBytesIntrinsic = getOrDeclare(jl_intrinsics::GCAllocBytes);
+-                auto ptlsLoad = get_current_ptls_from_task(builder, CI->getArgOperand(0));
++                auto ptlsLoad = get_current_ptls_from_task(builder, CI->getArgOperand(0), tbaa_gcframe);
+                 auto ptls = builder.CreateBitCast(ptlsLoad, Type::getInt8PtrTy(builder.getContext()));
+                 auto newI = builder.CreateCall(
+                     allocBytesIntrinsic,
+diff --git a/src/llvm-multiversioning.cpp b/src/llvm-multiversioning.cpp
+index 7cd50ac144c1..57e90a9aa805 100644
+--- a/src/llvm-multiversioning.cpp
++++ b/src/llvm-multiversioning.cpp
+@@ -40,8 +40,6 @@
+ 
+ using namespace llvm;
+ 
+-extern std::pair<MDNode*,MDNode*> tbaa_make_child(const char *name, MDNode *parent=nullptr,
+-                                                  bool isConstant=false);
+ 
+ namespace {
+ 
+@@ -346,7 +341,7 @@ CloneCtx::CloneCtx(MultiVersioning *pass, Module &M)
+       T_void(Type::getVoidTy(ctx)),
+       T_psize(PointerType::get(T_size, 0)),
+       T_pvoidfunc(FunctionType::get(T_void, false)->getPointerTo()),
+-      tbaa_const(tbaa_make_child("jtbaa_const", nullptr, true).first),
++      tbaa_const(tbaa_make_child_with_context(ctx, "jtbaa_const", nullptr, true).first),
+       pass(pass),
+       specs(jl_get_llvm_clone_targets()),
+       fvars(consume_gv<Function>(M, "jl_sysimg_fvars")),
+diff --git a/src/llvm-pass-helpers.cpp b/src/llvm-pass-helpers.cpp
+index 89263033ce56..f6708ef65ab7 100644
+--- a/src/llvm-pass-helpers.cpp
++++ b/src/llvm-pass-helpers.cpp
+@@ -19,27 +19,31 @@
+ 
+ using namespace llvm;
+ 
+-extern std::pair<MDNode*,MDNode*> tbaa_make_child(const char *name, MDNode *parent=nullptr, bool isConstant=false);
+-
+ JuliaPassContext::JuliaPassContext()
+     : T_size(nullptr), T_int8(nullptr), T_int32(nullptr),
+         T_pint8(nullptr), T_jlvalue(nullptr), T_prjlvalue(nullptr),
+         T_ppjlvalue(nullptr), T_pjlvalue(nullptr), T_pjlvalue_der(nullptr),
+-        T_ppjlvalue_der(nullptr), pgcstack_getter(nullptr), gc_flush_func(nullptr),
++        T_ppjlvalue_der(nullptr),
++
++        tbaa_gcframe(nullptr), tbaa_tag(nullptr),
++
++        pgcstack_getter(nullptr), gc_flush_func(nullptr),
+         gc_preserve_begin_func(nullptr), gc_preserve_end_func(nullptr),
+         pointer_from_objref_func(nullptr), alloc_obj_func(nullptr),
+         typeof_func(nullptr), write_barrier_func(nullptr), module(nullptr)
+ {
+-    tbaa_gcframe = tbaa_make_child("jtbaa_gcframe").first;
+-    MDNode *tbaa_data;
+-    MDNode *tbaa_data_scalar;
+-    std::tie(tbaa_data, tbaa_data_scalar) = tbaa_make_child("jtbaa_data");
+-    tbaa_tag = tbaa_make_child("jtbaa_tag", tbaa_data_scalar).first;
+ }
+ 
+ void JuliaPassContext::initFunctions(Module &M)
+ {
+     module = &M;
++    LLVMContext &llvmctx = M.getContext();
++
++    tbaa_gcframe = tbaa_make_child_with_context(llvmctx, "jtbaa_gcframe").first;
++    MDNode *tbaa_data;
++    MDNode *tbaa_data_scalar;
++    std::tie(tbaa_data, tbaa_data_scalar) = tbaa_make_child_with_context(llvmctx, "jtbaa_data");
++    tbaa_tag = tbaa_make_child_with_context(llvmctx, "jtbaa_tag", tbaa_data_scalar).first;
+ 
+     pgcstack_getter = M.getFunction("julia.get_pgcstack");
+     gc_flush_func = M.getFunction("julia.gcroot_flush");
+diff --git a/src/llvm-ptls.cpp b/src/llvm-ptls.cpp
+index c971774f23e6..a573d41dae32 100644
+--- a/src/llvm-ptls.cpp
++++ b/src/llvm-ptls.cpp
+@@ -32,9 +32,6 @@ using namespace llvm;
+ 
+ typedef Instruction TerminatorInst;
+ 
+-std::pair<MDNode*,MDNode*> tbaa_make_child(const char *name, MDNode *parent=nullptr,
+-                                           bool isConstant=false);
+-
+ namespace {
+ 
+ struct LowerPTLS: public ModulePass {
+@@ -264,7 +261,7 @@ bool LowerPTLS::runOnModule(Module &_M)
+         return false;
+ 
+     ctx = &M->getContext();
+-    tbaa_const = tbaa_make_child("jtbaa_const", nullptr, true).first;
++    tbaa_const = tbaa_make_child_with_context(*ctx, "jtbaa_const", nullptr, true).first;
+ 
+     T_int8 = Type::getInt8Ty(*ctx);
+     T_size = sizeof(size_t) == 8 ? Type::getInt64Ty(*ctx) : Type::getInt32Ty(*ctx);
+
+From 02cd72ee0cd79b629b0bd2d30d1a0512fd155f38 Mon Sep 17 00:00:00 2001
+From: Jameson Nash <jameson at juliacomputing.com>
+Date: Wed, 8 Dec 2021 11:30:34 -0500
+Subject: [PATCH 8/9] [JuliaJITEventListener] Use llvm::StringMap
+
+---
+ src/debuginfo.cpp | 15 +++++----------
+ 1 file changed, 5 insertions(+), 10 deletions(-)
+
+diff --git a/src/debuginfo.cpp b/src/debuginfo.cpp
+index 956559c17998..e7863d5aab34 100644
+--- a/src/debuginfo.cpp
++++ b/src/debuginfo.cpp
+@@ -177,13 +177,6 @@ struct revcomp {
+     { return lhs>rhs; }
+ };
+ 
+-struct strrefcomp {
+-    bool operator() (const StringRef& lhs, const StringRef& rhs) const
+-    {
+-        return lhs.compare(rhs) > 0;
+-    }
+-};
+-
+ class JuliaJITEventListener: public JITEventListener
+ {
+     std::map<size_t, ObjectInfo, revcomp> objectmap;
+@@ -234,11 +227,13 @@ class JuliaJITEventListener: public JITEventListener
+         SavedObject.second.release();
+ 
+         object::section_iterator EndSection = debugObj.section_end();
+-        std::map<StringRef, object::SectionRef, strrefcomp> loadedSections;
++        StringMap<object::SectionRef> loadedSections;
+         for (const object::SectionRef &lSection: Object.sections()) {
+             auto sName = lSection.getName();
+-            if (sName)
+-                loadedSections[*sName] = lSection;
++            if (sName) {
++                bool inserted = loadedSections.insert(std::make_pair(*sName, lSection)).second;
++                assert(inserted); (void)inserted;
++            }
+         }
+         auto getLoadAddress = [&] (const StringRef &sName) -> uint64_t {
+             auto search = loadedSections.find(sName);
+
+From 1c68695b493e6b7cde2327bf61b551d5e32e92d3 Mon Sep 17 00:00:00 2001
+From: Jameson Nash <jameson at juliacomputing.com>
+Date: Wed, 8 Dec 2021 11:35:53 -0500
+Subject: [PATCH 9/9] [EE] CompilerUsed instead of Used
+
+---
+ src/jitlayers.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp
+index 886887f1d329..c6a3de4f4ad8 100644
+--- a/src/jitlayers.cpp
++++ b/src/jitlayers.cpp
+@@ -1045,7 +1045,7 @@ static void jl_add_to_ee(std::unique_ptr<Module> m)
+             ConstantAggregateZero::get(atype), "__catchjmp") };
+     gvs[0]->setSection(".text");
+     gvs[1]->setSection(".text");
+-    appendToUsed(*m, makeArrayRef((GlobalValue**)gvs, 2));
++    appendToCompilerUsed(*m, makeArrayRef((GlobalValue**)gvs, 2));
+ #endif
+     jl_jit_share_data(*m);
+     assert(jl_ExecutionEngine);

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2022-01-04 20:19:02 UTC (rev 1093051)
+++ PKGBUILD	2022-01-04 20:24:04 UTC (rev 1093052)
@@ -9,7 +9,7 @@
 pkgname=julia
 epoch=2
 pkgver=1.7.1
-pkgrel=2
+pkgrel=3
 arch=(x86_64)
 pkgdesc='High-level, high-performance, dynamic programming language'
 url='https://julialang.org/'
@@ -22,7 +22,9 @@
 source=(https://github.com/JuliaLang/julia/releases/download/v$pkgver/$pkgname-$pkgver-full.tar.gz{,.asc}
         https://github.com/JuliaLang/julia/commit/677ce6d3.patch
         https://github.com/JuliaLang/julia/commit/47f9139e.patch
-        julia-llvm13.patch
+        https://github.com/JuliaLang/julia/commit/1eb063f1.patch
+        f8c918b0.patch
+        63303980.patch
         julia-libgit-1.2.patch
         julia-system-cblas.patch
         julia-hardcoded-libs.patch
@@ -34,7 +36,9 @@
             'SKIP'
             'a798c58ab518def84e4112538de59a10802e7dc854c20b08990a1619ba2aa95b'
             'c76c6fbb4e04b185d11e3c3e0aec99a2088f3b06621ce61d29cd21227a044a7a'
-            'ab8a8ec61963661dca5bb2fa965dccaa36c500d55ef7b6767b8faef5fff461b5'
+            '37130eabce304a01c1de389b4596905a3f33881f46f3f04a87f0738668e13985'
+            'bc6c85cbbca489ef0b2876dbeb6ae493c11573e058507b8bcb9e01273bc3a38c'
+            'ce9cd140c3bc39987d60340bf365d6238e79cf4d5385494272c49c64af22ef78'
             'c57ea92a11fa8dac72229e6a912d2372ec0d98d63486426fe3bdeeb795de48f7'
             '8f8c12853ce847f5d1b5a4a461ddec701decdb81dae7bb31d66560c1deaed97a'
             '03043f005c133ac9af1d4dc113ea8b525ad3b393690625be77975f0e29dd6457'
@@ -49,8 +53,9 @@
 # fix build with LLVM 13
   patch -p1 -i ../677ce6d3.patch
   patch -p1 -i ../47f9139e.patch
-# Adapt to LLVM 13 type changes
-  patch -p1 -i ../julia-llvm13.patch
+  patch -p1 -i ../1eb063f1.patch
+  patch -p1 -i ../f8c918b0.patch
+  patch -p1 -i ../63303980.patch
 # libgit2 1.2 compatibility
   patch -p1 -i ../julia-libgit-1.2.patch
 # libunwind 1.6 compatibility

Deleted: julia-llvm13.patch
===================================================================
--- julia-llvm13.patch	2022-01-04 20:19:02 UTC (rev 1093051)
+++ julia-llvm13.patch	2022-01-04 20:24:04 UTC (rev 1093052)
@@ -1,372 +0,0 @@
-From 9daa25a5f331a7e1c0f0b222373a853c2ce1462d Mon Sep 17 00:00:00 2001
-From: Valentin Churavy <v.churavy at gmail.com>
-Date: Tue, 12 Oct 2021 11:56:19 -0400
-Subject: [PATCH 2/6] WIP: add Type to ByVal attribute
-
----
- src/abi_aarch64.cpp |  2 +-
- src/abi_arm.cpp     |  2 +-
- src/abi_llvm.cpp    |  2 +-
- src/abi_ppc64le.cpp |  6 +++++-
- src/abi_win32.cpp   |  6 +++++-
- src/abi_win64.cpp   |  9 +++++++--
- src/abi_x86.cpp     |  8 ++++++--
- src/abi_x86_64.cpp  | 11 ++++++++++-
- src/ccall.cpp       |  4 ++--
- 9 files changed, 38 insertions(+), 12 deletions(-)
-
-diff --git a/src/abi_aarch64.cpp b/src/abi_aarch64.cpp
-index ce94cc66f0..7ffe107d61 100644
---- a/src/abi_aarch64.cpp
-+++ b/src/abi_aarch64.cpp
-@@ -194,7 +194,7 @@ Type *isHFAorHVA(jl_datatype_t *dt, size_t &nele) const
-     return NULL;
- }
- 
--bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab) override
-+bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, Type *Ty) override
- {
-     // B.2
-     //   If the argument type is an HFA or an HVA, then the argument is used
-diff --git a/src/abi_arm.cpp b/src/abi_arm.cpp
-index 1a5d3d0651..ed846dfafb 100644
---- a/src/abi_arm.cpp
-+++ b/src/abi_arm.cpp
-@@ -23,7 +23,7 @@
- 
- struct ABI_ARMLayout : AbiLayout {
- 
--bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab) override
-+bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, Type *Ty) override
- {
-     return false;
- }
-diff --git a/src/abi_llvm.cpp b/src/abi_llvm.cpp
-index 1ab30da1b2..dba8f4aa8a 100644
---- a/src/abi_llvm.cpp
-+++ b/src/abi_llvm.cpp
-@@ -45,7 +45,7 @@ bool use_sret(jl_datatype_t *ty) override
-     return false;
- }
- 
--bool needPassByRef(jl_datatype_t *ty, AttrBuilder &ab) override
-+bool needPassByRef(jl_datatype_t *ty, AttrBuilder &ab, Type *Ty) override
- {
-     return false;
- }
-diff --git a/src/abi_ppc64le.cpp b/src/abi_ppc64le.cpp
-index dd6f927d9c..35e444ef77 100644
---- a/src/abi_ppc64le.cpp
-+++ b/src/abi_ppc64le.cpp
-@@ -101,12 +101,16 @@ bool use_sret(jl_datatype_t *dt) override
-     return false;
- }
- 
--bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab) override
-+bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, Type *Ty) override
- {
-     jl_datatype_t *ty0 = NULL;
-     bool hva = false;
-     if (jl_datatype_size(dt) > 64 && isHFA(dt, &ty0, &hva) > 8) {
-+#if JL_LLVM_VERSION < 120000
-         ab.addAttribute(Attribute::ByVal);
-+#else
-+        ab.addByValAttr(Ty);
-+#endif
-         return true;
-     }
-     return false;
-diff --git a/src/abi_win32.cpp b/src/abi_win32.cpp
-index af16a0310b..0b34f840e4 100644
---- a/src/abi_win32.cpp
-+++ b/src/abi_win32.cpp
-@@ -49,11 +49,15 @@ bool use_sret(jl_datatype_t *dt) override
-     return true;
- }
- 
--bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab) override
-+bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, Type *Ty) override
- {
-     // Use pass by reference for all structs
-     if (dt->layout->nfields > 0) {
-+#if JL_LLVM_VERSION < 120000
-         ab.addAttribute(Attribute::ByVal);
-+#else
-+        ab.addByValAttr(Ty);
-+#endif
-         return true;
-     }
-     return false;
-diff --git a/src/abi_win64.cpp b/src/abi_win64.cpp
-index 16e46a9703..f47802edf1 100644
---- a/src/abi_win64.cpp
-+++ b/src/abi_win64.cpp
-@@ -56,14 +56,19 @@ bool use_sret(jl_datatype_t *dt) override
-     return true;
- }
- 
--bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab) override
-+bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, Type *Ty) override
- {
-     nargs++;
-     size_t size = jl_datatype_size(dt);
-     if (win64_reg_size(size))
-         return false;
--    if (nargs <= 4)
-+    if (nargs <= 4) {
-+#if JL_LLVM_VERSION < 120000
-         ab.addAttribute(Attribute::ByVal);
-+#else
-+        ab.addByValAttr(Ty);
-+#endif
-+    }
-     return true;
- }
- 
-diff --git a/src/abi_x86.cpp b/src/abi_x86.cpp
-index 7a65de028e..c6c0282602 100644
---- a/src/abi_x86.cpp
-+++ b/src/abi_x86.cpp
-@@ -67,12 +67,16 @@ bool use_sret(jl_datatype_t *dt) override
-     return true;
- }
- 
--bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab) override
-+bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, Type *Ty) override
- {
-     size_t size = jl_datatype_size(dt);
-     if (is_complex64(dt) || is_complex128(dt) || (jl_is_primitivetype(dt) && size <= 8))
-         return false;
--    ab.addAttribute(Attribute::ByVal);
-+#if JL_LLVM_VERSION < 120000
-+        ab.addAttribute(Attribute::ByVal);
-+#else
-+        ab.addByValAttr(Ty);
-+#endif
-     return true;
- }
- 
-diff --git a/src/abi_x86_64.cpp b/src/abi_x86_64.cpp
-index ac28af3011..5f8256dee4 100644
---- a/src/abi_x86_64.cpp
-+++ b/src/abi_x86_64.cpp
-@@ -178,11 +178,15 @@ bool use_sret(jl_datatype_t *dt) override
-     return sret;
- }
- 
--bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab) override
-+bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab, Type *Ty) override
- {
-     Classification cl = classify(dt);
-     if (cl.isMemory) {
-+#if JL_LLVM_VERSION < 120000
-         ab.addAttribute(Attribute::ByVal);
-+#else
-+        ab.addByValAttr(Ty);
-+#endif
-         return true;
-     }
- 
-@@ -202,7 +206,12 @@ bool needPassByRef(jl_datatype_t *dt, AttrBuilder &ab) override
-     else if (jl_is_structtype(dt)) {
-         // spill to memory even though we would ordinarily pass
-         // it in registers
-+#if JL_LLVM_VERSION < 120000
-         ab.addAttribute(Attribute::ByVal);
-+#else
-+        Type* Ty = preferred_llvm_type(dt, false);
-+        ab.addByValAttr(Ty);
-+#endif
-         return true;
-     }
-     return false;
-diff --git a/src/ccall.cpp b/src/ccall.cpp
-index 66ab84c264..e21c717d41 100644
---- a/src/ccall.cpp
-+++ b/src/ccall.cpp
-@@ -291,7 +291,7 @@ class AbiLayout {
- public:
-     virtual ~AbiLayout() {}
-     virtual bool use_sret(jl_datatype_t *ty) = 0;
--    virtual bool needPassByRef(jl_datatype_t *ty, AttrBuilder&) = 0;
-+    virtual bool needPassByRef(jl_datatype_t *ty, AttrBuilder&, Type* llvm_t) = 0;
-     virtual Type *preferred_llvm_type(jl_datatype_t *ty, bool isret) const = 0;
- };
- 
-@@ -1077,7 +1077,7 @@ std::string generate_func_sig(const char *fname)
-         }
- 
-         // Whether or not LLVM wants us to emit a pointer to the data
--        bool byRef = abi->needPassByRef((jl_datatype_t*)tti, ab);
-+        bool byRef = abi->needPassByRef((jl_datatype_t*)tti, ab, t);
- 
-         if (jl_is_cpointer_type(tti)) {
-             pat = t;
-
-From 1fe19a197ebbe33c9e60b2ca7d30c2573772b476 Mon Sep 17 00:00:00 2001
-From: Valentin Churavy <v.churavy at gmail.com>
-Date: Thu, 21 Oct 2021 20:32:39 -0400
-Subject: [PATCH 4/6] [LLVM/Win32] Force stack alignment on module
-
----
- src/aotcompile.cpp |  3 +++
- src/ccall.cpp      |  3 +++
- src/codegen.cpp    | 11 ++++++++++-
- 3 files changed, 16 insertions(+), 1 deletion(-)
-
-diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp
-index ffd43ee8d48d..d3dfc744fcd0 100644
---- a/src/aotcompile.cpp
-+++ b/src/aotcompile.cpp
-@@ -550,6 +550,9 @@ void jl_dump_native_impl(void *native_code,
-     std::unique_ptr<Module> sysimage(new Module("sysimage", Context));
-     sysimage->setTargetTriple(data->M->getTargetTriple());
-     sysimage->setDataLayout(data->M->getDataLayout());
-+#if JL_LLVM_VERSION >= 130000
-+    sysimage->setOverrideStackAlignment(data->M->getOverrideStackAlignment());
-+#endif
-     data->M.reset(); // free memory for data->M
- 
-     if (sysimg_data) {
-diff --git a/src/ccall.cpp b/src/ccall.cpp
-index fb70e53e2814..dd7626c918d0 100644
---- a/src/ccall.cpp
-+++ b/src/ccall.cpp
-@@ -891,6 +891,9 @@ static jl_cgval_t emit_llvmcall(jl_codectx_t &ctx, jl_value_t **args, size_t nar
-     // copy module properties that should always match
-     Mod->setTargetTriple(jl_Module->getTargetTriple());
-     Mod->setDataLayout(jl_Module->getDataLayout());
-+#if JL_LLVM_VERSION >= 130000
-+    Mod->setOverrideStackAlignment(jl_Module->getOverrideStackAlignment());
-+#endif
- 
-     // verify the definition
-     Function *def = Mod->getFunction(ir_name);
-diff --git a/src/codegen.cpp b/src/codegen.cpp
-index b09eb8db04e0..bc4ea7711a04 100644
---- a/src/codegen.cpp
-+++ b/src/codegen.cpp
-@@ -1707,6 +1707,14 @@ static void jl_setup_module(Module *m, const jl_cgparams_t *params = &jl_default
-             llvm::DEBUG_METADATA_VERSION);
-     m->setDataLayout(jl_data_layout);
-     m->setTargetTriple(jl_TargetMachine->getTargetTriple().str());
-+
-+#if defined(_OS_WINDOWS_) && !defined(_CPU_X86_64_) && JL_LLVM_VERSIOn >= 130000
-+    // tell Win32 to assume the stack is always 16-byte aligned,
-+    // and to ensure that it is 16-byte aligned for out-going calls,
-+    // to ensure compatibility with GCC codes
-+    m->setOverrideStackAlignment(16;)
-+#endif
-+
- }
- 
- Module *jl_create_llvm_module(StringRef name)
-@@ -8235,10 +8243,11 @@ extern "C" void jl_init_llvm(void)
- 
-     TargetOptions options = TargetOptions();
-     //options.PrintMachineCode = true; //Print machine code produced during JIT compiling
--#if defined(_OS_WINDOWS_) && !defined(_CPU_X86_64_)
-+#if defined(_OS_WINDOWS_) && !defined(_CPU_X86_64_) && JL_LLVM_VERSION <= 120000
-     // tell Win32 to assume the stack is always 16-byte aligned,
-     // and to ensure that it is 16-byte aligned for out-going calls,
-     // to ensure compatibility with GCC codes
-+    // In LLVM 13 and onwards this has turned into a module option
-     options.StackAlignmentOverride = 16;
- #endif
- #ifdef JL_DEBUG_BUILD
-
-From 7a320647976eb97fdd169b5e85397b9e493e4569 Mon Sep 17 00:00:00 2001
-From: Valentin Churavy <v.churavy at gmail.com>
-Date: Fri, 22 Oct 2021 15:35:38 -0400
-Subject: [PATCH 5/6] StackProtector is now a module flag
-
----
- src/aotcompile.cpp | 1 +
- src/ccall.cpp      | 1 +
- src/codegen.cpp    | 6 ++++--
- 3 files changed, 6 insertions(+), 2 deletions(-)
-
-diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp
-index d3dfc744fcd0..05fcca50c4ee 100644
---- a/src/aotcompile.cpp
-+++ b/src/aotcompile.cpp
-@@ -551,6 +551,7 @@ void jl_dump_native_impl(void *native_code,
-     sysimage->setTargetTriple(data->M->getTargetTriple());
-     sysimage->setDataLayout(data->M->getDataLayout());
- #if JL_LLVM_VERSION >= 130000
-+    sysimage->setStackProtectorGuard(data->M->getStackProtectorGuard());
-     sysimage->setOverrideStackAlignment(data->M->getOverrideStackAlignment());
- #endif
-     data->M.reset(); // free memory for data->M
-diff --git a/src/ccall.cpp b/src/ccall.cpp
-index dd7626c918d0..647735edb37d 100644
---- a/src/ccall.cpp
-+++ b/src/ccall.cpp
-@@ -892,6 +892,7 @@ static jl_cgval_t emit_llvmcall(jl_codectx_t &ctx, jl_value_t **args, size_t nar
-     Mod->setTargetTriple(jl_Module->getTargetTriple());
-     Mod->setDataLayout(jl_Module->getDataLayout());
- #if JL_LLVM_VERSION >= 130000
-+    Mod->setStackProtectorGuard(jl_Module->getStackProtectorGuard());
-     Mod->setOverrideStackAlignment(jl_Module->getOverrideStackAlignment());
- #endif
- 
-diff --git a/src/codegen.cpp b/src/codegen.cpp
-index bc4ea7711a04..1a7017d3aeb7 100644
---- a/src/codegen.cpp
-+++ b/src/codegen.cpp
-@@ -1714,7 +1714,9 @@ static void jl_setup_module(Module *m, const jl_cgparams_t *params = &jl_default
-     // to ensure compatibility with GCC codes
-     m->setOverrideStackAlignment(16;)
- #endif
--
-+#if defined(JL_DEBUG_BUILD) && JL_LLVM_VERSION >= 130000
-+    m->setStackProtectorGuard("global");
-+#endif
- }
- 
- Module *jl_create_llvm_module(StringRef name)
-
-From e323fc8f7be4ce053dec613076d7dd7517515134 Mon Sep 17 00:00:00 2001
-From: Valentin Churavy <v.churavy at gmail.com>
-Date: Sun, 24 Oct 2021 15:18:23 -0400
-Subject: [PATCH 6/6] Cleanup MachineObjectFileInfo handling in disassembly
-
----
- src/disasm.cpp | 18 +++++++++---------
- 1 file changed, 9 insertions(+), 9 deletions(-)
-
-diff --git a/src/disasm.cpp b/src/disasm.cpp
-index 73b394b77d0b..25e7841bde85 100644
---- a/src/disasm.cpp
-+++ b/src/disasm.cpp
-@@ -860,21 +860,21 @@ static void jl_dump_asm_internal(
-     std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TheTriple.str()));
-     assert(MRI && "Unable to create target register info!");
- 
--    std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
--#if JL_LLVM_VERSION >= 130000
--    MCSubtargetInfo *MSTI = TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features);
--    assert(MSTI && "Unable to create subtarget info!");
-+    std::unique_ptr<llvm::MCSubtargetInfo> STI(
-+      TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features));
-+    assert(STI && "Unable to create subtarget info!");
- 
--    MCContext Ctx(TheTriple, MAI.get(), MRI.get(), MSTI, &SrcMgr);
--    MOFI->initMCObjectFileInfo(Ctx, /* PIC */ false, /* LargeCodeModel */ false);
-+#if JL_LLVM_VERSION >= 130000
-+    MCContext Ctx(TheTriple, MAI.get(), MRI.get(), STI.get(), &SrcMgr);
-+    std::unique_ptr<MCObjectFileInfo> MOFI(
-+      TheTarget->createMCObjectFileInfo(Ctx, /*PIC=*/false, /*LargeCodeModel=*/ false));
-+    Ctx.setObjectFileInfo(MOFI.get());
- #else
-+    std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
-     MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
-     MOFI->InitMCObjectFileInfo(TheTriple, /* PIC */ false, Ctx);
- #endif
- 
--    // Set up Subtarget and Disassembler
--    std::unique_ptr<MCSubtargetInfo>
--        STI(TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features));
-     std::unique_ptr<MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI, Ctx));
-     if (!DisAsm) {
-         rstream << "ERROR: no disassembler for target " << TheTriple.str();



More information about the arch-commits mailing list