9#ifndef CIRCT_SUPPORT_UNUSEDOPPRUNER_H
10#define CIRCT_SUPPORT_UNUSEDOPPRUNER_H
13#include "mlir/IR/Operation.h"
14#include "mlir/Interfaces/ControlFlowInterfaces.h"
15#include "mlir/Interfaces/SideEffectInterfaces.h"
34 if (
auto *defOp = value.getDefiningOp())
43 for (
auto value : values)
58 using mlir::BranchOpInterface;
64 if (!isOpTriviallyDead(op))
75 if (!llvm::all_of(arg.getOwner()->getUses(), [](
auto &blockOperand) {
76 return isa<BranchOpInterface>(blockOperand.getOwner());
79 unsigned argIdx = arg.getArgNumber();
80 for (
auto &blockOperand : arg.getOwner()->getUses()) {
81 auto branchOp = cast<BranchOpInterface>(blockOperand.getOwner());
83 branchOp.getSuccessorOperands(blockOperand.getOperandNumber());
85 operands.erase(argIdx);
87 arg.getOwner()->eraseArgument(argIdx);
assert(baseType &&"element must be base type")
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Utility that tracks operations that have potentially become unused and allows them to be cleaned up a...
llvm::SmallDenseSet< BlockArgument > blockArgsToEraseIfUnused
The set of block arguments that may have become unused.
void eraseLaterIfUnused(Value value)
Mark the defining op of a value to be erased later if the op is unused at that point.
llvm::SmallDenseSet< Operation * > opsToEraseIfUnused
The set of operations that may have become unused.
void eraseLaterIfUnused(Operation *op)
Mark an op the be erased later if it is unused at that point.
void eraseLaterIfUnused(ValueRange values)
Mark the defining ops of a range of values to be erased later if the ops are unused at that point.
void eraseNow(Operation *op)
Erase an operation immediately, and remove it from the set of ops to be removed later.