aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/Analysis.cpp
diff options
context:
space:
mode:
authorPaul Walker <paul.walker@arm.com>2024-02-21 13:03:24 +0000
committerGitHub <noreply@github.com>2024-02-21 13:03:24 +0000
commit28fb2b33c2f43f6a8057e398eb899eb61e6652e9 (patch)
treea2a87ab7c4b12082f5a7326273d85c1403b07b41 /llvm/lib/CodeGen/Analysis.cpp
parent02e17ab1b97a8c0dc22facc8c66850e5aca28b60 (diff)
downloadllvm-28fb2b33c2f43f6a8057e398eb899eb61e6652e9.zip
llvm-28fb2b33c2f43f6a8057e398eb899eb61e6652e9.tar.gz
llvm-28fb2b33c2f43f6a8057e398eb899eb61e6652e9.tar.bz2
[LLVM][SelectionDAG] Reduce number of ComputeValueVTs variants. (#75614)
This is another step in the direction of fixing the `Fixed(0) != Scalable(0)` bugbear, although whilst weird I don't believe it's causing us any real issues.
Diffstat (limited to 'llvm/lib/CodeGen/Analysis.cpp')
-rw-r--r--llvm/lib/CodeGen/Analysis.cpp49
1 files changed, 6 insertions, 43 deletions
diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp
index 1994e6a..af7643d 100644
--- a/llvm/lib/CodeGen/Analysis.cpp
+++ b/llvm/lib/CodeGen/Analysis.cpp
@@ -81,6 +81,9 @@ void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
SmallVectorImpl<EVT> *MemVTs,
SmallVectorImpl<TypeSize> *Offsets,
TypeSize StartingOffset) {
+ assert((Ty->isScalableTy() == StartingOffset.isScalable() ||
+ StartingOffset.isZero()) &&
+ "Offset/TypeSize mismatch!");
// Given a struct type, recursively traverse the elements.
if (StructType *STy = dyn_cast<StructType>(Ty)) {
// If the Offsets aren't needed, don't query the struct layout. This allows
@@ -92,8 +95,8 @@ void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
EE = STy->element_end();
EI != EE; ++EI) {
// Don't compute the element offset if we didn't get a StructLayout above.
- TypeSize EltOffset = SL ? SL->getElementOffset(EI - EB)
- : TypeSize::get(0, StartingOffset.isScalable());
+ TypeSize EltOffset =
+ SL ? SL->getElementOffset(EI - EB) : TypeSize::getZero();
ComputeValueVTs(TLI, DL, *EI, ValueVTs, MemVTs, Offsets,
StartingOffset + EltOffset);
}
@@ -121,50 +124,10 @@ void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
Type *Ty, SmallVectorImpl<EVT> &ValueVTs,
- SmallVectorImpl<TypeSize> *Offsets,
- TypeSize StartingOffset) {
- return ComputeValueVTs(TLI, DL, Ty, ValueVTs, /*MemVTs=*/nullptr, Offsets,
- StartingOffset);
-}
-
-void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
- Type *Ty, SmallVectorImpl<EVT> &ValueVTs,
- SmallVectorImpl<TypeSize> *Offsets,
- uint64_t StartingOffset) {
- TypeSize Offset = TypeSize::get(StartingOffset, Ty->isScalableTy());
- return ComputeValueVTs(TLI, DL, Ty, ValueVTs, Offsets, Offset);
-}
-
-void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
- Type *Ty, SmallVectorImpl<EVT> &ValueVTs,
- SmallVectorImpl<uint64_t> *FixedOffsets,
- uint64_t StartingOffset) {
- TypeSize Offset = TypeSize::get(StartingOffset, Ty->isScalableTy());
- if (FixedOffsets) {
- SmallVector<TypeSize, 4> Offsets;
- ComputeValueVTs(TLI, DL, Ty, ValueVTs, &Offsets, Offset);
- for (TypeSize Offset : Offsets)
- FixedOffsets->push_back(Offset.getFixedValue());
- } else {
- ComputeValueVTs(TLI, DL, Ty, ValueVTs, nullptr, Offset);
- }
-}
-
-void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
- Type *Ty, SmallVectorImpl<EVT> &ValueVTs,
- SmallVectorImpl<EVT> *MemVTs,
- SmallVectorImpl<TypeSize> *Offsets,
- uint64_t StartingOffset) {
- TypeSize Offset = TypeSize::get(StartingOffset, Ty->isScalableTy());
- return ComputeValueVTs(TLI, DL, Ty, ValueVTs, MemVTs, Offsets, Offset);
-}
-
-void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
- Type *Ty, SmallVectorImpl<EVT> &ValueVTs,
SmallVectorImpl<EVT> *MemVTs,
SmallVectorImpl<uint64_t> *FixedOffsets,
uint64_t StartingOffset) {
- TypeSize Offset = TypeSize::get(StartingOffset, Ty->isScalableTy());
+ TypeSize Offset = TypeSize::getFixed(StartingOffset);
if (FixedOffsets) {
SmallVector<TypeSize, 4> Offsets;
ComputeValueVTs(TLI, DL, Ty, ValueVTs, MemVTs, &Offsets, Offset);