[Mlir-commits] [mlir] [MLIR] Preserve operand segment sizes when removing dead inputs (PR #223154)
Ivan Butygin
llvmlistbot at llvm.org
Sat Sep 19 02:27:05 PDT 2026
================
@@ -244,6 +244,37 @@ void RewriterBase::eraseBlock(Block *block) {
block->erase();
}
+void RewriterBase::eraseOperands(Operation *op, const BitVector &eraseIndices) {
+ assert(eraseIndices.size() == op->getNumOperands() &&
+ "expected one bit per operand");
+ if (eraseIndices.none())
+ return;
+
+ modifyOpInPlace(op, [&]() {
+ op->eraseOperands(eraseIndices);
+ if (!op->hasTrait<OpTrait::AttrSizedOperandSegments>())
+ return;
+
+ // TODO: Add an interface to update the operand segment-size property
+ // directly, without converting it to and from an attribute.
+ auto attrName = StringAttr::get(
----------------
Hardcode84 wrote:
`StringRef` will be converted into `StringAttr` internally on each call, and we will end up with 2 `StringAttr` constructions instead of 1. As a side comment, this is a common antipattern and I'd rather move into nuking `StringRef` overloads entirely.
https://github.com/llvm/llvm-project/pull/223154
More information about the Mlir-commits
mailing list