Skip to content

Commit

Permalink
Merge pull request #48700 from JuliaLang/vc/upgrade_llvm15
Browse files Browse the repository at this point in the history
Update LLVM to 15.0.7
  • Loading branch information
vchuravy authored May 10, 2023
2 parents 056112e + 77c13ad commit 21d4c2f
Show file tree
Hide file tree
Showing 26 changed files with 544 additions and 540 deletions.
2 changes: 1 addition & 1 deletion Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
224 changes: 108 additions & 116 deletions deps/checksums/clang

Large diffs are not rendered by default.

224 changes: 108 additions & 116 deletions deps/checksums/lld

Large diffs are not rendered by default.

452 changes: 218 additions & 234 deletions deps/checksums/llvm

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deps/clang.version
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## jll artifact
# Clang (paired with LLVM, only here as a JLL download)
CLANG_JLL_NAME := Clang
CLANG_JLL_VER := 14.0.6+3
CLANG_JLL_VER := 15.0.7+5
2 changes: 1 addition & 1 deletion deps/lld.version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## jll artifact
LLD_JLL_NAME := LLD
LLD_JLL_VER := 14.0.6+3
LLD_JLL_VER := 15.0.7+5
4 changes: 2 additions & 2 deletions deps/llvm-tools.version
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## jll artifact
# LLVM_tools (downloads LLVM_jll to get things like `lit` and `opt`)
LLVM_TOOLS_JLL_NAME := LLVM
LLVM_TOOLS_JLL_VER := 14.0.6+3
LLVM_TOOLS_ASSERT_JLL_VER := 14.0.6+3
LLVM_TOOLS_JLL_VER := 15.0.7+5
LLVM_TOOLS_ASSERT_JLL_VER := 15.0.7+5
9 changes: 4 additions & 5 deletions deps/llvm.version
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
## jll artifact
LLVM_JLL_NAME := libLLVM
LLVM_ASSERT_JLL_VER := 14.0.5+3

LLVM_ASSERT_JLL_VER := 15.0.7+5
## source build
LLVM_VER := 14.0.5
LLVM_BRANCH=julia-14.0.6-3
LLVM_SHA1=julia-14.0.6-3
LLVM_VER := 15.0.7
LLVM_BRANCH=julia-15.0.7-5
LLVM_SHA1=julia-15.0.7-5
18 changes: 14 additions & 4 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9073,16 +9073,24 @@ 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.
clopt = llvmopts.lookup("combiner-store-merge-dependence-limit");
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;
Expand Down Expand Up @@ -9158,7 +9166,9 @@ extern "C" JL_DLLEXPORT_CODEGEN void jl_init_codegen_impl(void)
extern "C" JL_DLLEXPORT_CODEGEN 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();
}

Expand Down
3 changes: 0 additions & 3 deletions src/jitlayers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,9 +1309,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
Expand Down
6 changes: 2 additions & 4 deletions src/jitlayers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/llvm-alloc-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions src/llvm-julia-licm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
LLVM_DEBUG(dbgs() << "Sunk gc_preserve_end: " << *call << "\n");
REMARK([&](){
return OptimizationRemark(DEBUG_TYPE, "Sunk", call)
Expand Down
1 change: 1 addition & 0 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"})) {
Expand Down
1 change: 1 addition & 0 deletions src/llvm-lower-handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 3 additions & 0 deletions src/llvm-multiversioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -784,6 +786,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++) {
Expand Down
2 changes: 2 additions & 0 deletions src/llvm-ptls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -159,6 +160,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));
Expand Down
18 changes: 11 additions & 7 deletions src/llvm-simdloop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ static bool markLoopInfo(Module &M, Function *marker, function_ref<LoopInfo &(Fu
Instruction *I = cast<Instruction>(U);
ToDelete.push_back(I);

OptimizationRemarkEmitter ORE(I->getParent()->getParent());
LoopInfo &LI = GetLI(*I->getParent()->getParent());
Loop *L = LI.getLoopFor(I->getParent());
I->removeFromParent();
if (!L)
BasicBlock *B = I->getParent();
OptimizationRemarkEmitter ORE(B->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;
Expand Down Expand Up @@ -209,8 +211,8 @@ static bool markLoopInfo(Module &M, Function *marker, function_ref<LoopInfo &(Fu

LLVM_DEBUG(dbgs() << "LSL: simd: " << simd << " ivdep: " << ivdep << "\n");

REMARK([&]() {
return OptimizationRemarkAnalysis(DEBUG_TYPE, "Loop SIMD Flags", I)
REMARK([=]() {
return OptimizationRemarkAnalysis(DEBUG_TYPE, "Loop SIMD Flags", I->getDebugLoc(), B)
<< "Loop marked for SIMD vectorization with flags { \"simd\": " << (simd ? "true" : "false") << ", \"ivdep\": " << (ivdep ? "true" : "false") << " }";
});

Expand Down Expand Up @@ -258,6 +260,8 @@ static bool markLoopInfo(Module &M, Function *marker, function_ref<LoopInfo &(Fu
}
}

I->removeFromParent();

Changed = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/llvm-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 4 additions & 3 deletions src/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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(/*NonTrivial*/true, true));
LPM2.addPass(LICMPass(LICMOptions()));
JULIA_PASS(LPM2.addPass(JuliaLICMPass()));
//LICM needs MemorySSA now, so we must use it
Expand All @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions stdlib/LLD_jll/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "LLD_jll"
uuid = "d55e3150-da41-5e91-b323-ecfd1eec6109"
version = "14.0.6+3"
version = "15.0.7+5"

[deps]
Zlib_jll = "83775a58-1f1d-513f-b197-d71354ab007a"
Expand All @@ -10,7 +10,7 @@ Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"

[compat]
julia = "1.9"
libLLVM_jll = "14.0.6"
libLLVM_jll = "15.0.7"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
2 changes: 1 addition & 1 deletion stdlib/libLLVM_jll/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "libLLVM_jll"
uuid = "8f36deef-c2a5-5394-99ed-8e07531fb29a"
version = "14.0.6+3"
version = "15.0.7+5"

[deps]
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Expand Down
3 changes: 3 additions & 0 deletions test/clangsa/MissingRoots.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading

0 comments on commit 21d4c2f

Please sign in to comment.