This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Make use of MachineInstr::all_defs and all_uses. NFCI.
ClosedPublic

Authored by foad on May 25 2023, 4:28 AM.

Diff Detail

Event Timeline

foad created this revision.May 25 2023, 4:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 4:28 AM
foad requested review of this revision.May 25 2023, 4:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 4:28 AM
qcolombet accepted this revision.Jun 1 2023, 6:42 AM

I like the improved readability.
Thanks!

This revision is now accepted and ready to land.Jun 1 2023, 6:42 AM
This revision was landed with ongoing or failed builds.Jun 1 2023, 11:21 AM
This revision was automatically updated to reflect the committed changes.
foad added a comment.Jun 1 2023, 10:50 PM

Thanks/sorry. I won't be able to look at this for a few days. Feel free to revert if you want.

foad added a comment.Jun 2 2023, 12:44 AM

It looks like this causes a major compile-time regression: https://llvm-compile-time-tracker.com/compare.php?from=2de54b919ba5fd9ccf37038cddfc36e97eb480af&to=5022fc2ad31b5e3211e2458347c89412b8c5ec1b&stat=instructions:u

Could you please add https://github.com/jayfoad/llvm-project to the compile time tracker?

The implementation of these methods looks somewhat suspect: https://github.com/llvm/llvm-project/blob/7f374b6902fad9caed41284a57d573abe9ada9d1/llvm/include/llvm/CodeGen/MachineInstr.h#L732 Not sure why this is creating an std::function.

That was part of my attempt at getting sane(ish) declared return types for the new functions. The first versions of this patch used auto and did not use std::function. What's so bad about std::function anyway?

nikic added a comment.Jun 2 2023, 1:02 AM

Done!

The implementation of these methods looks somewhat suspect: https://github.com/llvm/llvm-project/blob/7f374b6902fad9caed41284a57d573abe9ada9d1/llvm/include/llvm/CodeGen/MachineInstr.h#L732 Not sure why this is creating an std::function.

That was part of my attempt at getting sane(ish) declared return types for the new functions. The first versions of this patch used auto and did not use std::function. What's so bad about std::function anyway?

I've landed https://github.com/llvm/llvm-project/commit/1efbef4085fbe7098af4bb7013c6295ed3682cdf to remove the std::function use, which does seem to fully mitigate the regression. Not sure what exactly about std::function is so slow/unoptimizable, but it's a "well known" performance footgun (like so many things in the STL ... sigh)

foad added a comment.Jun 5 2023, 12:10 AM

Done!

The implementation of these methods looks somewhat suspect: https://github.com/llvm/llvm-project/blob/7f374b6902fad9caed41284a57d573abe9ada9d1/llvm/include/llvm/CodeGen/MachineInstr.h#L732 Not sure why this is creating an std::function.

That was part of my attempt at getting sane(ish) declared return types for the new functions. The first versions of this patch used auto and did not use std::function. What's so bad about std::function anyway?

I've landed https://github.com/llvm/llvm-project/commit/1efbef4085fbe7098af4bb7013c6295ed3682cdf to remove the std::function use, which does seem to fully mitigate the regression. Not sure what exactly about std::function is so slow/unoptimizable, but it's a "well known" performance footgun (like so many things in the STL ... sigh)

Thanks and thanks!