Richard Biener wrote:
On Mon, Mar 30, 2015 at 10:13 PM, Richard Biener <rguent...@suse.de> wrote:
It doesn't make sense to use the alignment of passed values.  That looks like 
bs.

This means that

Int I __aligned__(8);

Is passed differently than int.

Arm_function_arg needs to be fixed.

That is,

typedef int myint __attribute__((aligned(8)));

int main()
{
  myint i = 1;
  int j = 2;
  __builtin_printf("%d %d\n", i, j);
}

or

myint i;
int j;
myint *p = &i;
int *q = &j;

int main()
{
  __builtin_printf("%d %d", *p, *q);
}

should behave the same.  There isn't a printf modifier for an "aligned int"
because that sort of thing doesn't make sense.

Agreed. All of the cases you post do indeed behave the same, and correctly (they pass the format string in r0, the next argument in r1, and then r2). This is what my "aligned(16)" example was trying to achieve also. From the -fdump-rtl-expand of your last example:

(insn 7 6 8 2 (set (reg:SI 117)
        (mem:SI (reg/f:SI 116) [2 *_4+0 S4 A32])) richie2.c:10 -1
     (nil))
(insn 8 7 9 2 (set (reg/f:SI 118)
        (symbol_ref:SI ("*.LANCHOR0") [flags 0x182])) richie2.c:10 -1
     (nil))
(insn 9 8 10 2 (set (reg/f:SI 119)
        (mem/f/c:SI (plus:SI (reg/f:SI 118)
                (const_int 4 [0x4])) [1 p+0 S4 A32])) richie2.c:10 -1
     (nil))
(insn 10 9 11 2 (set (reg:SI 120)
        (mem:SI (reg/f:SI 119) [2 *_2+0 S4 A64])) richie2.c:10 -1      ***
     (nil))
(insn 11 10 12 2 (set (reg:SI 121)
(symbol_ref/v/f:SI ("*.LC0") [flags 0x82] <var_decl 0x2b2c3b35d240 *.LC0>)) richie2.c:10 -1
     (nil))
(insn 12 11 13 2 (set (reg:SI 2 r2)
        (reg:SI 117)) richie2.c:10 -1
     (nil))
(insn 13 12 14 2 (set (reg:SI 1 r1)
        (reg:SI 120)) richie2.c:10 -1
     (nil))
(insn 14 13 15 2 (set (reg:SI 0 r0)
        (reg:SI 121)) richie2.c:10 -1
     (nil))

*** is the load of *p. The mem has alignment 64, but the type describing the loaded value *p, passed to arm_function_arg, has alignment 32. Even in the first of your examples, or even with an explicit cast to the aligned type:
__builtin_printf("%d %d\n", (myint) i, j);
we still get alignment 32 in arm_function_arg. It's only if SRA is applied, do we get the situation where the int with 64-bit alignment, is passed to arm_function_arg.

Disclaimer, I haven't tracked down how the alignment information flows through the compiler i.e. from build_ref_for_offset into expand_call. But it looks to me like something different is happening in the SRA case...no?

--Alan

Reply via email to