agg_nested_byval.c (609B)
1 /* A nested struct (inner struct embedded in outer, 12 bytes total) passed BY 2 * VALUE. <= 16 bytes so it travels in integer registers per the PCS; the callee 3 * must extract the nested fields from the packed register operands. Exercises 4 * nested-field access combined with byval register lowering. 6+15+21 = 42. */ 5 struct Inner { 6 int x; 7 int y; 8 }; 9 struct Outer { 10 int tag; 11 struct Inner in; 12 }; 13 __attribute__((noinline)) static int eval(struct Outer o) { 14 return o.tag + o.in.x + o.in.y; 15 } 16 int test_main(void) { 17 volatile int a = 6, b = 15, c = 21; 18 struct Outer o = {a, {b, c}}; 19 return eval(o); 20 }