Skip to content

Commit 69d3793

Browse files
authored
[mlir][sroa] Update name of subelement types in destructurable slots (llvm#97226)
The `elementPtrs` has changed meaning over time and the name is now outdated which may be confusing. This PR updates it to a name representative of current usage.
1 parent cd68532 commit 69d3793

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

mlir/include/mlir/Interfaces/MemorySlotInterfaces.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct MemorySlot {
2727
/// Memory slot attached with information about its destructuring procedure.
2828
struct DestructurableMemorySlot : public MemorySlot {
2929
/// Maps an index within the memory slot to the corresponding subelement type.
30-
DenseMap<Attribute, Type> elementPtrs;
30+
DenseMap<Attribute, Type> subelementTypes;
3131
};
3232

3333
/// Returned by operation promotion logic requesting the deletion of an

mlir/lib/Dialect/LLVMIR/IR/LLVMMemorySlot.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,12 +841,12 @@ bool LLVM::GEPOp::canRewire(const DestructurableMemorySlot &slot,
841841
return false;
842842
auto indexAttr =
843843
IntegerAttr::get(IntegerType::get(getContext(), 32), accessInfo->index);
844-
assert(slot.elementPtrs.contains(indexAttr));
844+
assert(slot.subelementTypes.contains(indexAttr));
845845
usedIndices.insert(indexAttr);
846846

847847
// The remainder of the subslot should be accesses in-bounds. Thus, we create
848848
// a dummy slot with the size of the remainder.
849-
Type subslotType = slot.elementPtrs.lookup(indexAttr);
849+
Type subslotType = slot.subelementTypes.lookup(indexAttr);
850850
uint64_t slotSize = dataLayout.getTypeSize(subslotType);
851851
LLVM::LLVMArrayType remainingSlotType =
852852
getByteArrayType(getContext(), slotSize - accessInfo->subslotOffset);
@@ -923,7 +923,7 @@ static bool definitelyWritesOnlyWithinSlot(MemIntr op, const MemorySlot &slot,
923923
/// into them.
924924
static bool areAllIndicesI32(const DestructurableMemorySlot &slot) {
925925
Type i32 = IntegerType::get(slot.ptr.getContext(), 32);
926-
return llvm::all_of(llvm::make_first_range(slot.elementPtrs),
926+
return llvm::all_of(llvm::make_first_range(slot.subelementTypes),
927927
[&](Attribute index) {
928928
auto intIndex = dyn_cast<IntegerAttr>(index);
929929
return intIndex && intIndex.getType() == i32;
@@ -1159,7 +1159,7 @@ static bool memcpyCanRewire(MemcpyLike op, const DestructurableMemorySlot &slot,
11591159
return false;
11601160

11611161
if (op.getSrc() == slot.ptr)
1162-
for (Attribute index : llvm::make_first_range(slot.elementPtrs))
1162+
for (Attribute index : llvm::make_first_range(slot.subelementTypes))
11631163
usedIndices.insert(index);
11641164

11651165
return true;
@@ -1211,7 +1211,7 @@ memcpyRewire(MemcpyLike op, const DestructurableMemorySlot &slot,
12111211
// It was previously checked that index types are consistent, so this type can
12121212
// be fetched now.
12131213
Type indexType = cast<IntegerAttr>(subslots.begin()->first).getType();
1214-
for (size_t i = 0, e = slot.elementPtrs.size(); i != e; i++) {
1214+
for (size_t i = 0, e = slot.subelementTypes.size(); i != e; i++) {
12151215
Attribute index = IntegerAttr::get(indexType, i);
12161216
if (!subslots.contains(index))
12171217
continue;

mlir/lib/Dialect/MemRef/IR/MemRefMemorySlot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ bool memref::StoreOp::canRewire(const DestructurableMemorySlot &slot,
277277
return false;
278278
Attribute index = getAttributeIndexFromIndexOperands(
279279
getContext(), getIndices(), getMemRefType());
280-
if (!index || !slot.elementPtrs.contains(index))
280+
if (!index || !slot.subelementTypes.contains(index))
281281
return false;
282282
usedIndices.insert(index);
283283
return true;

mlir/lib/Transforms/SROA.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,11 @@ static void destructureSlot(
146146
allocator.destructure(slot, info.usedIndices, builder, newAllocators);
147147

148148
if (statistics.slotsWithMemoryBenefit &&
149-
slot.elementPtrs.size() != info.usedIndices.size())
149+
slot.subelementTypes.size() != info.usedIndices.size())
150150
(*statistics.slotsWithMemoryBenefit)++;
151151

152152
if (statistics.maxSubelementAmount)
153-
statistics.maxSubelementAmount->updateMax(slot.elementPtrs.size());
153+
statistics.maxSubelementAmount->updateMax(slot.subelementTypes.size());
154154

155155
SetVector<Operation *> usersToRewire;
156156
for (Operation *user : llvm::make_first_range(info.userToBlockingUses))

mlir/test/lib/Dialect/Test/TestOpDefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ DenseMap<Attribute, MemorySlot> TestMultiSlotAlloca::destructure(
13211321
DenseMap<Attribute, MemorySlot> slotMap;
13221322

13231323
for (Attribute usedIndex : usedIndices) {
1324-
Type elemType = slot.elementPtrs.lookup(usedIndex);
1324+
Type elemType = slot.subelementTypes.lookup(usedIndex);
13251325
MemRefType elemPtr = MemRefType::get({}, elemType);
13261326
auto subAlloca = builder.create<TestMultiSlotAlloca>(getLoc(), elemPtr);
13271327
newAllocators.push_back(subAlloca);

0 commit comments

Comments
 (0)