This is an archive of the discontinued LLVM Phabricator instance.

[mlir] DialectConversion: avoid double-free when rolling back op creation
ClosedPublic

Authored by ftynse on May 18 2020, 9:07 AM.

Details

Summary

Dialect conversion infrastructure may roll back op creation by erasing the
operations in the reverse order of their creation. While this guarantees uses
of values will be deleted before their definitions, this does not guarantee
that a parent operation will not be deleted before its child. (This may happen
in case of block inlining or if child operations, such as terminators, are
created in the parent's build function before the parent itself.) Handle the
parent/child relationship between ops by removing all child ops from the blocks
before erasing the parent. The child ops remain live, detached from a block,
and will be safely destroyed in their turn, which may come later than that of
the parent.

Depends On D80133

Diff Detail

Event Timeline

ftynse created this revision.May 18 2020, 9:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 18 2020, 9:07 AM
nicolasvasilache accepted this revision.May 18 2020, 9:46 AM

Thanks!
This must not have been fun to debug..

mlir/lib/Transforms/DialectConversion.cpp
672

recursively

This revision is now accepted and ready to land.May 18 2020, 9:46 AM
ftynse marked an inline comment as done.May 20 2020, 6:19 AM
This revision was automatically updated to reflect the committed changes.