Skip to content

[AIX] LLVM data layout is incorrect unless overridden by clang #133599

Open
@workingjubilee

Description

@workingjubilee

Frontends for LLVM that offer support for the powerpc64-ibm-aix target but do not manually implement the Clang patch that overrides the data layout, specifically here, are using an incorrect data layout. This has resulted in hundreds of hours being wasted on trying to identify bugs due to incompatible layouts in those compilers, partially because of further conflation between the notion of alignment and "preferred" alignment, and the presence of a cryptically-worded "power alignment" rule in IBM's documentation. This problem affects rustc, but it likely also affects other frontends for LLVM, like flang.

As far as I can tell, the so-called "power alignment" rule, if Clang's implementation is correct (and you don't care that much about trying to reason about the details of C++ object and subobject layouts), merely is a rule that the compiler should align the type on the stack using the "preferred" alignment. It has no other effect. Even if this happens to affect parameter passing, and is thus required in that case for FFI correctness, then it is not a noteworthy distinction: other ABIs have far more "interesting" ad-hoc on-stack alignment exceptions. Otherwise, compilers should not need to be told that they may wish to overalign things for their internal stack layouts if it seems performance would benefit, as that would hopefully be obvious.

This should be fixed by

  • ceasing to have an ad-hoc override in clang for the data layout
  • spelling out the target data layout in LLVM so other frontends can use it

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions