[Sorry, I forgot to copy GCC Patches before] Some of the libgomp testcases fail on AIX when using native TLS because variables annotated with
#pragma omp threadprivate(thr) sometimes are placed in section anchor blocks. Variables declared with "__thread" create decls with the correct TLS model from the beginning, but OpenMP sometimes creates a decl with TLS_MODEL_NONE and later tries to make the decl again. make_decl_rtl() is called again and it calls ENCODE_SECTION_INFO and then change_symbol_block(). However ENCODE_SECTION_INFO explicitly preserves SYMBOL_FLAG_HAS_BLOCK_INFO and change_symbol_block() place the symbol in a different block but never re-assesses if the new attributes of the symbol make it in appropriate for section anchor blocks. The following patch adds an ENCODE_SECTION_INFO hook for AIX that removes the SYMBOL_FLAG_HAS_BLOCK_INFO flag if the symbol is DECL_THREAD_LOCAL_P. This prevents the symbol from being emitted in a section anchor block and it correctly is emitted in its own section; it does not remove it from the section anchor blocks data structures. This fixes some of the libgomp failures. Is this a reasonable approach? Or should change_symbol_block re-test use_blocks_for_symbol_p()? Thanks, David Index: rs6000.c =================================================================== --- rs6000.c (revision 194278) +++ rs6000.c (working copy) @@ -25886,6 +25886,29 @@ ? "\t.long _section_.text\n" : "\t.llong _section_.text\n", asm_out_file); } + +static void +rs6000_xcoff_encode_section_info (tree decl, rtx rtl, int first) +{ + rtx symbol; + int flags; + + default_encode_section_info (decl, rtl, first); + + /* Careful not to prod global register variables. */ + if (!MEM_P (rtl)) + return; + symbol = XEXP (rtl, 0); + if (GET_CODE (symbol) != SYMBOL_REF) + return; + + flags = SYMBOL_REF_FLAGS (symbol); + + if (TREE_CODE (decl) == VAR_DECL && DECL_THREAD_LOCAL_P (decl)) + flags &= ~SYMBOL_FLAG_HAS_BLOCK_INFO; + + SYMBOL_REF_FLAGS (symbol) = flags; +} #endif /* TARGET_XCOFF */ /* Compute a (partial) cost for rtx X. Return true if the complete