You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
6.8 KiB
173 lines
6.8 KiB
This patch is from the julialang repository:
|
|
https://github.com/JuliaLang/julia/commit/677ce6d3.patch
|
|
but reference comes form ARCH Linux juia package
|
|
https://github.com/archlinux/svntogit-community/tree/packages/julia/trunk
|
|
|
|
From 677ce6d3adc2f70886f72795b0e5c739e75730ee Mon Sep 17 00:00:00 2001
|
|
From: Valentin Churavy <v.churavy@gmail.com>
|
|
Date: Sat, 28 Aug 2021 16:48:32 +0200
|
|
Subject: [PATCH] [LLVM] Adapt to LLVM 13 changes
|
|
|
|
---
|
|
src/cgutils.cpp | 8 +++++++-
|
|
src/codegen.cpp | 2 +-
|
|
src/disasm.cpp | 8 ++++++++
|
|
src/jitlayers.cpp | 7 +++++++
|
|
src/llvm-late-gc-lowering.cpp | 5 +++--
|
|
src/llvm-multiversioning.cpp | 5 +++++
|
|
src/llvm-remove-addrspaces.cpp | 8 ++++++++
|
|
7 files changed, 39 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/cgutils.cpp b/src/cgutils.cpp
|
|
index 4e9917b6b078..928e1a07b2f1 100644
|
|
--- a/src/cgutils.cpp
|
|
+++ b/src/cgutils.cpp
|
|
@@ -2757,8 +2757,14 @@ static jl_value_t *static_constant_instance(Constant *constant, jl_value_t *jt)
|
|
size_t nargs;
|
|
if (const auto *CC = dyn_cast<ConstantAggregate>(constant))
|
|
nargs = CC->getNumOperands();
|
|
- else if (const auto *CAZ = dyn_cast<ConstantAggregateZero>(constant))
|
|
+ else if (const auto *CAZ = dyn_cast<ConstantAggregateZero>(constant)) {
|
|
+#if JL_LLVM_VERSION >= 130000
|
|
+ // SVE: Elsewhere we use `getMinKownValue`
|
|
+ nargs = CAZ->getElementCount().getFixedValue();
|
|
+#else
|
|
nargs = CAZ->getNumElements();
|
|
+#endif
|
|
+ }
|
|
else if (const auto *CDS = dyn_cast<ConstantDataSequential>(constant))
|
|
nargs = CDS->getNumElements();
|
|
else
|
|
diff --git a/src/codegen.cpp b/src/codegen.cpp
|
|
index 5cc9f66ffaef..9000513151fe 100644
|
|
--- a/src/codegen.cpp
|
|
+++ b/src/codegen.cpp
|
|
@@ -7394,7 +7394,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
|
|
#endif
|
|
continue;
|
|
}
|
|
- assert(find(pred_begin(PhiBB), pred_end(PhiBB), FromBB) != pred_end(PhiBB)); // consistency check
|
|
+ assert(std::find(pred_begin(PhiBB), pred_end(PhiBB), FromBB) != pred_end(PhiBB)); // consistency check
|
|
TerminatorInst *terminator = FromBB->getTerminator();
|
|
if (!terminator->getParent()->getUniqueSuccessor()) {
|
|
// Can't use `llvm::SplitCriticalEdge` here because
|
|
diff --git a/src/disasm.cpp b/src/disasm.cpp
|
|
index 6157873ad71c..589f618396ea 100644
|
|
--- a/src/disasm.cpp
|
|
+++ b/src/disasm.cpp
|
|
@@ -857,8 +857,16 @@ static void jl_dump_asm_internal(
|
|
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!");
|
|
+
|
|
+ MCContext Ctx(TheTriple, MAI.get(), MRI.get(), MSTI, &SrcMgr);
|
|
+ MOFI->initMCObjectFileInfo(Ctx, /* PIC */ false, /* LargeCodeModel */ false);
|
|
+#else
|
|
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>
|
|
diff --git a/src/jitlayers.cpp b/src/jitlayers.cpp
|
|
index 60b1903aaa80..12497cadf491 100644
|
|
--- a/src/jitlayers.cpp
|
|
+++ b/src/jitlayers.cpp
|
|
@@ -10,6 +10,9 @@
|
|
#include <llvm/Analysis/TargetTransformInfo.h>
|
|
#include <llvm/ExecutionEngine/Orc/CompileUtils.h>
|
|
#include <llvm/ExecutionEngine/Orc/ExecutionUtils.h>
|
|
+#if JL_LLVM_VERSION >= 130000
|
|
+#include <llvm/ExecutionEngine/Orc/ExecutorProcessControl.h>
|
|
+#endif
|
|
#include <llvm/Support/DynamicLibrary.h>
|
|
#include <llvm/Support/FormattedStream.h>
|
|
#include <llvm/Support/SmallVectorMemoryBuffer.h>
|
|
@@ -654,7 +657,11 @@ JuliaOJIT::JuliaOJIT(TargetMachine &TM, LLVMContext *LLVMCtx)
|
|
MemMgr(createRTDyldMemoryManager()),
|
|
JuliaListener(CreateJuliaJITEventListener()),
|
|
TSCtx(std::unique_ptr<LLVMContext>(LLVMCtx)),
|
|
+#if JL_LLVM_VERSION >= 130000
|
|
+ ES(cantFail(orc::SelfExecutorProcessControl::Create())),
|
|
+#else
|
|
ES(),
|
|
+#endif
|
|
GlobalJD(ES.createBareJITDylib("JuliaGlobals")),
|
|
JD(ES.createBareJITDylib("JuliaOJIT")),
|
|
ObjectLayer(
|
|
diff --git a/src/llvm-late-gc-lowering.cpp b/src/llvm-late-gc-lowering.cpp
|
|
index 0aac7638be0d..db8b19bacea5 100644
|
|
--- a/src/llvm-late-gc-lowering.cpp
|
|
+++ b/src/llvm-late-gc-lowering.cpp
|
|
@@ -709,7 +709,7 @@ void LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) {
|
|
else
|
|
Numbers[i] = Number;
|
|
}
|
|
- if (auto VTy = dyn_cast<VectorType>(SI->getType())) {
|
|
+ if (auto VTy = dyn_cast<FixedVectorType>(SI->getType())) {
|
|
if (NumRoots != Numbers.size()) {
|
|
// broadcast the scalar root number to fill the vector
|
|
assert(NumRoots == 1);
|
|
@@ -736,11 +736,12 @@ void LateLowerGCFrame::LiftPhi(State &S, PHINode *Phi) {
|
|
SmallVector<PHINode *, 2> lifted;
|
|
std::vector<int> Numbers;
|
|
unsigned NumRoots = 1;
|
|
- if (auto VTy = dyn_cast<VectorType>(Phi->getType())) {
|
|
+ if (auto VTy = dyn_cast<FixedVectorType>(Phi->getType())) {
|
|
NumRoots = VTy->getNumElements();
|
|
Numbers.resize(NumRoots);
|
|
}
|
|
else {
|
|
+ // TODO: SVE
|
|
assert(isa<PointerType>(Phi->getType()) && "unimplemented");
|
|
}
|
|
for (unsigned i = 0; i < NumRoots; ++i) {
|
|
diff --git a/src/llvm-multiversioning.cpp b/src/llvm-multiversioning.cpp
|
|
index 68081eb53d3a..a82600162fa9 100644
|
|
--- a/src/llvm-multiversioning.cpp
|
|
+++ b/src/llvm-multiversioning.cpp
|
|
@@ -403,7 +403,12 @@ void CloneCtx::clone_function(Function *F, Function *new_f, ValueToValueMapTy &v
|
|
vmap[&*J] = &*DestI++;
|
|
}
|
|
SmallVector<ReturnInst*,8> Returns;
|
|
+#if JL_LLVM_VERSION >= 130000
|
|
+ // We are cloning into the same module
|
|
+ CloneFunctionInto(new_f, F, vmap, CloneFunctionChangeType::GlobalChanges, Returns);
|
|
+#else
|
|
CloneFunctionInto(new_f, F, vmap, true, Returns);
|
|
+#endif
|
|
}
|
|
|
|
// Clone all clone_all targets. Makes sure that the base targets are all available.
|
|
diff --git a/src/llvm-remove-addrspaces.cpp b/src/llvm-remove-addrspaces.cpp
|
|
index ada10c8d5f1f..7c6ef093fbce 100644
|
|
--- a/src/llvm-remove-addrspaces.cpp
|
|
+++ b/src/llvm-remove-addrspaces.cpp
|
|
@@ -345,7 +345,11 @@ bool RemoveAddrspacesPass::runOnModule(Module &M)
|
|
for (auto MD : MDs)
|
|
NGV->addMetadata(
|
|
MD.first,
|
|
+#if JL_LLVM_VERSION >= 130000
|
|
+ *MapMetadata(MD.second, VMap));
|
|
+#else
|
|
*MapMetadata(MD.second, VMap, RF_MoveDistinctMDs));
|
|
+#endif
|
|
|
|
copyComdat(NGV, GV);
|
|
|
|
@@ -372,7 +376,11 @@ bool RemoveAddrspacesPass::runOnModule(Module &M)
|
|
NF,
|
|
F,
|
|
VMap,
|
|
+#if JL_LLVM_VERSION >= 130000
|
|
+ CloneFunctionChangeType::GlobalChanges,
|
|
+#else
|
|
/*ModuleLevelChanges=*/true,
|
|
+#endif
|
|
Returns,
|
|
"",
|
|
nullptr,
|