This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, updated] Make emulated TLS lto-friendly.


This is an update of a patch originally posted and discussed in this thread:
http://gcc.gnu.org/ml/gcc-patches/2010-06/threads.html#00995


I guess it needs a global approver - so cc-ing Diego who, IIRC, approved the previous EMUTLS changes.

changes from the previous thread.
(a) emutls.c is no longer modified in any way.
(b) I have taken on board the comments about not rearranging code.
(c) the cases where we should not have emutls variables are now asserts.

tested on {i686,powerpc*}-apple-darwin{8,9}, x86_64-apple-darwin10 - EMUTLS target without aliases.
{i686,x86_64}unknown-linux-gnu - native TLS targets (i.e. for a null response)
cris-elf(sim) - EMUTLS target with aliases
+ armel-linux-eabi(compile-only), mipsabi64-elf(sim), s390x(sompile only).


The test-suite additions are motivated by:
(a) the fact that initialization of the emults vars was a weakness w.r.t. optimization,
(b) to include the test that is used as the configury check for TLS compliance.



OK for trunk now? (and eventually 4.5)?


Iain

gcc/Changelog (email addresses omitted)
	
	Iain Sandoe
	Jan Hubika

	PR target/44132
	* expr.c (emutls_var_address): Remove.
	(expand_expr_addr_expr_1): Remove TLS emulation hook.
	(expand_expr_real_1): Ditto.

	* gimplify.c (emutls_var_address): Add proc.
	(gimplify_decl_expr): expand TLS vars.
	(gimplify_var_or_parm_decl): Ditto.
	(omp_notice_variable): Recognize TLS_MODEL_EMULATED.

* passes.c (rest_of_decl_compilation): Substitute TLS control vars for the master.

* varasm.c (get_emutls_init_templ_addr): Do not reset the caller's DECL_INITIAL.
(emutls_decl): copy DECL_PRESERVE_P instead of setting it, copy
TREE_ADDRESSABLE. Create the init template as soon as we see a valid initializer.
Mark the original var with error_mark_node so that re- initializations will be diagnosed
properly. Mark the original var as not to be output.
(emutls_common_1): Do not rely on DECL_COMMON as a decision on whether a constructor
is needed, it is also required for lcomm. Ensure that the var is laid out before the constructor
is built.
(emutls_finalize_control_var): Assert on incorrect type, copy USED.
(asm_output_bss): Assert on DECL_THREAD_LOCAL_P for EMUTLS targets.
(asm_output_aligned_bss): Likewise.
(assemble_variable): Remove TLS var. substitution. Back up TREE_ASM_WRITTEN so that
assemble_variable() has no side-effects for unwritten vars. Assert on DECL_THREAD_LOCAL_P
for EMUTLS targets.
(do_assemble_alias): Assert on DECL_THREAD_LOCAL_P for EMUTLS targets.
(var_decl_for_asm): New.
(finish_aliases_1): Walk alias pairs substituting tls controls for originals.


* passes.c (rest_of_decl_compilation): Substitute TLS control vars for the master.

* varpool.c (varpool_mark_needed_node): Do not handle TLS substitution here.
(decide_is_variable_needed): Or here.
(varpool_finalize_decl): Handle TLS substitution.
Remove early calls to varpool_assemble_pending_decls().
Check enqueuing of vars after all tests for need are complete.
(varpool_analyze_pending_decls): Do not record references if the initializer is error_mark.


testsuite:
	
	PR target/44132
	* gcc.dg/tls/thr-init-1.c: New.
	* gcc.dg/tls/thr-init-2.c: New.
	* gcc.dg/torture/tls New.
	* gcc.dg/torture/tls/tls-test.c: New.
	* gcc.dg/torture/tls/thr-init-1.c: New.
	* gcc.dg/torture/tls/tls.exp: New.
	* gcc.dg/torture/tls/thr-init-2.c: New.

Attachment: 161773-emutls-lto.txt
Description: Text document



Attachment: 161773-tls-testsuite-additions.txt
Description: Text document



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]