]> git.lizzy.rs Git - rust.git/commit - src/librustdoc/json/mod.rs
Auto merge of #105119 - JakobDegen:inline-experiments, r=cjgillot
authorbors <bors@rust-lang.org>
Tue, 6 Dec 2022 00:53:01 +0000 (00:53 +0000)
committerbors <bors@rust-lang.org>
Tue, 6 Dec 2022 00:53:01 +0000 (00:53 +0000)
commit226202d9026b0f24b4f7aad4de398bd8378774cd
tree679a85a3146a7cdd82c2b04217b5f1b06535a2a6
parent8e440b03761f725d452120a992723c7e261822b2
parentf4f777772e751066b0ca75f942d403111595c45c
Auto merge of #105119 - JakobDegen:inline-experiments, r=cjgillot

Disable top down MIR inlining

The current MIR inliner has exponential behavior in some cases: <https://godbolt.org/z/7jnWah4fE>. The cause of this is top-down inlining, where we repeatedly do inlining like `call_a() => { call_b(); call_b(); }`. Each decision on its own seems to make sense, but the result is exponential.

Disabling top-down inlining fundamentally prevents this. Each call site in the original, unoptimized source code is now considered for inlining exactly one time, which means that the total growth in MIR size is limited to number of call sites * inlining threshold.

Top down inlining may be worth re-introducing at some point, but it needs to be accompanied with a principled way to prevent this kind of behavior.
compiler/rustc_mir_transform/src/inline.rs