[ODS] Fix operation argument population to avoid crash
authorLei Zhang <antiagainst@google.com>
Thu, 14 Nov 2019 19:02:52 +0000 (11:02 -0800)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Thu, 14 Nov 2019 19:03:29 +0000 (11:03 -0800)
commit796ca609ebd4978d0779eaf5a7a44310aa368c73
tree4c36d52011536daa5d316c6bee98c7341f7c2515
parent971b8dd4d881cdc21b6aa73a3797bf9a6d48ca14
[ODS] Fix operation argument population to avoid crash

The `Operator` class keeps an `arguments` field, which contains pointers
to `operands` and `attributes` elements. Thus it must be populated after
`operands` and `attributes` are finalized so to have stable pointers.
SmallVector may re-allocate when still having new elements added, which
will invalidate pointers.

PiperOrigin-RevId: 280466896
mlir/include/mlir/TableGen/Operator.h
mlir/lib/TableGen/Operator.cpp
mlir/lib/TableGen/Pattern.cpp
mlir/test/lib/TestDialect/TestOps.td
mlir/test/mlir-tblgen/pattern.mlir