Date: Thursday, May 11, 2023 @ 16:37:03 Author: arojas Revision: 1459932
Drop unused patch Deleted: julia/trunk/julia-LLVM-15.patch ---------------------+ julia-LLVM-15.patch | 329 -------------------------------------------------- 1 file changed, 329 deletions(-) Deleted: julia-LLVM-15.patch =================================================================== --- julia-LLVM-15.patch 2023-05-11 16:28:54 UTC (rev 1459931) +++ julia-LLVM-15.patch 2023-05-11 16:37:03 UTC (rev 1459932) @@ -1,329 +0,0 @@ -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(); -
