https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95558

            Bug ID: 95558
           Summary: Invalid IPA optimizations based on weak definition
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugdal at aerifal dot cx
  Target Milestone: ---

Created attachment 48689
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48689&action=edit
test case

Here is a case that came up in WIP code on musl libc, where I wanted to provide
a weak dummy definition for functionality that would optionally be replaced by
a strong definition elsewhere at ld time. I've been looking for some plausible
explanation aside from an IPA bug, like interaction with UB, but I can't find
any.

In the near-minimal test case here, the function reclaim() still has all of the
logic it should, but reclaim_gaps gets optimized down to a nop.

What seems to be happening is that the dummy weak definition does not leak into
its direct caller via IPA optimizations, but does leak to the caller's caller.

Reply via email to