Skip to content

Commit 677ce6d

Browse files
committed
[LLVM] Adapt to LLVM 13 changes
1 parent bf5ac8c commit 677ce6d

File tree

7 files changed

+39
-4
lines changed

7 files changed

+39
-4
lines changed

src/cgutils.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2757,8 +2757,14 @@ static jl_value_t *static_constant_instance(Constant *constant, jl_value_t *jt)
27572757
size_t nargs;
27582758
if (const auto *CC = dyn_cast<ConstantAggregate>(constant))
27592759
nargs = CC->getNumOperands();
2760-
else if (const auto *CAZ = dyn_cast<ConstantAggregateZero>(constant))
2760+
else if (const auto *CAZ = dyn_cast<ConstantAggregateZero>(constant)) {
2761+
#if JL_LLVM_VERSION >= 130000
2762+
// SVE: Elsewhere we use `getMinKownValue`
2763+
nargs = CAZ->getElementCount().getFixedValue();
2764+
#else
27612765
nargs = CAZ->getNumElements();
2766+
#endif
2767+
}
27622768
else if (const auto *CDS = dyn_cast<ConstantDataSequential>(constant))
27632769
nargs = CDS->getNumElements();
27642770
else

src/codegen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7394,7 +7394,7 @@ static std::pair<std::unique_ptr<Module>, jl_llvm_functions_t>
73947394
#endif
73957395
continue;
73967396
}
7397-
assert(find(pred_begin(PhiBB), pred_end(PhiBB), FromBB) != pred_end(PhiBB)); // consistency check
7397+
assert(std::find(pred_begin(PhiBB), pred_end(PhiBB), FromBB) != pred_end(PhiBB)); // consistency check
73987398
TerminatorInst *terminator = FromBB->getTerminator();
73997399
if (!terminator->getParent()->getUniqueSuccessor()) {
74007400
// Can't use `llvm::SplitCriticalEdge` here because

src/disasm.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,16 @@ static void jl_dump_asm_internal(
857857
assert(MRI && "Unable to create target register info!");
858858

859859
std::unique_ptr<MCObjectFileInfo> MOFI(new MCObjectFileInfo());
860+
#if JL_LLVM_VERSION >= 130000
861+
MCSubtargetInfo *MSTI = TheTarget->createMCSubtargetInfo(TheTriple.str(), cpu, features);
862+
assert(MSTI && "Unable to create subtarget info!");
863+
864+
MCContext Ctx(TheTriple, MAI.get(), MRI.get(), MSTI, &SrcMgr);
865+
MOFI->initMCObjectFileInfo(Ctx, /* PIC */ false, /* LargeCodeModel */ false);
866+
#else
860867
MCContext Ctx(MAI.get(), MRI.get(), MOFI.get(), &SrcMgr);
861868
MOFI->InitMCObjectFileInfo(TheTriple, /* PIC */ false, Ctx);
869+
#endif
862870

863871
// Set up Subtarget and Disassembler
864872
std::unique_ptr<MCSubtargetInfo>

src/jitlayers.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
#include <llvm/Analysis/TargetTransformInfo.h>
1111
#include <llvm/ExecutionEngine/Orc/CompileUtils.h>
1212
#include <llvm/ExecutionEngine/Orc/ExecutionUtils.h>
13+
#if JL_LLVM_VERSION >= 130000
14+
#include <llvm/ExecutionEngine/Orc/ExecutorProcessControl.h>
15+
#endif
1316
#include <llvm/Support/DynamicLibrary.h>
1417
#include <llvm/Support/FormattedStream.h>
1518
#include <llvm/Support/SmallVectorMemoryBuffer.h>
@@ -654,7 +657,11 @@ JuliaOJIT::JuliaOJIT(TargetMachine &TM, LLVMContext *LLVMCtx)
654657
MemMgr(createRTDyldMemoryManager()),
655658
JuliaListener(CreateJuliaJITEventListener()),
656659
TSCtx(std::unique_ptr<LLVMContext>(LLVMCtx)),
660+
#if JL_LLVM_VERSION >= 130000
661+
ES(cantFail(orc::SelfExecutorProcessControl::Create())),
662+
#else
657663
ES(),
664+
#endif
658665
GlobalJD(ES.createBareJITDylib("JuliaGlobals")),
659666
JD(ES.createBareJITDylib("JuliaOJIT")),
660667
ObjectLayer(

src/llvm-late-gc-lowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ void LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) {
709709
else
710710
Numbers[i] = Number;
711711
}
712-
if (auto VTy = dyn_cast<VectorType>(SI->getType())) {
712+
if (auto VTy = dyn_cast<FixedVectorType>(SI->getType())) {
713713
if (NumRoots != Numbers.size()) {
714714
// broadcast the scalar root number to fill the vector
715715
assert(NumRoots == 1);
@@ -736,11 +736,12 @@ void LateLowerGCFrame::LiftPhi(State &S, PHINode *Phi) {
736736
SmallVector<PHINode *, 2> lifted;
737737
std::vector<int> Numbers;
738738
unsigned NumRoots = 1;
739-
if (auto VTy = dyn_cast<VectorType>(Phi->getType())) {
739+
if (auto VTy = dyn_cast<FixedVectorType>(Phi->getType())) {
740740
NumRoots = VTy->getNumElements();
741741
Numbers.resize(NumRoots);
742742
}
743743
else {
744+
// TODO: SVE
744745
assert(isa<PointerType>(Phi->getType()) && "unimplemented");
745746
}
746747
for (unsigned i = 0; i < NumRoots; ++i) {

src/llvm-multiversioning.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,12 @@ void CloneCtx::clone_function(Function *F, Function *new_f, ValueToValueMapTy &v
403403
vmap[&*J] = &*DestI++;
404404
}
405405
SmallVector<ReturnInst*,8> Returns;
406+
#if JL_LLVM_VERSION >= 130000
407+
// We are cloning into the same module
408+
CloneFunctionInto(new_f, F, vmap, CloneFunctionChangeType::GlobalChanges, Returns);
409+
#else
406410
CloneFunctionInto(new_f, F, vmap, true, Returns);
411+
#endif
407412
}
408413

409414
// Clone all clone_all targets. Makes sure that the base targets are all available.

src/llvm-remove-addrspaces.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,11 @@ bool RemoveAddrspacesPass::runOnModule(Module &M)
345345
for (auto MD : MDs)
346346
NGV->addMetadata(
347347
MD.first,
348+
#if JL_LLVM_VERSION >= 130000
349+
*MapMetadata(MD.second, VMap));
350+
#else
348351
*MapMetadata(MD.second, VMap, RF_MoveDistinctMDs));
352+
#endif
349353

350354
copyComdat(NGV, GV);
351355

@@ -372,7 +376,11 @@ bool RemoveAddrspacesPass::runOnModule(Module &M)
372376
NF,
373377
F,
374378
VMap,
379+
#if JL_LLVM_VERSION >= 130000
380+
CloneFunctionChangeType::GlobalChanges,
381+
#else
375382
/*ModuleLevelChanges=*/true,
383+
#endif
376384
Returns,
377385
"",
378386
nullptr,

0 commit comments

Comments
 (0)