]> git.lizzy.rs Git - rust.git/commit
Avoid quadratic growth of functions due to cleanups
authorBjörn Steinbrink <bsteinbr@gmail.com>
Wed, 3 Feb 2016 18:27:32 +0000 (19:27 +0100)
committerBjörn Steinbrink <bsteinbr@gmail.com>
Wed, 3 Feb 2016 23:34:53 +0000 (00:34 +0100)
commit8c0f4f5d3aa6deac4ef8b371bd043f5c1df2c254
tree9734ce3a276f99e3f83bab6f87a1726ac73cf12c
parent2d4e94a501d77248e6c8bbf08b8489a823bc7c29
Avoid quadratic growth of functions due to cleanups

If a new cleanup is added to a cleanup scope, the cached exits for that
scope are cleared, so all previous cleanups have to be translated
again. In the worst case this means that we get N distinct landing pads
where the last one has N cleanups, then N-1 and so on.

As new cleanups are to be executed before older ones, we can instead
cache the number of already translated cleanups in addition to the
block that contains them, and then only translate new ones, if any and
then jump to the cached ones, getting away with linear growth instead.

For the crate in #31381 this reduces the compile time for an optimized
build from >20 minutes (I cancelled the build at that point) to about 11
seconds. Testing a few crates that come with rustc show compile time
improvements somewhere between 1 and 8%. The "big" winner being
rustc_platform_intrinsics which features code similar to that in #31381.

Fixes #31381
src/librustc_trans/trans/cleanup.rs
src/test/codegen/drop.rs [new file with mode: 0644]