[cfe-dev] clang not using prefered alignment for 'long long' or 'double'

Robert Lytton robert at xmos.com
Fri Oct 11 09:26:28 PDT 2013


Hi

I'm working on the XCore target where the target datalayout specifies i64:32:32 and f64:32:32.

The target also specifies:
    LongLongAlign = 32;
    SuitableAlign = 32;
    DoubleAlign = LongDoubleAlign = 32;
(debug confirms that the access functions correctly returning 32)

However compiling:
    void test(){ long long v=0; }
produces 64bit alignment:
    define void @test() #0 {
    entry:
      %v = alloca i64, align 8
      store i64 0, i64* %v, align 8
      ret void
    }

The following also fails:
    // RUN: %clang_cc1 -triple xcore -verify %s
    // expected-no-diagnostics
    _Static_assert(sizeof(long long) == 8, "sizeof long long is wrong");
    _Static_assert(_Alignof(long long) == 4, "alignof long long is wrong");
    _Static_assert(sizeof(double) == 8, "sizeof double is wrong");
    _Static_assert(_Alignof(double) == 4, "alignof double is wrong");

As the target is very memory sensitive 'align 8' is a wasteful, needless operation and as such is considered an error!

I have tried to trace where the decision to use an alignment of 8 is being made without success so far.
Help or comment most welcome.
Thanks.
Robert

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131011/ab39dc76/attachment.html>


More information about the cfe-dev mailing list