Stream: t-compiler/help

Topic: Does rustc do any cross-crate inlining?


osa1 (Dec 12 2019 at 06:38, on Zulip):

I'm very new at rustc development -- I'm wondering if rustc does any cross-crate optimizations, and if it does where do I find the code that serializes/deserializes HIR/MIR for cross-crate inlining. Also, am I right that a crate is one compilation unit, and optimized/code generated as a whole? Thanks.

(I've searched about this but the term "cross" mostly brings cross-compilation related stuff. There's one blog post, but it's published in 2012 so it's probably not too relevant these days)

oli (Dec 12 2019 at 07:58, on Zulip):

Our optimizations do not care whether a function is from the same crate or from a different crate. I fact, except for lints the optimizations can't even tell the difference

oli (Dec 12 2019 at 07:58, on Zulip):

The (de-)serialization happens completely transparently in the query system

oli (Dec 12 2019 at 07:59, on Zulip):

You request the MIR of a function from another crate with the same query that you use for local crates

oli (Dec 12 2019 at 08:02, on Zulip):

That said, if you are still interested in metadata serialization and deserialization, the typr you want to look at is CrateMetadata. Although note that this is just a tiny cog in the metadata (de)serialization scheme.

oli (Dec 12 2019 at 08:03, on Zulip):

There may also be a rustc-guide topic about this, I'm not sure, search the guide for "metadata" I guess

osa1 (Dec 12 2019 at 12:06, on Zulip):

Thanks @oli , that's very helpful. I'll check the code and the rustc-guide section.

Last update: Jan 28 2020 at 01:25UTC