Skip to content

compiler-rt: omit symbols that are not needed because of machine instructions #11884

Open

Description

@andrewrk

As an optimization, our compiler-rt can check if generating a given symbol would be redundant, because it would never be called due to a machine code instruction being available, and avoid calling @export for that symbol. This will make 2 small improvements:

  • Faster compiler-rt build from cold cache (fewer functions to optimize)
  • Faster link against compiler-rt (since the static archive will be smaller)

Similar issue: #11883

Activity

  1. added
    enhancementSolving this issue will likely involve adding new logic or components to the codebase.
    contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.
    on Jun 18, 2022
  2. added this to the 1.1.0 milestone on Jun 18, 2022
  3. Vexu commented on Jul 14, 2022

    @Vexu
    Member

    A compiler-rt symbol is unnecessary if the target architecture has a native machine code instruction for that operation. For example __multi3 multiplies two 128-bit integers producing a new 128-bit integer, so if the target architecture has a machine code instruction that also does this multiplication then __multi3 is unnecessary.

  4. Vexu commented on Jul 15, 2022

    @Vexu
    Member

    I'd recommend the architecture's Instruction Set Architecture manual or some equivalent document.

  5. andrewrk commented on Jul 15, 2022

    @andrewrk
    MemberAuthor

    You could also try writing zig code and see if it lowers to a compiler-rt function call instead of machine code instructions. You do need to be mindful of CPU feature sets, however, and unfortunately we don't have a section in the language reference about this yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    compiler-rtcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.enhancementSolving this issue will likely involve adding new logic or components to the codebase.optimization

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions