Skip to content

Commit 4c694da

Browse files
author
Shay Kleiman
committed
Added trait NoMemoryEffect to assume_alignment
Assume_alignment has no trait which specifies how it interacts with memory, this causes an issue in OwnershipBasedBufferDeallocation, which require all operations which operate on buffers to have explicit traits defining how the operation interacts with memory. From my understanding, technically the operation is pure, however to make sure the operation doesn't get optimized away it has to have some side effect. I defined it to have similar side effects to CF AssertOp as both are asserts. I'm not sure if this is correct and would appreciate the opinion of someone more experienced.
1 parent acd6294 commit 4c694da

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

mlir/include/mlir/Dialect/MemRef/IR/MemRefOps.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class AllocLikeOp<string mnemonic,
142142
// AssumeAlignmentOp
143143
//===----------------------------------------------------------------------===//
144144

145-
def AssumeAlignmentOp : MemRef_Op<"assume_alignment"> {
145+
def AssumeAlignmentOp : MemRef_Op<"assume_alignment",[DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
146146
let summary =
147147
"assertion that gives alignment information to the input memref";
148148
let description = [{

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,11 @@ LogicalResult AssumeAlignmentOp::verify() {
526526
return emitOpError("alignment must be power of 2");
527527
return success();
528528
}
529+
void AssumeAlignmentOp::getEffects(
530+
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
531+
&effects) {
532+
effects.emplace_back(MemoryEffects::Write::get());
533+
}
529534

530535
//===----------------------------------------------------------------------===//
531536
// CastOp

0 commit comments

Comments
 (0)