This is an archive of the discontinued LLVM Phabricator instance.

[mlir][NFC] Avoid `OpBuilder::setListener` when possible
ClosedPublic

Authored by springerm on Jul 18 2023, 7:48 AM.

Details

Summary

setListener is dangerous because an already registered listener may accidentally be overwritten/replaced. (A ForwardingListener must be used in such cases.) This change updates a few trivial call sites of setListener, where no forwarding listener is needed.

Diff Detail

Event Timeline

springerm created this revision.Jul 18 2023, 7:48 AM
Herald added a project: Restricted Project. · View Herald Transcript
springerm requested review of this revision.Jul 18 2023, 7:48 AM
jpienaar accepted this revision.Jul 18 2023, 8:49 AM
This revision is now accepted and ready to land.Jul 18 2023, 8:49 AM
This revision was landed with ongoing or failed builds.Jul 19 2023, 12:14 AM
This revision was automatically updated to reflect the committed changes.

Thanks for the fix! LGTM!

mlir/lib/Transforms/Utils/OneToNTypeConversion.cpp
293

Just to spell it out for me: this is a trivial case because setListener is called a few lines after the construction of the rewriter, so no other listener can be attached already and replaced by the call, right?

springerm added inline comments.Jul 19 2023, 7:20 AM
mlir/lib/Transforms/Utils/OneToNTypeConversion.cpp
293

Yes that's correct.