https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107640
Bug ID: 107640 Summary: IPA-CP drops known values passed by reference when the reference is to a global variable Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: jamborm at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- Host: x86_64-linux Target: x86_64-linux Combining IPA-CP of (scalar) parameter values and of values passed by reference (aggregate values) does not work in the same function parameter, we drop the aggregate values on the floor. The following aborts when compiled with -O2 -DFAIL struct S { int a, b, c; }; volatile int gi; void __attribute__((noipa)) consume_s (struct S *p) { gi = p->a; } static void __attribute__((noinline)) foo (struct S *p) { if (!__builtin_constant_p (p->b)) __builtin_abort (); consume_s (p); } static struct S __attribute((used)) gs; int main (int argc, char *argv[]) { struct S *p; #ifdef FAIL p = &gs; #else struct S s; p = &s; #endif p->a = 10; p->b = 20; foo (p); return 0; }