https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77957
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 39798 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39798&action=edit gcc7-pr77957.patch One of the problems is that for TARGET_THREAD_SSP_OFFSET targets we completely wastefully create a MEM we don't really need and then ignore it. This untested patch attempts to avoid that. The more important bug is somewhere in the rs6000 backend, that the useless MEMs at -O0 confuse the backend enough that it contains (useless) .LCTOC0 reference/load without corresponding definition of .LCTOC0. I'll leave this part to the rs6000 maintainers.