This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][NFC] Change FunctionLike::setAllArgAttrs/setAllResultAttrs to do a one-shot attribute update.
ClosedPublic

Authored by jurahul on Dec 28 2020, 12:06 PM.

Details

Summary
  • Change FunctionLike::setAllArgAttrs() and setAllResultAttrs() to rebuild the new list of function attributes locally and call setAttr() just once instead of calling setArgAttr()/setResultAttrs() for each argument which incrementally build the attribute dictionary and can end up creating a lot of unused DictionaryAttr's (which are uniqued and nor garbage collected).

Diff Detail

Event Timeline

jurahul created this revision.Dec 28 2020, 12:06 PM
jurahul requested review of this revision.Dec 28 2020, 12:06 PM
jpienaar accepted this revision.Dec 28 2020, 12:36 PM

Thanks (this reminds me of wanting some benchmarks/tracking ...)

mlir/include/mlir/IR/FunctionSupport.h
598

An if-then-else seems shorter and simpler here (and below).

This revision is now accepted and ready to land.Dec 28 2020, 12:36 PM
mehdi_amini accepted this revision.Dec 28 2020, 1:07 PM

LGTM.

NFC?

jurahul updated this revision to Diff 313890.Dec 28 2020, 1:34 PM

Use if-else

jurahul retitled this revision from [MLIR] Change FunctionLike::setAllArgAttrs/setAllResultAttrs to do a one-shot attribute update. to [MLIR][NFC] Change FunctionLike::setAllArgAttrs/setAllResultAttrs to do a one-shot attribute update..Dec 28 2020, 1:34 PM
jurahul marked an inline comment as done.