http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59777
Bug ID: 59777 Summary: Incorrect expansion of TLS arguments in a call Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: danglin at gcc dot gnu.org Host: hppa-unknown-linux-gnu Target: hppa-unknown-linux-gnu Build: hppa-unknown-linux-gnu Created attachment 31813 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31813&action=edit Testcase. The attached testcase shows the problem. Argument expressions containing a TLS symbol reference need to be precomputed as a call may be needed to legitimize the address and this may clobber the setup for earlier arguments causing wrong code. For example, compilation of the testcase with: gcc-4.8 -fPIC -DPIC -W -Wall -Wextra -Wshadow -Wformat -Wundef -D_GNU_SOURCE -O0 cap-ng.c -fPIC -DPIC -o cap-ng results in the following output: $ ./cap-ng cc m.hdr1 = 0x400015c8 pidaaaa = 0 There seems to be some attempt to handle this in precompute_register_parameters().