[flang-commits] [flang] [mlir] [mlir][side effect] refactor(*): Include more precise side effects (PR #94213)

donald chen via flang-commits flang-commits at lists.llvm.org
Wed Jun 19 03:09:32 PDT 2024


================
@@ -25,16 +25,28 @@ def SideEffectOpB : TEST_Op<"side_effect_op_b",
     [MemoryEffects<[MemWrite<CustomResource, 0>]>]>;
 
 // CHECK: void SideEffectOpA::getEffects
-// CHECK:   for (::mlir::Value value : getODSOperands(0))
-// CHECK:     effects.emplace_back(::mlir::MemoryEffects::Read::get(), value, 0, false, ::mlir::SideEffects::DefaultResource::get());
-// CHECK:   for (::mlir::Value value : getODSOperands(1))
-// CHECK:     effects.emplace_back(::mlir::MemoryEffects::Write::get(), value, 1, true, ::mlir::SideEffects::DefaultResource::get());
+// CHECK:  {
+// CHECK:    auto valueRange = getODSOperandIndexAndLength(0);
+// CHECK:    for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) {
+// CHECK:      effects.emplace_back(::mlir::MemoryEffects::Read::get(), &getOperation()->getOpOperand(idx), 0, false, ::mlir::SideEffects::DefaultResource::get());
+// CHECK:    }
+// CHECK:  }
+// CHECK:  {
+// CHECK:    auto valueRange = getODSOperandIndexAndLength(1);
+// CHECK:    for (unsigned idx = valueRange.first; idx < valueRange.first + valueRange.second; idx++) {
+// CHECK:      effects.emplace_back(::mlir::MemoryEffects::Write::get(), &getOperation()->getOpOperand(idx), 1, true, ::mlir::SideEffects::DefaultResource::get());
+// CHECK:    }
+// CHECK:  }
 // CHECK:   effects.emplace_back(::mlir::MemoryEffects::Read::get(), getSymbolAttr(), 0, false, ::mlir::SideEffects::DefaultResource::get());
 // CHECK:   effects.emplace_back(::mlir::MemoryEffects::Write::get(), getFlatSymbolAttr(), 0, false, ::mlir::SideEffects::DefaultResource::get());
 // CHECK:   if (auto symbolRef = getOptionalSymbolAttr())
 // CHECK:     effects.emplace_back(::mlir::MemoryEffects::Read::get(), symbolRef, 0, false, ::mlir::SideEffects::DefaultResource::get());
-// CHECK:   for (::mlir::Value value : getODSResults(0))
-// CHECK:     effects.emplace_back(::mlir::MemoryEffects::Allocate::get(), value, 0, false, CustomResource::get());
+// CHECK:  {
+// CHECK:    auto valueRange = getODSResultIndexAndLength(0);
----------------
cxy-1993 wrote:

Indeed

https://github.com/llvm/llvm-project/pull/94213


More information about the flang-commits mailing list