Date: Thursday, May 11, 2023 @ 16:28:26
  Author: arojas
Revision: 1459930

upgpkg: julia 2:1.9.0-2: Backport LLVM 15 support, move lld to dependencies 
(FS#78456)

Added:
  julia/trunk/21d4c2f1.patch
  julia/trunk/959902f1.patch
  julia/trunk/e08e1444.patch
  julia/trunk/f11bfc6c.patch
  julia/trunk/julia-LLVM-15.patch
Modified:
  julia/trunk/PKGBUILD
  julia/trunk/julia-hardcoded-libs.patch

----------------------------+
 21d4c2f1.patch             |  452 +++++++++++++++++++++++++++++++++++++++++++
 959902f1.patch             |  188 +++++++++++++++++
 PKGBUILD                   |   26 +-
 e08e1444.patch             |  304 ++++++++++++++++++++++++++++
 f11bfc6c.patch             |   95 +++++++++
 julia-LLVM-15.patch        |  329 +++++++++++++++++++++++++++++++
 julia-hardcoded-libs.patch |    2 
 7 files changed, 1388 insertions(+), 8 deletions(-)

Added: 21d4c2f1.patch
===================================================================
--- 21d4c2f1.patch                              (rev 0)
+++ 21d4c2f1.patch      2023-05-11 16:28:26 UTC (rev 1459930)
@@ -0,0 +1,452 @@
+From 921f1b9d5e9389756826898d6907c0a2829efa51 Mon Sep 17 00:00:00 2001
+From: Prem Chintalapudi <[email protected]>
+Date: Wed, 10 May 2023 09:58:04 -0400
+Subject: [PATCH 1/7] Fix remarks emissions from simdloop pass
+
+Co-authored-by: Valentin Churavy <[email protected]>
+---
+ src/llvm-simdloop.cpp | 18 +++++++++++-------
+ 1 file changed, 11 insertions(+), 7 deletions(-)
+
+diff --git a/src/llvm-simdloop.cpp b/src/llvm-simdloop.cpp
+index 3c94b226ad7b8..233f61c9fea6b 100644
+--- a/src/llvm-simdloop.cpp
++++ b/src/llvm-simdloop.cpp
+@@ -165,11 +165,13 @@ static bool markLoopInfo(Module &M, Function *marker, 
function_ref<LoopInfo &(Fu
+         Instruction *I = cast<Instruction>(U);
+         ToDelete.push_back(I);
+ 
+-        LoopInfo &LI = GetLI(*I->getParent()->getParent());
+-        Loop *L = LI.getLoopFor(I->getParent());
+-        I->removeFromParent();
+-        if (!L)
++        BasicBlock *B = I->getParent();
++        LoopInfo &LI = GetLI(*B->getParent());
++        Loop *L = LI.getLoopFor(B);
++        if (!L) {
++            I->removeFromParent();
+             continue;
++        }
+ 
+         LLVM_DEBUG(dbgs() << "LSL: loopinfo marker found\n");
+         bool simd = false;
+@@ -258,6 +260,8 @@ static bool markLoopInfo(Module &M, Function *marker, 
function_ref<LoopInfo &(Fu
+             }
+         }
+ 
++        I->removeFromParent();
++
+         Changed = true;
+     }
+ 
+
+From 286b371d680efe4350f85769c3f5ba9c1faee726 Mon Sep 17 00:00:00 2001
+From: Prem Chintalapudi <[email protected]>
+Date: Tue, 9 May 2023 21:51:00 -0400
+Subject: [PATCH 2/7] Update MemorySSA correctly when sinking gc_preserve_end
+
+---
+ src/llvm-julia-licm.cpp | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/llvm-julia-licm.cpp b/src/llvm-julia-licm.cpp
+index 7bc8d91b525f3..6c996b313ce38 100644
+--- a/src/llvm-julia-licm.cpp
++++ b/src/llvm-julia-licm.cpp
+@@ -58,13 +58,13 @@ static void eraseInstruction(Instruction &I,
+ //Stolen and modified from LICM.cpp
+ static void moveInstructionBefore(Instruction &I, Instruction &Dest,
+                                   MemorySSAUpdater &MSSAU,
+-                                  ScalarEvolution *SE) {
++                                  ScalarEvolution *SE,
++                                  MemorySSA::InsertionPlace Place = 
MemorySSA::BeforeTerminator) {
+   I.moveBefore(&Dest);
+   if (MSSAU.getMemorySSA())
+     if (MemoryUseOrDef *OldMemAcc = cast_or_null<MemoryUseOrDef>(
+             MSSAU.getMemorySSA()->getMemoryAccess(&I)))
+-      MSSAU.moveToPlace(OldMemAcc, Dest.getParent(),
+-                         MemorySSA::BeforeTerminator);
++      MSSAU.moveToPlace(OldMemAcc, Dest.getParent(), Place);
+   if (SE)
+     SE->forgetValue(&I);
+ }
+@@ -241,7 +241,7 @@ struct JuliaLICM : public JuliaPassContext {
+                         continue;
+                     }
+                     ++SunkPreserveEnd;
+-                    moveInstructionBefore(*call, *exit_pts[0], MSSAU, SE);
++                    moveInstructionBefore(*call, *exit_pts[0], MSSAU, SE, 
MemorySSA::Beginning);
+                     for (unsigned i = 1; i < exit_pts.size(); i++) {
+                         // Clone exit
+                         auto CI = CallInst::Create(call, {}, exit_pts[i]);
+
+From b2273d39542fe803f7d9da03ef57af7e815db68c Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <[email protected]>
+Date: Sun, 30 Apr 2023 20:19:08 -0400
+Subject: [PATCH 3/7] Do not yet mandate opaque pointers for LLVM 15
+
+---
+ src/codegen.cpp    | 11 +++++++++++
+ src/jitlayers.cpp  |  3 ---
+ src/llvm-version.h |  2 +-
+ 3 files changed, 12 insertions(+), 4 deletions(-)
+
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index a9d2cb0c60333..2e3f7eb2bf7bb 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -9083,6 +9083,17 @@ extern "C" void jl_init_llvm(void)
+     if (clopt && clopt->getNumOccurrences() == 0)
+         cl::ProvidePositionalOption(clopt, "4", 1);
+ 
++#if JL_LLVM_VERSION >= 150000
++    clopt = llvmopts.lookup("opaque-pointers");
++    if (clopt && clopt->getNumOccurrences() == 0) {
++#ifdef JL_LLVM_OPAQUE_POINTERS
++        cl::ProvidePositionalOption(clopt, "true", 1);
++#else
++        cl::ProvidePositionalOption(clopt, "false", 1);
++#endif
++    }
++#endif
++
+     jl_ExecutionEngine = new JuliaOJIT();
+ 
+     bool jl_using_gdb_jitevents = false;
+diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp
+index 643f0468457ae..ef7e98bb7852a 100644
+--- a/src/jitlayers.cpp
++++ b/src/jitlayers.cpp
+@@ -1306,9 +1306,6 @@ JuliaOJIT::JuliaOJIT()
+     JD(ES.createBareJITDylib("JuliaOJIT")),
+     ContextPool([](){
+         auto ctx = std::make_unique<LLVMContext>();
+-#ifdef JL_LLVM_OPAQUE_POINTERS
+-        ctx->setOpaquePointers(true);
+-#endif
+         return orc::ThreadSafeContext(std::move(ctx));
+     }),
+ #ifdef JL_USE_JITLINK
+diff --git a/src/llvm-version.h b/src/llvm-version.h
+index a3f3774b6dc15..819ec1c88976b 100644
+--- a/src/llvm-version.h
++++ b/src/llvm-version.h
+@@ -14,7 +14,7 @@
+     #error Only LLVM versions >= 12.0.0 are supported by Julia
+ #endif
+ 
+-#if JL_LLVM_VERSION >= 150000
++#if JL_LLVM_VERSION >= 160000
+ #define JL_LLVM_OPAQUE_POINTERS 1
+ #endif
+ 
+
+From 190f84180883eb498cb7b7ed27e10af9a6c62863 Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <[email protected]>
+Date: Wed, 26 Apr 2023 20:48:45 -0400
+Subject: [PATCH 4/7] Upgrade Julia to LLVM 15.0.7+5
+
+Co-authored-by: Gabriel Baraldi <[email protected]>
+---
+ Make.inc                        |   2 +-
+ deps/checksums/clang            | 224 ++++++++--------
+ deps/checksums/lld              | 224 ++++++++--------
+ deps/checksums/llvm             | 452 +++++++++++++++-----------------
+ deps/clang.version              |   2 +-
+ deps/lld.version                |   2 +-
+ deps/llvm-tools.version         |   4 +-
+ deps/llvm.version               |   9 +-
+ stdlib/LLD_jll/Project.toml     |   4 +-
+ stdlib/libLLVM_jll/Project.toml |   2 +-
+ 10 files changed, 446 insertions(+), 479 deletions(-)
+
+diff --git a/Make.inc b/Make.inc
+index 4d564f057a3da..35b0657de5aa2 100644
+--- a/Make.inc
++++ b/Make.inc
+@@ -480,7 +480,7 @@ FC := $(CROSS_COMPILE)gfortran
+ ifeq ($(OS), Darwin)
+ APPLE_ARCH := $(shell uname -m)
+ ifneq ($(APPLE_ARCH),arm64)
+-MACOSX_VERSION_MIN := 10.10
++MACOSX_VERSION_MIN := 10.14
+ else
+ MACOSX_VERSION_MIN := 11.0
+ endif
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index 2e3f7eb2bf7bb..07e7b15afc165 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -9169,7 +9169,9 @@ extern "C" JL_DLLEXPORT void jl_init_codegen_impl(void)
+ extern "C" JL_DLLEXPORT void jl_teardown_codegen_impl() JL_NOTSAFEPOINT
+ {
+     // output LLVM timings and statistics
+-    jl_ExecutionEngine->printTimers();
++    // Guard against exits before we have initialized the ExecutionEngine
++    if (jl_ExecutionEngine)
++        jl_ExecutionEngine->printTimers();
+     PrintStatistics();
+ }
+ 
+diff --git a/src/jitlayers.h b/src/jitlayers.h
+index bbbcbe73f1e54..4c6921cd42dab 100644
+--- a/src/jitlayers.h
++++ b/src/jitlayers.h
+@@ -97,10 +97,8 @@ struct OptimizationOptions {
+ };
+ 
+ // LLVM's new pass manager is scheduled to replace the legacy pass manager
+-// for middle-end IR optimizations. However, we have not qualified the new
+-// pass manager on our optimization pipeline yet, so this remains an optional
+-// define
+-#if defined(HAS_SANITIZER) && JL_LLVM_VERSION >= 150000
++// for middle-end IR optimizations.
++#if JL_LLVM_VERSION >= 150000
+ #define JL_USE_NEW_PM
+ #endif
+ 
+diff --git a/src/pipeline.cpp b/src/pipeline.cpp
+index 4403653a9d8e4..7e61171d288e6 100644
+--- a/src/pipeline.cpp
++++ b/src/pipeline.cpp
+@@ -361,7 +361,8 @@ static void buildFullPipeline(ModulePassManager &MPM, 
PassBuilder *PB, Optimizat
+     {
+         FunctionPassManager FPM;
+         FPM.addPass(SROAPass());
+-        FPM.addPass(InstSimplifyPass());
++        // SROA can duplicate PHI nodes which can block LowerSIMD
++        FPM.addPass(InstCombinePass());
+         FPM.addPass(JumpThreadingPass());
+         FPM.addPass(CorrelatedValuePropagationPass());
+         FPM.addPass(ReassociatePass());
+@@ -384,7 +385,7 @@ static void buildFullPipeline(ModulePassManager &MPM, 
PassBuilder *PB, Optimizat
+ #endif
+             LPM2.addPass(LICMPass(LICMOptions()));
+             JULIA_PASS(LPM2.addPass(JuliaLICMPass()));
+-            LPM2.addPass(SimpleLoopUnswitchPass(true, true));
++            LPM2.addPass(SimpleLoopUnswitchPass(false, true));
+             LPM2.addPass(LICMPass(LICMOptions()));
+             JULIA_PASS(LPM2.addPass(JuliaLICMPass()));
+             //LICM needs MemorySSA now, so we must use it
+@@ -397,11 +398,11 @@ static void buildFullPipeline(ModulePassManager &MPM, 
PassBuilder *PB, Optimizat
+             LPM.addPass(LoopIdiomRecognizePass());
+             LPM.addPass(IndVarSimplifyPass());
+             LPM.addPass(LoopDeletionPass());
++            LPM.addPass(LoopFullUnrollPass());
+             invokeLoopOptimizerEndCallbacks(LPM, PB, O);
+             //We don't know if the loop end callbacks support MSSA
+             FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM), 
/*UseMemorySSA = */false));
+         }
+-        FPM.addPass(LoopUnrollPass(LoopUnrollOptions().setRuntime(false)));
+         JULIA_PASS(FPM.addPass(AllocOptPass()));
+         FPM.addPass(SROAPass());
+         FPM.addPass(InstSimplifyPass());
+
+From 2ddbb5abb93045eeb4513e223c86e9c25fa774a4 Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <[email protected]>
+Date: Wed, 26 Apr 2023 20:49:16 -0400
+Subject: [PATCH 6/7] Fix tests and static analyzer for LLVM 15
+
+Co-authored-by: Gabriel Baraldi <[email protected]>
+Co-authored-by: Prem Chintalapudi <[email protected]>
+---
+ src/llvm-alloc-opt.cpp                   |  3 ++
+ src/llvm-late-gc-lowering.cpp            |  1 +
+ src/llvm-lower-handlers.cpp              |  1 +
+ src/llvm-multiversioning.cpp             |  3 ++
+ src/llvm-ptls.cpp                        |  2 +
+ test/clangsa/MissingRoots.c              |  3 ++
+ test/cmdlineargs.jl                      | 10 ++--
+ test/llvmpasses/pipeline-o2-broadcast.jl | 68 ++++++++++++++----------
+ test/llvmpasses/pipeline-o2.jl           |  6 +--
+ 9 files changed, 62 insertions(+), 35 deletions(-)
+
+diff --git a/src/llvm-alloc-opt.cpp b/src/llvm-alloc-opt.cpp
+index 1a524cbe8d419..bb6de67f347ff 100644
+--- a/src/llvm-alloc-opt.cpp
++++ b/src/llvm-alloc-opt.cpp
+@@ -1138,9 +1138,12 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
+                     ref->setOrdering(AtomicOrdering::NotAtomic);
+                     operands.push_back(ref);
+                 }
++#ifndef __clang_analyzer__
++                // FIXME: SA finds "Called C++ object pointer is null" inside 
the LLVM code.
+                 auto new_call = 
builder.CreateCall(pass.gc_preserve_begin_func, operands);
+                 new_call->takeName(call);
+                 call->replaceAllUsesWith(new_call);
++#endif
+                 call->eraseFromParent();
+                 return;
+             }
+diff --git a/src/llvm-late-gc-lowering.cpp b/src/llvm-late-gc-lowering.cpp
+index a836ff1361768..ac70685e7431b 100644
+--- a/src/llvm-late-gc-lowering.cpp
++++ b/src/llvm-late-gc-lowering.cpp
+@@ -1262,6 +1262,7 @@ static bool isLoadFromConstGV(LoadInst *LI, bool 
&task_local, PhiSet *seen)
+     // We only emit single slot GV in codegen
+     // but LLVM global merging can change the pointer operands to 
GEPs/bitcasts
+     auto load_base = LI->getPointerOperand()->stripInBoundsOffsets();
++    assert(load_base); // Static analyzer
+     auto gv = dyn_cast<GlobalVariable>(load_base);
+     if (isTBAA(LI->getMetadata(LLVMContext::MD_tbaa),
+                {"jtbaa_immut", "jtbaa_const", "jtbaa_datatype"})) {
+diff --git a/src/llvm-lower-handlers.cpp b/src/llvm-lower-handlers.cpp
+index 919128769019b..39a36bfc3ba76 100644
+--- a/src/llvm-lower-handlers.cpp
++++ b/src/llvm-lower-handlers.cpp
+@@ -8,6 +8,7 @@
+ 
+ #include <llvm/ADT/DepthFirstIterator.h>
+ #include <llvm/ADT/Statistic.h>
++#include <llvm/ADT/Triple.h>
+ #include <llvm/Analysis/CFG.h>
+ #include <llvm/IR/BasicBlock.h>
+ #include <llvm/IR/Constants.h>
+diff --git a/src/llvm-multiversioning.cpp b/src/llvm-multiversioning.cpp
+index 21a090724802a..cdba03047a4b7 100644
+--- a/src/llvm-multiversioning.cpp
++++ b/src/llvm-multiversioning.cpp
+@@ -14,11 +14,13 @@
+ #include <llvm/Pass.h>
+ #include <llvm/ADT/BitVector.h>
+ #include <llvm/ADT/Statistic.h>
++#include <llvm/ADT/Triple.h>
+ #include <llvm/IR/Module.h>
+ #include <llvm/IR/LegacyPassManager.h>
+ #include <llvm/IR/Function.h>
+ #include <llvm/IR/Instructions.h>
+ #include <llvm/IR/Constants.h>
++#include <llvm/IR/Dominators.h>
+ #include <llvm/IR/LLVMContext.h>
+ #include <llvm/Analysis/LoopInfo.h>
+ #include <llvm/Analysis/CallGraph.h>
+@@ -779,6 +781,7 @@ static Value *rewrite_inst_use(const Stack& stack, Type 
*T_size, Value *replace,
+             replace = inst;
+             continue;
+         }
++        assert(val);
+         unsigned nargs = val->getNumOperands();
+         args.resize(nargs);
+         for (unsigned j = 0; j < nargs; j++) {
+diff --git a/src/llvm-ptls.cpp b/src/llvm-ptls.cpp
+index 8174832b3cebf..a628710916327 100644
+--- a/src/llvm-ptls.cpp
++++ b/src/llvm-ptls.cpp
+@@ -9,6 +9,7 @@
+ #include <llvm-c/Types.h>
+ 
+ #include <llvm/Pass.h>
++#include <llvm/ADT/Triple.h>
+ #include <llvm/IR/Module.h>
+ #include <llvm/IR/LegacyPassManager.h>
+ #include <llvm/IR/Function.h>
+@@ -161,6 +162,7 @@ void LowerPTLS::fix_pgcstack_use(CallInst *pgcstack, 
Function *pgcstack_getter,
+         SmallVector<uint32_t, 2> Weights{9, 1};
+         TerminatorInst *fastTerm;
+         TerminatorInst *slowTerm;
++        assert(pgcstack->getType()); // Static analyzer
+         auto cmp = new ICmpInst(phi, CmpInst::ICMP_NE, pgcstack, 
Constant::getNullValue(pgcstack->getType()));
+         SplitBlockAndInsertIfThenElse(cmp, phi, &fastTerm, &slowTerm,
+                                       MDB.createBranchWeights(Weights));
+diff --git a/test/clangsa/MissingRoots.c b/test/clangsa/MissingRoots.c
+index f0b32c54bc7b8..0ff5e633622ce 100644
+--- a/test/clangsa/MissingRoots.c
++++ b/test/clangsa/MissingRoots.c
+@@ -352,6 +352,9 @@ void assoc_exact_broken(jl_value_t **args, size_t n, 
int8_t offs, size_t world)
+ }
+ */
+ 
++// declare
++jl_typemap_level_t *jl_new_typemap_level(void);
++
+ void assoc_exact_ok(jl_value_t *args1, jl_value_t **args, size_t n, int8_t 
offs, size_t world) {
+     jl_typemap_level_t *cache = jl_new_typemap_level();
+     JL_GC_PUSH1(&cache);
+diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl
+index 389b195d97935..1d04926ef23af 100644
+--- a/test/cmdlineargs.jl
++++ b/test/cmdlineargs.jl
+@@ -188,10 +188,12 @@ let exename = `$(Base.julia_cmd()) --startup-file=no 
--color=no`
+         @test contains(v[2], r"enable-tail-merge + = 1")
+         @test isempty(v[3])
+     end
+-    @testset let v = readchomperrors(setenv(`$exename -e 0`, 
"JULIA_LLVM_ARGS" => "-print-options -enable-tail-merge=1 
-enable-tail-merge=1", "HOME" => homedir()))
+-        @test !v[1]
+-        @test isempty(v[2])
+-        @test v[3] == "julia: for the --enable-tail-merge option: may only 
occur zero or one times!"
++    if Base.libllvm_version < v"15" #LLVM over 15 doesn't care for multiple 
options
++        @testset let v = readchomperrors(setenv(`$exename -e 0`, 
"JULIA_LLVM_ARGS" => "-print-options -enable-tail-merge=1 
-enable-tail-merge=1", "HOME" => homedir()))
++            @test !v[1]
++            @test isempty(v[2])
++            @test v[3] == "julia: for the --enable-tail-merge option: may 
only occur zero or one times!"
++        end
+     end
+ end
+ 
+diff --git a/test/llvmpasses/pipeline-o2.jl b/test/llvmpasses/pipeline-o2.jl
+index 2996a44de62b3..fcb2161de7614 100644
+--- a/test/llvmpasses/pipeline-o2.jl
++++ b/test/llvmpasses/pipeline-o2.jl
+@@ -78,21 +78,21 @@ end
+ # COM: memset checks
+ 
+ # COM: INT64
+-# ALL-LABEL: define nonnull {} addrspace(10)* @julia_zeros
++# ALL: define {{.*}} @julia_zeros
+ # ALL-NOT: bounds_error
+ # COM: memset is not used with bounds checks on (too late in the pipeline)
+ # BC_OFF: llvm.memset
+ # BC_AUTO: llvm.memset
+ 
+ # COM: INT32
+-# ALL-LABEL: define nonnull {} addrspace(10)* @julia_zeros
++# ALL: define {{.*}} @julia_zeros
+ # ALL-NOT: bounds_error
+ # COM: memset is not used with bounds checks on (too late in the pipeline)
+ # BC_OFF: llvm.memset
+ # BC_AUTO: llvm.memset
+ 
+ # COM: INT16
+-# ALL-LABEL: define nonnull {} addrspace(10)* @julia_zeros
++# ALL: define {{.*}} @julia_zeros
+ # ALL-NOT: bounds_error
+ # COM: memset is not used with bounds checks on (too late in the pipeline)
+ # BC_OFF: llvm.memset
+
+From 77c13ad59364189386114b546a7482dbe2edf233 Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <[email protected]>
+Date: Wed, 10 May 2023 10:51:16 -0400
+Subject: [PATCH 7/7] Reenable NonTrivial Loop Unswitch
+
+---
+ src/codegen.cpp  | 3 ---
+ src/pipeline.cpp | 2 +-
+ 2 files changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index 07e7b15afc165..ae306d3d1cdb5 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -9073,9 +9073,6 @@ extern "C" void jl_init_llvm(void)
+     clopt = llvmopts.lookup("unswitch-threshold");
+     if (clopt->getNumOccurrences() == 0)
+         cl::ProvidePositionalOption(clopt, "100", 1);
+-    clopt = llvmopts.lookup("enable-unswitch-cost-multiplier");
+-    if (clopt->getNumOccurrences() == 0)
+-        cl::ProvidePositionalOption(clopt, "false", 1);
+ #endif
+     // if the patch adding this option has been applied, lower its limit to 
provide
+     // better DAGCombiner performance.
+diff --git a/src/pipeline.cpp b/src/pipeline.cpp
+index 7e61171d288e6..6e6a9a3c37d02 100644
+--- a/src/pipeline.cpp
++++ b/src/pipeline.cpp
+@@ -385,7 +385,7 @@ static void buildFullPipeline(ModulePassManager &MPM, 
PassBuilder *PB, Optimizat
+ #endif
+             LPM2.addPass(LICMPass(LICMOptions()));
+             JULIA_PASS(LPM2.addPass(JuliaLICMPass()));
+-            LPM2.addPass(SimpleLoopUnswitchPass(false, true));
++            LPM2.addPass(SimpleLoopUnswitchPass(/*NonTrivial*/true, true));
+             LPM2.addPass(LICMPass(LICMOptions()));
+             JULIA_PASS(LPM2.addPass(JuliaLICMPass()));
+             //LICM needs MemorySSA now, so we must use it

Added: 959902f1.patch
===================================================================
--- 959902f1.patch                              (rev 0)
+++ 959902f1.patch      2023-05-11 16:28:26 UTC (rev 1459930)
@@ -0,0 +1,188 @@
+From 959902f1c6099c1b513e29103b998545c16731fc Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <[email protected]>
+Date: Thu, 27 Apr 2023 16:27:09 -0400
+Subject: [PATCH] Support both Float16 ABIs depending on LLVM and platform
+ (#49527)
+
+There are two Float16 ABIs in the wild, one for platforms that have a
+defing register and the original one where we used i16.
+
+LLVM 15 follows GCC and uses the new ABI on x86/ARM but not PPC.
+
+Co-authored-by: Gabriel Baraldi <[email protected]>
+---
+ src/aotcompile.cpp | 11 +++++++--
+ src/codegen.cpp    | 56 ++++++++++++++++++++++++++++++++++++++++++++++
+ src/jitlayers.cpp  |  2 ++
+ src/llvm-version.h | 10 +++++++++
+ 4 files changed, 77 insertions(+), 2 deletions(-)
+
+diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp
+index 391c5d3df46fb..2a14e2a4fa0ab 100644
+--- a/src/aotcompile.cpp
++++ b/src/aotcompile.cpp
+@@ -494,6 +494,7 @@ static void reportWriterError(const ErrorInfoBase &E)
+     jl_safe_printf("ERROR: failed to emit output file %s\n", err.c_str());
+ }
+ 
++#if JULIA_FLOAT16_ABI == 1
+ static void injectCRTAlias(Module &M, StringRef name, StringRef alias, 
FunctionType *FT)
+ {
+     Function *target = M.getFunction(alias);
+@@ -510,7 +511,8 @@ static void injectCRTAlias(Module &M, StringRef name, 
StringRef alias, FunctionT
+     auto val = builder.CreateCall(target, CallArgs);
+     builder.CreateRet(val);
+ }
+-
++#endif
++void emitFloat16Wrappers(Module &M, bool external);
+ 
+ // takes the running content that has collected in the shadow module and dump 
it to disk
+ // this builds the object file portion of the sysimage files for fast startup
+@@ -1003,6 +1006,7 @@ static void add_output_impl(Module &M, TargetMachine 
&SourceTM, std::string *out
+         }
+
+         if (inject_crt) {
++#if JULIA_FLOAT16_ABI == 1
+             // We would like to emit an alias or an weakref alias to redirect 
these symbols
+             // but LLVM doesn't let us emit a GlobalAlias to a declaration...
+             // So for now we inject a definition of these functions that 
calls our runtime
+@@ -1018,6 +1023,9 @@ static void add_output_impl(Module &M, TargetMachine 
&SourceTM, std::string *out
+                     FunctionType::get(Type::getHalfTy(Context), { 
Type::getFloatTy(Context) }, false));
+             injectCRTAlias(M, "__truncdfhf2", "julia__truncdfhf2",
+                     FunctionType::get(Type::getHalfTy(Context), { 
Type::getDoubleTy(Context) }, false));
++#else
++            emitFloat16Wrappers(M, false);
++#endif
+ 
+ #if defined(_OS_WINDOWS_)
+             // Windows expect that the function `_DllMainStartup` is present 
in an dll.
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index 329c4b452a9dc..f4b0fd518cd39 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -5818,6 +5818,7 @@ static void emit_cfunc_invalidate(
+         prepare_call_in(gf_thunk->getParent(), jlapplygeneric_func));
+ }
+ 
++#include <iostream>
+ static Function* gen_cfun_wrapper(
+     Module *into, jl_codegen_params_t &params,
+     const function_sig_t &sig, jl_value_t *ff, const char *aliasname,
+@@ -8704,6 +8705,58 @@ static JuliaVariable *julia_const_gv(jl_value_t *val)
+     return nullptr;
+ }
+ 
++// Handle FLOAT16 ABI v2
++#if JULIA_FLOAT16_ABI == 2
++static void makeCastCall(Module &M, StringRef wrapperName, StringRef 
calledName, FunctionType *FTwrapper, FunctionType *FTcalled, bool external)
++{
++    Function *calledFun = M.getFunction(calledName);
++    if (!calledFun) {
++        calledFun = Function::Create(FTcalled, Function::ExternalLinkage, 
calledName, M);
++    }
++    auto linkage = external ? Function::ExternalLinkage : 
Function::InternalLinkage;
++    auto wrapperFun = Function::Create(FTwrapper, linkage, wrapperName, M);
++    wrapperFun->addFnAttr(Attribute::AlwaysInline);
++    llvm::IRBuilder<> builder(BasicBlock::Create(M.getContext(), "top", 
wrapperFun));
++    SmallVector<Value *, 4> CallArgs;
++    if (wrapperFun->arg_size() != calledFun->arg_size()){
++        llvm::errs() << "FATAL ERROR: Can't match wrapper to called function";
++        abort();
++    }
++    for (auto wrapperArg = wrapperFun->arg_begin(), calledArg = 
calledFun->arg_begin();
++            wrapperArg != wrapperFun->arg_end() && calledArg != 
calledFun->arg_end(); ++wrapperArg, ++calledArg)
++    {
++        CallArgs.push_back(builder.CreateBitCast(wrapperArg, 
calledArg->getType()));
++    }
++    auto val = builder.CreateCall(calledFun, CallArgs);
++    auto retval = builder.CreateBitCast(val,wrapperFun->getReturnType());
++    builder.CreateRet(retval);
++}
++
++void emitFloat16Wrappers(Module &M, bool external)
++{
++    auto &ctx = M.getContext();
++    makeCastCall(M, "__gnu_h2f_ieee", "julia__gnu_h2f_ieee", 
FunctionType::get(Type::getFloatTy(ctx), { Type::getHalfTy(ctx) }, false),
++                FunctionType::get(Type::getFloatTy(ctx), { 
Type::getInt16Ty(ctx) }, false), external);
++    makeCastCall(M, "__extendhfsf2", "julia__gnu_h2f_ieee", 
FunctionType::get(Type::getFloatTy(ctx), { Type::getHalfTy(ctx) }, false),
++                FunctionType::get(Type::getFloatTy(ctx), { 
Type::getInt16Ty(ctx) }, false), external);
++    makeCastCall(M, "__gnu_f2h_ieee", "julia__gnu_f2h_ieee", 
FunctionType::get(Type::getHalfTy(ctx), { Type::getFloatTy(ctx) }, false),
++                FunctionType::get(Type::getInt16Ty(ctx), { 
Type::getFloatTy(ctx) }, false), external);
++    makeCastCall(M, "__truncsfhf2", "julia__gnu_f2h_ieee", 
FunctionType::get(Type::getHalfTy(ctx), { Type::getFloatTy(ctx) }, false),
++                FunctionType::get(Type::getInt16Ty(ctx), { 
Type::getFloatTy(ctx) }, false), external);
++    makeCastCall(M, "__truncdfhf2", "julia__truncdfhf2", 
FunctionType::get(Type::getHalfTy(ctx), { Type::getDoubleTy(ctx) }, false),
++                FunctionType::get(Type::getInt16Ty(ctx), { 
Type::getDoubleTy(ctx) }, false), external);
++}
++
++static void init_f16_funcs(void)
++{
++    auto ctx = jl_ExecutionEngine->acquireContext();
++    auto TSM =  jl_create_ts_module("F16Wrappers", ctx, imaging_default());
++    auto aliasM = TSM.getModuleUnlocked();
++    emitFloat16Wrappers(*aliasM, true);
++    jl_ExecutionEngine->addModule(std::move(TSM));
++}
++#endif
++
+ static void init_jit_functions(void)
+ {
+     add_named_global(jlstack_chk_guard_var, &__stack_chk_guard);
+@@ -8942,6 +8995,9 @@ extern "C" JL_DLLEXPORT void jl_init_codegen_impl(void)
+     jl_init_llvm();
+     // Now that the execution engine exists, initialize all modules
+     init_jit_functions();
++#if JULIA_FLOAT16_ABI == 2
++    init_f16_funcs();
++#endif
+ }
+ 
+ extern "C" JL_DLLEXPORT void jl_teardown_codegen_impl() JL_NOTSAFEPOINT
+diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp
+index 37302e8ca2ace..b3ec102821858 100644
+--- a/src/jitlayers.cpp
++++ b/src/jitlayers.cpp
+@@ -1383,6 +1383,7 @@ JuliaOJIT::JuliaOJIT()
+ 
+     JD.addToLinkOrder(GlobalJD, 
orc::JITDylibLookupFlags::MatchExportedSymbolsOnly);
+ 
++#if JULIA_FLOAT16_ABI == 1
+     orc::SymbolAliasMap jl_crt = {
+         { mangle("__gnu_h2f_ieee"), { mangle("julia__gnu_h2f_ieee"), 
JITSymbolFlags::Exported } },
+         { mangle("__extendhfsf2"),  { mangle("julia__gnu_h2f_ieee"), 
JITSymbolFlags::Exported } },
+@@ -1391,6 +1392,7 @@ JuliaOJIT::JuliaOJIT()
+         { mangle("__truncdfhf2"),   { mangle("julia__truncdfhf2"),   
JITSymbolFlags::Exported } }
+     };
+     cantFail(GlobalJD.define(orc::symbolAliases(jl_crt)));
++#endif
+ 
+ #ifdef MSAN_EMUTLS_WORKAROUND
+     orc::SymbolMap msan_crt;
+diff --git a/src/llvm-version.h b/src/llvm-version.h
+index 4e15e787b7de8..a3f3774b6dc15 100644
+--- a/src/llvm-version.h
++++ b/src/llvm-version.h
+@@ -2,6 +2,7 @@
+ 
+ #include <llvm/Config/llvm-config.h>
+ #include "julia_assert.h"
++#include "platform.h"
+ 
+ // The LLVM version used, JL_LLVM_VERSION, is represented as a 5-digit integer
+ // of the form ABBCC, where A is the major version, B is minor, and C is 
patch.
+@@ -17,6 +18,15 @@
+ #define JL_LLVM_OPAQUE_POINTERS 1
+ #endif
+ 
++// Pre GCC 12 libgcc defined the ABI for Float16->Float32
++// to take an i16. GCC 12 silently changed the ABI to now pass
++// Float16 in Float32 registers.
++#if JL_LLVM_VERSION < 150000 || defined(_CPU_PPC64_) || defined(_CPU_PPC_)
++#define JULIA_FLOAT16_ABI 1
++#else
++#define JULIA_FLOAT16_ABI 2
++#endif
++
+ #ifdef __cplusplus
+ #if defined(__GNUC__) && (__GNUC__ >= 9)
+ // Added in GCC 9, this warning is annoying

Modified: PKGBUILD
===================================================================
--- PKGBUILD    2023-05-11 16:26:30 UTC (rev 1459929)
+++ PKGBUILD    2023-05-11 16:28:26 UTC (rev 1459930)
@@ -9,14 +9,14 @@
 pkgname=julia
 epoch=2
 pkgver=1.9.0
-pkgrel=1
+pkgrel=2
 arch=(x86_64)
 pkgdesc='High-level, high-performance, dynamic programming language'
 url='https://julialang.org/'
 license=(MIT)
 depends=(fftw hicolor-icon-theme libgit2 libunwind libutf8proc openblas64 
cblas64 lapack64
-         suitesparse64 mbedtls openlibm pcre2 llvm14-libs p7zip 
libblastrampoline)
-makedepends=(cmake gcc-fortran python llvm14 patchelf libwhich lld)
+         suitesparse64 mbedtls openlibm pcre2 llvm-libs p7zip 
libblastrampoline lld)
+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}
@@ -24,15 +24,23 @@
         julia-system-blas-libs.patch
         julia-hardcoded-libs.patch
         julia-suitesparse-7.patch
-        julia-mpfr-4.2.patch)
+        julia-mpfr-4.2.patch
+        959902f1.patch
+        e08e1444.patch
+        f11bfc6c.patch
+        21d4c2f1.patch)
 backup=(etc/julia/startup.jl)
 sha256sums=('222eb533c9dc54734949eb3a4169f54aefa1bc20be385fc1cf798c8219fe6400'
             'SKIP'
             '3c0c03eabb668e3242fcd3058c1011dfbb579cc1c5adc3ae1016531e711cc64e'
             '7845e6ce0f652ba35f00ed23b30d11ef3325398da1f9d094b737169522e453e3'
-            '7530593f5772389f3d98cc1a88931693f1f2e3027ef602e1c1a3c75aefcd8eb3'
+            '8d1bdfd0f8fd482044b20f5e5964e44f2d2b67d3f5c3a3cbca07e5ef39f7f1b6'
             '481ce9b093969c2433b86d4d2bc0815470225f680712fc6231df3629ca7fbe5e'
-            '9c959381a94e9ab6691b76b91b494808cd489a749f86c71bd0a36e406f1e2a7c')
+            '9c959381a94e9ab6691b76b91b494808cd489a749f86c71bd0a36e406f1e2a7c'
+            '5e3f55e68e3f7172d545888479cd9a35e7589d0467684c6d98c721e3b1878acd'
+            '628d41c0b7739ed6c4c34c7416efd81646fbd17ebab9e88ae46a3668650d3104'
+            'ea1b30a11fe4d381d5a2ee2aeb4d7cb688d03e0520805cad8939a11267545e04'
+            '2bcae4dc2478f738ebaaf3650a632ae9eb4a593340c578be3a5631a54661afdc')
 validpgpkeys=('3673DF529D9049477F76B37566E3C7DC03D6E495') # Julia (Binary 
signing key) <[email protected]>
 options=(!lto)
 
@@ -39,6 +47,11 @@
 prepare() {
   cd $pkgname-$pkgver
 
+# Port to LLVM 15
+  patch -p1 -i ../e08e1444.patch
+  patch -p1 -i ../959902f1.patch
+  patch -p1 -i ../f11bfc6c.patch
+  patch -p1 -i ../21d4c2f1.patch
 # libunwind 1.6 compatibility
   patch -p1 -i ../julia-libunwind-1.6.patch
 # Use system lapack and cblas libraries
@@ -92,7 +105,6 @@
     LIBBLASNAME=libblas64 \
     LIBLAPACK=-llapack64 \
     LIBLAPACKNAME=liblapack64 \
-    LLVM_CONFIG=llvm-config-14 \
     MARCH=x86-64"
 
 build() {

Added: e08e1444.patch
===================================================================
--- e08e1444.patch                              (rev 0)
+++ e08e1444.patch      2023-05-11 16:28:26 UTC (rev 1459930)
@@ -0,0 +1,304 @@
+From e08e14449fdec30d83ae2b9f0d6d1f4a9acf0b75 Mon Sep 17 00:00:00 2001
+From: pchintalapudi <[email protected]>
+Date: Mon, 17 Apr 2023 19:37:59 +0000
+Subject: [PATCH] Bring in newpm (new pass manager) updates to master (#47038)
+
+* Workaround missing ASAN global
+* Add alias analysis at O2 instead of O3
+* Disable runtime unrolling
+* Make SimpleLoopUnswitch act like LoopUnswitch
+* Add --time-passes support
+* Only add verification passes in debug mode
+* Hide assertion function
+---
+ src/codegen.cpp   | 11 ++++++++++-
+ src/jitlayers.cpp | 49 ++++++++++++++++++++++++++++++++++++-----------
+ src/jitlayers.h   | 17 ++++++++++++----
+ src/pipeline.cpp  | 27 ++++++++++++++------------
+ 4 files changed, 76 insertions(+), 28 deletions(-)
+
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index b6b86ba4442e1..fb8cefe5eb44f 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -8838,6 +8838,15 @@ extern "C" void jl_init_llvm(void)
+     clopt = llvmopts.lookup("enable-tail-merge"); // NOO TOUCHIE; NO TOUCH! 
See #922
+     if (clopt->getNumOccurrences() == 0)
+         cl::ProvidePositionalOption(clopt, "0", 1);
++#ifdef JL_USE_NEW_PM
++    // For parity with LoopUnswitch
++    clopt = llvmopts.lookup("unswitch-threshold");
++    if (clopt->getNumOccurrences() == 0)
++        cl::ProvidePositionalOption(clopt, "100", 1);
++    clopt = llvmopts.lookup("enable-unswitch-cost-multiplier");
++    if (clopt->getNumOccurrences() == 0)
++        cl::ProvidePositionalOption(clopt, "false", 1);
++#endif
+     // if the patch adding this option has been applied, lower its limit to 
provide
+     // better DAGCombiner performance.
+     clopt = llvmopts.lookup("combiner-store-merge-dependence-limit");
+@@ -8916,7 +8925,7 @@ extern "C" JL_DLLEXPORT void jl_init_codegen_impl(void)
+ extern "C" JL_DLLEXPORT void jl_teardown_codegen_impl() JL_NOTSAFEPOINT
+ {
+     // output LLVM timings and statistics
+-    reportAndResetTimings();
++    jl_ExecutionEngine->printTimers();
+     PrintStatistics();
+ }
+ 
+diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp
+index c7e202b98efab..29665d4e420b9 100644
+--- a/src/jitlayers.cpp
++++ b/src/jitlayers.cpp
+@@ -1103,6 +1103,8 @@ namespace {
+         std::unique_ptr<TargetMachine> TM;
+         int optlevel;
+         PMCreator(TargetMachine &TM, int optlevel) : 
TM(cantFail(createJTMBFromTM(TM, optlevel).createTargetMachine())), 
optlevel(optlevel) {}
++        // overload for newpm compatibility
++        PMCreator(TargetMachine &TM, int optlevel, 
std::vector<std::function<void()>> &) : PMCreator(TM, optlevel) {}
+         PMCreator(const PMCreator &other) : PMCreator(*other.TM, 
other.optlevel) {}
+         PMCreator(PMCreator &&other) : TM(std::move(other.TM)), 
optlevel(other.optlevel) {}
+         friend void swap(PMCreator &self, PMCreator &other) {
+@@ -1128,16 +1131,21 @@ namespace {
+     struct PMCreator {
+         orc::JITTargetMachineBuilder JTMB;
+         OptimizationLevel O;
+-        PMCreator(TargetMachine &TM, int optlevel) : 
JTMB(createJTMBFromTM(TM, optlevel)), O(getOptLevel(optlevel)) {}
++        std::vector<std::function<void()>> &printers;
++        PMCreator(TargetMachine &TM, int optlevel, 
std::vector<std::function<void()>> &printers) JL_NOTSAFEPOINT : 
JTMB(createJTMBFromTM(TM, optlevel)), O(getOptLevel(optlevel)), 
printers(printers) {}
+ 
+         auto operator()() {
+-            return 
std::make_unique<NewPM>(cantFail(JTMB.createTargetMachine()), O);
++            auto NPM = 
std::make_unique<NewPM>(cantFail(JTMB.createTargetMachine()), O);
++            printers.push_back([NPM = NPM.get()]() JL_NOTSAFEPOINT {
++                NPM->printTimers();
++            });
++            return NPM;
+         }
+     };
+ #endif
+ 
+     struct OptimizerT {
+-        OptimizerT(TargetMachine &TM, int optlevel) : optlevel(optlevel), 
PMs(PMCreator(TM, optlevel)) {}
++        OptimizerT(TargetMachine &TM, int optlevel, 
std::vector<std::function<void()>> &printers) : optlevel(optlevel), 
PMs(PMCreator(TM, optlevel, printers)) {}
+ 
+         OptimizerResultT operator()(orc::ThreadSafeModule TSM, 
orc::MaterializationResponsibility &R) {
+             TSM.withModuleDo([&](Module &M) {
+@@ -1247,10 +1255,14 @@ llvm::DataLayout jl_create_datalayout(TargetMachine 
&TM) {
+     return jl_data_layout;
+ }
+ 
+-JuliaOJIT::PipelineT::PipelineT(orc::ObjectLayer &BaseLayer, TargetMachine 
&TM, int optlevel)
++JuliaOJIT::PipelineT::PipelineT(orc::ObjectLayer &BaseLayer, TargetMachine 
&TM, int optlevel, std::vector<std::function<void()>> &PrintLLVMTimers)
+ : CompileLayer(BaseLayer.getExecutionSession(), BaseLayer,
+     
std::make_unique<CompilerT>(orc::irManglingOptionsFromTargetOptions(TM.Options),
 TM, optlevel)),
+-  OptimizeLayer(CompileLayer.getExecutionSession(), CompileLayer, 
OptimizerT(TM, optlevel)) {}
++  OptimizeLayer(CompileLayer.getExecutionSession(), CompileLayer, 
OptimizerT(TM, optlevel, PrintLLVMTimers)) {}
++
++#ifdef _COMPILER_ASAN_ENABLED_
++int64_t ___asan_globals_registered;
++#endif
+ 
+ JuliaOJIT::JuliaOJIT()
+   : TM(createTargetMachine()),
+@@ -1285,10 +1297,10 @@ JuliaOJIT::JuliaOJIT()
+         ),
+ #endif
+     Pipelines{
+-        std::make_unique<PipelineT>(ObjectLayer, *TM, 0),
+-        std::make_unique<PipelineT>(ObjectLayer, *TM, 1),
+-        std::make_unique<PipelineT>(ObjectLayer, *TM, 2),
+-        std::make_unique<PipelineT>(ObjectLayer, *TM, 3),
++        std::make_unique<PipelineT>(ObjectLayer, *TM, 0, PrintLLVMTimers),
++        std::make_unique<PipelineT>(ObjectLayer, *TM, 1, PrintLLVMTimers),
++        std::make_unique<PipelineT>(ObjectLayer, *TM, 2, PrintLLVMTimers),
++        std::make_unique<PipelineT>(ObjectLayer, *TM, 3, PrintLLVMTimers),
+     },
+     OptSelLayer(Pipelines)
+ {
+@@ -1393,6 +1405,11 @@ JuliaOJIT::JuliaOJIT()
+         reinterpret_cast<void 
*>(static_cast<uintptr_t>(msan_workaround::MSanTLS::origin)), 
JITSymbolFlags::Exported);
+     cantFail(GlobalJD.define(orc::absoluteSymbols(msan_crt)));
+ #endif
++#ifdef _COMPILER_ASAN_ENABLED_
++    orc::SymbolMap asan_crt;
++    asan_crt[mangle("___asan_globals_registered")] = 
JITEvaluatedSymbol::fromPointer(&___asan_globals_registered, 
JITSymbolFlags::Exported);
++    cantFail(JD.define(orc::absoluteSymbols(asan_crt)));
++#endif
+ }
+ 
+ JuliaOJIT::~JuliaOJIT() = default;
+@@ -1583,6 +1600,16 @@ size_t JuliaOJIT::getTotalBytes() const
+ }
+ #endif
+ 
++void JuliaOJIT::printTimers()
++{
++#ifdef JL_USE_NEW_PM
++    for (auto &printer : PrintLLVMTimers) {
++        printer();
++    }
++#endif
++    reportAndResetTimings();
++}
++
+ JuliaOJIT *jl_ExecutionEngine;
+ 
+ // destructively move the contents of src into dest
+diff --git a/src/jitlayers.h b/src/jitlayers.h
+index d8c06df44176f..7f07034586c80 100644
+--- a/src/jitlayers.h
++++ b/src/jitlayers.h
+@@ -42,9 +42,7 @@
+ // and feature support (e.g. Windows, JITEventListeners for various profilers,
+ // etc.). Thus, we currently only use JITLink where absolutely required, that 
is,
+ // for Mac/aarch64.
+-// #define JL_FORCE_JITLINK
+-
+-#if defined(_OS_DARWIN_) && defined(_CPU_AARCH64_) || 
defined(JL_FORCE_JITLINK)
++#if defined(_OS_DARWIN_) && defined(_CPU_AARCH64_) || 
defined(_COMPILER_ASAN_ENABLED_) || defined(JL_FORCE_JITLINK)
+ # if JL_LLVM_VERSION < 130000
+ #  pragma message("On aarch64-darwin, LLVM version >= 13 is required for 
JITLink; fallback suffers from occasional segfaults")
+ # endif
+@@ -91,6 +89,12 @@ struct OptimizationOptions {
+     }
+ };
+ 
++// LLVM's new pass manager is scheduled to replace the legacy pass manager
++// for middle-end IR optimizations. However, we have not qualified the new
++// pass manager on our optimization pipeline yet, so this remains an optional
++// define
++// #define JL_USE_NEW_PM
++
+ struct NewPM {
+     std::unique_ptr<TargetMachine> TM;
+     StandardInstrumentations SI;
+@@ -103,6 +107,8 @@ struct NewPM {
+     NewPM(std::unique_ptr<TargetMachine> TM, OptimizationLevel O, 
OptimizationOptions options = OptimizationOptions::defaults());
+ 
+     void run(Module &M);
++
++    void printTimers();
+ };
+ 
+ struct AnalysisManagers {
+@@ -420,7 +426,7 @@ class JuliaOJIT {
+         std::unique_ptr<WNMutex> mutex;
+     };
+     struct PipelineT {
+-        PipelineT(orc::ObjectLayer &BaseLayer, TargetMachine &TM, int 
optlevel);
++        PipelineT(orc::ObjectLayer &BaseLayer, TargetMachine &TM, int 
optlevel, std::vector<std::function<void()>> &PrintLLVMTimers);
+         CompileLayerT CompileLayer;
+         OptimizeLayerT OptimizeLayer;
+     };
+@@ -490,6 +496,7 @@ class JuliaOJIT {
+     TargetIRAnalysis getTargetIRAnalysis() const;
+ 
+     size_t getTotalBytes() const;
++    void printTimers();
+ 
+     JITDebugInfoRegistry &getDebugInfoRegistry() JL_NOTSAFEPOINT {
+         return DebugRegistry;
+@@ -522,6 +529,8 @@ class JuliaOJIT {
+     jl_locked_stream dump_compiles_stream;
+     jl_locked_stream dump_llvm_opt_stream;
+ 
++    std::vector<std::function<void()>> PrintLLVMTimers;
++
+     ResourcePool<orc::ThreadSafeContext, 0, 
std::queue<orc::ThreadSafeContext>> ContextPool;
+ 
+ #ifndef JL_USE_JITLINK
+diff --git a/src/pipeline.cpp b/src/pipeline.cpp
+index ae2b1c3202f04..4403653a9d8e4 100644
+--- a/src/pipeline.cpp
++++ b/src/pipeline.cpp
+@@ -146,7 +146,7 @@ namespace {
+             // Opts.Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+             // Opts.UseAfterScope = CodeGenOpts.SanitizeAddressUseAfterScope;
+             // Opts.UseAfterReturn = 
CodeGenOpts.getSanitizeAddressUseAfterReturn();
+-            MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, 
Module>());
++            // MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, 
Module>());
+             // MPM.addPass(ModuleAddressSanitizerPass(
+             //     Opts, UseGlobalGC, UseOdrIndicator, DestructorKind));
+             //Let's assume the defaults are actually fine for our purposes
+@@ -173,11 +173,13 @@ namespace {
+         // }
+     }
+ 
+-    void addVerificationPasses(ModulePassManager &MPM, bool llvm_only) {
++#ifdef JL_DEBUG_BUILD
++    static inline void addVerificationPasses(ModulePassManager &MPM, bool 
llvm_only) {
+         if (!llvm_only)
+             
MPM.addPass(llvm::createModuleToFunctionPassAdaptor(GCInvariantVerifierPass()));
+         MPM.addPass(VerifierPass());
+     }
++#endif
+ 
+     auto basicSimplifyCFGOptions() {
+         return SimplifyCFGOptions()
+@@ -244,9 +246,9 @@ namespace {
+ 
+ //Use for O1 and below
+ void buildBasicPipeline(ModulePassManager &MPM, PassBuilder *PB, 
OptimizationLevel O, OptimizationOptions options) {
+-// #ifdef JL_DEBUG_BUILD
++#ifdef JL_DEBUG_BUILD
+     addVerificationPasses(MPM, options.llvm_only);
+-// #endif
++#endif
+     invokePipelineStartCallbacks(MPM, PB, O);
+     MPM.addPass(ConstantMergePass());
+     if (!options.dump_native) {
+@@ -320,9 +322,9 @@ static void buildBasicPipeline(ModulePassManager &MPM, 
PassBuilder *PB, Optimiza
+ 
+ //Use for O2 and above
+ void buildFullPipeline(ModulePassManager &MPM, PassBuilder *PB, 
OptimizationLevel O, OptimizationOptions options) {
+-// #ifdef JL_DEBUG_BUILD
++#ifdef JL_DEBUG_BUILD
+     addVerificationPasses(MPM, options.llvm_only);
+-// #endif
++#endif
+     invokePipelineStartCallbacks(MPM, PB, O);
+     MPM.addPass(ConstantMergePass());
+     {
+@@ -382,7 +384,7 @@ static void buildFullPipeline(ModulePassManager &MPM, 
PassBuilder *PB, Optimizat
+ #endif
+             LPM2.addPass(LICMPass(LICMOptions()));
+             JULIA_PASS(LPM2.addPass(JuliaLICMPass()));
+-            LPM2.addPass(SimpleLoopUnswitchPass());
++            LPM2.addPass(SimpleLoopUnswitchPass(true, true));
+             LPM2.addPass(LICMPass(LICMOptions()));
+             JULIA_PASS(LPM2.addPass(JuliaLICMPass()));
+             //LICM needs MemorySSA now, so we must use it
+@@ -399,7 +401,7 @@ static void buildFullPipeline(ModulePassManager &MPM, 
PassBuilder *PB, Optimizat
+             //We don't know if the loop end callbacks support MSSA
+             FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM), 
/*UseMemorySSA = */false));
+         }
+-        FPM.addPass(LoopUnrollPass());
++        FPM.addPass(LoopUnrollPass(LoopUnrollOptions().setRuntime(false)));
+         JULIA_PASS(FPM.addPass(AllocOptPass()));
+         FPM.addPass(SROAPass());
+         FPM.addPass(InstSimplifyPass());
+@@ -541,11 +543,8 @@ PIC->addClassToPassName(decltype(CREATE_PASS)::name(), 
NAME);
+         // Register the AA manager first so that our version is the one used.
+         FAM.registerPass([&] JL_NOTSAFEPOINT {
+             AAManager AA;
+-            // TODO: Why are we only doing this for -O3?
+-            if (O.getSpeedupLevel() >= 3) {
+-                AA.registerFunctionAnalysis<BasicAA>();
+-            }
+             if (O.getSpeedupLevel() >= 2) {
++                AA.registerFunctionAnalysis<BasicAA>();
+                 AA.registerFunctionAnalysis<ScopedNoAliasAA>();
+                 AA.registerFunctionAnalysis<TypeBasedAA>();
+             }
+@@ -603,6 +602,10 @@ void NewPM::run(Module &M) {
+ #endif
+ }
+ 
++void NewPM::printTimers() {
++    SI.getTimePasses().print();
++}
++
+ OptimizationLevel getOptLevel(int optlevel) {
+     switch (std::min(std::max(optlevel, 0), 3)) {
+         case 0:

Added: f11bfc6c.patch
===================================================================
--- f11bfc6c.patch                              (rev 0)
+++ f11bfc6c.patch      2023-05-11 16:28:26 UTC (rev 1459930)
@@ -0,0 +1,95 @@
+From f11bfc6ccad3e07fde4e40493635bd832d108477 Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <[email protected]>
+Date: Thu, 27 Apr 2023 16:29:25 -0400
+Subject: [PATCH] Use NewPM for ASAN/MSAN (#49530)
+
+Co-authored-by: Gabriel Baraldi <[email protected]>
+Co-authored-by: Prem Chintalapudi <[email protected]>
+---
+ src/aotcompile.cpp |  4 ++++
+ src/cgmemmgr.cpp   |  4 ++--
+ src/jitlayers.h    | 13 +++++++++++--
+ 3 files changed, 17 insertions(+), 4 deletions(-)
+
+diff --git a/src/aotcompile.cpp b/src/aotcompile.cpp
+index 2a14e2a4fa0ab..b89cdf550171f 100644
+--- a/src/aotcompile.cpp
++++ b/src/aotcompile.cpp
+@@ -1775,6 +1775,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, 
int opt_level,
+                 PM->add(createCFGSimplificationPass(basicSimplifyCFGOptions));
+             }
+         }
++#if JL_LLVM_VERSION < 150000
+ #if defined(_COMPILER_ASAN_ENABLED_)
+         PM->add(createAddressSanitizerFunctionPass());
+ #endif
+@@ -1783,6 +1784,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, 
int opt_level,
+ #endif
+ #if defined(_COMPILER_TSAN_ENABLED_)
+         PM->add(createThreadSanitizerLegacyPassPass());
++#endif
+ #endif
+         return;
+     }
+@@ -1934,6 +1936,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, 
int opt_level,
+     }
+     PM->add(createCombineMulAddPass());
+     PM->add(createDivRemPairsPass());
++#if JL_LLVM_VERSION < 150000
+ #if defined(_COMPILER_ASAN_ENABLED_)
+     PM->add(createAddressSanitizerFunctionPass());
+ #endif
+@@ -1943,6 +1946,7 @@ void addOptimizationPasses(legacy::PassManagerBase *PM, 
int opt_level,
+ #if defined(_COMPILER_TSAN_ENABLED_)
+     PM->add(createThreadSanitizerLegacyPassPass());
+ #endif
++#endif
+ }
+ 
+ // An LLVM module pass that just runs all julia passes in order. Useful for
+diff --git a/src/cgmemmgr.cpp b/src/cgmemmgr.cpp
+index 9f4d69137c0fd..15d28ff270c55 100644
+--- a/src/cgmemmgr.cpp
++++ b/src/cgmemmgr.cpp
+@@ -860,8 +860,8 @@ uint8_t 
*RTDyldMemoryManagerJL::allocateCodeSection(uintptr_t Size,
+                                                     StringRef SectionName)
+ {
+     // allocating more than one code section can confuse libunwind.
+-#if !defined(_COMPILER_MSAN_ENABLED_)
+-    // TODO: Figure out why msan needs this.
++#if !defined(_COMPILER_MSAN_ENABLED_) && !defined(_COMPILER_ASAN_ENABLED_)
++    // TODO: Figure out why msan and now asan too need this.
+     assert(!code_allocated);
+     code_allocated = true;
+ #endif
+diff --git a/src/jitlayers.h b/src/jitlayers.h
+index 7f07034586c80..f63f3a42842f1 100644
+--- a/src/jitlayers.h
++++ b/src/jitlayers.h
+@@ -42,7 +42,14 @@
+ // and feature support (e.g. Windows, JITEventListeners for various profilers,
+ // etc.). Thus, we currently only use JITLink where absolutely required, that 
is,
+ // for Mac/aarch64.
+-#if defined(_OS_DARWIN_) && defined(_CPU_AARCH64_) || 
defined(_COMPILER_ASAN_ENABLED_) || defined(JL_FORCE_JITLINK)
++// #define JL_FORCE_JITLINK
++
++#if defined(_COMPILER_ASAN_ENABLED_) || defined(_COMPILER_MSAN_ENABLED_) || 
defined(_COMPILER_TSAN_ENABLED_)
++# define HAS_SANITIZER
++#endif
++// The sanitizers don't play well with our memory manager
++
++#if defined(_OS_DARWIN_) && defined(_CPU_AARCH64_) || 
defined(JL_FORCE_JITLINK) || JL_LLVM_VERSION >= 150000 && defined(HAS_SANITIZER)
+ # if JL_LLVM_VERSION < 130000
+ #  pragma message("On aarch64-darwin, LLVM version >= 13 is required for 
JITLink; fallback suffers from occasional segfaults")
+ # endif
+@@ -93,7 +100,9 @@ struct OptimizationOptions {
+ // for middle-end IR optimizations. However, we have not qualified the new
+ // pass manager on our optimization pipeline yet, so this remains an optional
+ // define
+-// #define JL_USE_NEW_PM
++#if defined(HAS_SANITIZER) && JL_LLVM_VERSION >= 150000
++#define JL_USE_NEW_PM
++#endif
+ 
+ struct NewPM {
+     std::unique_ptr<TargetMachine> TM;

Added: julia-LLVM-15.patch
===================================================================
--- julia-LLVM-15.patch                         (rev 0)
+++ julia-LLVM-15.patch 2023-05-11 16:28:26 UTC (rev 1459930)
@@ -0,0 +1,329 @@
+From b621a9febd61c94fff1bfb7e0d3f468facd1c8b8 Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <[email protected]>
+Date: Sun, 30 Apr 2023 20:19:08 -0400
+Subject: [PATCH 1/5] Do not yet mandate opaque pointers for LLVM 15
+
+---
+ src/codegen.cpp    | 11 +++++++++++
+ src/jitlayers.cpp  |  3 ---
+ src/llvm-version.h |  2 +-
+ 3 files changed, 12 insertions(+), 4 deletions(-)
+
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index 16149325eb3e0..84dc0405a988e 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -9061,6 +9061,17 @@ extern "C" void jl_init_llvm(void)
+     if (clopt && clopt->getNumOccurrences() == 0)
+         cl::ProvidePositionalOption(clopt, "4", 1);
+ 
++#if JL_LLVM_VERSION >= 150000
++    clopt = llvmopts.lookup("opaque-pointers");
++    if (clopt && clopt->getNumOccurrences() == 0) {
++#ifdef JL_LLVM_OPAQUE_POINTERS
++        cl::ProvidePositionalOption(clopt, "true", 1);
++#else
++        cl::ProvidePositionalOption(clopt, "false", 1);
++#endif
++    }
++#endif
++
+     jl_ExecutionEngine = new JuliaOJIT();
+ 
+     bool jl_using_gdb_jitevents = false;
+diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp
+index c6aef2d35839c..1fdf14334266a 100644
+--- a/src/jitlayers.cpp
++++ b/src/jitlayers.cpp
+@@ -1306,9 +1306,6 @@ JuliaOJIT::JuliaOJIT()
+     JD(ES.createBareJITDylib("JuliaOJIT")),
+     ContextPool([](){
+         auto ctx = std::make_unique<LLVMContext>();
+-#ifdef JL_LLVM_OPAQUE_POINTERS
+-        ctx->setOpaquePointers(true);
+-#endif
+         return orc::ThreadSafeContext(std::move(ctx));
+     }),
+ #ifdef JL_USE_JITLINK
+diff --git a/src/llvm-version.h b/src/llvm-version.h
+index a3f3774b6dc15..819ec1c88976b 100644
+--- a/src/llvm-version.h
++++ b/src/llvm-version.h
+@@ -14,7 +14,7 @@
+     #error Only LLVM versions >= 12.0.0 are supported by Julia
+ #endif
+ 
+-#if JL_LLVM_VERSION >= 150000
++#if JL_LLVM_VERSION >= 160000
+ #define JL_LLVM_OPAQUE_POINTERS 1
+ #endif
+ 
+
+From 78f25cdd43d898b5175b467ce6e0bac660de4753 Mon Sep 17 00:00:00 2001
+From: pchintalapudi <[email protected]>
+Date: Thu, 4 May 2023 02:47:22 +0000
+Subject: [PATCH 3/5] Activate NewPM support
+
+Co-authored-by: Valentin Churavy <[email protected]>
+---
+ src/codegen.cpp  | 4 +++-
+ src/jitlayers.h  | 6 ++----
+ src/pipeline.cpp | 7 ++++---
+ 3 files changed, 9 insertions(+), 8 deletions(-)
+
+diff --git a/src/jitlayers.h b/src/jitlayers.h
+index bbbcbe73f1e54..4c6921cd42dab 100644
+--- a/src/jitlayers.h
++++ b/src/jitlayers.h
+@@ -97,10 +97,8 @@ struct OptimizationOptions {
+ };
+ 
+ // LLVM's new pass manager is scheduled to replace the legacy pass manager
+-// for middle-end IR optimizations. However, we have not qualified the new
+-// pass manager on our optimization pipeline yet, so this remains an optional
+-// define
+-#if defined(HAS_SANITIZER) && JL_LLVM_VERSION >= 150000
++// for middle-end IR optimizations.
++#if JL_LLVM_VERSION >= 150000
+ #define JL_USE_NEW_PM
+ #endif
+ 
+diff --git a/src/pipeline.cpp b/src/pipeline.cpp
+index 4403653a9d8e4..7e61171d288e6 100644
+--- a/src/pipeline.cpp
++++ b/src/pipeline.cpp
+@@ -361,7 +361,8 @@ static void buildFullPipeline(ModulePassManager &MPM, 
PassBuilder *PB, Optimizat
+     {
+         FunctionPassManager FPM;
+         FPM.addPass(SROAPass());
+-        FPM.addPass(InstSimplifyPass());
++        // SROA can duplicate PHI nodes which can block LowerSIMD
++        FPM.addPass(InstCombinePass());
+         FPM.addPass(JumpThreadingPass());
+         FPM.addPass(CorrelatedValuePropagationPass());
+         FPM.addPass(ReassociatePass());
+@@ -384,7 +385,7 @@ static void buildFullPipeline(ModulePassManager &MPM, 
PassBuilder *PB, Optimizat
+ #endif
+             LPM2.addPass(LICMPass(LICMOptions()));
+             JULIA_PASS(LPM2.addPass(JuliaLICMPass()));
+-            LPM2.addPass(SimpleLoopUnswitchPass(true, true));
++            LPM2.addPass(SimpleLoopUnswitchPass(false, true));
+             LPM2.addPass(LICMPass(LICMOptions()));
+             JULIA_PASS(LPM2.addPass(JuliaLICMPass()));
+             //LICM needs MemorySSA now, so we must use it
+@@ -397,11 +398,11 @@ static void buildFullPipeline(ModulePassManager &MPM, 
PassBuilder *PB, Optimizat
+             LPM.addPass(LoopIdiomRecognizePass());
+             LPM.addPass(IndVarSimplifyPass());
+             LPM.addPass(LoopDeletionPass());
++            LPM.addPass(LoopFullUnrollPass());
+             invokeLoopOptimizerEndCallbacks(LPM, PB, O);
+             //We don't know if the loop end callbacks support MSSA
+             FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM), 
/*UseMemorySSA = */false));
+         }
+-        FPM.addPass(LoopUnrollPass(LoopUnrollOptions().setRuntime(false)));
+         JULIA_PASS(FPM.addPass(AllocOptPass()));
+         FPM.addPass(SROAPass());
+         FPM.addPass(InstSimplifyPass());
+
+From e3c03d619f83811362a2470939ddfad1155d35d7 Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <[email protected]>
+Date: Wed, 26 Apr 2023 20:49:16 -0400
+Subject: [PATCH 4/5] Fix tests and static analyzer for LLVM 15
+
+Co-authored-by: Gabriel Baraldi <[email protected]>
+Co-authored-by: Prem Chintalapudi <[email protected]>
+---
+ src/llvm-alloc-opt.cpp                   |  3 ++
+ src/llvm-late-gc-lowering.cpp            |  1 +
+ src/llvm-lower-handlers.cpp              |  1 +
+ src/llvm-multiversioning.cpp             |  3 ++
+ src/llvm-ptls.cpp                        |  2 +
+ test/clangsa/MissingRoots.c              |  3 ++
+ test/cmdlineargs.jl                      | 10 ++--
+ test/llvmpasses/pipeline-o2-broadcast.jl | 60 ++++++++++++++----------
+ test/llvmpasses/pipeline-o2.jl           |  6 +--
+ 9 files changed, 58 insertions(+), 31 deletions(-)
+
+diff --git a/src/llvm-alloc-opt.cpp b/src/llvm-alloc-opt.cpp
+index 1a524cbe8d419..bb6de67f347ff 100644
+--- a/src/llvm-alloc-opt.cpp
++++ b/src/llvm-alloc-opt.cpp
+@@ -1138,9 +1138,12 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
+                     ref->setOrdering(AtomicOrdering::NotAtomic);
+                     operands.push_back(ref);
+                 }
++#ifndef __clang_analyzer__
++                // FIXME: SA finds "Called C++ object pointer is null" inside 
the LLVM code.
+                 auto new_call = 
builder.CreateCall(pass.gc_preserve_begin_func, operands);
+                 new_call->takeName(call);
+                 call->replaceAllUsesWith(new_call);
++#endif
+                 call->eraseFromParent();
+                 return;
+             }
+diff --git a/src/llvm-late-gc-lowering.cpp b/src/llvm-late-gc-lowering.cpp
+index a8bab71ce91b5..49198f8abacd2 100644
+--- a/src/llvm-late-gc-lowering.cpp
++++ b/src/llvm-late-gc-lowering.cpp
+@@ -1262,6 +1262,7 @@ static bool isLoadFromConstGV(LoadInst *LI, bool 
&task_local, PhiSet *seen)
+     // We only emit single slot GV in codegen
+     // but LLVM global merging can change the pointer operands to 
GEPs/bitcasts
+     auto load_base = LI->getPointerOperand()->stripInBoundsOffsets();
++    assert(load_base); // Static analyzer
+     auto gv = dyn_cast<GlobalVariable>(load_base);
+     if (isTBAA(LI->getMetadata(LLVMContext::MD_tbaa),
+                {"jtbaa_immut", "jtbaa_const", "jtbaa_datatype"})) {
+diff --git a/src/llvm-lower-handlers.cpp b/src/llvm-lower-handlers.cpp
+index 919128769019b..39a36bfc3ba76 100644
+--- a/src/llvm-lower-handlers.cpp
++++ b/src/llvm-lower-handlers.cpp
+@@ -8,6 +8,7 @@
+ 
+ #include <llvm/ADT/DepthFirstIterator.h>
+ #include <llvm/ADT/Statistic.h>
++#include <llvm/ADT/Triple.h>
+ #include <llvm/Analysis/CFG.h>
+ #include <llvm/IR/BasicBlock.h>
+ #include <llvm/IR/Constants.h>
+diff --git a/src/llvm-multiversioning.cpp b/src/llvm-multiversioning.cpp
+index 21a090724802a..cdba03047a4b7 100644
+--- a/src/llvm-multiversioning.cpp
++++ b/src/llvm-multiversioning.cpp
+@@ -14,11 +14,13 @@
+ #include <llvm/Pass.h>
+ #include <llvm/ADT/BitVector.h>
+ #include <llvm/ADT/Statistic.h>
++#include <llvm/ADT/Triple.h>
+ #include <llvm/IR/Module.h>
+ #include <llvm/IR/LegacyPassManager.h>
+ #include <llvm/IR/Function.h>
+ #include <llvm/IR/Instructions.h>
+ #include <llvm/IR/Constants.h>
++#include <llvm/IR/Dominators.h>
+ #include <llvm/IR/LLVMContext.h>
+ #include <llvm/Analysis/LoopInfo.h>
+ #include <llvm/Analysis/CallGraph.h>
+@@ -779,6 +781,7 @@ static Value *rewrite_inst_use(const Stack& stack, Type 
*T_size, Value *replace,
+             replace = inst;
+             continue;
+         }
++        assert(val);
+         unsigned nargs = val->getNumOperands();
+         args.resize(nargs);
+         for (unsigned j = 0; j < nargs; j++) {
+diff --git a/src/llvm-ptls.cpp b/src/llvm-ptls.cpp
+index 8174832b3cebf..a628710916327 100644
+--- a/src/llvm-ptls.cpp
++++ b/src/llvm-ptls.cpp
+@@ -9,6 +9,7 @@
+ #include <llvm-c/Types.h>
+ 
+ #include <llvm/Pass.h>
++#include <llvm/ADT/Triple.h>
+ #include <llvm/IR/Module.h>
+ #include <llvm/IR/LegacyPassManager.h>
+ #include <llvm/IR/Function.h>
+@@ -161,6 +162,7 @@ void LowerPTLS::fix_pgcstack_use(CallInst *pgcstack, 
Function *pgcstack_getter,
+         SmallVector<uint32_t, 2> Weights{9, 1};
+         TerminatorInst *fastTerm;
+         TerminatorInst *slowTerm;
++        assert(pgcstack->getType()); // Static analyzer
+         auto cmp = new ICmpInst(phi, CmpInst::ICMP_NE, pgcstack, 
Constant::getNullValue(pgcstack->getType()));
+         SplitBlockAndInsertIfThenElse(cmp, phi, &fastTerm, &slowTerm,
+                                       MDB.createBranchWeights(Weights));
+diff --git a/test/clangsa/MissingRoots.c b/test/clangsa/MissingRoots.c
+index f0b32c54bc7b8..0ff5e633622ce 100644
+--- a/test/clangsa/MissingRoots.c
++++ b/test/clangsa/MissingRoots.c
+@@ -352,6 +352,9 @@ void assoc_exact_broken(jl_value_t **args, size_t n, 
int8_t offs, size_t world)
+ }
+ */
+ 
++// declare
++jl_typemap_level_t *jl_new_typemap_level(void);
++
+ void assoc_exact_ok(jl_value_t *args1, jl_value_t **args, size_t n, int8_t 
offs, size_t world) {
+     jl_typemap_level_t *cache = jl_new_typemap_level();
+     JL_GC_PUSH1(&cache);
+diff --git a/test/cmdlineargs.jl b/test/cmdlineargs.jl
+index 389b195d97935..1d04926ef23af 100644
+--- a/test/cmdlineargs.jl
++++ b/test/cmdlineargs.jl
+@@ -188,10 +188,12 @@ let exename = `$(Base.julia_cmd()) --startup-file=no 
--color=no`
+         @test contains(v[2], r"enable-tail-merge + = 1")
+         @test isempty(v[3])
+     end
+-    @testset let v = readchomperrors(setenv(`$exename -e 0`, 
"JULIA_LLVM_ARGS" => "-print-options -enable-tail-merge=1 
-enable-tail-merge=1", "HOME" => homedir()))
+-        @test !v[1]
+-        @test isempty(v[2])
+-        @test v[3] == "julia: for the --enable-tail-merge option: may only 
occur zero or one times!"
++    if Base.libllvm_version < v"15" #LLVM over 15 doesn't care for multiple 
options
++        @testset let v = readchomperrors(setenv(`$exename -e 0`, 
"JULIA_LLVM_ARGS" => "-print-options -enable-tail-merge=1 
-enable-tail-merge=1", "HOME" => homedir()))
++            @test !v[1]
++            @test isempty(v[2])
++            @test v[3] == "julia: for the --enable-tail-merge option: may 
only occur zero or one times!"
++        end
+     end
+ end
+ 
+diff --git a/test/llvmpasses/pipeline-o2.jl b/test/llvmpasses/pipeline-o2.jl
+index 2996a44de62b3..fcb2161de7614 100644
+--- a/test/llvmpasses/pipeline-o2.jl
++++ b/test/llvmpasses/pipeline-o2.jl
+@@ -78,21 +78,21 @@ end
+ # COM: memset checks
+ 
+ # COM: INT64
+-# ALL-LABEL: define nonnull {} addrspace(10)* @julia_zeros
++# ALL: define {{.*}} @julia_zeros
+ # ALL-NOT: bounds_error
+ # COM: memset is not used with bounds checks on (too late in the pipeline)
+ # BC_OFF: llvm.memset
+ # BC_AUTO: llvm.memset
+ 
+ # COM: INT32
+-# ALL-LABEL: define nonnull {} addrspace(10)* @julia_zeros
++# ALL: define {{.*}} @julia_zeros
+ # ALL-NOT: bounds_error
+ # COM: memset is not used with bounds checks on (too late in the pipeline)
+ # BC_OFF: llvm.memset
+ # BC_AUTO: llvm.memset
+ 
+ # COM: INT16
+-# ALL-LABEL: define nonnull {} addrspace(10)* @julia_zeros
++# ALL: define {{.*}} @julia_zeros
+ # ALL-NOT: bounds_error
+ # COM: memset is not used with bounds checks on (too late in the pipeline)
+ # BC_OFF: llvm.memset
+
+From a596f95e006144b73f145dcfb2596532f1a7d3b2 Mon Sep 17 00:00:00 2001
+From: Valentin Churavy <[email protected]>
+Date: Mon, 8 May 2023 11:01:49 -0400
+Subject: [PATCH 5/5] verify memoryssa on debug
+
+---
+ src/codegen.cpp | 10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+diff --git a/src/codegen.cpp b/src/codegen.cpp
+index 6d81d143659f2..f391e36f41ff9 100644
+--- a/src/codegen.cpp
++++ b/src/codegen.cpp
+@@ -9068,9 +9068,15 @@ extern "C" void jl_init_llvm(void)
+         cl::ProvidePositionalOption(clopt, "true", 1);
+ #else
+         cl::ProvidePositionalOption(clopt, "false", 1);
+-#endif
++#endif // JL_LLVM_OPAQUE_POINTERS
+     }
+-#endif
++#ifdef JL_DEBUG_BUILD
++    clopt = llvmopts.lookup("verify-memoryssa");
++    if (clopt && clopt->getNumOccurrences() == 0) {
++        cl::ProvidePositionalOption(clopt, "true", 1);
++    }
++#endif // JL_DEBUG_BUILD
++#endif // JL_LLVM_VERSION
+ 
+     jl_ExecutionEngine = new JuliaOJIT();
+ 

Modified: julia-hardcoded-libs.patch
===================================================================
--- julia-hardcoded-libs.patch  2023-05-11 16:26:30 UTC (rev 1459929)
+++ julia-hardcoded-libs.patch  2023-05-11 16:28:26 UTC (rev 1459930)
@@ -24,7 +24,7 @@
      const libLLVM = "@rpath/libLLVM.dylib"
  else
 -    const libLLVM = "libLLVM-14jl.so"
-+    const libLLVM = "libLLVM-14.so"
++    const libLLVM = "libLLVM-15.so"
  end
  
  function __init__()

Reply via email to