This is an archive of the discontinued LLVM Phabricator instance.

[mlir][DialectConversion] Do not prematurely drop unused cast operations
ClosedPublic

Authored by herhut on Nov 26 2020, 8:11 AM.

Details

Summary

The rewrite logic has an optimization to drop a cast operation after
rewriting block arguments if the cast operation has no users. This is
unsafe as there might be a pending rewrite that replaced the cast operation
itself and hence would trigger a second free.

Instead, do not remove the casts and leave it up to a later canonicalization
to do so.

Diff Detail

Event Timeline

herhut created this revision.Nov 26 2020, 8:11 AM
herhut requested review of this revision.Nov 26 2020, 8:11 AM

PTAL. This fixes a use after free.

bkramer accepted this revision.Nov 26 2020, 8:25 AM

Let's land this now to unblock asan. It's breaking test/Transforms/test-legalizer.mlir though because there's a cast being left behind.

This revision is now accepted and ready to land.Nov 26 2020, 8:25 AM
herhut updated this revision to Diff 307879.Nov 26 2020, 8:38 AM

Fix test

This revision was landed with ongoing or failed builds.Nov 26 2020, 8:39 AM
This revision was automatically updated to reflect the committed changes.