forked from OSchip/llvm-project
[mlir] Only treat "Alloc" effects as dead if they are for operation results.
Allocate could be used for an "output" of an operation in the case of buffer-style operations.
This commit is contained in:
parent
43959a2592
commit
4df44c4f9c
|
@ -63,9 +63,13 @@ static bool wouldOpBeTriviallyDeadImpl(Operation *rootOp) {
|
|||
// memory.
|
||||
SmallVector<MemoryEffects::EffectInstance, 1> effects;
|
||||
effectInterface.getEffects(effects);
|
||||
if (!llvm::all_of(effects, [](const auto &it) {
|
||||
return isa<MemoryEffects::Read>(it.getEffect()) ||
|
||||
isa<MemoryEffects::Allocate>(it.getEffect());
|
||||
if (!llvm::all_of(effects, [op](const MemoryEffects::EffectInstance &it) {
|
||||
// We can drop allocations if the value is a result of the
|
||||
// operation.
|
||||
if (isa<MemoryEffects::Allocate>(it.getEffect()))
|
||||
return it.getValue() && it.getValue().getDefiningOp() == op;
|
||||
// Otherwise, the effect must be a read.
|
||||
return isa<MemoryEffects::Read>(it.getEffect());
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue