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

--- Comment #12 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Rich Felker from comment #11)
> Are you sure? If pure/const discovery is no longer applied to weak
> definitions, it shouldn't be able to propagate to a non-inlined caller. Of
> course the fix may be incomplete or not working, which I guess we could tell
> from whether it happened prior to or after comment 5. :)

There still looks like there is a bug as shown by taking the original testcase
in comment #0 and using -O2 -fno-inline, you will get:

reclaim_gaps:
        ret
...
foo:
        ret

Which is still wrong as reclaim should not be considered as pure.

>From *.pure-const:

Starting cycle
  Visiting donate_dummy/0 state:const looping 0
Result const looping 0
Function found not to call free: donate_dummy/0
Starting cycle
  Visiting reclaim/2 state:pure looping 0
    Call to __malloc_donate/1 const
Result pure looping 0
Function found to be pure: reclaim/2
Declaration updated to be pure: reclaim/2
Starting cycle
  Visiting reclaim_gaps/3 state:pure looping 0
    Call to reclaim/2 state:pure looping:0
    Call to reclaim/2 state:pure looping:0
Result pure looping 0
Function found to be pure: reclaim_gaps/3
Declaration updated to be pure: reclaim_gaps/3
Starting cycle
  Visiting foo/4 state:const looping 0
    Call to reclaim_gaps/3 state:pure looping:0
Result pure looping 0
Function found to be pure: foo/4
Declaration updated to be pure: foo/4

reclaim, reclaim_gaps and foo are all found as pure. without -fno-inline, we
get some early inlining which causes the difference there.

Reply via email to