@@ -965,14 +965,14 @@ class ModifyOperationRewrite : public OperationRewrite {
965
965
ModifyOperationRewrite (ConversionPatternRewriterImpl &rewriterImpl,
966
966
Operation *op)
967
967
: OperationRewrite(Kind::ModifyOperation, rewriterImpl, op),
968
- loc (op->getLoc ()), attrs(op->getAttrDictionary ()),
968
+ name (op-> getName ()), loc(op->getLoc ()), attrs(op->getAttrDictionary ()),
969
969
operands(op->operand_begin (), op->operand_end()),
970
970
successors(op->successor_begin (), op->successor_end()) {
971
971
if (OpaqueProperties prop = op->getPropertiesStorage ()) {
972
972
// Make a copy of the properties.
973
973
propertiesStorage = operator new (op->getPropertiesStorageSize ());
974
974
OpaqueProperties propCopy (propertiesStorage);
975
- op-> getName () .initOpProperties (propCopy, /* init=*/ prop);
975
+ name .initOpProperties (propCopy, /* init=*/ prop);
976
976
}
977
977
}
978
978
@@ -988,7 +988,9 @@ class ModifyOperationRewrite : public OperationRewrite {
988
988
void commit () override {
989
989
if (propertiesStorage) {
990
990
OpaqueProperties propCopy (propertiesStorage);
991
- op->getName ().destroyOpProperties (propCopy);
991
+ // Note: The operation may have been erased in the mean time, so
992
+ // OperationName must be stored in this object.
993
+ name.destroyOpProperties (propCopy);
992
994
operator delete (propertiesStorage);
993
995
propertiesStorage = nullptr ;
994
996
}
@@ -1003,13 +1005,14 @@ class ModifyOperationRewrite : public OperationRewrite {
1003
1005
if (propertiesStorage) {
1004
1006
OpaqueProperties propCopy (propertiesStorage);
1005
1007
op->copyProperties (propCopy);
1006
- op-> getName () .destroyOpProperties (propCopy);
1008
+ name .destroyOpProperties (propCopy);
1007
1009
operator delete (propertiesStorage);
1008
1010
propertiesStorage = nullptr ;
1009
1011
}
1010
1012
}
1011
1013
1012
1014
private:
1015
+ OperationName name;
1013
1016
LocationAttr loc;
1014
1017
DictionaryAttr attrs;
1015
1018
SmallVector<Value, 8 > operands;
0 commit comments