Skip to content

Use LLVM's externally_available linkage for inline functions #89154

Open
@bjorn3

Description

@bjorn3

This tells LLVM that the function has a given definition to allow for inlining, but that the function is already externally defined, so locally emitting object code for it is not necessary. It is necessary to provide an export elsewhere though. This can be done by making the monomorphization collector handle them like normal functions when it isn't being inlined from another crate or cgu.

On one hand this will likely save executable size and for debug mode compilation time as codegen of inline functions can be skipped. On the other hand it will likely result in bigger libraries due to the extra inlined functions. It will also break the (incorrect) assumption that some crates have that #[inline] functions are never codegened if not used.

Codegen backends that don't support externally_available can treat it as local or if they don't support inlining at all don't codegen them at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationA-linkageArea: linking into static, shared libraries and binariesC-enhancementCategory: An issue proposing an enhancement or a PR with one.WG-llvmWorking group: LLVM backend code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions