Skip to content

Is there any problem with the "remove-temporaries" pass #1115

@TracyMac1

Description

@TracyMac1
/// Check whether `op` can have a write effect on value `val`
static bool opHasWriteEffect(::mlir::Value val, ::mlir::Operation *op) {
  // Check whether the operation `op` has write effect on the memory.
  if (!llvm::is_contained(val.getUsers(), op))
    return false;
  if (auto memEffect = ::mlir::dyn_cast<::mlir::MemoryEffectOpInterface>(op)) {
    ::mlir::SmallVector<::mlir::MemoryEffects::EffectInstance, 1> effects;
    memEffect.getEffects(effects);
    return llvm::any_of(
        effects, [](::mlir::MemoryEffects::EffectInstance effect) {
          return ::mlir::isa<::mlir::MemoryEffects::Write>(effect.getEffect());
        });
  }
  // Op does not implement the interface, assume effect is present
  return true;
}

This function not only finds the op written to val, but also the op written from val to other memory. However, according to the meaning of the comment, it should only find the op written to val. Is this an error in the comment or in the code implementation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions