On Wed, Mar 18, 2015 at 9:25 PM, Xinliang David Li <davi...@google.com> wrote:
> get_local_tls_init_fn can be called from other contexts other than
> 'handle_tls_init' -- is the added new assertion safe ?

In fact there is still an issue here, for file static TLS vars. Will
work on a fix and send the original test case (forgot to include in
first patch) and the new one with the fixed patch.

Teresa

>
> David
>
> On Wed, Mar 18, 2015 at 9:18 PM, Teresa Johnson <tejohn...@google.com>
> wrote:
>>
>> Ensure TLS variable wrapper and init functions are recorded at
>> the module scope upon creation so that they are cleared when
>> popping the module scope in between modules in LIPO mode.
>>
>> Also, do not generate a local TLS init function (__tls_init)
>> for aux functions, only in the primary modules.
>>
>> Passes regression tests. Ok for Google branches?
>> Teresa
>>
>> 2015-03-18  Teresa Johnson  <tejohn...@google.com>
>>
>>         Google ref b/19618364.
>>         * cp/decl2.c (get_local_tls_init_fn): Assert on aux module.
>>         (get_tls_init_fn): Record new global decl.
>>         (get_tls_wrapper_fn): Ditto.
>>         (handle_tls_init): Skip aux modules.
>>
>> Index: cp/decl2.c
>> ===================================================================
>> --- cp/decl2.c  (revision 221425)
>> +++ cp/decl2.c  (working copy)
>> @@ -3036,6 +3036,9 @@ get_local_tls_init_fn (void)
>>        DECL_ARTIFICIAL (fn) = true;
>>        mark_used (fn);
>>        SET_IDENTIFIER_GLOBAL_VALUE (sname, fn);
>> +      /* In LIPO mode we should not generate local init functions for
>> +         the aux modules (see handle_tls_init).  */
>> +      gcc_assert (!L_IPO_IS_AUXILIARY_MODULE);
>>      }
>>    return fn;
>>  }
>> @@ -3100,6 +3103,11 @@ get_tls_init_fn (tree var)
>>        DECL_BEFRIENDING_CLASSES (fn) = var;
>>
>>        SET_IDENTIFIER_GLOBAL_VALUE (sname, fn);
>> +      /* In LIPO mode make sure we record the new global value so that it
>> +         is cleared before parsing the next aux module.  */
>> +      if (L_IPO_COMP_MODE && !is_parsing_done_p ())
>> +        add_decl_to_current_module_scope (fn,
>> +                                          NAMESPACE_LEVEL
>> (global_namespace));
>>      }
>>    return fn;
>>  }
>> @@ -3157,6 +3165,11 @@ get_tls_wrapper_fn (tree var)
>>        DECL_BEFRIENDING_CLASSES (fn) = var;
>>
>>        SET_IDENTIFIER_GLOBAL_VALUE (sname, fn);
>> +      /* In LIPO mode make sure we record the new global value so that it
>> +         is cleared before parsing the next aux module.  */
>> +      if (L_IPO_COMP_MODE && !is_parsing_done_p ())
>> +        add_decl_to_current_module_scope (fn,
>> +                                          NAMESPACE_LEVEL
>> (global_namespace));
>>      }
>>    return fn;
>>  }
>> @@ -4179,6 +4192,14 @@ clear_decl_external (struct cgraph_node *node, voi
>>  static void
>>  handle_tls_init (void)
>>  {
>> +  /* In LIPO mode we should not generate local init functions for
>> +     aux modules. The wrapper will reference the variable's init function
>> +     that is defined in its own primary module. Otherwise there is
>> +     a name conflict between the primary and aux __tls_init functions,
>> +     and difficulty ensuring each TLS variable is initialized exactly
>> once.  */
>> +  if (L_IPO_IS_AUXILIARY_MODULE)
>> +    return;
>> +
>>    tree vars = prune_vars_needing_no_initialization (&tls_aggregates);
>>    if (vars == NULL_TREE)
>>      return;
>>
>>
>> --
>> Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413
>
>



-- 
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413

Reply via email to