Skip to content

Commit

Permalink
Fix VMVX StrideBufferDescriptor initialization (#14541)
Browse files Browse the repository at this point in the history
GCC complains about the maybe uninitialized MemRefType, but it is set by
the buffer analyzer.

Change StrideBufferDescriptor from struct to class and fix the initialization.
  • Loading branch information
hcindyl authored Aug 3, 2023
1 parent 54a9cca commit 83284b2
Showing 1 changed file with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,14 @@ bool verifyMemRefInnerDimsContiguousRowMajor(MemRefType type) {
return true;
}

struct StridedBufferDescriptor {
MemRefType memRefType;

class StridedBufferDescriptor {
public:
// Size/offset/strides of the buffer.
Value offset;
SmallVector<Value> sizes;
SmallVector<Value> strides;

StridedBufferDescriptor() = default;
StridedBufferDescriptor(MemRefType memRefType) : memRefType(memRefType) {}

unsigned getRank() { return strides.size(); }
Type getElementType() { return memRefType.getElementType(); }
Expand All @@ -149,8 +148,8 @@ struct StridedBufferDescriptor {
// The base !util.buffer
Value baseBuffer;
friend class StridedBufferAnalysis;
MemRefType memRefType;
};

/// Holds the results of an analysis which indicates whether a given memref
/// can be decomposed into fully known static or dynamic base, strides, offset
/// and sizes. If this holds, then a StridedBufferDescriptor is guaranteed to
Expand Down Expand Up @@ -187,8 +186,7 @@ class StridedBufferAnalysis {
builder.setInsertionPointAfterValue(buffer);

Location loc = buffer.getLoc();
desc = StridedBufferDescriptor();
desc->memRefType = llvm::cast<MemRefType>(buffer.getType());
desc = StridedBufferDescriptor(llvm::cast<MemRefType>(buffer.getType()));

int rank = getType().getRank();
SmallVector<Type> sizeStrideTypes;
Expand Down

0 comments on commit 83284b2

Please sign in to comment.