[all-commits] [llvm/llvm-project] bae8e1: [MLIR][DRR] Fix inconsistent operand and arg index...

Xiaomin Liu via All-commits all-commits at lists.llvm.org
Fri May 23 03:03:44 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bae8e1f99e0b245ec31912e29b4c80e823f635c6
      https://github.com/llvm/llvm-project/commit/bae8e1f99e0b245ec31912e29b4c80e823f635c6
  Author: Xiaomin Liu <xl4624 at nyu.edu>
  Date:   2025-05-23 (Fri, 23 May 2025)

  Changed paths:
    M mlir/test/lib/Dialect/Test/TestOps.td
    M mlir/test/mlir-tblgen/pattern.mlir
    M mlir/tools/mlir-tblgen/RewriterGen.cpp

  Log Message:
  -----------
  [MLIR][DRR] Fix inconsistent operand and arg index usage (#139816)

Background issue: #139813

In
[emitEitherOperandMatch()](https://github.com/llvm/llvm-project/blob/e62fc14a5d214f801758b35bdcad0c8efc65e8b8/mlir/tools/mlir-tblgen/RewriterGen.cpp#L774)
we check if `op.getArg(argIndex)` is a `NamedTypeConstraint`:

```cpp
} else if (isa<NamedTypeConstraint *>(op.getArg(argIndex))) {
      emitOperandMatch(tree, opName, /*operandName=*/formatv("v{0}", i).str(),
                       operandIndex,
                       /*operandMatcher=*/eitherArgTree.getArgAsLeaf(i),
                       /*argName=*/eitherArgTree.getArgName(i), argIndex,
                       /*variadicSubIndex=*/std::nullopt);
      ++operandIndex;
}
```

but in `emitOperandMatch()` we cast on `op.getArg(operandIndex)`, which
is incorrect if the operation has attributes or other non-operand
arguments before its operands.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list