https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108511
--- Comment #6 from Jan Hubicka <hubicka at gcc dot gnu.org> --- The function is used to discard early summaries that will lead to external calls. This saves some memory allocations. At this stage we have identified prevailing symbols and they are first in the next_sharing_asm_name lists. So the code looks it up and it ices because there is an external reference from one unit while previaling symbol is not public. It happens with -r only since there we do not have resolution info. Relaxing the assert to TREE_PUBLIC || DECL_EXTERNAL is safe and I guess easiest way to get around.