[arch-commits] Commit in julia/repos/community-x86_64 (22 files)

Antonio Rojas arojas at gemini.archlinux.org
Fri Jan 21 20:32:58 UTC 2022


    Date: Friday, January 21, 2022 @ 20:32:58
  Author: arojas
Revision: 1112622

archrelease: copy trunk to community-x86_64

Added:
  julia/repos/community-x86_64/63303980.patch
    (from rev 1112621, julia/trunk/63303980.patch)
  julia/repos/community-x86_64/PKGBUILD
    (from rev 1112621, julia/trunk/PKGBUILD)
  julia/repos/community-x86_64/f8c918b0.patch
    (from rev 1112621, julia/trunk/f8c918b0.patch)
  julia/repos/community-x86_64/julia-curl-7.81.patch
    (from rev 1112621, julia/trunk/julia-curl-7.81.patch)
  julia/repos/community-x86_64/julia-hardcoded-libs.patch
    (from rev 1112621, julia/trunk/julia-hardcoded-libs.patch)
  julia/repos/community-x86_64/julia-libblastrampoline-4.patch
    (from rev 1112621, julia/trunk/julia-libblastrampoline-4.patch)
  julia/repos/community-x86_64/julia-libgit-1.2.patch
    (from rev 1112621, julia/trunk/julia-libgit-1.2.patch)
  julia/repos/community-x86_64/julia-libunwind-1.6.patch
    (from rev 1112621, julia/trunk/julia-libunwind-1.6.patch)
  julia/repos/community-x86_64/julia-llvm-patchelf.patch
    (from rev 1112621, julia/trunk/julia-llvm-patchelf.patch)
  julia/repos/community-x86_64/julia-system-cblas.patch
    (from rev 1112621, julia/trunk/julia-system-cblas.patch)
  julia/repos/community-x86_64/make-install-no-build.patch
    (from rev 1112621, julia/trunk/make-install-no-build.patch)
Deleted:
  julia/repos/community-x86_64/63303980.patch
  julia/repos/community-x86_64/PKGBUILD
  julia/repos/community-x86_64/f8c918b0.patch
  julia/repos/community-x86_64/julia-curl-7.81.patch
  julia/repos/community-x86_64/julia-hardcoded-libs.patch
  julia/repos/community-x86_64/julia-libblastrampoline-4.patch
  julia/repos/community-x86_64/julia-libgit-1.2.patch
  julia/repos/community-x86_64/julia-libunwind-1.6.patch
  julia/repos/community-x86_64/julia-llvm-patchelf.patch
  julia/repos/community-x86_64/julia-system-cblas.patch
  julia/repos/community-x86_64/make-install-no-build.patch

---------------------------------+
 63303980.patch                  | 1366 +++++++++++++++++++-------------------
 PKGBUILD                        |  321 ++++----
 f8c918b0.patch                  |  472 ++++++-------
 julia-curl-7.81.patch           |   56 -
 julia-hardcoded-libs.patch      |  138 +--
 julia-libblastrampoline-4.patch |   28 
 julia-libgit-1.2.patch          |   28 
 julia-libunwind-1.6.patch       |   40 -
 julia-llvm-patchelf.patch       |   30 
 julia-system-cblas.patch        |  266 +++----
 make-install-no-build.patch     |   28 
 11 files changed, 1389 insertions(+), 1384 deletions(-)

Deleted: 63303980.patch
===================================================================
--- 63303980.patch	2022-01-21 20:32:37 UTC (rev 1112621)
+++ 63303980.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,683 +0,0 @@
-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);

Copied: julia/repos/community-x86_64/63303980.patch (from rev 1112621, julia/trunk/63303980.patch)
===================================================================
--- 63303980.patch	                        (rev 0)
+++ 63303980.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -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);

Deleted: PKGBUILD
===================================================================
--- PKGBUILD	2022-01-21 20:32:37 UTC (rev 1112621)
+++ PKGBUILD	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,159 +0,0 @@
-# Maintainer: Antonio Rojas <arojas at archlinux.org>
-# Contributor: Alexander F. Rødseth <xyproto at archlinux.org>
-# Contributor: Eli Schwartz <eschwartz at archlinux.org>
-# Contributor: Lex Black <autumn-wind at web.de>
-# Contributor: Michael Jakl <jakl.michael at gmail.com>
-# Contributor: devmotion <nospam-archlinux.org at devmotion.de>
-# Contributor: Valentin Churavy <v.churavy at gmail.com>
-
-pkgname=julia
-epoch=2
-pkgver=1.7.1
-pkgrel=5
-arch=(x86_64)
-pkgdesc='High-level, high-performance, dynamic programming language'
-url='https://julialang.org/'
-license=(MIT)
-depends=(cblas fftw hicolor-icon-theme libgit2 libunwind libutf8proc openblas
-         suitesparse mbedtls openlibm pcre2 llvm-libs p7zip libblastrampoline)
-makedepends=(cmake gcc-fortran python llvm patchelf libwhich)
-optdepends=('gnuplot: If using the Gaston Package from julia')
-replaces=(julia-docs)
-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
-        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
-        make-install-no-build.patch
-        julia-llvm-patchelf.patch
-        julia-libunwind-1.6.patch
-        julia-curl-7.81.patch
-        julia-libblastrampoline-4.patch)
-backup=(etc/julia/startup.jl)
-sha256sums=('add869121b7e788ff487a234fd39484469dbb3ded29b17041c63c4757515dd58'
-            'SKIP'
-            'a798c58ab518def84e4112538de59a10802e7dc854c20b08990a1619ba2aa95b'
-            'c76c6fbb4e04b185d11e3c3e0aec99a2088f3b06621ce61d29cd21227a044a7a'
-            '37130eabce304a01c1de389b4596905a3f33881f46f3f04a87f0738668e13985'
-            'bc6c85cbbca489ef0b2876dbeb6ae493c11573e058507b8bcb9e01273bc3a38c'
-            'ce9cd140c3bc39987d60340bf365d6238e79cf4d5385494272c49c64af22ef78'
-            'c57ea92a11fa8dac72229e6a912d2372ec0d98d63486426fe3bdeeb795de48f7'
-            '8f8c12853ce847f5d1b5a4a461ddec701decdb81dae7bb31d66560c1deaed97a'
-            '03043f005c133ac9af1d4dc113ea8b525ad3b393690625be77975f0e29dd6457'
-            '8be4605f92a009072ca7e843549c225fc4e959893498e7c4f8f79e861e63714d'
-            '6048c69c987f33f2b17d78b63368b0762d1d6a1e531ef9932d0c23bda49d1384'
-            '3afa172e8b54ce48e77542677b2b7143199d444bfeed39be1644ce88b513a3d0'
-            '710587dd88c7698dc5cdf47a1a50f6f144b584b7d9ffb85fac3f5f79c65fce11'
-            '7077a4321eab9b4b67efdfc80dfa6acac1f88bd45f2f55c417a19e50019ee4f2')
-validpgpkeys=('3673DF529D9049477F76B37566E3C7DC03D6E495') # Julia (Binary signing key) <buildbot at julialang.org>
-options=(!lto)
-
-prepare() {
-  cd $pkgname-$pkgver
-
-# fix build with LLVM 13
-  patch -p1 -i ../677ce6d3.patch
-  patch -p1 -i ../47f9139e.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
-  patch -p1 -i ../julia-libunwind-1.6.patch
-# Add and use option to build with system cblas
-  patch -p1 -i ../julia-system-cblas.patch # Add and use option to build with system cblas
-# Don't hardcode library names
-  patch -p1 -i ../julia-hardcoded-libs.patch
-# Don't build again in install
-  patch -p1 -i ../make-install-no-build.patch
-# Fix test failure
-  sed -e 's|0.22314355f0 + 3.1415927f0im|0.22314355f0 - 3.1415927f0im|' -i stdlib/LinearAlgebra/test/lu.jl
-# Don't try to run patchelf on system LLVM
-  patch -p1 -i ../julia-llvm-patchelf.patch
-# Port to libblastrampoline 4 API
-  patch -p1 -i ../julia-libblastrampoline-4.patch
-
-# Fix segfault with curl 7.81
-  cd stdlib/srccache
-  tar -xzf Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz
-  patch -d JuliaLang-Downloads.jl-26d79af -p1 < "$srcdir"/julia-curl-7.81.patch
-  rm Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz
-  tar -czf Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz JuliaLang-Downloads.jl-26d79af
-  md5sum Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz | cut -d ' ' -f 1 > ../../deps/checksums/Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz/md5
-  sha512sum Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz | cut -d ' ' -f 1 > ../../deps/checksums/Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz/sha512
-}
-
-_buildopts="prefix=/usr \
-    bindir=/usr/bin \
-    sysconfdir=/etc \
-    libexecdir=/usr/lib \
-    USE_BINARYBUILDER=0 \
-    USE_SYSTEM_CSL=1 \
-    USE_SYSTEM_LLVM=1 \
-    USE_SYSTEM_LIBUNWIND=1 \
-    USE_SYSTEM_PCRE=1 \
-    USE_SYSTEM_BLAS=1 \
-    USE_SYSTEM_LAPACK=1 \
-    USE_SYSTEM_GMP=1 \
-    USE_SYSTEM_MPFR=1 \
-    USE_SYSTEM_LIBSUITESPARSE=1 \
-    USE_SYSTEM_LIBBLASTRAMPOLINE=1 \
-    USE_SYSTEM_LIBWHICH=1 \
-    USE_SYSTEM_DSFMT=0 \
-    USE_SYSTEM_LIBUV=0 \
-    USE_SYSTEM_UTF8PROC=1 \
-    USE_SYSTEM_LIBGIT2=1 \
-    USE_SYSTEM_LIBSSH2=1 \
-    USE_SYSTEM_MBEDTLS=1 \
-    USE_SYSTEM_CURL=1 \
-    USE_SYSTEM_PATCHELF=1 \
-    USE_SYSTEM_ZLIB=1 \
-    USE_SYSTEM_P7ZIP=1 \
-    USE_SYSTEM_OPENLIBM=1 \
-    MARCH=x86-64"
-
-build() {
-  cd $pkgname-$pkgver
-  make release VERBOSE=1 JLDFLAGS=${LDFLAGS} $_buildopts
-}
-
-check() {
-  cd $pkgname-$pkgver/test
-
-  # this is the make testall target, plus the --skip option from
-  # travis/appveyor/circleci (one test fails with DNS resolution errors)
-  # Also skip tests that check for a hardcoded version number
-  ../julia --check-bounds=yes --startup-file=no ./runtests.jl \
-    --skip Sockets \
-    --skip broadcast \
-    --skip Distributed \
-    --skip nghttp2_jll \
-    --skip GMP_jll \
-    --skip LibCURL \
-    --skip LibSSH2_jll \
-    --skip MbedTLS_jll \
-    --skip MPFR_jll \
-    --skip SuiteSparse_jll \
-    --skip PCRE2_jll \
-    --skip LibGit2_jll \
-    --skip MozillaCACerts_jll \
-    --skip NetworkOptions \
-    --skip Downloads
-  find ../stdlib \( -name \*.cov -o -name \*.mem \) -delete
-  rm -fr ../stdlib/Artifacts/test/artifacts
-}
-
-package() {
-  cd $pkgname-$pkgver
-  make DESTDIR="$pkgdir" install $_buildopts
-
-  ln -s /usr/lib/libopenblas.so "$pkgdir"/usr/lib/julia/libopenblas64_.so # Needed by some 3rd party packages
-
-  rm "$pkgdir"/usr/lib/julia/libccalltest.so.debug # Remove debug testing library
-  install -Dm644 LICENSE.md -t "$pkgdir"/usr/share/licenses/$pkgname
-}

