This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Interfaces] Generate a struct containing function pointers instead of a class with vtables
ClosedPublic

Authored by rriddle on Oct 23 2020, 4:51 PM.

Details

Summary

When compiling for code size, the use of a vtable causes a destructor(and constructor in certain cases) to be generated for the class. Interface models don't need a complex constructor or a destructor, so this can lead to many megabytes of code size increase(even in opt). This revision switches to a simpler struct of function pointers approach that accomplishes the same API requirements as before. This change requires no updates to user code, or any other code aside from the generator, as the user facing API is still exactly the same.

Depends On D90084

Diff Detail

Event Timeline

rriddle created this revision.Oct 23 2020, 4:51 PM
rriddle requested review of this revision.Oct 23 2020, 4:51 PM

Impressively simple!

mehdi_amini accepted this revision.Oct 23 2020, 5:34 PM
This revision is now accepted and ready to land.Oct 23 2020, 5:34 PM
jpienaar accepted this revision.Oct 26 2020, 4:04 PM
jpienaar added inline comments.
mlir/tools/mlir-tblgen/OpInterfacesGen.cpp
204

Why 2 lines here? (e.g., os << ");\n"; doesn't seem more difficult to read).

rriddle updated this revision to Diff 301113.Oct 27 2020, 4:03 PM
rriddle marked an inline comment as done.

Rebase