[cfe-dev] Over-aligned vst1.64 and vld1.64 for arm-linux-androideabi

Greg McGary via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 14 12:08:47 PST 2018


On Thu, Feb 8, 2018 at 12:10 PM, Friedman, Eli <efriedma at codeaurora.org>
wrote:

> On 2/7/2018 5:53 PM, Greg McGary via cfe-dev wrote:
>
> I am seeing clang for arm-linux-androideabi emit 16-byte-aligned vst1.64
> and vld1.64, but the ABI only guarantees 8-byte alignment. Result at
> runtime is SIGBUS. Since clang emits "#define __BIGGEST_ALIGNMENT__ 8",
> it is aware of the ABI's maximum alignment.
>
>
> __BIGGEST_ALIGNMENT__ is not the alignment of any particular object; some
> pointers have lower alignment, some pointers have higher alignment.  And
> the compiler will raise the alignment of a load or store if it can prove
> the pointer is sufficiently aligned.
>
> It's hard to say more without a testcase.
>

Here is a testcase:

struct R {
  void *v = nullptr;
  R(R& rx) { v = rx.v; }
  R() {}
};

struct S {
  R r;
  long long ll[2];
  int i;

  S() {}
};

extern void bar(S&);

void foo(S& sin) {
  S s(sin);
  bar(s);
}

Compile like so:
/opt/android_ndk/r15c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
-target armv7-none-linux-androideabi -std=c++11 test.cpp -S -o test.s

An excerpt from test.s:

S::S(S&):
        .fnstart
...
        vld1.64 {d16, d17}, [r2]!
        vst1.64 {d16, d17}, [lr]!

The vxx1.64 insns assemble to forms with 128-bit alignment, so :128 is the
default alignment clause.
The load/store insns would be OK in this form, with 64-bit alignment:

        vld1.64 {d16, d17}, [r2:64]!
        vst1.64 {d16, d17}, [lr:64]!

However, I don't see how to alter that default.

Passing -fmax-type-align=8 to clang does nothing, though I expected it to
drop :128 to :64 for the alignment clause on the address-register operand.
-fmax-type-align=4 downgrades the vxx1.64 to vxx64.32.

G
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180214/546731ef/attachment.html>


More information about the cfe-dev mailing list