Copied: julia/repos/community-x86_64/PKGBUILD (from rev 1112621, julia/trunk/PKGBUILD)
===================================================================
--- PKGBUILD	                        (rev 0)
+++ PKGBUILD	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -0,0 +1,162 @@
+# Maintainer: Antonio Rojas <arojas at archlinux.org>
+# Contributor: Alexander F. Rødseth <xyproto at archlinux.org>
+# Contributor: Eli Schwartz <eschwartz at archlinux.org>
+# Contributor: Lex Black <autumn-wind at web.de>
+# Contributor: Michael Jakl <jakl.michael at gmail.com>
+# Contributor: devmotion <nospam-archlinux.org at devmotion.de>
+# Contributor: Valentin Churavy <v.churavy at gmail.com>
+
+pkgname=julia
+epoch=2
+pkgver=1.7.1
+pkgrel=6
+arch=(x86_64)
+pkgdesc='High-level, high-performance, dynamic programming language'
+url='https://julialang.org/'
+license=(MIT)
+depends=(cblas fftw hicolor-icon-theme libgit2 libunwind libutf8proc openblas
+         suitesparse mbedtls openlibm pcre2 llvm-libs p7zip libblastrampoline)
+makedepends=(cmake gcc-fortran python llvm patchelf libwhich)
+optdepends=('gnuplot: If using the Gaston Package from julia')
+replaces=(julia-docs)
+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
+        https://github.com/JuliaLang/julia/commit/1eb063f1.patch
+        https://github.com/JuliaLang/julia/commit/99d4e655.patch
+        f8c918b0.patch
+        63303980.patch
+        julia-libgit-1.2.patch
+        julia-system-cblas.patch
+        julia-hardcoded-libs.patch
+        make-install-no-build.patch
+        julia-llvm-patchelf.patch
+        julia-libunwind-1.6.patch
+        julia-curl-7.81.patch
+        julia-libblastrampoline-4.patch)
+backup=(etc/julia/startup.jl)
+sha256sums=('add869121b7e788ff487a234fd39484469dbb3ded29b17041c63c4757515dd58'
+            'SKIP'
+            'a798c58ab518def84e4112538de59a10802e7dc854c20b08990a1619ba2aa95b'
+            'c76c6fbb4e04b185d11e3c3e0aec99a2088f3b06621ce61d29cd21227a044a7a'
+            '37130eabce304a01c1de389b4596905a3f33881f46f3f04a87f0738668e13985'
+            'b6ea2d6b2cfa8cd9a8903fd25d609544710f25bb3074841c884459f62e8dc74a'
+            'bc6c85cbbca489ef0b2876dbeb6ae493c11573e058507b8bcb9e01273bc3a38c'
+            'ce9cd140c3bc39987d60340bf365d6238e79cf4d5385494272c49c64af22ef78'
+            'c57ea92a11fa8dac72229e6a912d2372ec0d98d63486426fe3bdeeb795de48f7'
+            '8f8c12853ce847f5d1b5a4a461ddec701decdb81dae7bb31d66560c1deaed97a'
+            '03043f005c133ac9af1d4dc113ea8b525ad3b393690625be77975f0e29dd6457'
+            '8be4605f92a009072ca7e843549c225fc4e959893498e7c4f8f79e861e63714d'
+            '6048c69c987f33f2b17d78b63368b0762d1d6a1e531ef9932d0c23bda49d1384'
+            '3afa172e8b54ce48e77542677b2b7143199d444bfeed39be1644ce88b513a3d0'
+            '710587dd88c7698dc5cdf47a1a50f6f144b584b7d9ffb85fac3f5f79c65fce11'
+            '79cd957d0599a8ee1dbdf7f2ebd1a5bd85ab7e499584858e89a8d9609ba1ced4')
+validpgpkeys=('3673DF529D9049477F76B37566E3C7DC03D6E495') # Julia (Binary signing key) <buildbot at julialang.org>
+options=(!lto)
+
+prepare() {
+  cd $pkgname-$pkgver
+
+# fixes for LLVM 13
+  patch -p1 -i ../677ce6d3.patch
+  patch -p1 -i ../47f9139e.patch
+  patch -p1 -i ../1eb063f1.patch
+  patch -p1 -i ../f8c918b0.patch
+  patch -p1 -i ../63303980.patch
+  patch -p1 -i ../99d4e655.patch
+# libgit2 1.2 compatibility
+  patch -p1 -i ../julia-libgit-1.2.patch
+# libunwind 1.6 compatibility
+  patch -p1 -i ../julia-libunwind-1.6.patch
+# Add and use option to build with system cblas
+  patch -p1 -i ../julia-system-cblas.patch # Add and use option to build with system cblas
+# Don't hardcode library names
+  patch -p1 -i ../julia-hardcoded-libs.patch
+# Don't build again in install
+  patch -p1 -i ../make-install-no-build.patch
+# Fix test failure
+  sed -e 's|0.22314355f0 + 3.1415927f0im|0.22314355f0 - 3.1415927f0im|' -i stdlib/LinearAlgebra/test/lu.jl
+# Don't try to run patchelf on system LLVM
+  patch -p1 -i ../julia-llvm-patchelf.patch
+# Port to libblastrampoline 4 API
+  patch -p1 -i ../julia-libblastrampoline-4.patch
+
+# Fix segfault with curl 7.81
+  cd stdlib/srccache
+  tar -xzf Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz
+  patch -d JuliaLang-Downloads.jl-26d79af -p1 < "$srcdir"/julia-curl-7.81.patch
+  rm Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz
+  tar -czf Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz JuliaLang-Downloads.jl-26d79af
+  md5sum Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz | cut -d ' ' -f 1 > ../../deps/checksums/Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz/md5
+  sha512sum Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz | cut -d ' ' -f 1 > ../../deps/checksums/Downloads-26d79afcde9cf837a331fce023b31f1d3699700c.tar.gz/sha512
+}
+
+_buildopts="prefix=/usr \
+    bindir=/usr/bin \
+    sysconfdir=/etc \
+    libexecdir=/usr/lib \
+    USE_BINARYBUILDER=0 \
+    USE_SYSTEM_CSL=1 \
+    USE_SYSTEM_LLVM=1 \
+    USE_SYSTEM_LIBUNWIND=1 \
+    USE_SYSTEM_PCRE=1 \
+    USE_SYSTEM_BLAS=1 \
+    USE_SYSTEM_LAPACK=1 \
+    USE_SYSTEM_GMP=1 \
+    USE_SYSTEM_MPFR=1 \
+    USE_SYSTEM_LIBSUITESPARSE=1 \
+    USE_SYSTEM_LIBBLASTRAMPOLINE=1 \
+    USE_SYSTEM_LIBWHICH=1 \
+    USE_SYSTEM_DSFMT=0 \
+    USE_SYSTEM_LIBUV=0 \
+    USE_SYSTEM_UTF8PROC=1 \
+    USE_SYSTEM_LIBGIT2=1 \
+    USE_SYSTEM_LIBSSH2=1 \
+    USE_SYSTEM_MBEDTLS=1 \
+    USE_SYSTEM_CURL=1 \
+    USE_SYSTEM_PATCHELF=1 \
+    USE_SYSTEM_ZLIB=1 \
+    USE_SYSTEM_P7ZIP=1 \
+    USE_SYSTEM_OPENLIBM=1 \
+    MARCH=x86-64"
+
+build() {
+  cd $pkgname-$pkgver
+  make release VERBOSE=1 JLDFLAGS=${LDFLAGS} $_buildopts
+}
+
+check() {
+  cd $pkgname-$pkgver/test
+
+  # this is the make testall target, plus the --skip option from
+  # travis/appveyor/circleci (one test fails with DNS resolution errors)
+  # Also skip tests that check for a hardcoded version number
+  ../julia --check-bounds=yes --startup-file=no ./runtests.jl \
+    --skip Sockets \
+    --skip broadcast \
+    --skip Distributed \
+    --skip nghttp2_jll \
+    --skip GMP_jll \
+    --skip LibCURL \
+    --skip LibSSH2_jll \
+    --skip MbedTLS_jll \
+    --skip MPFR_jll \
+    --skip SuiteSparse_jll \
+    --skip PCRE2_jll \
+    --skip LibGit2_jll \
+    --skip MozillaCACerts_jll \
+    --skip NetworkOptions \
+    --skip Downloads
+  find ../stdlib \( -name \*.cov -o -name \*.mem \) -delete
+  rm -fr ../stdlib/Artifacts/test/artifacts
+}
+
+package() {
+  cd $pkgname-$pkgver
+  make DESTDIR="$pkgdir" install $_buildopts
+
+  ln -s /usr/lib/libopenblas.so "$pkgdir"/usr/lib/julia/libopenblas64_.so # Needed by some 3rd party packages
+
+  rm "$pkgdir"/usr/lib/julia/libccalltest.so.debug # Remove debug testing library
+  install -Dm644 LICENSE.md -t "$pkgdir"/usr/share/licenses/$pkgname
+}

Deleted: f8c918b0.patch
===================================================================
--- f8c918b0.patch	2022-01-21 20:32:37 UTC (rev 1112621)
+++ f8c918b0.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,236 +0,0 @@
-From f8c918b00f7c62e204d324a827e2ee2ef05bb66a Mon Sep 17 00:00:00 2001
-From: pchintalapudi <34727397+pchintalapudi at users.noreply.github.com>
-Date: Wed, 10 Nov 2021 17:56:26 -0500
-Subject: [PATCH] Move PTLS load emission from codegen to late-gc-lowering
- (#42572)
-
-* Move PTLS load emission from codegen to late-gc-lowering
-
-* Address PR comments
-
-* Fix tests and move TBAA node generation to codegen_shared
-
-* Add check for null metadata node
-
-Co-authored-by: Prem Chintalapudi <premc at csail.mit.edu>
----
- src/Makefile                         |  2 +-
- src/cgutils.cpp                      | 12 +---
- src/codegen.cpp                      | 18 +-----
- src/codegen_shared.h                 | 83 +++++++++++++++++++++++++++
- src/llvm-late-gc-lowering.cpp        |  4 +-
- test/llvmpasses/alloc-opt-gcframe.jl | 86 +++++++++++++---------------
- test/llvmpasses/late-lower-gc.ll     | 58 +++++++++++--------
- 7 files changed, 167 insertions(+), 96 deletions(-)
-
-diff --git a/src/Makefile b/src/Makefile
-index 17e70fe6d01f..1494fe3be40a 100644
---- a/src/Makefile
-+++ b/src/Makefile
-@@ -293,7 +293,7 @@ $(build_shlibdir)/libllvmcalltest.$(SHLIB_EXT): $(SRCDIR)/codegen_shared.h $(BUI
- $(BUILDDIR)/llvm-alloc-opt.o $(BUILDDIR)/llvm-alloc-opt.dbg.obj: $(SRCDIR)/codegen_shared.h
- $(BUILDDIR)/llvm-final-gc-lowering.o $(BUILDDIR)/llvm-final-gc-lowering.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h
- $(BUILDDIR)/llvm-gc-invariant-verifier.o $(BUILDDIR)/llvm-gc-invariant-verifier.dbg.obj: $(SRCDIR)/codegen_shared.h
--$(BUILDDIR)/llvm-late-gc-lowering.o $(BUILDDIR)/llvm-late-gc-lowering.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h
-+$(BUILDDIR)/llvm-late-gc-lowering.o $(BUILDDIR)/llvm-late-gc-lowering.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h $(SRCDIR)/codegen_shared.h
- $(BUILDDIR)/llvm-multiversioning.o $(BUILDDIR)/llvm-multiversioning.dbg.obj: $(SRCDIR)/codegen_shared.h
- $(BUILDDIR)/llvm-pass-helpers.o $(BUILDDIR)/llvm-pass-helpers.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h $(SRCDIR)/codegen_shared.h
- $(BUILDDIR)/llvm-ptls.o $(BUILDDIR)/llvm-ptls.dbg.obj: $(SRCDIR)/codegen_shared.h
-diff --git a/src/cgutils.cpp b/src/cgutils.cpp
-index a1fef5279a6b..219b42dae75a 100644
---- a/src/cgutils.cpp
-+++ b/src/cgutils.cpp
-@@ -2,14 +2,6 @@
- 
- // utility procedures used in code generation
- 
--static Instruction *tbaa_decorate(MDNode *md, Instruction *inst)
--{
--    inst->setMetadata(llvm::LLVMContext::MD_tbaa, md);
--    if (isa<LoadInst>(inst) && md == tbaa_const)
--        inst->setMetadata(LLVMContext::MD_invariant_load, MDNode::get(md->getContext(), None));
--    return inst;
--}
--
- static Value *track_pjlvalue(jl_codectx_t &ctx, Value *V)
- {
-     assert(V->getType() == T_pjlvalue);
-@@ -3218,9 +3210,9 @@ static void emit_cpointercheck(jl_codectx_t &ctx, const jl_cgval_t &x, const std
- // allocation for known size object
- static Value *emit_allocobj(jl_codectx_t &ctx, size_t static_size, Value *jt)
- {
--    Value *ptls_ptr = emit_bitcast(ctx, get_current_ptls(ctx), T_pint8);
-+    Value *current_task = get_current_task(ctx);
-     Function *F = prepare_call(jl_alloc_obj_func);
--    auto call = ctx.builder.CreateCall(F, {ptls_ptr, ConstantInt::get(T_size, static_size), maybe_decay_untracked(ctx, jt)});
-+    auto call = ctx.builder.CreateCall(F, {current_task, ConstantInt::get(T_size, static_size), maybe_decay_untracked(ctx, jt)});
-     call->setAttributes(F->getAttributes());
-     return call;
- }
-diff --git a/src/codegen.cpp b/src/codegen.cpp
-index 6ab179bb5446..3e0457972caf 100644
---- a/src/codegen.cpp
-+++ b/src/codegen.cpp
-@@ -634,7 +634,7 @@ static const auto jlegalx_func = new JuliaFunction{
- static const auto jl_alloc_obj_func = new JuliaFunction{
-     "julia.gc_alloc_obj",
-     [](LLVMContext &C) { return FunctionType::get(T_prjlvalue,
--                {T_pint8, T_size, T_prjlvalue}, false); },
-+                {T_ppjlvalue, T_size, T_prjlvalue}, false); },
-     [](LLVMContext &C) { return AttributeList::get(C,
-             AttributeSet::get(C, makeArrayRef({Attribute::getWithAllocSizeArgs(C, 1, None)})), // returns %1 bytes
-             Attributes(C, {Attribute::NoAlias, Attribute::NonNull}),
-@@ -1131,7 +1131,7 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, const jl_cgval_t &lival, const
- 
- static Value *literal_pointer_val(jl_codectx_t &ctx, jl_value_t *p);
- static GlobalVariable *prepare_global_in(Module *M, GlobalVariable *G);
--static Instruction *tbaa_decorate(MDNode *md, Instruction *inst);
-+Instruction *tbaa_decorate(MDNode *md, Instruction *inst);
- 
- static GlobalVariable *prepare_global_in(Module *M, JuliaVariable *G)
- {
-@@ -4792,19 +4792,7 @@ static Value *get_current_task(jl_codectx_t &ctx)
- // Get PTLS through current task.
- static Value *get_current_ptls(jl_codectx_t &ctx)
- {
--    const int ptls_offset = offsetof(jl_task_t, ptls);
--    Value *pptls = ctx.builder.CreateInBoundsGEP(
--        T_pjlvalue, get_current_task(ctx),
--        ConstantInt::get(T_size, ptls_offset / sizeof(void *)),
--        "ptls_field");
--    LoadInst *ptls_load = ctx.builder.CreateAlignedLoad(
--        emit_bitcast(ctx, pptls, T_ppjlvalue), Align(sizeof(void *)), "ptls_load");
--    // Note: Corresponding store (`t->ptls = ptls`) happens in `ctx_switch` of tasks.c.
--    tbaa_decorate(tbaa_gcframe, ptls_load);
--    // Using `CastInst::Create` to get an `Instruction*` without explicit cast:
--    auto ptls = CastInst::Create(Instruction::BitCast, ptls_load, T_ppjlvalue, "ptls");
--    ctx.builder.Insert(ptls);
--    return ptls;
-+    return get_current_ptls_from_task(ctx.builder, get_current_task(ctx));
- }
- 
- // Store world age at the entry block of the function. This function should be
-diff --git a/src/codegen_shared.h b/src/codegen_shared.h
-index ca876b9b0310..93c913fd7a76 100644
---- a/src/codegen_shared.h
-+++ b/src/codegen_shared.h
-@@ -5,6 +5,8 @@
- #include <llvm/Support/Debug.h>
- #include <llvm/IR/DebugLoc.h>
- #include <llvm/IR/IRBuilder.h>
-+#include <llvm/IR/MDBuilder.h>
-+#include "julia.h"
- 
- enum AddressSpace {
-     Generic = 0,
-@@ -19,6 +21,24 @@ enum AddressSpace {
-     LastSpecial = Loaded,
- };
- 
-+namespace JuliaType {
-+    static inline llvm::StructType* get_jlvalue_ty(llvm::LLVMContext &C) {
-+        return llvm::StructType::get(C);
-+    }
-+
-+    static inline llvm::PointerType* get_pjlvalue_ty(llvm::LLVMContext &C) {
-+        return llvm::PointerType::get(get_jlvalue_ty(C), 0);
-+    }
-+
-+    static inline llvm::PointerType* get_prjlvalue_ty(llvm::LLVMContext &C) {
-+        return llvm::PointerType::get(get_jlvalue_ty(C), AddressSpace::Tracked);
-+    }
-+
-+    static inline llvm::PointerType* get_ppjlvalue_ty(llvm::LLVMContext &C) {
-+        return llvm::PointerType::get(get_pjlvalue_ty(C), 0);
-+    }
-+}
-+
- // JLCALL with API arguments ([extra], arg0, arg1, arg2, ...) has the following ABI calling conventions defined:
- #define JLCALL_F_CC (CallingConv::ID)37     // (jl_value_t *arg0, jl_value_t **argv, uint32_t nargv)
- #define JLCALL_F2_CC (CallingConv::ID)38    // (jl_value_t *arg0, jl_value_t **argv, uint32_t nargv, jl_value_t *extra)
-@@ -68,3 +88,66 @@ static inline void llvm_dump(llvm::DebugLoc *dbg)
-     dbg->print(llvm::dbgs());
-     llvm::dbgs() << "\n";
- }
-+
-+static inline std::pair<llvm::MDNode*,llvm::MDNode*> tbaa_make_child_with_context(llvm::LLVMContext &ctxt, const char *name, llvm::MDNode *parent=nullptr, bool isConstant=false)
-+{
-+    llvm::MDBuilder mbuilder(ctxt);
-+    llvm::MDNode *jtbaa = mbuilder.createTBAARoot("jtbaa");
-+    llvm::MDNode *tbaa_root = mbuilder.createTBAAScalarTypeNode("jtbaa", jtbaa);
-+    llvm::MDNode *scalar = mbuilder.createTBAAScalarTypeNode(name, parent ? parent : tbaa_root);
-+    llvm::MDNode *n = mbuilder.createTBAAStructTagNode(scalar, scalar, 0, isConstant);
-+    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;
-+}
-+
-+static inline llvm::Instruction *tbaa_decorate(llvm::MDNode *md, llvm::Instruction *inst)
-+{
-+    inst->setMetadata(llvm::LLVMContext::MD_tbaa, md);
-+    if (llvm::isa<llvm::LoadInst>(inst) && md && md == get_tbaa_const(md->getContext()))
-+        inst->setMetadata(llvm::LLVMContext::MD_invariant_load, llvm::MDNode::get(md->getContext(), llvm::None));
-+    return inst;
-+}
-+
-+// bitcast a value, but preserve its address space when dealing with pointer types
-+static inline llvm::Value *emit_bitcast_with_builder(llvm::IRBuilder<> &builder, llvm::Value *v, llvm::Type *jl_value)
-+{
-+    using namespace llvm;
-+    if (isa<PointerType>(jl_value) &&
-+        v->getType()->getPointerAddressSpace() != jl_value->getPointerAddressSpace()) {
-+        // Cast to the proper address space
-+        Type *jl_value_addr =
-+                PointerType::get(cast<PointerType>(jl_value)->getElementType(),
-+                                 v->getType()->getPointerAddressSpace());
-+        return builder.CreateBitCast(v, jl_value_addr);
-+    }
-+    else {
-+        return builder.CreateBitCast(v, jl_value);
-+    }
-+}
-+
-+// Get PTLS through current task.
-+static inline llvm::Value *get_current_ptls_from_task(llvm::IRBuilder<> &builder, llvm::Value *current_task)
-+{
-+    using namespace llvm;
-+    auto T_ppjlvalue = JuliaType::get_ppjlvalue_ty(builder.getContext());
-+    auto T_size = builder.GetInsertBlock()->getModule()->getDataLayout().getIntPtrType(builder.getContext());
-+    const int ptls_offset = offsetof(jl_task_t, ptls);
-+    llvm::Value *pptls = builder.CreateInBoundsGEP(
-+        JuliaType::get_pjlvalue_ty(builder.getContext()), current_task,
-+        ConstantInt::get(T_size, ptls_offset / sizeof(void *)),
-+        "ptls_field");
-+    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);
-+    // 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 b4e1f5009424..ed5fe7c43a59 100644
---- a/src/llvm-late-gc-lowering.cpp
-+++ b/src/llvm-late-gc-lowering.cpp
-@@ -2296,10 +2296,12 @@ 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 ptls = builder.CreateBitCast(ptlsLoad, Type::getInt8PtrTy(builder.getContext()));
-                 auto newI = builder.CreateCall(
-                     allocBytesIntrinsic,
-                     {
--                        CI->getArgOperand(0),
-+                        ptls,
-                         builder.CreateIntCast(
-                             CI->getArgOperand(1),
-                             allocBytesIntrinsic->getFunctionType()->getParamType(1),

Copied: julia/repos/community-x86_64/f8c918b0.patch (from rev 1112621, julia/trunk/f8c918b0.patch)
===================================================================
--- f8c918b0.patch	                        (rev 0)
+++ f8c918b0.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -0,0 +1,236 @@
+From f8c918b00f7c62e204d324a827e2ee2ef05bb66a Mon Sep 17 00:00:00 2001
+From: pchintalapudi <34727397+pchintalapudi at users.noreply.github.com>
+Date: Wed, 10 Nov 2021 17:56:26 -0500
+Subject: [PATCH] Move PTLS load emission from codegen to late-gc-lowering
+ (#42572)
+
+* Move PTLS load emission from codegen to late-gc-lowering
+
+* Address PR comments
+
+* Fix tests and move TBAA node generation to codegen_shared
+
+* Add check for null metadata node
+
+Co-authored-by: Prem Chintalapudi <premc at csail.mit.edu>
+---
+ src/Makefile                         |  2 +-
+ src/cgutils.cpp                      | 12 +---
+ src/codegen.cpp                      | 18 +-----
+ src/codegen_shared.h                 | 83 +++++++++++++++++++++++++++
+ src/llvm-late-gc-lowering.cpp        |  4 +-
+ test/llvmpasses/alloc-opt-gcframe.jl | 86 +++++++++++++---------------
+ test/llvmpasses/late-lower-gc.ll     | 58 +++++++++++--------
+ 7 files changed, 167 insertions(+), 96 deletions(-)
+
+diff --git a/src/Makefile b/src/Makefile
+index 17e70fe6d01f..1494fe3be40a 100644
+--- a/src/Makefile
++++ b/src/Makefile
+@@ -293,7 +293,7 @@ $(build_shlibdir)/libllvmcalltest.$(SHLIB_EXT): $(SRCDIR)/codegen_shared.h $(BUI
+ $(BUILDDIR)/llvm-alloc-opt.o $(BUILDDIR)/llvm-alloc-opt.dbg.obj: $(SRCDIR)/codegen_shared.h
+ $(BUILDDIR)/llvm-final-gc-lowering.o $(BUILDDIR)/llvm-final-gc-lowering.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h
+ $(BUILDDIR)/llvm-gc-invariant-verifier.o $(BUILDDIR)/llvm-gc-invariant-verifier.dbg.obj: $(SRCDIR)/codegen_shared.h
+-$(BUILDDIR)/llvm-late-gc-lowering.o $(BUILDDIR)/llvm-late-gc-lowering.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h
++$(BUILDDIR)/llvm-late-gc-lowering.o $(BUILDDIR)/llvm-late-gc-lowering.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h $(SRCDIR)/codegen_shared.h
+ $(BUILDDIR)/llvm-multiversioning.o $(BUILDDIR)/llvm-multiversioning.dbg.obj: $(SRCDIR)/codegen_shared.h
+ $(BUILDDIR)/llvm-pass-helpers.o $(BUILDDIR)/llvm-pass-helpers.dbg.obj: $(SRCDIR)/llvm-pass-helpers.h $(SRCDIR)/codegen_shared.h
+ $(BUILDDIR)/llvm-ptls.o $(BUILDDIR)/llvm-ptls.dbg.obj: $(SRCDIR)/codegen_shared.h
+diff --git a/src/cgutils.cpp b/src/cgutils.cpp
+index a1fef5279a6b..219b42dae75a 100644
+--- a/src/cgutils.cpp
++++ b/src/cgutils.cpp
+@@ -2,14 +2,6 @@
+ 
+ // utility procedures used in code generation
+ 
+-static Instruction *tbaa_decorate(MDNode *md, Instruction *inst)
+-{
+-    inst->setMetadata(llvm::LLVMContext::MD_tbaa, md);
+-    if (isa<LoadInst>(inst) && md == tbaa_const)
+-        inst->setMetadata(LLVMContext::MD_invariant_load, MDNode::get(md->getContext(), None));
+-    return inst;
+-}
+-
+ static Value *track_pjlvalue(jl_codectx_t &ctx, Value *V)
+ {
+     assert(V->getType() == T_pjlvalue);
+@@ -3218,9 +3210,9 @@ static void emit_cpointercheck(jl_codectx_t &ctx, const jl_cgval_t &x, const std
+ // allocation for known size object
+ static Value *emit_allocobj(jl_codectx_t &ctx, size_t static_size, Value *jt)
+ {
+-    Value *ptls_ptr = emit_bitcast(ctx, get_current_ptls(ctx), T_pint8);
++    Value *current_task = get_current_task(ctx);
+     Function *F = prepare_call(jl_alloc_obj_func);
+-    auto call = ctx.builder.CreateCall(F, {ptls_ptr, ConstantInt::get(T_size, static_size), maybe_decay_untracked(ctx, jt)});
++    auto call = ctx.builder.CreateCall(F, {current_task, ConstantInt::get(T_size, static_size), maybe_decay_untracked(ctx, jt)});
+     call->setAttributes(F->getAttributes());
+     return call;
+ }
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index 6ab179bb5446..3e0457972caf 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -634,7 +634,7 @@ static const auto jlegalx_func = new JuliaFunction{
+ static const auto jl_alloc_obj_func = new JuliaFunction{
+     "julia.gc_alloc_obj",
+     [](LLVMContext &C) { return FunctionType::get(T_prjlvalue,
+-                {T_pint8, T_size, T_prjlvalue}, false); },
++                {T_ppjlvalue, T_size, T_prjlvalue}, false); },
+     [](LLVMContext &C) { return AttributeList::get(C,
+             AttributeSet::get(C, makeArrayRef({Attribute::getWithAllocSizeArgs(C, 1, None)})), // returns %1 bytes
+             Attributes(C, {Attribute::NoAlias, Attribute::NonNull}),
+@@ -1131,7 +1131,7 @@ static jl_cgval_t emit_invoke(jl_codectx_t &ctx, const jl_cgval_t &lival, const
+ 
+ static Value *literal_pointer_val(jl_codectx_t &ctx, jl_value_t *p);
+ static GlobalVariable *prepare_global_in(Module *M, GlobalVariable *G);
+-static Instruction *tbaa_decorate(MDNode *md, Instruction *inst);
++Instruction *tbaa_decorate(MDNode *md, Instruction *inst);
+ 
+ static GlobalVariable *prepare_global_in(Module *M, JuliaVariable *G)
+ {
+@@ -4792,19 +4792,7 @@ static Value *get_current_task(jl_codectx_t &ctx)
+ // Get PTLS through current task.
+ static Value *get_current_ptls(jl_codectx_t &ctx)
+ {
+-    const int ptls_offset = offsetof(jl_task_t, ptls);
+-    Value *pptls = ctx.builder.CreateInBoundsGEP(
+-        T_pjlvalue, get_current_task(ctx),
+-        ConstantInt::get(T_size, ptls_offset / sizeof(void *)),
+-        "ptls_field");
+-    LoadInst *ptls_load = ctx.builder.CreateAlignedLoad(
+-        emit_bitcast(ctx, pptls, T_ppjlvalue), Align(sizeof(void *)), "ptls_load");
+-    // Note: Corresponding store (`t->ptls = ptls`) happens in `ctx_switch` of tasks.c.
+-    tbaa_decorate(tbaa_gcframe, ptls_load);
+-    // Using `CastInst::Create` to get an `Instruction*` without explicit cast:
+-    auto ptls = CastInst::Create(Instruction::BitCast, ptls_load, T_ppjlvalue, "ptls");
+-    ctx.builder.Insert(ptls);
+-    return ptls;
++    return get_current_ptls_from_task(ctx.builder, get_current_task(ctx));
+ }
+ 
+ // Store world age at the entry block of the function. This function should be
+diff --git a/src/codegen_shared.h b/src/codegen_shared.h
+index ca876b9b0310..93c913fd7a76 100644
+--- a/src/codegen_shared.h
++++ b/src/codegen_shared.h
+@@ -5,6 +5,8 @@
+ #include <llvm/Support/Debug.h>
+ #include <llvm/IR/DebugLoc.h>
+ #include <llvm/IR/IRBuilder.h>
++#include <llvm/IR/MDBuilder.h>
++#include "julia.h"
+ 
+ enum AddressSpace {
+     Generic = 0,
+@@ -19,6 +21,24 @@ enum AddressSpace {
+     LastSpecial = Loaded,
+ };
+ 
++namespace JuliaType {
++    static inline llvm::StructType* get_jlvalue_ty(llvm::LLVMContext &C) {
++        return llvm::StructType::get(C);
++    }
++
++    static inline llvm::PointerType* get_pjlvalue_ty(llvm::LLVMContext &C) {
++        return llvm::PointerType::get(get_jlvalue_ty(C), 0);
++    }
++
++    static inline llvm::PointerType* get_prjlvalue_ty(llvm::LLVMContext &C) {
++        return llvm::PointerType::get(get_jlvalue_ty(C), AddressSpace::Tracked);
++    }
++
++    static inline llvm::PointerType* get_ppjlvalue_ty(llvm::LLVMContext &C) {
++        return llvm::PointerType::get(get_pjlvalue_ty(C), 0);
++    }
++}
++
+ // JLCALL with API arguments ([extra], arg0, arg1, arg2, ...) has the following ABI calling conventions defined:
+ #define JLCALL_F_CC (CallingConv::ID)37     // (jl_value_t *arg0, jl_value_t **argv, uint32_t nargv)
+ #define JLCALL_F2_CC (CallingConv::ID)38    // (jl_value_t *arg0, jl_value_t **argv, uint32_t nargv, jl_value_t *extra)
+@@ -68,3 +88,66 @@ static inline void llvm_dump(llvm::DebugLoc *dbg)
+     dbg->print(llvm::dbgs());
+     llvm::dbgs() << "\n";
+ }
++
++static inline std::pair<llvm::MDNode*,llvm::MDNode*> tbaa_make_child_with_context(llvm::LLVMContext &ctxt, const char *name, llvm::MDNode *parent=nullptr, bool isConstant=false)
++{
++    llvm::MDBuilder mbuilder(ctxt);
++    llvm::MDNode *jtbaa = mbuilder.createTBAARoot("jtbaa");
++    llvm::MDNode *tbaa_root = mbuilder.createTBAAScalarTypeNode("jtbaa", jtbaa);
++    llvm::MDNode *scalar = mbuilder.createTBAAScalarTypeNode(name, parent ? parent : tbaa_root);
++    llvm::MDNode *n = mbuilder.createTBAAStructTagNode(scalar, scalar, 0, isConstant);
++    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;
++}
++
++static inline llvm::Instruction *tbaa_decorate(llvm::MDNode *md, llvm::Instruction *inst)
++{
++    inst->setMetadata(llvm::LLVMContext::MD_tbaa, md);
++    if (llvm::isa<llvm::LoadInst>(inst) && md && md == get_tbaa_const(md->getContext()))
++        inst->setMetadata(llvm::LLVMContext::MD_invariant_load, llvm::MDNode::get(md->getContext(), llvm::None));
++    return inst;
++}
++
++// bitcast a value, but preserve its address space when dealing with pointer types
++static inline llvm::Value *emit_bitcast_with_builder(llvm::IRBuilder<> &builder, llvm::Value *v, llvm::Type *jl_value)
++{
++    using namespace llvm;
++    if (isa<PointerType>(jl_value) &&
++        v->getType()->getPointerAddressSpace() != jl_value->getPointerAddressSpace()) {
++        // Cast to the proper address space
++        Type *jl_value_addr =
++                PointerType::get(cast<PointerType>(jl_value)->getElementType(),
++                                 v->getType()->getPointerAddressSpace());
++        return builder.CreateBitCast(v, jl_value_addr);
++    }
++    else {
++        return builder.CreateBitCast(v, jl_value);
++    }
++}
++
++// Get PTLS through current task.
++static inline llvm::Value *get_current_ptls_from_task(llvm::IRBuilder<> &builder, llvm::Value *current_task)
++{
++    using namespace llvm;
++    auto T_ppjlvalue = JuliaType::get_ppjlvalue_ty(builder.getContext());
++    auto T_size = builder.GetInsertBlock()->getModule()->getDataLayout().getIntPtrType(builder.getContext());
++    const int ptls_offset = offsetof(jl_task_t, ptls);
++    llvm::Value *pptls = builder.CreateInBoundsGEP(
++        JuliaType::get_pjlvalue_ty(builder.getContext()), current_task,
++        ConstantInt::get(T_size, ptls_offset / sizeof(void *)),
++        "ptls_field");
++    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);
++    // 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 b4e1f5009424..ed5fe7c43a59 100644
+--- a/src/llvm-late-gc-lowering.cpp
++++ b/src/llvm-late-gc-lowering.cpp
+@@ -2296,10 +2296,12 @@ 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 ptls = builder.CreateBitCast(ptlsLoad, Type::getInt8PtrTy(builder.getContext()));
+                 auto newI = builder.CreateCall(
+                     allocBytesIntrinsic,
+                     {
+-                        CI->getArgOperand(0),
++                        ptls,
+                         builder.CreateIntCast(
+                             CI->getArgOperand(1),
+                             allocBytesIntrinsic->getFunctionType()->getParamType(1),

Deleted: julia-curl-7.81.patch
===================================================================
--- julia-curl-7.81.patch	2022-01-21 20:32:37 UTC (rev 1112621)
+++ julia-curl-7.81.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,28 +0,0 @@
-From a6d88d774087a1bff90a853e769b307a06de9293 Mon Sep 17 00:00:00 2001
-From: Jameson Nash <vtjnash at gmail.com>
-Date: Mon, 8 Nov 2021 14:25:20 -0500
-Subject: [PATCH] Avoid infinite recursion in `timer_callback`
-
-Fixes https://github.com/JuliaLang/Downloads.jl/issues/163
----
- src/Curl/Multi.jl | 4 +---
- 1 file changed, 1 insertion(+), 3 deletions(-)
-
-diff --git a/src/Curl/Multi.jl b/src/Curl/Multi.jl
-index fc865b0..0ef1b63 100644
---- a/src/Curl/Multi.jl
-+++ b/src/Curl/Multi.jl
-@@ -142,12 +142,7 @@ function timer_callback(
- )::Cint
-     multi = unsafe_pointer_to_objref(multi_p)::Multi
-     @assert multi_h == multi.handle
--    if timeout_ms == 0
--        lock(multi.lock) do
--            @check curl_multi_socket_action(multi.handle, CURL_SOCKET_TIMEOUT, 0)
--            check_multi_info(multi)
--        end
--    elseif timeout_ms >= 0
-+    if timeout_ms >= 0
-         timeout_cb = @cfunction(timeout_callback, Cvoid, (Ptr{Cvoid},))
-         uv_timer_start(multi.timer, timeout_cb, max(1, timeout_ms), 0)
-     elseif timeout_ms == -1

Copied: julia/repos/community-x86_64/julia-curl-7.81.patch (from rev 1112621, julia/trunk/julia-curl-7.81.patch)
===================================================================
--- julia-curl-7.81.patch	                        (rev 0)
+++ julia-curl-7.81.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -0,0 +1,28 @@
+From a6d88d774087a1bff90a853e769b307a06de9293 Mon Sep 17 00:00:00 2001
+From: Jameson Nash <vtjnash at gmail.com>
+Date: Mon, 8 Nov 2021 14:25:20 -0500
+Subject: [PATCH] Avoid infinite recursion in `timer_callback`
+
+Fixes https://github.com/JuliaLang/Downloads.jl/issues/163
+---
+ src/Curl/Multi.jl | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/src/Curl/Multi.jl b/src/Curl/Multi.jl
+index fc865b0..0ef1b63 100644
+--- a/src/Curl/Multi.jl
++++ b/src/Curl/Multi.jl
+@@ -142,12 +142,7 @@ function timer_callback(
+ )::Cint
+     multi = unsafe_pointer_to_objref(multi_p)::Multi
+     @assert multi_h == multi.handle
+-    if timeout_ms == 0
+-        lock(multi.lock) do
+-            @check curl_multi_socket_action(multi.handle, CURL_SOCKET_TIMEOUT, 0)
+-            check_multi_info(multi)
+-        end
+-    elseif timeout_ms >= 0
++    if timeout_ms >= 0
+         timeout_cb = @cfunction(timeout_callback, Cvoid, (Ptr{Cvoid},))
+         uv_timer_start(multi.timer, timeout_cb, max(1, timeout_ms), 0)
+     elseif timeout_ms == -1

Deleted: julia-hardcoded-libs.patch
===================================================================
--- julia-hardcoded-libs.patch	2022-01-21 20:32:37 UTC (rev 1112621)
+++ julia-hardcoded-libs.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,69 +0,0 @@
-diff --git a/stdlib/MbedTLS_jll/src/MbedTLS_jll.jl b/stdlib/MbedTLS_jll/src/MbedTLS_jll.jl
-index a7ca666b23..b84a42f4e7 100644
---- a/stdlib/MbedTLS_jll/src/MbedTLS_jll.jl
-+++ b/stdlib/MbedTLS_jll/src/MbedTLS_jll.jl
-@@ -31,9 +31,9 @@ elseif Sys.isapple()
-     const libmbedtls = "@rpath/libmbedtls.13.dylib"
-     const libmbedx509 = "@rpath/libmbedx509.1.dylib"
- else
--    const libmbedcrypto = "libmbedcrypto.so.5"
--    const libmbedtls = "libmbedtls.so.13"
--    const libmbedx509 = "libmbedx509.so.1"
-+    const libmbedcrypto = "libmbedcrypto.so"
-+    const libmbedtls = "libmbedtls.so"
-+    const libmbedx509 = "libmbedx509.so"
- end
- 
- function __init__()
-diff --git a/stdlib/libLLVM_jll/src/libLLVM_jll.jl b/stdlib/libLLVM_jll/src/libLLVM_jll.jl
-index fa45e754e5..b51812e3a8 100644
---- a/stdlib/libLLVM_jll/src/libLLVM_jll.jl
-+++ b/stdlib/libLLVM_jll/src/libLLVM_jll.jl
-@@ -23,7 +23,7 @@ if Sys.iswindows()
- elseif Sys.isapple()
-     const libLLVM = "@rpath/libLLVM.dylib"
- else
--    const libLLVM = "libLLVM-12jl.so"
-+    const libLLVM = "libLLVM.so"
- end
- 
- function __init__()
-diff --git a/stdlib/nghttp2_jll/src/nghttp2_jll.jl b/stdlib/nghttp2_jll/src/nghttp2_jll.jl
-index 8b98c76ac5..77ad9e3800 100644
---- a/stdlib/nghttp2_jll/src/nghttp2_jll.jl
-+++ b/stdlib/nghttp2_jll/src/nghttp2_jll.jl
-@@ -22,7 +22,7 @@ if Sys.iswindows()
- elseif Sys.isapple()
-     const libnghttp2 = "@rpath/libnghttp2.14.dylib"
- else
--    const libnghttp2 = "libnghttp2.so.14"
-+    const libnghttp2 = "libnghttp2.so"
- end
- 
- function __init__()
-diff --git a/stdlib/LibGit2_jll/src/LibGit2_jll.jl b/stdlib/LibGit2_jll/src/LibGit2_jll.jl
-index f0d4b5dda6..2ed3017b51 100644
---- a/stdlib/LibGit2_jll/src/LibGit2_jll.jl
-+++ b/stdlib/LibGit2_jll/src/LibGit2_jll.jl
-@@ -23,7 +23,7 @@ if Sys.iswindows()
- elseif Sys.isapple()
-     const libgit2 = "@rpath/libgit2.1.1.dylib"
- else
--    const libgit2 = "libgit2.so.1.1"
-+    const libgit2 = "libgit2.so"
- end
- 
- function __init__()
-diff --git a/stdlib/OpenLibm_jll/src/OpenLibm_jll.jl b/stdlib/OpenLibm_jll/src/OpenLibm_jll.jl
-index 215de8aed6..918d1ffdc2 100644
---- a/stdlib/OpenLibm_jll/src/OpenLibm_jll.jl
-+++ b/stdlib/OpenLibm_jll/src/OpenLibm_jll.jl
-@@ -22,7 +22,7 @@ if Sys.iswindows()
- elseif Sys.isapple()
-     const libopenlibm = "@rpath/libopenlibm.3.dylib"
- else
--    const libopenlibm = "libopenlibm.so.3"
-+    const libopenlibm = "libopenlibm.so"
- end
- 
- function __init__()

Copied: julia/repos/community-x86_64/julia-hardcoded-libs.patch (from rev 1112621, julia/trunk/julia-hardcoded-libs.patch)
===================================================================
--- julia-hardcoded-libs.patch	                        (rev 0)
+++ julia-hardcoded-libs.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -0,0 +1,69 @@
+diff --git a/stdlib/MbedTLS_jll/src/MbedTLS_jll.jl b/stdlib/MbedTLS_jll/src/MbedTLS_jll.jl
+index a7ca666b23..b84a42f4e7 100644
+--- a/stdlib/MbedTLS_jll/src/MbedTLS_jll.jl
++++ b/stdlib/MbedTLS_jll/src/MbedTLS_jll.jl
+@@ -31,9 +31,9 @@ elseif Sys.isapple()
+     const libmbedtls = "@rpath/libmbedtls.13.dylib"
+     const libmbedx509 = "@rpath/libmbedx509.1.dylib"
+ else
+-    const libmbedcrypto = "libmbedcrypto.so.5"
+-    const libmbedtls = "libmbedtls.so.13"
+-    const libmbedx509 = "libmbedx509.so.1"
++    const libmbedcrypto = "libmbedcrypto.so"
++    const libmbedtls = "libmbedtls.so"
++    const libmbedx509 = "libmbedx509.so"
+ end
+ 
+ function __init__()
+diff --git a/stdlib/libLLVM_jll/src/libLLVM_jll.jl b/stdlib/libLLVM_jll/src/libLLVM_jll.jl
+index fa45e754e5..b51812e3a8 100644
+--- a/stdlib/libLLVM_jll/src/libLLVM_jll.jl
++++ b/stdlib/libLLVM_jll/src/libLLVM_jll.jl
+@@ -23,7 +23,7 @@ if Sys.iswindows()
+ elseif Sys.isapple()
+     const libLLVM = "@rpath/libLLVM.dylib"
+ else
+-    const libLLVM = "libLLVM-12jl.so"
++    const libLLVM = "libLLVM.so"
+ end
+ 
+ function __init__()
+diff --git a/stdlib/nghttp2_jll/src/nghttp2_jll.jl b/stdlib/nghttp2_jll/src/nghttp2_jll.jl
+index 8b98c76ac5..77ad9e3800 100644
+--- a/stdlib/nghttp2_jll/src/nghttp2_jll.jl
++++ b/stdlib/nghttp2_jll/src/nghttp2_jll.jl
+@@ -22,7 +22,7 @@ if Sys.iswindows()
+ elseif Sys.isapple()
+     const libnghttp2 = "@rpath/libnghttp2.14.dylib"
+ else
+-    const libnghttp2 = "libnghttp2.so.14"
++    const libnghttp2 = "libnghttp2.so"
+ end
+ 
+ function __init__()
+diff --git a/stdlib/LibGit2_jll/src/LibGit2_jll.jl b/stdlib/LibGit2_jll/src/LibGit2_jll.jl
+index f0d4b5dda6..2ed3017b51 100644
+--- a/stdlib/LibGit2_jll/src/LibGit2_jll.jl
++++ b/stdlib/LibGit2_jll/src/LibGit2_jll.jl
+@@ -23,7 +23,7 @@ if Sys.iswindows()
+ elseif Sys.isapple()
+     const libgit2 = "@rpath/libgit2.1.1.dylib"
+ else
+-    const libgit2 = "libgit2.so.1.1"
++    const libgit2 = "libgit2.so"
+ end
+ 
+ function __init__()
+diff --git a/stdlib/OpenLibm_jll/src/OpenLibm_jll.jl b/stdlib/OpenLibm_jll/src/OpenLibm_jll.jl
+index 215de8aed6..918d1ffdc2 100644
+--- a/stdlib/OpenLibm_jll/src/OpenLibm_jll.jl
++++ b/stdlib/OpenLibm_jll/src/OpenLibm_jll.jl
+@@ -22,7 +22,7 @@ if Sys.iswindows()
+ elseif Sys.isapple()
+     const libopenlibm = "@rpath/libopenlibm.3.dylib"
+ else
+-    const libopenlibm = "libopenlibm.so.3"
++    const libopenlibm = "libopenlibm.so"
+ end
+ 
+ function __init__()

Deleted: julia-libblastrampoline-4.patch
===================================================================
--- julia-libblastrampoline-4.patch	2022-01-21 20:32:37 UTC (rev 1112621)
+++ julia-libblastrampoline-4.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,13 +0,0 @@
-diff --git a/stdlib/LinearAlgebra/src/lbt.jl b/stdlib/LinearAlgebra/src/lbt.jl
-index b1a2dc24b3..b0d6242738 100644
---- a/stdlib/LinearAlgebra/src/lbt.jl
-+++ b/stdlib/LinearAlgebra/src/lbt.jl
-@@ -155,7 +155,7 @@ function lbt_set_num_threads(nthreads)
- end
- 
- function lbt_forward(path; clear::Bool = false, verbose::Bool = false)
--    ccall((:lbt_forward, libblastrampoline), Int32, (Cstring, Int32, Int32), path, clear ? 1 : 0, verbose ? 1 : 0)
-+    ccall((:lbt_forward, libblastrampoline), Int32, (Cstring, Int32, Int32, Cstring), path, clear ? 1 : 0, verbose ? 1 : 0, C_NULL)
- end
- 
- function lbt_set_default_func(addr)

Copied: julia/repos/community-x86_64/julia-libblastrampoline-4.patch (from rev 1112621, julia/trunk/julia-libblastrampoline-4.patch)
===================================================================
--- julia-libblastrampoline-4.patch	                        (rev 0)
+++ julia-libblastrampoline-4.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -0,0 +1,15 @@
+diff --git a/stdlib/LinearAlgebra/src/lbt.jl b/stdlib/LinearAlgebra/src/lbt.jl
+index 26b3a1210a3f..ea1ab25c9e1a 100644
+--- a/stdlib/LinearAlgebra/src/lbt.jl
++++ b/stdlib/LinearAlgebra/src/lbt.jl
+@@ -156,8 +156,8 @@ function lbt_set_num_threads(nthreads)
+     return ccall((:lbt_set_num_threads, libblastrampoline), Cvoid, (Int32,), nthreads)
+ end
+ 
+-function lbt_forward(path; clear::Bool = false, verbose::Bool = false)
+-    ccall((:lbt_forward, libblastrampoline), Int32, (Cstring, Int32, Int32), path, clear ? 1 : 0, verbose ? 1 : 0)
++function lbt_forward(path; clear::Bool = false, verbose::Bool = false, suffix_hint::Union{String,Nothing} = nothing)
++    ccall((:lbt_forward, libblastrampoline), Int32, (Cstring, Int32, Int32, Cstring), path, clear ? 1 : 0, verbose ? 1 : 0, something(suffix_hint, C_NULL))
+ end
+ 
+ function lbt_set_default_func(addr)

Deleted: julia-libgit-1.2.patch
===================================================================
--- julia-libgit-1.2.patch	2022-01-21 20:32:37 UTC (rev 1112621)
+++ julia-libgit-1.2.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,14 +0,0 @@
-diff --git a/stdlib/LibGit2/src/types.jl b/stdlib/LibGit2/src/types.jl
-index 9ffcaa3646..5f571e7b26 100644
---- a/stdlib/LibGit2/src/types.jl
-+++ b/stdlib/LibGit2/src/types.jl
-@@ -230,6 +230,9 @@ Matches the [`git_remote_callbacks`](https://libgit2.org/libgit2/#HEAD/type/git_
-     push_update_reference::Ptr{Cvoid}  = C_NULL
-     push_negotiation::Ptr{Cvoid}       = C_NULL
-     transport::Ptr{Cvoid}              = C_NULL
-+    @static if LibGit2.VERSION >= v"1.2.0"
-+        remote_ready::Ptr{Cvoid}       = C_NULL
-+    end
-     payload::Any                       = nothing
-     @static if LibGit2.VERSION >= v"0.99.0"
-         resolve_url::Ptr{Cvoid}        = C_NULL

Copied: julia/repos/community-x86_64/julia-libgit-1.2.patch (from rev 1112621, julia/trunk/julia-libgit-1.2.patch)
===================================================================
--- julia-libgit-1.2.patch	                        (rev 0)
+++ julia-libgit-1.2.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -0,0 +1,14 @@
+diff --git a/stdlib/LibGit2/src/types.jl b/stdlib/LibGit2/src/types.jl
+index 9ffcaa3646..5f571e7b26 100644
+--- a/stdlib/LibGit2/src/types.jl
++++ b/stdlib/LibGit2/src/types.jl
+@@ -230,6 +230,9 @@ Matches the [`git_remote_callbacks`](https://libgit2.org/libgit2/#HEAD/type/git_
+     push_update_reference::Ptr{Cvoid}  = C_NULL
+     push_negotiation::Ptr{Cvoid}       = C_NULL
+     transport::Ptr{Cvoid}              = C_NULL
++    @static if LibGit2.VERSION >= v"1.2.0"
++        remote_ready::Ptr{Cvoid}       = C_NULL
++    end
+     payload::Any                       = nothing
+     @static if LibGit2.VERSION >= v"0.99.0"
+         resolve_url::Ptr{Cvoid}        = C_NULL

Deleted: julia-libunwind-1.6.patch
===================================================================
--- julia-libunwind-1.6.patch	2022-01-21 20:32:37 UTC (rev 1112621)
+++ julia-libunwind-1.6.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,20 +0,0 @@
-diff --git a/src/debuginfo.cpp b/src/debuginfo.cpp
-index 95b562311b..69fceb0cfe 100644
---- a/src/debuginfo.cpp
-+++ b/src/debuginfo.cpp
-@@ -287,6 +287,7 @@ public:
-             di->format = UNW_INFO_FORMAT_ARM_EXIDX;
-             di->start_ip = (uintptr_t)arm_text_addr;
-             di->end_ip = (uintptr_t)(arm_text_addr + arm_text_len);
-+            di->load_offset = 0;
-             di->u.rti.name_ptr = 0;
-             di->u.rti.table_data = arm_exidx_addr;
-             di->u.rti.table_len = arm_exidx_len;
-@@ -1597,6 +1598,7 @@ void register_eh_frames(uint8_t *Addr, size_t Size)
-     di->u.rti.table_data = (unw_word_t)table;
-     di->start_ip = start_ip;
-     di->end_ip = end_ip;
-+    di->load_offset = 0;
- 
-     jl_profile_atomic([&]() {
-         _U_dyn_register(di);

Copied: julia/repos/community-x86_64/julia-libunwind-1.6.patch (from rev 1112621, julia/trunk/julia-libunwind-1.6.patch)
===================================================================
--- julia-libunwind-1.6.patch	                        (rev 0)
+++ julia-libunwind-1.6.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -0,0 +1,20 @@
+diff --git a/src/debuginfo.cpp b/src/debuginfo.cpp
+index 95b562311b..69fceb0cfe 100644
+--- a/src/debuginfo.cpp
++++ b/src/debuginfo.cpp
+@@ -287,6 +287,7 @@ public:
+             di->format = UNW_INFO_FORMAT_ARM_EXIDX;
+             di->start_ip = (uintptr_t)arm_text_addr;
+             di->end_ip = (uintptr_t)(arm_text_addr + arm_text_len);
++            di->load_offset = 0;
+             di->u.rti.name_ptr = 0;
+             di->u.rti.table_data = arm_exidx_addr;
+             di->u.rti.table_len = arm_exidx_len;
+@@ -1597,6 +1598,7 @@ void register_eh_frames(uint8_t *Addr, size_t Size)
+     di->u.rti.table_data = (unw_word_t)table;
+     di->start_ip = start_ip;
+     di->end_ip = end_ip;
++    di->load_offset = 0;
+ 
+     jl_profile_atomic([&]() {
+         _U_dyn_register(di);

Deleted: julia-llvm-patchelf.patch
===================================================================
--- julia-llvm-patchelf.patch	2022-01-21 20:32:37 UTC (rev 1112621)
+++ julia-llvm-patchelf.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,15 +0,0 @@
-diff --git a/Makefile b/Makefile
-index a013747a97..02e566de2e 100644
---- a/Makefile
-+++ b/Makefile
-@@ -368,10 +368,6 @@ ifeq ($(BUNDLE_DEBUG_LIBS),1)
- endif
- endif
- 
--	# Set rpath for LLVM.so which is `$ORIGIN/../lib` moving from `../lib` to `../lib/julia`.  We only need to do this for Linux/FreeBSD
--ifneq (,$(findstring $(OS),Linux FreeBSD))
--	$(PATCHELF) --set-rpath '$$ORIGIN:$$ORIGIN/$(reverse_private_libdir_rel)' $(DESTDIR)$(private_libdir)/libLLVM.$(SHLIB_EXT)
--endif
- 
- 
- ifneq ($(LOADER_BUILD_DEP_LIBS),$(LOADER_INSTALL_DEP_LIBS))

Copied: julia/repos/community-x86_64/julia-llvm-patchelf.patch (from rev 1112621, julia/trunk/julia-llvm-patchelf.patch)
===================================================================
--- julia-llvm-patchelf.patch	                        (rev 0)
+++ julia-llvm-patchelf.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -0,0 +1,15 @@
+diff --git a/Makefile b/Makefile
+index a013747a97..02e566de2e 100644
+--- a/Makefile
++++ b/Makefile
+@@ -368,10 +368,6 @@ ifeq ($(BUNDLE_DEBUG_LIBS),1)
+ endif
+ endif
+ 
+-	# Set rpath for LLVM.so which is `$ORIGIN/../lib` moving from `../lib` to `../lib/julia`.  We only need to do this for Linux/FreeBSD
+-ifneq (,$(findstring $(OS),Linux FreeBSD))
+-	$(PATCHELF) --set-rpath '$$ORIGIN:$$ORIGIN/$(reverse_private_libdir_rel)' $(DESTDIR)$(private_libdir)/libLLVM.$(SHLIB_EXT)
+-endif
+ 
+ 
+ ifneq ($(LOADER_BUILD_DEP_LIBS),$(LOADER_INSTALL_DEP_LIBS))

Deleted: julia-system-cblas.patch
===================================================================
--- julia-system-cblas.patch	2022-01-21 20:32:37 UTC (rev 1112621)
+++ julia-system-cblas.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,133 +0,0 @@
-From 0c442318196389d653ee21eba65d8c4f7beb72a0 Mon Sep 17 00:00:00 2001
-From: Eli Schwartz <eschwartz at archlinux.org>
-Date: Fri, 5 Oct 2018 15:52:17 +0000
-Subject: [PATCH] Use a dedicated cblas library, that may or may not be in fact
- the blas one.
-
-Openblas can be built with statically compiled convenience copies of
-cblas, but if not, then the system libcblas.so should be used.
----
- Make.inc                         | 12 +++++++++++-
- Makefile                         |  3 +++
- base/Makefile                    |  4 ++++
- stdlib/LinearAlgebra/src/blas.jl | 15 +++++++++++++--
- 4 files changed, 31 insertions(+), 3 deletions(-)
-
-diff --git a/Make.inc b/Make.inc
-index b00a41b356d8..7bc6cd69e863 100644
---- a/Make.inc
-+++ b/Make.inc
-@@ -1109,6 +1109,7 @@ endif
- ifeq ($(USE_SYSTEM_BLAS), 1)
- ifeq ($(OS), Darwin)
- USE_BLAS64 := 0
-+USE_SYSTEM_CBLAS := 0
- USE_SYSTEM_LAPACK := 0
- LIBBLAS := -L$(build_libdir) -lgfortblas
- LIBBLASNAME := libgfortblas
-@@ -1121,12 +1122,21 @@ LIBBLAS := -L$(build_shlibdir) -lopenblas
- LIBBLASNAME := libopenblas
- endif
- 
--# OpenBLAS builds LAPACK as part of its build.
-+# OpenBLAS builds cblas/LAPACK as part of its build.
- # We only need to build LAPACK if we are not using OpenBLAS.
- ifeq ($(USE_SYSTEM_BLAS), 0)
-+LIBCBLAS := $(LIBBLAS)
-+LIBCBLASNAME := $(LIBBLASNAME)
- LIBLAPACK := $(LIBBLAS)
- LIBLAPACKNAME := $(LIBBLASNAME)
- else
-+ifeq ($(USE_SYSTEM_CBLAS), 1)
-+LIBCBLAS ?= -lcblas
-+LIBCBLASNAME ?= libcblas
-+else
-+LIBCBLAS := -L$(build_shlibdir) -lcblas $(LIBBLAS)
-+LIBCBLASNAME := libcblas
-+endif
- ifeq ($(USE_SYSTEM_LAPACK), 1)
- LIBLAPACK ?= -llapack
- LIBLAPACKNAME ?= liblapack
-diff --git a/Makefile b/Makefile
-index 6063e79ae956..7df60b8170d6 100644
---- a/Makefile
-+++ b/Makefile
-@@ -198,6 +198,9 @@ endif
- endif
- 
- JL_PRIVATE_LIBS-$(USE_SYSTEM_BLAS) += $(LIBBLASNAME)
-+ifneq ($(LIBCBLASNAME),$(LIBBLASNAME))
-+JL_PRIVATE_LIBS-$(USE_SYSTEM_CBLAS) += $(LIBCBLASNAME)
-+endif
- ifneq ($(LIBLAPACKNAME),$(LIBBLASNAME))
- JL_PRIVATE_LIBS-$(USE_SYSTEM_LAPACK) += $(LIBLAPACKNAME)
- endif
-diff --git a/base/Makefile b/base/Makefile
-index 70e6da933d70..8ecfa6902b59 100644
---- a/base/Makefile
-+++ b/base/Makefile
-@@ -54,6 +54,7 @@ else
- endif
- 	@echo "const libm_name = \"$(LIBMNAME)\"" >> $@
- 	@echo "const libblas_name = \"$(LIBBLASNAME)\"" >> $@
-+	@echo "const libcblas_name = \"$(LIBCBLASNAME)\"" >> $@
- 	@echo "const liblapack_name = \"$(LIBLAPACKNAME)\"" >> $@
- ifeq ($(USE_BLAS64), 1)
- 	@echo "const USE_BLAS64 = true" >> $@
-@@ -183,6 +184,9 @@ endif
- $(eval $(call symlink_system_library,PCRE,libpcre2-8))
- $(eval $(call symlink_system_library,DSFMT,libdSFMT))
- $(eval $(call symlink_system_library,BLAS,$(LIBBLASNAME)))
-+ifneq ($(LIBCBLASNAME),$(LIBBLASNAME))
-+$(eval $(call symlink_system_library,CBLAS,$(LIBCBLASNAME)))
-+endif
- ifneq ($(LIBLAPACKNAME),$(LIBBLASNAME))
- $(eval $(call symlink_system_library,LAPACK,$(LIBLAPACKNAME)))
- endif
-diff --git a/stdlib/LinearAlgebra/src/blas.jl b/stdlib/LinearAlgebra/src/blas.jl
-index 661e9e2b15..9bc1034682 100644
---- a/stdlib/LinearAlgebra/src/blas.jl
-+++ b/stdlib/LinearAlgebra/src/blas.jl
-@@ -71,6 +71,7 @@ libblastrampoline_handle = C_NULL
- # should not look at these, instead preferring to parse the output
- # of BLAS.get_config()
- const libblas = libblastrampoline
-+const libcblas = Base.libcblas_name
- const liblapack = libblastrampoline
- 
- import LinearAlgebra
-@@ -109,6 +110,16 @@ else
-     end
- end
- 
-+if libcblas == libblastrampoline
-+     macro cblasfunc(x)
-+        return @blasfunc(x)
-+    end
-+else
-+    macro cblasfunc(x)
-+        return Expr(:quote, x)
-+    end
-+end
-+
- _tryparse_env_int(key) = tryparse(Int, get(ENV, key, ""))
- 
- 
-@@ -327,7 +338,7 @@ for (fname, elty) in ((:cblas_zdotc_sub,:ComplexF64),
-                 #       DOUBLE PRECISION DX(*),DY(*)
-         function dotc(n::Integer, DX::Union{Ptr{$elty},AbstractArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},AbstractArray{$elty}}, incy::Integer)
-             result = Ref{$elty}()
--            ccall((@blasfunc($fname), libblastrampoline), Cvoid,
-+            ccall((@cblasfunc($fname), libcblas), Cvoid,
-                 (BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
-                  n, DX, incx, DY, incy, result)
-             result[]
-@@ -345,7 +356,7 @@ for (fname, elty) in ((:cblas_zdotu_sub,:ComplexF64),
-                 #       DOUBLE PRECISION DX(*),DY(*)
-         function dotu(n::Integer, DX::Union{Ptr{$elty},AbstractArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},AbstractArray{$elty}}, incy::Integer)
-             result = Ref{$elty}()
--            ccall((@blasfunc($fname), libblastrampoline), Cvoid,
-+            ccall((@cblasfunc($fname), libcblas), Cvoid,
-                 (BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
-                  n, DX, incx, DY, incy, result)
-             result[]

Copied: julia/repos/community-x86_64/julia-system-cblas.patch (from rev 1112621, julia/trunk/julia-system-cblas.patch)
===================================================================
--- julia-system-cblas.patch	                        (rev 0)
+++ julia-system-cblas.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -0,0 +1,133 @@
+From 0c442318196389d653ee21eba65d8c4f7beb72a0 Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <eschwartz at archlinux.org>
+Date: Fri, 5 Oct 2018 15:52:17 +0000
+Subject: [PATCH] Use a dedicated cblas library, that may or may not be in fact
+ the blas one.
+
+Openblas can be built with statically compiled convenience copies of
+cblas, but if not, then the system libcblas.so should be used.
+---
+ Make.inc                         | 12 +++++++++++-
+ Makefile                         |  3 +++
+ base/Makefile                    |  4 ++++
+ stdlib/LinearAlgebra/src/blas.jl | 15 +++++++++++++--
+ 4 files changed, 31 insertions(+), 3 deletions(-)
+
+diff --git a/Make.inc b/Make.inc
+index b00a41b356d8..7bc6cd69e863 100644
+--- a/Make.inc
++++ b/Make.inc
+@@ -1109,6 +1109,7 @@ endif
+ ifeq ($(USE_SYSTEM_BLAS), 1)
+ ifeq ($(OS), Darwin)
+ USE_BLAS64 := 0
++USE_SYSTEM_CBLAS := 0
+ USE_SYSTEM_LAPACK := 0
+ LIBBLAS := -L$(build_libdir) -lgfortblas
+ LIBBLASNAME := libgfortblas
+@@ -1121,12 +1122,21 @@ LIBBLAS := -L$(build_shlibdir) -lopenblas
+ LIBBLASNAME := libopenblas
+ endif
+ 
+-# OpenBLAS builds LAPACK as part of its build.
++# OpenBLAS builds cblas/LAPACK as part of its build.
+ # We only need to build LAPACK if we are not using OpenBLAS.
+ ifeq ($(USE_SYSTEM_BLAS), 0)
++LIBCBLAS := $(LIBBLAS)
++LIBCBLASNAME := $(LIBBLASNAME)
+ LIBLAPACK := $(LIBBLAS)
+ LIBLAPACKNAME := $(LIBBLASNAME)
+ else
++ifeq ($(USE_SYSTEM_CBLAS), 1)
++LIBCBLAS ?= -lcblas
++LIBCBLASNAME ?= libcblas
++else
++LIBCBLAS := -L$(build_shlibdir) -lcblas $(LIBBLAS)
++LIBCBLASNAME := libcblas
++endif
+ ifeq ($(USE_SYSTEM_LAPACK), 1)
+ LIBLAPACK ?= -llapack
+ LIBLAPACKNAME ?= liblapack
+diff --git a/Makefile b/Makefile
+index 6063e79ae956..7df60b8170d6 100644
+--- a/Makefile
++++ b/Makefile
+@@ -198,6 +198,9 @@ endif
+ endif
+ 
+ JL_PRIVATE_LIBS-$(USE_SYSTEM_BLAS) += $(LIBBLASNAME)
++ifneq ($(LIBCBLASNAME),$(LIBBLASNAME))
++JL_PRIVATE_LIBS-$(USE_SYSTEM_CBLAS) += $(LIBCBLASNAME)
++endif
+ ifneq ($(LIBLAPACKNAME),$(LIBBLASNAME))
+ JL_PRIVATE_LIBS-$(USE_SYSTEM_LAPACK) += $(LIBLAPACKNAME)
+ endif
+diff --git a/base/Makefile b/base/Makefile
+index 70e6da933d70..8ecfa6902b59 100644
+--- a/base/Makefile
++++ b/base/Makefile
+@@ -54,6 +54,7 @@ else
+ endif
+ 	@echo "const libm_name = \"$(LIBMNAME)\"" >> $@
+ 	@echo "const libblas_name = \"$(LIBBLASNAME)\"" >> $@
++	@echo "const libcblas_name = \"$(LIBCBLASNAME)\"" >> $@
+ 	@echo "const liblapack_name = \"$(LIBLAPACKNAME)\"" >> $@
+ ifeq ($(USE_BLAS64), 1)
+ 	@echo "const USE_BLAS64 = true" >> $@
+@@ -183,6 +184,9 @@ endif
+ $(eval $(call symlink_system_library,PCRE,libpcre2-8))
+ $(eval $(call symlink_system_library,DSFMT,libdSFMT))
+ $(eval $(call symlink_system_library,BLAS,$(LIBBLASNAME)))
++ifneq ($(LIBCBLASNAME),$(LIBBLASNAME))
++$(eval $(call symlink_system_library,CBLAS,$(LIBCBLASNAME)))
++endif
+ ifneq ($(LIBLAPACKNAME),$(LIBBLASNAME))
+ $(eval $(call symlink_system_library,LAPACK,$(LIBLAPACKNAME)))
+ endif
+diff --git a/stdlib/LinearAlgebra/src/blas.jl b/stdlib/LinearAlgebra/src/blas.jl
+index 661e9e2b15..9bc1034682 100644
+--- a/stdlib/LinearAlgebra/src/blas.jl
++++ b/stdlib/LinearAlgebra/src/blas.jl
+@@ -71,6 +71,7 @@ libblastrampoline_handle = C_NULL
+ # should not look at these, instead preferring to parse the output
+ # of BLAS.get_config()
+ const libblas = libblastrampoline
++const libcblas = Base.libcblas_name
+ const liblapack = libblastrampoline
+ 
+ import LinearAlgebra
+@@ -109,6 +110,16 @@ else
+     end
+ end
+ 
++if libcblas == libblastrampoline
++     macro cblasfunc(x)
++        return @blasfunc(x)
++    end
++else
++    macro cblasfunc(x)
++        return Expr(:quote, x)
++    end
++end
++
+ _tryparse_env_int(key) = tryparse(Int, get(ENV, key, ""))
+ 
+ 
+@@ -327,7 +338,7 @@ for (fname, elty) in ((:cblas_zdotc_sub,:ComplexF64),
+                 #       DOUBLE PRECISION DX(*),DY(*)
+         function dotc(n::Integer, DX::Union{Ptr{$elty},AbstractArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},AbstractArray{$elty}}, incy::Integer)
+             result = Ref{$elty}()
+-            ccall((@blasfunc($fname), libblastrampoline), Cvoid,
++            ccall((@cblasfunc($fname), libcblas), Cvoid,
+                 (BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
+                  n, DX, incx, DY, incy, result)
+             result[]
+@@ -345,7 +356,7 @@ for (fname, elty) in ((:cblas_zdotu_sub,:ComplexF64),
+                 #       DOUBLE PRECISION DX(*),DY(*)
+         function dotu(n::Integer, DX::Union{Ptr{$elty},AbstractArray{$elty}}, incx::Integer, DY::Union{Ptr{$elty},AbstractArray{$elty}}, incy::Integer)
+             result = Ref{$elty}()
+-            ccall((@blasfunc($fname), libblastrampoline), Cvoid,
++            ccall((@cblasfunc($fname), libcblas), Cvoid,
+                 (BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}, BlasInt, Ptr{$elty}),
+                  n, DX, incx, DY, incy, result)
+             result[]

Deleted: make-install-no-build.patch
===================================================================
--- make-install-no-build.patch	2022-01-21 20:32:37 UTC (rev 1112621)
+++ make-install-no-build.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -1,14 +0,0 @@
---- julia-1.3.0/Makefile.orig	2019-12-06 12:54:23.879790955 +0000
-+++ julia-1.3.0/Makefile	2019-12-06 12:54:36.329952953 +0000
-@@ -277,11 +277,6 @@
- 
- 
- install: $(build_depsbindir)/stringreplace $(BUILDROOT)/doc/_build/html/en/index.html
--ifeq ($(BUNDLE_DEBUG_LIBS),1)
--	@$(MAKE) $(QUIET_MAKE) all
--else
--	@$(MAKE) $(QUIET_MAKE) release
--endif
- 	@for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir) $(libexecdir); do \
- 		mkdir -p $(DESTDIR)$$subdir; \
- 	done

Copied: julia/repos/community-x86_64/make-install-no-build.patch (from rev 1112621, julia/trunk/make-install-no-build.patch)
===================================================================
--- make-install-no-build.patch	                        (rev 0)
+++ make-install-no-build.patch	2022-01-21 20:32:58 UTC (rev 1112622)
@@ -0,0 +1,14 @@
+--- julia-1.3.0/Makefile.orig	2019-12-06 12:54:23.879790955 +0000
++++ julia-1.3.0/Makefile	2019-12-06 12:54:36.329952953 +0000
+@@ -277,11 +277,6 @@
+ 
+ 
+ install: $(build_depsbindir)/stringreplace $(BUILDROOT)/doc/_build/html/en/index.html
+-ifeq ($(BUNDLE_DEBUG_LIBS),1)
+-	@$(MAKE) $(QUIET_MAKE) all
+-else
+-	@$(MAKE) $(QUIET_MAKE) release
+-endif
+ 	@for subdir in $(bindir) $(datarootdir)/julia/stdlib/$(VERSDIR) $(docdir) $(man1dir) $(includedir)/julia $(libdir) $(private_libdir) $(sysconfdir) $(libexecdir); do \
+ 		mkdir -p $(DESTDIR)$$subdir; \
+ 	done



More information about the arch-commits mailing list