agg_byval.c (569B)
1 /* A small struct (two ints, 8 bytes) passed BY VALUE. On the AArch64 PCS a 2 * struct <= 16 bytes is passed in integer registers (here packed into one x 3 * register), so this exercises the caller packing the fields and the callee 4 * unpacking them. `noinline` forces a real call so the byval lowering is 5 * actually emitted. sum.a + sum.b = 20 + 22 = 42. */ 6 struct Pair { 7 int a; 8 int b; 9 }; 10 __attribute__((noinline)) static int sum(struct Pair p) { return p.a + p.b; } 11 int test_main(void) { 12 volatile int x = 20, y = 22; 13 struct Pair p = {x, y}; 14 return sum(p); 15 }