opt_13_pointer_first_record_copy.c (772B)
1 /* A record first crossing the CG boundary through a pointer has only a nominal 2 * declaration there. Its first by-value use must complete the record layout 3 * before aggregate-copy IR captures the byte count. Keep clone_value before 4 * test_main so no earlier by-value local happens to complete Value for it. */ 5 typedef unsigned long long U64; 6 7 typedef struct Value { 8 U64 word[8]; 9 } Value; 10 11 __attribute__((noinline)) static void clone_value(Value* dst, 12 const Value* src) { 13 *dst = *src; 14 } 15 16 int test_main(void) { 17 Value src = {{1, 2, 3, 4, 5, 6, 7, 8}}; 18 Value dst = {{0, 0, 0, 0, 0, 0, 0, 0}}; 19 clone_value(&dst, &src); 20 for (unsigned i = 0; i < 8; ++i) 21 if (dst.word[i] != src.word[i]) return 1; 22 return 0; 23 }