1 /* Lower TLS operations to emulation functions.
2 Copyright (C) 2006-2015 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
22 #include "coretypes.h"
27 #include "fold-const.h"
28 #include "stor-layout.h"
32 #include "hard-reg-set.h"
34 #include "dominance.h"
36 #include "basic-block.h"
37 #include "tree-ssa-alias.h"
38 #include "internal-fn.h"
39 #include "gimple-expr.h"
41 #include "gimple-iterator.h"
42 #include "gimple-walk.h"
43 #include "tree-pass.h"
44 #include "gimple-ssa.h"
46 #include "tree-phinodes.h"
47 #include "ssa-iterators.h"
48 #include "stringpool.h"
49 #include "tree-ssanames.h"
50 #include "langhooks.h"
52 #include "targhooks.h"
53 #include "tree-iterator.h"
55 /* Whenever a target does not support thread-local storage (TLS) natively,
56 we can emulate it with some run-time support in libgcc. This will in
57 turn rely on "keyed storage" a-la pthread_key_create; essentially all
58 thread libraries provide such functionality.
60 In order to coordinate with the libgcc runtime, each TLS variable is
61 described by a "control variable". This control variable records the
62 required size, alignment, and initial value of the TLS variable for
63 instantiation at runtime. It also stores an integer token to be used
64 by the runtime to find the address of the variable within each thread.
66 On the compiler side, this means that we need to replace all instances
67 of "tls_var" in the code with "*__emutls_get_addr(&control_var)". We
68 also need to eliminate "tls_var" from the symbol table and introduce
71 We used to perform all of the transformations during conversion to rtl,
72 and the variable substitutions magically within assemble_variable.
73 However, this late fiddling of the symbol table conflicts with LTO and
74 whole-program compilation. Therefore we must now make all the changes
75 to the symbol table early in the GIMPLE optimization path, before we
76 write things out to LTO intermediate files. */
78 /* Value for TLS varpool node where a pointer to control variable and
79 access variable are stored. */
82 varpool_node
*control_var
;
86 /* TLS map accesses mapping between a TLS varpool node and a pair
87 made by control variable and access variable. */
88 static hash_map
<varpool_node
*, tls_var_data
> *tls_map
= NULL
;
90 /* The type of the control structure, shared with the emutls.c runtime. */
91 static tree emutls_object_type
;
93 #if !defined (NO_DOT_IN_LABEL)
94 # define EMUTLS_SEPARATOR "."
95 #elif !defined (NO_DOLLAR_IN_LABEL)
96 # define EMUTLS_SEPARATOR "$"
98 # define EMUTLS_SEPARATOR "_"
101 /* Create an IDENTIFIER_NODE by prefixing PREFIX to the
102 IDENTIFIER_NODE NAME's name. */
105 prefix_name (const char *prefix
, tree name
)
107 unsigned plen
= strlen (prefix
);
108 unsigned nlen
= strlen (IDENTIFIER_POINTER (name
));
109 char *toname
= (char *) alloca (plen
+ nlen
+ 1);
111 memcpy (toname
, prefix
, plen
);
112 memcpy (toname
+ plen
, IDENTIFIER_POINTER (name
), nlen
+ 1);
114 return get_identifier (toname
);
117 /* Create an identifier for the struct __emutls_object, given an identifier
118 of the DECL_ASSEMBLY_NAME of the original object. */
121 get_emutls_object_name (tree name
)
123 const char *prefix
= (targetm
.emutls
.var_prefix
124 ? targetm
.emutls
.var_prefix
125 : "__emutls_v" EMUTLS_SEPARATOR
);
126 return prefix_name (prefix
, name
);
129 /* Create the fields of the type for the control variables. Ordinarily
130 this must match struct __emutls_object defined in emutls.c. However
131 this is a target hook so that VxWorks can define its own layout. */
134 default_emutls_var_fields (tree type
, tree
*name ATTRIBUTE_UNUSED
)
136 tree word_type_node
, field
, next_field
;
138 field
= build_decl (UNKNOWN_LOCATION
,
139 FIELD_DECL
, get_identifier ("__templ"), ptr_type_node
);
140 DECL_CONTEXT (field
) = type
;
143 field
= build_decl (UNKNOWN_LOCATION
,
144 FIELD_DECL
, get_identifier ("__offset"),
146 DECL_CONTEXT (field
) = type
;
147 DECL_CHAIN (field
) = next_field
;
150 word_type_node
= lang_hooks
.types
.type_for_mode (word_mode
, 1);
151 field
= build_decl (UNKNOWN_LOCATION
,
152 FIELD_DECL
, get_identifier ("__align"),
154 DECL_CONTEXT (field
) = type
;
155 DECL_CHAIN (field
) = next_field
;
158 field
= build_decl (UNKNOWN_LOCATION
,
159 FIELD_DECL
, get_identifier ("__size"), word_type_node
);
160 DECL_CONTEXT (field
) = type
;
161 DECL_CHAIN (field
) = next_field
;
166 /* Initialize emulated tls object TO, which refers to TLS variable DECL and
167 is initialized by PROXY. As above, this is the default implementation of
168 a target hook overridden by VxWorks. */
171 default_emutls_var_init (tree to
, tree decl
, tree proxy
)
173 vec
<constructor_elt
, va_gc
> *v
;
176 tree type
= TREE_TYPE (to
);
177 tree field
= TYPE_FIELDS (type
);
180 elt
.value
= fold_convert (TREE_TYPE (field
), DECL_SIZE_UNIT (decl
));
183 field
= DECL_CHAIN (field
);
185 elt
.value
= build_int_cst (TREE_TYPE (field
),
186 DECL_ALIGN_UNIT (decl
));
189 field
= DECL_CHAIN (field
);
191 elt
.value
= null_pointer_node
;
194 field
= DECL_CHAIN (field
);
199 return build_constructor (type
, v
);
202 /* Create the structure for struct __emutls_object. This should match the
203 structure at the top of emutls.c, modulo the union there. */
206 get_emutls_object_type (void)
208 tree type
, type_name
, field
;
210 type
= emutls_object_type
;
214 emutls_object_type
= type
= lang_hooks
.types
.make_type (RECORD_TYPE
);
216 field
= targetm
.emutls
.var_fields (type
, &type_name
);
218 type_name
= get_identifier ("__emutls_object");
219 type_name
= build_decl (UNKNOWN_LOCATION
,
220 TYPE_DECL
, type_name
, type
);
221 TYPE_NAME (type
) = type_name
;
222 TYPE_FIELDS (type
) = field
;
228 /* Create a read-only variable like DECL, with the same DECL_INITIAL.
229 This will be used for initializing the emulated tls data area. */
232 get_emutls_init_templ_addr (tree decl
)
236 if (targetm
.emutls
.register_common
&& !DECL_INITIAL (decl
)
237 && !DECL_SECTION_NAME (decl
))
238 return null_pointer_node
;
240 name
= DECL_ASSEMBLER_NAME (decl
);
241 if (!targetm
.emutls
.tmpl_prefix
|| targetm
.emutls
.tmpl_prefix
[0])
243 const char *prefix
= (targetm
.emutls
.tmpl_prefix
244 ? targetm
.emutls
.tmpl_prefix
245 : "__emutls_t" EMUTLS_SEPARATOR
);
246 name
= prefix_name (prefix
, name
);
249 to
= build_decl (DECL_SOURCE_LOCATION (decl
),
250 VAR_DECL
, name
, TREE_TYPE (decl
));
251 SET_DECL_ASSEMBLER_NAME (to
, DECL_NAME (to
));
253 DECL_ARTIFICIAL (to
) = 1;
254 TREE_USED (to
) = TREE_USED (decl
);
255 TREE_READONLY (to
) = 1;
256 DECL_IGNORED_P (to
) = 1;
257 DECL_CONTEXT (to
) = DECL_CONTEXT (decl
);
258 DECL_PRESERVE_P (to
) = DECL_PRESERVE_P (decl
);
260 DECL_WEAK (to
) = DECL_WEAK (decl
);
261 if (DECL_ONE_ONLY (decl
))
263 TREE_STATIC (to
) = TREE_STATIC (decl
);
264 TREE_PUBLIC (to
) = TREE_PUBLIC (decl
);
265 DECL_VISIBILITY (to
) = DECL_VISIBILITY (decl
);
266 make_decl_one_only (to
, DECL_ASSEMBLER_NAME (to
));
269 TREE_STATIC (to
) = 1;
271 DECL_VISIBILITY_SPECIFIED (to
) = DECL_VISIBILITY_SPECIFIED (decl
);
272 DECL_INITIAL (to
) = DECL_INITIAL (decl
);
273 DECL_INITIAL (decl
) = NULL
;
275 if (targetm
.emutls
.tmpl_section
)
276 set_decl_section_name (to
, targetm
.emutls
.tmpl_section
);
278 set_decl_section_name (to
, DECL_SECTION_NAME (decl
));
280 /* Create varpool node for the new variable and finalize it if it is
282 if (DECL_EXTERNAL (to
))
283 varpool_node::get_create (to
);
285 varpool_node::add (to
);
286 return build_fold_addr_expr (to
);
289 /* Create and return the control variable for the TLS variable DECL. */
292 new_emutls_decl (tree decl
, tree alias_of
)
296 name
= DECL_ASSEMBLER_NAME (decl
);
297 to
= build_decl (DECL_SOURCE_LOCATION (decl
), VAR_DECL
,
298 get_emutls_object_name (name
),
299 get_emutls_object_type ());
301 SET_DECL_ASSEMBLER_NAME (to
, DECL_NAME (to
));
303 DECL_ARTIFICIAL (to
) = 1;
304 DECL_IGNORED_P (to
) = 1;
305 TREE_READONLY (to
) = 0;
306 TREE_STATIC (to
) = 1;
308 DECL_PRESERVE_P (to
) = DECL_PRESERVE_P (decl
);
309 DECL_CONTEXT (to
) = DECL_CONTEXT (decl
);
310 TREE_USED (to
) = TREE_USED (decl
);
311 TREE_PUBLIC (to
) = TREE_PUBLIC (decl
);
312 DECL_EXTERNAL (to
) = DECL_EXTERNAL (decl
);
313 DECL_COMMON (to
) = DECL_COMMON (decl
);
314 DECL_WEAK (to
) = DECL_WEAK (decl
);
315 DECL_VISIBILITY (to
) = DECL_VISIBILITY (decl
);
316 DECL_VISIBILITY_SPECIFIED (to
) = DECL_VISIBILITY_SPECIFIED (decl
);
317 DECL_DLLIMPORT_P (to
) = DECL_DLLIMPORT_P (decl
);
319 DECL_ATTRIBUTES (to
) = targetm
.merge_decl_attributes (decl
, to
);
321 if (DECL_ONE_ONLY (decl
))
322 make_decl_one_only (to
, DECL_ASSEMBLER_NAME (to
));
324 set_decl_tls_model (to
, TLS_MODEL_EMULATED
);
326 /* If we're not allowed to change the proxy object's alignment,
327 pretend it has been set by the user. */
328 if (targetm
.emutls
.var_align_fixed
)
329 DECL_USER_ALIGN (to
) = 1;
331 /* If the target wants the control variables grouped, do so. */
332 if (!DECL_COMMON (to
) && targetm
.emutls
.var_section
)
334 set_decl_section_name (to
, targetm
.emutls
.var_section
);
337 /* If this variable is defined locally, then we need to initialize the
338 control structure with size and alignment information. Initialization
339 of COMMON block variables happens elsewhere via a constructor. */
340 if (!DECL_EXTERNAL (to
)
341 && (!DECL_COMMON (to
)
342 || (DECL_INITIAL (decl
)
343 && DECL_INITIAL (decl
) != error_mark_node
)))
345 tree tmpl
= get_emutls_init_templ_addr (decl
);
346 DECL_INITIAL (to
) = targetm
.emutls
.var_init (to
, decl
, tmpl
);
347 record_references_in_initializer (to
, false);
350 /* Create varpool node for the new variable and finalize it if it is
352 if (DECL_EXTERNAL (to
))
353 varpool_node::get_create (to
);
355 varpool_node::add (to
);
359 varpool_node
*t
= varpool_node::get_for_asmname
360 (DECL_ASSEMBLER_NAME (DECL_VALUE_EXPR (alias_of
)));
362 n
= varpool_node::create_alias (to
, t
->decl
);
363 n
->resolve_alias (t
);
368 /* Generate a call statement to initialize CONTROL_DECL for TLS_DECL.
369 This only needs to happen for TLS COMMON variables; non-COMMON
370 variables can be initialized statically. Insert the generated
371 call statement at the end of PSTMTS. */
374 emutls_common_1 (tree tls_decl
, tree control_decl
, tree
*pstmts
)
379 if (! DECL_COMMON (tls_decl
)
380 || (DECL_INITIAL (tls_decl
)
381 && DECL_INITIAL (tls_decl
) != error_mark_node
))
384 word_type_node
= lang_hooks
.types
.type_for_mode (word_mode
, 1);
386 x
= build_call_expr (builtin_decl_explicit (BUILT_IN_EMUTLS_REGISTER_COMMON
),
387 4, build_fold_addr_expr (control_decl
),
388 fold_convert (word_type_node
,
389 DECL_SIZE_UNIT (tls_decl
)),
390 build_int_cst (word_type_node
,
391 DECL_ALIGN_UNIT (tls_decl
)),
392 get_emutls_init_templ_addr (tls_decl
));
394 append_to_statement_list (x
, pstmts
);
397 struct lower_emutls_data
399 struct cgraph_node
*cfun_node
;
400 struct cgraph_node
*builtin_node
;
408 /* Given a TLS variable DECL, return an SSA_NAME holding its address.
409 Append any new computation statements required to D->SEQ. */
412 gen_emutls_addr (tree decl
, struct lower_emutls_data
*d
)
414 /* Compute the address of the TLS variable with help from runtime. */
415 tls_var_data
*data
= tls_map
->get (varpool_node::get (decl
));
416 tree addr
= data
->access
;
424 cvar
= data
->control_var
;
426 TREE_ADDRESSABLE (cdecl) = 1;
428 addr
= create_tmp_var (build_pointer_type (TREE_TYPE (decl
)));
429 x
= gimple_build_call (d
->builtin_decl
, 1, build_fold_addr_expr (cdecl));
430 gimple_set_location (x
, d
->loc
);
432 addr
= make_ssa_name (addr
, x
);
433 gimple_call_set_lhs (x
, addr
);
435 gimple_seq_add_stmt (&d
->seq
, x
);
437 d
->cfun_node
->create_edge (d
->builtin_node
, x
, d
->bb
->count
, d
->bb_freq
);
439 /* We may be adding a new reference to a new variable to the function.
440 This means we have to play with the ipa-reference web. */
441 d
->cfun_node
->create_reference (cvar
, IPA_REF_ADDR
, x
);
443 /* Record this ssa_name for possible use later in the basic block. */
450 /* Callback for walk_gimple_op. D = WI->INFO is a struct lower_emutls_data.
451 Given an operand *PTR within D->STMT, if the operand references a TLS
452 variable, then lower the reference to a call to the runtime. Insert
453 any new statements required into D->SEQ; the caller is responsible for
454 placing those appropriately. */
457 lower_emutls_1 (tree
*ptr
, int *walk_subtrees
, void *cb_data
)
459 struct walk_stmt_info
*wi
= (struct walk_stmt_info
*) cb_data
;
460 struct lower_emutls_data
*d
= (struct lower_emutls_data
*) wi
->info
;
462 bool is_addr
= false;
467 switch (TREE_CODE (t
))
470 /* If this is not a straight-forward "&var", but rather something
471 like "&var.a", then we may need special handling. */
472 if (TREE_CODE (TREE_OPERAND (t
, 0)) != VAR_DECL
)
476 /* If we're allowed more than just is_gimple_val, continue. */
483 /* See if any substitution would be made. */
484 save_changed
= wi
->changed
;
486 wi
->val_only
= false;
487 walk_tree (&TREE_OPERAND (t
, 0), lower_emutls_1
, wi
, NULL
);
490 /* If so, then extract this entire sub-expression "&p->a" into a
491 new assignment statement, and substitute yet another SSA_NAME. */
496 addr
= create_tmp_var (TREE_TYPE (t
));
497 x
= gimple_build_assign (addr
, t
);
498 gimple_set_location (x
, d
->loc
);
500 addr
= make_ssa_name (addr
, x
);
501 gimple_assign_set_lhs (x
, addr
);
503 gimple_seq_add_stmt (&d
->seq
, x
);
508 wi
->changed
= save_changed
;
513 t
= TREE_OPERAND (t
, 0);
518 if (!DECL_THREAD_LOCAL_P (t
))
523 /* We're not interested in other decls or types, only subexpressions. */
529 /* Special-case the return of SSA_NAME, since it's so common. */
533 addr
= gen_emutls_addr (t
, d
);
536 /* Replace "&var" with "addr" in the statement. */
541 /* Replace "var" with "*addr" in the statement. */
542 t
= build2 (MEM_REF
, TREE_TYPE (t
), addr
,
543 build_int_cst (TREE_TYPE (addr
), 0));
551 /* Lower all of the operands of STMT. */
554 lower_emutls_stmt (gimple stmt
, struct lower_emutls_data
*d
)
556 struct walk_stmt_info wi
;
558 d
->loc
= gimple_location (stmt
);
560 memset (&wi
, 0, sizeof (wi
));
563 walk_gimple_op (stmt
, lower_emutls_1
, &wi
);
569 /* Lower the I'th operand of PHI. */
572 lower_emutls_phi_arg (gphi
*phi
, unsigned int i
,
573 struct lower_emutls_data
*d
)
575 struct walk_stmt_info wi
;
576 struct phi_arg_d
*pd
= gimple_phi_arg (phi
, i
);
578 /* Early out for a very common case we don't care about. */
579 if (TREE_CODE (pd
->def
) == SSA_NAME
)
584 memset (&wi
, 0, sizeof (wi
));
587 walk_tree (&pd
->def
, lower_emutls_1
, &wi
, NULL
);
589 /* For normal statements, we let update_stmt do its job. But for phi
590 nodes, we have to manipulate the immediate use list by hand. */
593 gcc_assert (TREE_CODE (pd
->def
) == SSA_NAME
);
594 link_imm_use_stmt (&pd
->imm_use
, pd
->def
, phi
);
598 /* Reset access variable for a given TLS variable data DATA. */
601 reset_access (varpool_node
* const &, tls_var_data
*data
, void *)
608 /* Clear the access variables, in order to begin a new block. */
611 clear_access_vars (void)
613 tls_map
->traverse
<void *, reset_access
> (NULL
);
616 /* Lower the entire function NODE. */
619 lower_emutls_function_body (struct cgraph_node
*node
)
621 struct lower_emutls_data d
;
622 bool any_edge_inserts
= false;
624 push_cfun (DECL_STRUCT_FUNCTION (node
->decl
));
627 d
.builtin_decl
= builtin_decl_explicit (BUILT_IN_EMUTLS_GET_ADDRESS
);
628 /* This is where we introduce the declaration to the IL and so we have to
629 create a node for it. */
630 d
.builtin_node
= cgraph_node::get_create (d
.builtin_decl
);
632 FOR_EACH_BB_FN (d
.bb
, cfun
)
634 unsigned int i
, nedge
;
636 /* Lower each of the PHI nodes of the block, as we may have
637 propagated &tlsvar into a PHI argument. These loops are
638 arranged so that we process each edge at once, and each
639 PHI argument for that edge. */
640 if (!gimple_seq_empty_p (phi_nodes (d
.bb
)))
642 /* The calls will be inserted on the edges, and the frequencies
643 will be computed during the commit process. */
646 nedge
= EDGE_COUNT (d
.bb
->preds
);
647 for (i
= 0; i
< nedge
; ++i
)
649 edge e
= EDGE_PRED (d
.bb
, i
);
651 /* We can re-use any SSA_NAME created on this edge. */
652 clear_access_vars ();
655 for (gphi_iterator gsi
= gsi_start_phis (d
.bb
);
658 lower_emutls_phi_arg (gsi
.phi (), i
, &d
);
660 /* Insert all statements generated by all phi nodes for this
661 particular edge all at once. */
664 gsi_insert_seq_on_edge (e
, d
.seq
);
665 any_edge_inserts
= true;
670 d
.bb_freq
= compute_call_stmt_bb_frequency (current_function_decl
, d
.bb
);
672 /* We can re-use any SSA_NAME created during this basic block. */
673 clear_access_vars ();
675 /* Lower each of the statements of the block. */
676 for (gimple_stmt_iterator gsi
= gsi_start_bb (d
.bb
); !gsi_end_p (gsi
);
680 lower_emutls_stmt (gsi_stmt (gsi
), &d
);
682 /* If any new statements were created, insert them immediately
683 before the first use. This prevents variable lifetimes from
684 becoming unnecessarily long. */
686 gsi_insert_seq_before (&gsi
, d
.seq
, GSI_SAME_STMT
);
690 if (any_edge_inserts
)
691 gsi_commit_edge_inserts ();
696 /* Create emutls variable for VAR, DATA is pointer to static
697 ctor body we can add constructors to.
698 Callback for varpool_for_variable_and_aliases. */
701 create_emultls_var (varpool_node
*var
, void *data
)
706 cdecl = new_emutls_decl (var
->decl
,
707 var
->alias
&& var
->analyzed
708 ? var
->get_alias_target ()->decl
: NULL
);
710 varpool_node
*cvar
= varpool_node::get (cdecl);
714 /* Make sure the COMMON block control variable gets initialized.
715 Note that there's no point in doing this for aliases; we only
716 need to do this once for the main variable. */
717 emutls_common_1 (var
->decl
, cdecl, (tree
*)data
);
719 if (var
->alias
&& !var
->analyzed
)
722 /* Indicate that the value of the TLS variable may be found elsewhere,
723 preventing the variable from re-appearing in the GIMPLE. We cheat
724 and use the control variable here (rather than a full call_expr),
725 which is special-cased inside the DWARF2 output routines. */
726 SET_DECL_VALUE_EXPR (var
->decl
, cdecl);
727 DECL_HAS_VALUE_EXPR_P (var
->decl
) = 1;
729 value
.control_var
= cvar
;
730 tls_map
->put (var
, value
);
735 /* Main entry point to the tls lowering pass. */
738 ipa_lower_emutls (void)
742 bool any_aliases
= false;
743 tree ctor_body
= NULL
;
744 hash_set
<varpool_node
*> visited
;
745 auto_vec
<varpool_node
*> tls_vars
;
747 /* Examine all global variables for TLS variables. */
748 FOR_EACH_VARIABLE (var
)
749 if (DECL_THREAD_LOCAL_P (var
->decl
)
750 && !visited
.add (var
))
752 gcc_checking_assert (TREE_STATIC (var
->decl
)
753 || DECL_EXTERNAL (var
->decl
));
754 tls_vars
.safe_push (var
);
755 if (var
->alias
&& var
->definition
756 && !visited
.add (var
->ultimate_alias_target ()))
757 tls_vars
.safe_push (var
->ultimate_alias_target ());
760 /* If we found no TLS variables, then there is no further work to do. */
761 if (tls_vars
.is_empty ())
764 fprintf (dump_file
, "No TLS variables found.\n");
768 tls_map
= new hash_map
<varpool_node
*, tls_var_data
> ();
770 /* Create the control variables for each TLS variable. */
771 for (unsigned i
= 0; i
< tls_vars
.length (); i
++)
775 if (var
->alias
&& !var
->analyzed
)
777 else if (!var
->alias
)
778 var
->call_for_symbol_and_aliases (create_emultls_var
, &ctor_body
, true);
781 /* If there were any aliases, then frob the alias_pairs vector. */
786 FOR_EACH_VEC_SAFE_ELT (alias_pairs
, i
, p
)
787 if (DECL_THREAD_LOCAL_P (p
->decl
))
789 p
->decl
= tls_map
->get
790 (varpool_node::get (p
->decl
))->control_var
->decl
;
791 p
->target
= get_emutls_object_name (p
->target
);
795 /* Adjust all uses of TLS variables within the function bodies. */
796 FOR_EACH_DEFINED_FUNCTION (func
)
798 lower_emutls_function_body (func
);
800 /* Generate the constructor for any COMMON control variables created. */
802 cgraph_build_static_cdtor ('I', ctor_body
, DEFAULT_INIT_PRIORITY
);
811 const pass_data pass_data_ipa_lower_emutls
=
813 SIMPLE_IPA_PASS
, /* type */
815 OPTGROUP_NONE
, /* optinfo_flags */
816 TV_IPA_OPT
, /* tv_id */
817 ( PROP_cfg
| PROP_ssa
), /* properties_required */
818 0, /* properties_provided */
819 0, /* properties_destroyed */
820 0, /* todo_flags_start */
821 0, /* todo_flags_finish */
824 class pass_ipa_lower_emutls
: public simple_ipa_opt_pass
827 pass_ipa_lower_emutls (gcc::context
*ctxt
)
828 : simple_ipa_opt_pass (pass_data_ipa_lower_emutls
, ctxt
)
831 /* opt_pass methods: */
832 virtual bool gate (function
*)
834 /* If the target supports TLS natively, we need do nothing here. */
835 return !targetm
.have_tls
;
838 virtual unsigned int execute (function
*) { return ipa_lower_emutls (); }
840 }; // class pass_ipa_lower_emutls
844 simple_ipa_opt_pass
*
845 make_pass_ipa_lower_emutls (gcc::context
*ctxt
)
847 return new pass_ipa_lower_emutls (ctxt
);