Bug 59777 - Incorrect expansion of TLS arguments in a call
Summary: Incorrect expansion of TLS arguments in a call
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.8.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-12 18:10 UTC by John David Anglin
Modified: 2014-02-05 01:02 UTC (History)
1 user (show)

See Also:
Host: hppa-unknown-linux-gnu
Target: hppa-unknown-linux-gnu
Build: hppa-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Testcase. (525 bytes, text/plain)
2014-01-12 18:10 UTC, John David Anglin
Details
Output from expand. (3.13 KB, text/plain)
2014-01-12 18:13 UTC, John David Anglin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2014-01-12 18:10:39 UTC
Created attachment 31813 [details]
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().
Comment 1 John David Anglin 2014-01-12 18:13:34 UTC
Created attachment 31814 [details]
Output from expand.

One can see in .expand that TLS arguments to printf are not being
precomputed causing wrong code.
Comment 2 John David Anglin 2014-02-05 00:44:28 UTC
Author: danglin
Date: Wed Feb  5 00:43:56 2014
New Revision: 207493

URL: http://gcc.gnu.org/viewcvs?rev=207493&root=gcc&view=rev
Log:
	PR target/59777
	* config/pa/pa.c (legitimize_tls_address): Return original address
	if not passed a SYMBOL_REF rtx.
	(hppa_legitimize_address): Call legitimize_tls_address for all TLS
	addresses.
	(pa_emit_move_sequence): Simplify TLS source operands.
	(pa_legitimate_constant_p): Reject all TLS constants.
	* config/pa/pa.h (PA_SYMBOL_REF_TLS_P): Correct comment.
	(CONSTANT_ADDRESS_P): Reject TLS CONST addresses.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/pa/pa.c
    trunk/gcc/config/pa/pa.h
Comment 3 John David Anglin 2014-02-05 00:47:56 UTC
Author: danglin
Date: Wed Feb  5 00:47:25 2014
New Revision: 207494

URL: http://gcc.gnu.org/viewcvs?rev=207494&root=gcc&view=rev
Log:
	PR target/59777
	* config/pa/pa.c (legitimize_tls_address): Return original address
	if not passed a SYMBOL_REF rtx.
	(hppa_legitimize_address): Call legitimize_tls_address for all TLS
	addresses.
	(pa_emit_move_sequence): Simplify TLS source operands.
	(pa_legitimate_constant_p): Reject all TLS constants.
	* config/pa/pa.h (PA_SYMBOL_REF_TLS_P): Correct comment.
	(CONSTANT_ADDRESS_P): Reject TLS CONST addresses.


Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/config/pa/pa.c
    branches/gcc-4_8-branch/gcc/config/pa/pa.h
Comment 4 John David Anglin 2014-02-05 01:02:12 UTC
Fixed on trunk and 4.8 branch.