Skip to content

[Downstream Change] Add AEABI unaligned helpers to compiler-rt and make LLVM ARM lower unaligned i32/i64 loads/stores to __aeabi_uread/uwrite{4,8} #727

Closed

Description

@simpal01

What is the change
When targeting ARM (in particular architectures or variants that do not allow unaligned memory accesses, e.g., with -mno-unaligned-access or older cores like ARMv6-M) the backend currently handles unaligned loads or stores by expanding them into sequences of byte/half-word loads/stores.

This change proposes to detect unaligned loads/stores of size 4 bytes (i32) or 8 bytes (i64) when alignment is insufficient, and instead emit calls to the AEABI helper functions by llvm:

• __aeabi_uread4, __aeabi_uread8 for unaligned reads

• __aeabi_uwrite4, __aeabi_uwrite8 for unaligned writes

By lowering to these functions, code size can be reduced compared to in-lined byte/half-word sequences providing they are invoked more than once across a program. This also needs to add the implementations for the __aeabi_uread and __aeabi_uwrite helper functions to compiler-rt.

Why this change cannot be done upstream
This was committed upstream after the LLVM 22 branch was created. Mostly upstream will not accept it into the 22 branch, as it is not considered critical enough for backporting.

Activity

  1. added
    ATfEArm Toolchain for Embedded specific issue
    on Jul 7, 2026
  2. added this to the LLVM-22 milestone on Jul 7, 2026
  3. voltur01 commented on Oct 21, 2026

    @voltur01
    Contributor

    One off release branch downstream change - closing.

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

    ATfEArm Toolchain for Embedded specific issuedownstream-changeDownstream change to LLVM tree

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions