Skip to content

Commit

Permalink
codegen: replace deprecated llvm::VectorType::getNumElements with new…
Browse files Browse the repository at this point in the history
… APIs (JuliaLang#41144)
  • Loading branch information
TH3CHARLie committed Jun 9, 2021
1 parent de1444c commit 47f9139
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,14 @@ CountTrackedPointers::CountTrackedPointers(Type *T) {
}
if (isa<ArrayType>(T))
count *= cast<ArrayType>(T)->getNumElements();
else if (isa<VectorType>(T))
else if (isa<VectorType>(T)) {
#if JL_LLVM_VERSION >= 120000
ElementCount EC = cast<VectorType>(T)->getElementCount();
count *= EC.getKnownMinValue();
#else
count *= cast<VectorType>(T)->getNumElements();
#endif
}
}
if (count == 0)
all = false;
Expand All @@ -408,8 +414,14 @@ unsigned getCompositeNumElements(Type *T) {
return ST->getNumElements();
else if (auto *AT = dyn_cast<ArrayType>(T))
return AT->getNumElements();
else
else {
#if JL_LLVM_VERSION >= 120000
ElementCount EC = cast<VectorType>(T)->getElementCount();
return EC.getKnownMinValue();
#else
return cast<VectorType>(T)->getNumElements();
#endif
}
}

// Walk through a Type, and record the element path to every tracked value inside
Expand Down Expand Up @@ -625,8 +637,14 @@ void LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) {
}
std::vector<int> Numbers;
unsigned NumRoots = 1;
if (auto VTy = dyn_cast<VectorType>(SI->getType()))
if (auto VTy = dyn_cast<VectorType>(SI->getType())) {
#if JL_LLVM_VERSION >= 120000
ElementCount EC = VTy->getElementCount();
Numbers.resize(EC.getKnownMinValue(), -1);
#else
Numbers.resize(VTy->getNumElements(), -1);
#endif
}
else
assert(isa<PointerType>(SI->getType()) && "unimplemented");
assert(!isTrackedValue(SI));
Expand Down Expand Up @@ -686,7 +704,12 @@ void LateLowerGCFrame::LiftSelect(State &S, SelectInst *SI) {
assert(NumRoots == 1);
int Number = Numbers[0];
Numbers.resize(0);
#if JL_LLVM_VERSION >= 120000
ElementCount EC = VTy->getElementCount();
Numbers.resize(EC.getKnownMinValue(), Number);
#else
Numbers.resize(VTy->getNumElements(), Number);
#endif
}
}
if (!isa<PointerType>(SI->getType()))
Expand Down

0 comments on commit 47f9139

Please sign in to comment.