[PATCH] D158115: [SelectionDAG][RISCV][SVE] Harden fixed offset version of ComputeValueVTs against scalable offsets.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 21 10:36:44 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe620eac75e47: [SelectionDAG][RISCV][SVE] Harden fixed offset version of ComputeValueVTs… (authored by craig.topper).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158115/new/
https://reviews.llvm.org/D158115
Files:
llvm/include/llvm/Support/TypeSize.h
llvm/lib/CodeGen/Analysis.cpp
Index: llvm/lib/CodeGen/Analysis.cpp
===================================================================
--- llvm/lib/CodeGen/Analysis.cpp
+++ llvm/lib/CodeGen/Analysis.cpp
@@ -140,15 +140,14 @@
SmallVectorImpl<uint64_t> *FixedOffsets,
uint64_t StartingOffset) {
TypeSize Offset = TypeSize::get(StartingOffset, Ty->isScalableTy());
- SmallVector<TypeSize, 4> Offsets;
- if (FixedOffsets)
+ if (FixedOffsets) {
+ SmallVector<TypeSize, 4> Offsets;
ComputeValueVTs(TLI, DL, Ty, ValueVTs, &Offsets, Offset);
- else
- ComputeValueVTs(TLI, DL, Ty, ValueVTs, nullptr, Offset);
-
- if (FixedOffsets)
for (TypeSize Offset : Offsets)
- FixedOffsets->push_back(Offset.getKnownMinValue());
+ FixedOffsets->push_back(Offset.getFixedValue());
+ } else {
+ ComputeValueVTs(TLI, DL, Ty, ValueVTs, nullptr, Offset);
+ }
}
void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
@@ -166,15 +165,14 @@
SmallVectorImpl<uint64_t> *FixedOffsets,
uint64_t StartingOffset) {
TypeSize Offset = TypeSize::get(StartingOffset, Ty->isScalableTy());
- SmallVector<TypeSize, 4> Offsets;
- if (FixedOffsets)
+ if (FixedOffsets) {
+ SmallVector<TypeSize, 4> Offsets;
ComputeValueVTs(TLI, DL, Ty, ValueVTs, MemVTs, &Offsets, Offset);
- else
- ComputeValueVTs(TLI, DL, Ty, ValueVTs, MemVTs, nullptr, Offset);
-
- if (FixedOffsets)
for (TypeSize Offset : Offsets)
- FixedOffsets->push_back(Offset.getKnownMinValue());
+ FixedOffsets->push_back(Offset.getFixedValue());
+ } else {
+ ComputeValueVTs(TLI, DL, Ty, ValueVTs, MemVTs, nullptr, Offset);
+ }
}
void llvm::computeValueLLTs(const DataLayout &DL, Type &Ty,
Index: llvm/include/llvm/Support/TypeSize.h
===================================================================
--- llvm/include/llvm/Support/TypeSize.h
+++ llvm/include/llvm/Support/TypeSize.h
@@ -180,7 +180,7 @@
// Use in places where a scalable count doesn't make sense (e.g. non-vector
// types, or vectors in backends which don't support scalable vectors).
constexpr ScalarTy getFixedValue() const {
- assert(!isScalable() &&
+ assert((!isScalable() || isZero()) &&
"Request for a fixed element count on a scalable object");
return getKnownMinValue();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158115.552075.patch
Type: text/x-patch
Size: 2389 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230821/77ecb7e6/attachment.bin>
More information about the llvm-commits
mailing list