[PATCH] D137497: [ArgumentPromotion] Allow the frontend to specify the maximum number of elements to promote on a per-function basis via metadata.
Patrick Walton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 5 17:22:02 PDT 2022
pcwalton added a comment.
Sure. Check this one out. It's `backtrace::symbolize::gimli::macho::Object::parse` in `backtrace-rs`.
No argument promotion: https://gist.github.com/pcwalton/38ff053dd1973ca383b85183e13de0fc
With argument promotion with elements = 99 (converting hidden to internal so arg promotion works): https://gist.github.com/pcwalton/6195ccd7b1b49cde8920f3e65c048b84
Notice that:
- Many of the structures have more elements than 2.
- There are no memcpys in `parse()` with argument promotion. Without it there are 384 bytes in 13 stack to stack memcpys. Teaching memcpyopt to eliminate these would require a lot of expensive flow sensitive analysis if it's even feasible at all.
Here is the codegen without the argument promotion: https://gist.github.com/pcwalton/6c589ee875d5f6a639d2139990db66d2
And with argument promotion with max elements at 99: https://gist.github.com/pcwalton/f359acd836a61ceb8669c6ce823d141e
Notice that, with the argument promotion, we reduce the size of the stack in that function from 408 bytes to 328 bytes, a 24% savings. The main remaining memcpy-like codegen segment is basically just copying into the retptr which we may be able to eliminate in other ways.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137497/new/
https://reviews.llvm.org/D137497
More information about the llvm-commits
mailing list