Skip to content

Commit 47f9139

Browse files
authored
codegen: replace deprecated llvm::VectorType::getNumElements with new APIs (#41144)
1 parent de1444c commit 47f9139

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

src/llvm-late-gc-lowering.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,14 @@ CountTrackedPointers::CountTrackedPointers(Type *T) {
396396
}
397397
if (isa<ArrayType>(T))
398398
count *= cast<ArrayType>(T)->getNumElements();
399-
else if (isa<VectorType>(T))
399+
else if (isa<VectorType>(T)) {
400+
#if JL_LLVM_VERSION >= 120000
401+
ElementCount EC = cast<VectorType>(T)->getElementCount();
402+
count *= EC.getKnownMinValue();
403+
#else
400404
count *= cast<VectorType>(T)->getNumElements();
405+
#endif
406+
}
401407
}
402408
if (count == 0)
403409
all = false;
@@ -408,8 +414,14 @@ unsigned getCompositeNumElements(Type *T) {
408414
return ST->getNumElements();
409415
else if (auto *AT = dyn_cast<ArrayType>(T))
410416
return AT->getNumElements();
411-
else
417+
else {
418+
#if JL_LLVM_VERSION >= 120000
419+
ElementCount EC = cast<VectorType>(T)->getElementCount();
420+
return EC.getKnownMinValue();
421+
#else
412422
return cast<VectorType>(T)->getNumElements();
423+
#endif
424+
}
413425
}
414426

415427
// Walk through a Type, and record the element path to every tracked value inside
@@ -625,8 +637,14 @@ void LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) {
625637
}
626638
std::vector<int> Numbers;
627639
unsigned NumRoots = 1;
628-
if (auto VTy = dyn_cast<VectorType>(SI->getType()))
640+
if (auto VTy = dyn_cast<VectorType>(SI->getType())) {
641+
#if JL_LLVM_VERSION >= 120000
642+
ElementCount EC = VTy->getElementCount();
643+
Numbers.resize(EC.getKnownMinValue(), -1);
644+
#else
629645
Numbers.resize(VTy->getNumElements(), -1);
646+
#endif
647+
}
630648
else
631649
assert(isa<PointerType>(SI->getType()) && "unimplemented");
632650
assert(!isTrackedValue(SI));
@@ -686,7 +704,12 @@ void LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) {
686704
assert(NumRoots == 1);
687705
int Number = Numbers[0];
688706
Numbers.resize(0);
707+
#if JL_LLVM_VERSION >= 120000
708+
ElementCount EC = VTy->getElementCount();
709+
Numbers.resize(EC.getKnownMinValue(), Number);
710+
#else
689711
Numbers.resize(VTy->getNumElements(), Number);
712+
#endif
690713
}
691714
}
692715
if (!isa<PointerType>(SI->getType()))

0 commit comments

Comments
 (0)