1*38fd1498Szrj /* Lower TLS operations to emulation functions.
2*38fd1498Szrj Copyright (C) 2006-2018 Free Software Foundation, Inc.
3*38fd1498Szrj
4*38fd1498Szrj This file is part of GCC.
5*38fd1498Szrj
6*38fd1498Szrj GCC is free software; you can redistribute it and/or modify it
7*38fd1498Szrj under the terms of the GNU General Public License as published by the
8*38fd1498Szrj Free Software Foundation; either version 3, or (at your option) any
9*38fd1498Szrj later version.
10*38fd1498Szrj
11*38fd1498Szrj GCC is distributed in the hope that it will be useful, but WITHOUT
12*38fd1498Szrj ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13*38fd1498Szrj FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14*38fd1498Szrj for more details.
15*38fd1498Szrj
16*38fd1498Szrj You should have received a copy of the GNU General Public License
17*38fd1498Szrj along with GCC; see the file COPYING3. If not see
18*38fd1498Szrj <http://www.gnu.org/licenses/>. */
19*38fd1498Szrj
20*38fd1498Szrj #include "config.h"
21*38fd1498Szrj #include "system.h"
22*38fd1498Szrj #include "coretypes.h"
23*38fd1498Szrj #include "backend.h"
24*38fd1498Szrj #include "target.h"
25*38fd1498Szrj #include "tree.h"
26*38fd1498Szrj #include "gimple.h"
27*38fd1498Szrj #include "tree-pass.h"
28*38fd1498Szrj #include "ssa.h"
29*38fd1498Szrj #include "cgraph.h"
30*38fd1498Szrj #include "fold-const.h"
31*38fd1498Szrj #include "stor-layout.h"
32*38fd1498Szrj #include "varasm.h"
33*38fd1498Szrj #include "gimple-iterator.h"
34*38fd1498Szrj #include "gimple-walk.h"
35*38fd1498Szrj #include "langhooks.h"
36*38fd1498Szrj #include "tree-iterator.h"
37*38fd1498Szrj #include "gimplify.h"
38*38fd1498Szrj
39*38fd1498Szrj /* Whenever a target does not support thread-local storage (TLS) natively,
40*38fd1498Szrj we can emulate it with some run-time support in libgcc. This will in
41*38fd1498Szrj turn rely on "keyed storage" a-la pthread_key_create; essentially all
42*38fd1498Szrj thread libraries provide such functionality.
43*38fd1498Szrj
44*38fd1498Szrj In order to coordinate with the libgcc runtime, each TLS variable is
45*38fd1498Szrj described by a "control variable". This control variable records the
46*38fd1498Szrj required size, alignment, and initial value of the TLS variable for
47*38fd1498Szrj instantiation at runtime. It also stores an integer token to be used
48*38fd1498Szrj by the runtime to find the address of the variable within each thread.
49*38fd1498Szrj
50*38fd1498Szrj On the compiler side, this means that we need to replace all instances
51*38fd1498Szrj of "tls_var" in the code with "*__emutls_get_addr(&control_var)". We
52*38fd1498Szrj also need to eliminate "tls_var" from the symbol table and introduce
53*38fd1498Szrj "control_var".
54*38fd1498Szrj
55*38fd1498Szrj We used to perform all of the transformations during conversion to rtl,
56*38fd1498Szrj and the variable substitutions magically within assemble_variable.
57*38fd1498Szrj However, this late fiddling of the symbol table conflicts with LTO and
58*38fd1498Szrj whole-program compilation. Therefore we must now make all the changes
59*38fd1498Szrj to the symbol table early in the GIMPLE optimization path, before we
60*38fd1498Szrj write things out to LTO intermediate files. */
61*38fd1498Szrj
62*38fd1498Szrj /* Value for TLS varpool node where a pointer to control variable and
63*38fd1498Szrj access variable are stored. */
64*38fd1498Szrj struct tls_var_data
65*38fd1498Szrj {
66*38fd1498Szrj varpool_node *control_var;
67*38fd1498Szrj tree access;
68*38fd1498Szrj };
69*38fd1498Szrj
70*38fd1498Szrj /* TLS map accesses mapping between a TLS varpool node and a pair
71*38fd1498Szrj made by control variable and access variable. */
72*38fd1498Szrj static hash_map<varpool_node *, tls_var_data> *tls_map = NULL;
73*38fd1498Szrj
74*38fd1498Szrj /* The type of the control structure, shared with the emutls.c runtime. */
75*38fd1498Szrj static tree emutls_object_type;
76*38fd1498Szrj
77*38fd1498Szrj #if !defined (NO_DOT_IN_LABEL)
78*38fd1498Szrj # define EMUTLS_SEPARATOR "."
79*38fd1498Szrj #elif !defined (NO_DOLLAR_IN_LABEL)
80*38fd1498Szrj # define EMUTLS_SEPARATOR "$"
81*38fd1498Szrj #else
82*38fd1498Szrj # define EMUTLS_SEPARATOR "_"
83*38fd1498Szrj #endif
84*38fd1498Szrj
85*38fd1498Szrj /* Create an IDENTIFIER_NODE by prefixing PREFIX to the
86*38fd1498Szrj IDENTIFIER_NODE NAME's name. */
87*38fd1498Szrj
88*38fd1498Szrj static tree
prefix_name(const char * prefix,tree name)89*38fd1498Szrj prefix_name (const char *prefix, tree name)
90*38fd1498Szrj {
91*38fd1498Szrj unsigned plen = strlen (prefix);
92*38fd1498Szrj unsigned nlen = strlen (IDENTIFIER_POINTER (name));
93*38fd1498Szrj char *toname = (char *) alloca (plen + nlen + 1);
94*38fd1498Szrj
95*38fd1498Szrj memcpy (toname, prefix, plen);
96*38fd1498Szrj memcpy (toname + plen, IDENTIFIER_POINTER (name), nlen + 1);
97*38fd1498Szrj
98*38fd1498Szrj return get_identifier (toname);
99*38fd1498Szrj }
100*38fd1498Szrj
101*38fd1498Szrj /* Create an identifier for the struct __emutls_object, given an identifier
102*38fd1498Szrj of the DECL_ASSEMBLY_NAME of the original object. */
103*38fd1498Szrj
104*38fd1498Szrj static tree
get_emutls_object_name(tree name)105*38fd1498Szrj get_emutls_object_name (tree name)
106*38fd1498Szrj {
107*38fd1498Szrj const char *prefix = (targetm.emutls.var_prefix
108*38fd1498Szrj ? targetm.emutls.var_prefix
109*38fd1498Szrj : "__emutls_v" EMUTLS_SEPARATOR);
110*38fd1498Szrj return prefix_name (prefix, name);
111*38fd1498Szrj }
112*38fd1498Szrj
113*38fd1498Szrj /* Create the fields of the type for the control variables. Ordinarily
114*38fd1498Szrj this must match struct __emutls_object defined in emutls.c. However
115*38fd1498Szrj this is a target hook so that VxWorks can define its own layout. */
116*38fd1498Szrj
117*38fd1498Szrj tree
default_emutls_var_fields(tree type,tree * name ATTRIBUTE_UNUSED)118*38fd1498Szrj default_emutls_var_fields (tree type, tree *name ATTRIBUTE_UNUSED)
119*38fd1498Szrj {
120*38fd1498Szrj tree word_type_node, field, next_field;
121*38fd1498Szrj
122*38fd1498Szrj field = build_decl (UNKNOWN_LOCATION,
123*38fd1498Szrj FIELD_DECL, get_identifier ("__templ"), ptr_type_node);
124*38fd1498Szrj DECL_CONTEXT (field) = type;
125*38fd1498Szrj next_field = field;
126*38fd1498Szrj
127*38fd1498Szrj field = build_decl (UNKNOWN_LOCATION,
128*38fd1498Szrj FIELD_DECL, get_identifier ("__offset"),
129*38fd1498Szrj ptr_type_node);
130*38fd1498Szrj DECL_CONTEXT (field) = type;
131*38fd1498Szrj DECL_CHAIN (field) = next_field;
132*38fd1498Szrj next_field = field;
133*38fd1498Szrj
134*38fd1498Szrj word_type_node = lang_hooks.types.type_for_mode (word_mode, 1);
135*38fd1498Szrj field = build_decl (UNKNOWN_LOCATION,
136*38fd1498Szrj FIELD_DECL, get_identifier ("__align"),
137*38fd1498Szrj word_type_node);
138*38fd1498Szrj DECL_CONTEXT (field) = type;
139*38fd1498Szrj DECL_CHAIN (field) = next_field;
140*38fd1498Szrj next_field = field;
141*38fd1498Szrj
142*38fd1498Szrj field = build_decl (UNKNOWN_LOCATION,
143*38fd1498Szrj FIELD_DECL, get_identifier ("__size"), word_type_node);
144*38fd1498Szrj DECL_CONTEXT (field) = type;
145*38fd1498Szrj DECL_CHAIN (field) = next_field;
146*38fd1498Szrj
147*38fd1498Szrj return field;
148*38fd1498Szrj }
149*38fd1498Szrj
150*38fd1498Szrj /* Initialize emulated tls object TO, which refers to TLS variable DECL and
151*38fd1498Szrj is initialized by PROXY. As above, this is the default implementation of
152*38fd1498Szrj a target hook overridden by VxWorks. */
153*38fd1498Szrj
154*38fd1498Szrj tree
default_emutls_var_init(tree to,tree decl,tree proxy)155*38fd1498Szrj default_emutls_var_init (tree to, tree decl, tree proxy)
156*38fd1498Szrj {
157*38fd1498Szrj vec<constructor_elt, va_gc> *v;
158*38fd1498Szrj vec_alloc (v, 4);
159*38fd1498Szrj constructor_elt elt;
160*38fd1498Szrj tree type = TREE_TYPE (to);
161*38fd1498Szrj tree field = TYPE_FIELDS (type);
162*38fd1498Szrj
163*38fd1498Szrj elt.index = field;
164*38fd1498Szrj elt.value = fold_convert (TREE_TYPE (field), DECL_SIZE_UNIT (decl));
165*38fd1498Szrj v->quick_push (elt);
166*38fd1498Szrj
167*38fd1498Szrj field = DECL_CHAIN (field);
168*38fd1498Szrj elt.index = field;
169*38fd1498Szrj elt.value = build_int_cst (TREE_TYPE (field),
170*38fd1498Szrj DECL_ALIGN_UNIT (decl));
171*38fd1498Szrj v->quick_push (elt);
172*38fd1498Szrj
173*38fd1498Szrj field = DECL_CHAIN (field);
174*38fd1498Szrj elt.index = field;
175*38fd1498Szrj elt.value = null_pointer_node;
176*38fd1498Szrj v->quick_push (elt);
177*38fd1498Szrj
178*38fd1498Szrj field = DECL_CHAIN (field);
179*38fd1498Szrj elt.index = field;
180*38fd1498Szrj elt.value = proxy;
181*38fd1498Szrj v->quick_push (elt);
182*38fd1498Szrj
183*38fd1498Szrj return build_constructor (type, v);
184*38fd1498Szrj }
185*38fd1498Szrj
186*38fd1498Szrj /* Create the structure for struct __emutls_object. This should match the
187*38fd1498Szrj structure at the top of emutls.c, modulo the union there. */
188*38fd1498Szrj
189*38fd1498Szrj static tree
get_emutls_object_type(void)190*38fd1498Szrj get_emutls_object_type (void)
191*38fd1498Szrj {
192*38fd1498Szrj tree type, type_name, field;
193*38fd1498Szrj
194*38fd1498Szrj type = emutls_object_type;
195*38fd1498Szrj if (type)
196*38fd1498Szrj return type;
197*38fd1498Szrj
198*38fd1498Szrj emutls_object_type = type = lang_hooks.types.make_type (RECORD_TYPE);
199*38fd1498Szrj type_name = NULL;
200*38fd1498Szrj field = targetm.emutls.var_fields (type, &type_name);
201*38fd1498Szrj if (!type_name)
202*38fd1498Szrj type_name = get_identifier ("__emutls_object");
203*38fd1498Szrj type_name = build_decl (UNKNOWN_LOCATION,
204*38fd1498Szrj TYPE_DECL, type_name, type);
205*38fd1498Szrj TYPE_NAME (type) = type_name;
206*38fd1498Szrj TYPE_FIELDS (type) = field;
207*38fd1498Szrj layout_type (type);
208*38fd1498Szrj
209*38fd1498Szrj return type;
210*38fd1498Szrj }
211*38fd1498Szrj
212*38fd1498Szrj /* Create a read-only variable like DECL, with the same DECL_INITIAL.
213*38fd1498Szrj This will be used for initializing the emulated tls data area. */
214*38fd1498Szrj
215*38fd1498Szrj static tree
get_emutls_init_templ_addr(tree decl)216*38fd1498Szrj get_emutls_init_templ_addr (tree decl)
217*38fd1498Szrj {
218*38fd1498Szrj tree name, to;
219*38fd1498Szrj
220*38fd1498Szrj if (targetm.emutls.register_common && !DECL_INITIAL (decl)
221*38fd1498Szrj && !DECL_SECTION_NAME (decl))
222*38fd1498Szrj return null_pointer_node;
223*38fd1498Szrj
224*38fd1498Szrj name = DECL_ASSEMBLER_NAME (decl);
225*38fd1498Szrj if (!targetm.emutls.tmpl_prefix || targetm.emutls.tmpl_prefix[0])
226*38fd1498Szrj {
227*38fd1498Szrj const char *prefix = (targetm.emutls.tmpl_prefix
228*38fd1498Szrj ? targetm.emutls.tmpl_prefix
229*38fd1498Szrj : "__emutls_t" EMUTLS_SEPARATOR);
230*38fd1498Szrj name = prefix_name (prefix, name);
231*38fd1498Szrj }
232*38fd1498Szrj
233*38fd1498Szrj to = build_decl (DECL_SOURCE_LOCATION (decl),
234*38fd1498Szrj VAR_DECL, name, TREE_TYPE (decl));
235*38fd1498Szrj SET_DECL_ASSEMBLER_NAME (to, DECL_NAME (to));
236*38fd1498Szrj
237*38fd1498Szrj DECL_ARTIFICIAL (to) = 1;
238*38fd1498Szrj TREE_USED (to) = TREE_USED (decl);
239*38fd1498Szrj TREE_READONLY (to) = 1;
240*38fd1498Szrj DECL_IGNORED_P (to) = 1;
241*38fd1498Szrj DECL_CONTEXT (to) = DECL_CONTEXT (decl);
242*38fd1498Szrj DECL_PRESERVE_P (to) = DECL_PRESERVE_P (decl);
243*38fd1498Szrj
244*38fd1498Szrj DECL_WEAK (to) = DECL_WEAK (decl);
245*38fd1498Szrj if (DECL_ONE_ONLY (decl))
246*38fd1498Szrj {
247*38fd1498Szrj TREE_STATIC (to) = TREE_STATIC (decl);
248*38fd1498Szrj TREE_PUBLIC (to) = TREE_PUBLIC (decl);
249*38fd1498Szrj DECL_VISIBILITY (to) = DECL_VISIBILITY (decl);
250*38fd1498Szrj make_decl_one_only (to, DECL_ASSEMBLER_NAME (to));
251*38fd1498Szrj }
252*38fd1498Szrj else
253*38fd1498Szrj TREE_STATIC (to) = 1;
254*38fd1498Szrj
255*38fd1498Szrj DECL_VISIBILITY_SPECIFIED (to) = DECL_VISIBILITY_SPECIFIED (decl);
256*38fd1498Szrj DECL_INITIAL (to) = DECL_INITIAL (decl);
257*38fd1498Szrj DECL_INITIAL (decl) = NULL;
258*38fd1498Szrj
259*38fd1498Szrj if (targetm.emutls.tmpl_section)
260*38fd1498Szrj set_decl_section_name (to, targetm.emutls.tmpl_section);
261*38fd1498Szrj else
262*38fd1498Szrj set_decl_section_name (to, DECL_SECTION_NAME (decl));
263*38fd1498Szrj
264*38fd1498Szrj /* Create varpool node for the new variable and finalize it if it is
265*38fd1498Szrj not external one. */
266*38fd1498Szrj if (DECL_EXTERNAL (to))
267*38fd1498Szrj varpool_node::get_create (to);
268*38fd1498Szrj else
269*38fd1498Szrj varpool_node::add (to);
270*38fd1498Szrj return build_fold_addr_expr (to);
271*38fd1498Szrj }
272*38fd1498Szrj
273*38fd1498Szrj /* Create and return the control variable for the TLS variable DECL. */
274*38fd1498Szrj
275*38fd1498Szrj static tree
new_emutls_decl(tree decl,tree alias_of)276*38fd1498Szrj new_emutls_decl (tree decl, tree alias_of)
277*38fd1498Szrj {
278*38fd1498Szrj tree name, to;
279*38fd1498Szrj
280*38fd1498Szrj name = DECL_ASSEMBLER_NAME (decl);
281*38fd1498Szrj to = build_decl (DECL_SOURCE_LOCATION (decl), VAR_DECL,
282*38fd1498Szrj get_emutls_object_name (name),
283*38fd1498Szrj get_emutls_object_type ());
284*38fd1498Szrj
285*38fd1498Szrj SET_DECL_ASSEMBLER_NAME (to, DECL_NAME (to));
286*38fd1498Szrj
287*38fd1498Szrj DECL_ARTIFICIAL (to) = 1;
288*38fd1498Szrj DECL_IGNORED_P (to) = 1;
289*38fd1498Szrj TREE_READONLY (to) = 0;
290*38fd1498Szrj TREE_STATIC (to) = 1;
291*38fd1498Szrj
292*38fd1498Szrj DECL_PRESERVE_P (to) = DECL_PRESERVE_P (decl);
293*38fd1498Szrj DECL_CONTEXT (to) = DECL_CONTEXT (decl);
294*38fd1498Szrj TREE_USED (to) = TREE_USED (decl);
295*38fd1498Szrj TREE_PUBLIC (to) = TREE_PUBLIC (decl);
296*38fd1498Szrj DECL_EXTERNAL (to) = DECL_EXTERNAL (decl);
297*38fd1498Szrj DECL_COMMON (to) = DECL_COMMON (decl);
298*38fd1498Szrj DECL_WEAK (to) = DECL_WEAK (decl);
299*38fd1498Szrj DECL_VISIBILITY (to) = DECL_VISIBILITY (decl);
300*38fd1498Szrj DECL_VISIBILITY_SPECIFIED (to) = DECL_VISIBILITY_SPECIFIED (decl);
301*38fd1498Szrj DECL_DLLIMPORT_P (to) = DECL_DLLIMPORT_P (decl);
302*38fd1498Szrj
303*38fd1498Szrj DECL_ATTRIBUTES (to) = targetm.merge_decl_attributes (decl, to);
304*38fd1498Szrj
305*38fd1498Szrj if (DECL_ONE_ONLY (decl))
306*38fd1498Szrj make_decl_one_only (to, DECL_ASSEMBLER_NAME (to));
307*38fd1498Szrj
308*38fd1498Szrj set_decl_tls_model (to, TLS_MODEL_EMULATED);
309*38fd1498Szrj
310*38fd1498Szrj /* If we're not allowed to change the proxy object's alignment,
311*38fd1498Szrj pretend it has been set by the user. */
312*38fd1498Szrj if (targetm.emutls.var_align_fixed)
313*38fd1498Szrj DECL_USER_ALIGN (to) = 1;
314*38fd1498Szrj
315*38fd1498Szrj /* If the target wants the control variables grouped, do so. */
316*38fd1498Szrj if (!DECL_COMMON (to) && targetm.emutls.var_section)
317*38fd1498Szrj {
318*38fd1498Szrj set_decl_section_name (to, targetm.emutls.var_section);
319*38fd1498Szrj }
320*38fd1498Szrj
321*38fd1498Szrj /* If this variable is defined locally, then we need to initialize the
322*38fd1498Szrj control structure with size and alignment information. Initialization
323*38fd1498Szrj of COMMON block variables happens elsewhere via a constructor. */
324*38fd1498Szrj if (!DECL_EXTERNAL (to)
325*38fd1498Szrj && (!DECL_COMMON (to)
326*38fd1498Szrj || (DECL_INITIAL (decl)
327*38fd1498Szrj && DECL_INITIAL (decl) != error_mark_node)))
328*38fd1498Szrj {
329*38fd1498Szrj tree tmpl = get_emutls_init_templ_addr (decl);
330*38fd1498Szrj DECL_INITIAL (to) = targetm.emutls.var_init (to, decl, tmpl);
331*38fd1498Szrj record_references_in_initializer (to, false);
332*38fd1498Szrj }
333*38fd1498Szrj
334*38fd1498Szrj /* Create varpool node for the new variable and finalize it if it is
335*38fd1498Szrj not external one. */
336*38fd1498Szrj if (DECL_EXTERNAL (to))
337*38fd1498Szrj varpool_node::get_create (to);
338*38fd1498Szrj else if (!alias_of)
339*38fd1498Szrj varpool_node::add (to);
340*38fd1498Szrj else
341*38fd1498Szrj {
342*38fd1498Szrj varpool_node *n;
343*38fd1498Szrj varpool_node *t = varpool_node::get_for_asmname
344*38fd1498Szrj (DECL_ASSEMBLER_NAME (DECL_VALUE_EXPR (alias_of)));
345*38fd1498Szrj
346*38fd1498Szrj n = varpool_node::create_alias (to, t->decl);
347*38fd1498Szrj n->resolve_alias (t);
348*38fd1498Szrj }
349*38fd1498Szrj return to;
350*38fd1498Szrj }
351*38fd1498Szrj
352*38fd1498Szrj /* Generate a call statement to initialize CONTROL_DECL for TLS_DECL.
353*38fd1498Szrj This only needs to happen for TLS COMMON variables; non-COMMON
354*38fd1498Szrj variables can be initialized statically. Insert the generated
355*38fd1498Szrj call statement at the end of PSTMTS. */
356*38fd1498Szrj
357*38fd1498Szrj static void
emutls_common_1(tree tls_decl,tree control_decl,tree * pstmts)358*38fd1498Szrj emutls_common_1 (tree tls_decl, tree control_decl, tree *pstmts)
359*38fd1498Szrj {
360*38fd1498Szrj tree x;
361*38fd1498Szrj tree word_type_node;
362*38fd1498Szrj
363*38fd1498Szrj if (! DECL_COMMON (tls_decl)
364*38fd1498Szrj || (DECL_INITIAL (tls_decl)
365*38fd1498Szrj && DECL_INITIAL (tls_decl) != error_mark_node))
366*38fd1498Szrj return;
367*38fd1498Szrj
368*38fd1498Szrj word_type_node = lang_hooks.types.type_for_mode (word_mode, 1);
369*38fd1498Szrj
370*38fd1498Szrj x = build_call_expr (builtin_decl_explicit (BUILT_IN_EMUTLS_REGISTER_COMMON),
371*38fd1498Szrj 4, build_fold_addr_expr (control_decl),
372*38fd1498Szrj fold_convert (word_type_node,
373*38fd1498Szrj DECL_SIZE_UNIT (tls_decl)),
374*38fd1498Szrj build_int_cst (word_type_node,
375*38fd1498Szrj DECL_ALIGN_UNIT (tls_decl)),
376*38fd1498Szrj get_emutls_init_templ_addr (tls_decl));
377*38fd1498Szrj
378*38fd1498Szrj append_to_statement_list (x, pstmts);
379*38fd1498Szrj }
380*38fd1498Szrj
381*38fd1498Szrj struct lower_emutls_data
382*38fd1498Szrj {
383*38fd1498Szrj struct cgraph_node *cfun_node;
384*38fd1498Szrj struct cgraph_node *builtin_node;
385*38fd1498Szrj tree builtin_decl;
386*38fd1498Szrj basic_block bb;
387*38fd1498Szrj location_t loc;
388*38fd1498Szrj gimple_seq seq;
389*38fd1498Szrj };
390*38fd1498Szrj
391*38fd1498Szrj /* Given a TLS variable DECL, return an SSA_NAME holding its address.
392*38fd1498Szrj Append any new computation statements required to D->SEQ. */
393*38fd1498Szrj
394*38fd1498Szrj static tree
gen_emutls_addr(tree decl,struct lower_emutls_data * d)395*38fd1498Szrj gen_emutls_addr (tree decl, struct lower_emutls_data *d)
396*38fd1498Szrj {
397*38fd1498Szrj /* Compute the address of the TLS variable with help from runtime. */
398*38fd1498Szrj tls_var_data *data = tls_map->get (varpool_node::get (decl));
399*38fd1498Szrj tree addr = data->access;
400*38fd1498Szrj
401*38fd1498Szrj if (addr == NULL)
402*38fd1498Szrj {
403*38fd1498Szrj varpool_node *cvar;
404*38fd1498Szrj tree cdecl;
405*38fd1498Szrj gcall *x;
406*38fd1498Szrj
407*38fd1498Szrj cvar = data->control_var;
408*38fd1498Szrj cdecl = cvar->decl;
409*38fd1498Szrj TREE_ADDRESSABLE (cdecl) = 1;
410*38fd1498Szrj
411*38fd1498Szrj addr = create_tmp_var (build_pointer_type (TREE_TYPE (decl)));
412*38fd1498Szrj x = gimple_build_call (d->builtin_decl, 1, build_fold_addr_expr (cdecl));
413*38fd1498Szrj gimple_set_location (x, d->loc);
414*38fd1498Szrj
415*38fd1498Szrj addr = make_ssa_name (addr, x);
416*38fd1498Szrj gimple_call_set_lhs (x, addr);
417*38fd1498Szrj
418*38fd1498Szrj gimple_seq_add_stmt (&d->seq, x);
419*38fd1498Szrj
420*38fd1498Szrj d->cfun_node->create_edge (d->builtin_node, x, d->bb->count);
421*38fd1498Szrj
422*38fd1498Szrj /* We may be adding a new reference to a new variable to the function.
423*38fd1498Szrj This means we have to play with the ipa-reference web. */
424*38fd1498Szrj d->cfun_node->create_reference (cvar, IPA_REF_ADDR, x);
425*38fd1498Szrj
426*38fd1498Szrj /* Record this ssa_name for possible use later in the basic block. */
427*38fd1498Szrj data->access = addr;
428*38fd1498Szrj }
429*38fd1498Szrj
430*38fd1498Szrj return addr;
431*38fd1498Szrj }
432*38fd1498Szrj
433*38fd1498Szrj /* Callback for lower_emutls_1, return non-NULL if there is any TLS
434*38fd1498Szrj VAR_DECL in the subexpressions. */
435*38fd1498Szrj
436*38fd1498Szrj static tree
lower_emutls_2(tree * ptr,int * walk_subtrees,void *)437*38fd1498Szrj lower_emutls_2 (tree *ptr, int *walk_subtrees, void *)
438*38fd1498Szrj {
439*38fd1498Szrj tree t = *ptr;
440*38fd1498Szrj if (TREE_CODE (t) == VAR_DECL)
441*38fd1498Szrj return DECL_THREAD_LOCAL_P (t) ? t : NULL_TREE;
442*38fd1498Szrj else if (!EXPR_P (t))
443*38fd1498Szrj *walk_subtrees = 0;
444*38fd1498Szrj return NULL_TREE;
445*38fd1498Szrj }
446*38fd1498Szrj
447*38fd1498Szrj /* Callback for walk_gimple_op. D = WI->INFO is a struct lower_emutls_data.
448*38fd1498Szrj Given an operand *PTR within D->STMT, if the operand references a TLS
449*38fd1498Szrj variable, then lower the reference to a call to the runtime. Insert
450*38fd1498Szrj any new statements required into D->SEQ; the caller is responsible for
451*38fd1498Szrj placing those appropriately. */
452*38fd1498Szrj
453*38fd1498Szrj static tree
lower_emutls_1(tree * ptr,int * walk_subtrees,void * cb_data)454*38fd1498Szrj lower_emutls_1 (tree *ptr, int *walk_subtrees, void *cb_data)
455*38fd1498Szrj {
456*38fd1498Szrj struct walk_stmt_info *wi = (struct walk_stmt_info *) cb_data;
457*38fd1498Szrj struct lower_emutls_data *d = (struct lower_emutls_data *) wi->info;
458*38fd1498Szrj tree t = *ptr;
459*38fd1498Szrj bool is_addr = false;
460*38fd1498Szrj tree addr;
461*38fd1498Szrj
462*38fd1498Szrj *walk_subtrees = 0;
463*38fd1498Szrj
464*38fd1498Szrj switch (TREE_CODE (t))
465*38fd1498Szrj {
466*38fd1498Szrj case ADDR_EXPR:
467*38fd1498Szrj /* If this is not a straight-forward "&var", but rather something
468*38fd1498Szrj like "&var.a", then we may need special handling. */
469*38fd1498Szrj if (TREE_CODE (TREE_OPERAND (t, 0)) != VAR_DECL)
470*38fd1498Szrj {
471*38fd1498Szrj bool save_changed;
472*38fd1498Szrj
473*38fd1498Szrj /* Gimple invariants are shareable trees, so before changing
474*38fd1498Szrj anything in them if we will need to change anything, unshare
475*38fd1498Szrj them. */
476*38fd1498Szrj if (is_gimple_min_invariant (t)
477*38fd1498Szrj && walk_tree (&TREE_OPERAND (t, 0), lower_emutls_2, NULL, NULL))
478*38fd1498Szrj *ptr = t = unshare_expr (t);
479*38fd1498Szrj
480*38fd1498Szrj /* If we're allowed more than just is_gimple_val, continue. */
481*38fd1498Szrj if (!wi->val_only)
482*38fd1498Szrj {
483*38fd1498Szrj *walk_subtrees = 1;
484*38fd1498Szrj return NULL_TREE;
485*38fd1498Szrj }
486*38fd1498Szrj
487*38fd1498Szrj /* See if any substitution would be made. */
488*38fd1498Szrj save_changed = wi->changed;
489*38fd1498Szrj wi->changed = false;
490*38fd1498Szrj wi->val_only = false;
491*38fd1498Szrj walk_tree (&TREE_OPERAND (t, 0), lower_emutls_1, wi, NULL);
492*38fd1498Szrj wi->val_only = true;
493*38fd1498Szrj
494*38fd1498Szrj /* If so, then extract this entire sub-expression "&p->a" into a
495*38fd1498Szrj new assignment statement, and substitute yet another SSA_NAME. */
496*38fd1498Szrj if (wi->changed)
497*38fd1498Szrj {
498*38fd1498Szrj gimple *x;
499*38fd1498Szrj
500*38fd1498Szrj addr = create_tmp_var (TREE_TYPE (t));
501*38fd1498Szrj x = gimple_build_assign (addr, t);
502*38fd1498Szrj gimple_set_location (x, d->loc);
503*38fd1498Szrj
504*38fd1498Szrj addr = make_ssa_name (addr, x);
505*38fd1498Szrj gimple_assign_set_lhs (x, addr);
506*38fd1498Szrj
507*38fd1498Szrj gimple_seq_add_stmt (&d->seq, x);
508*38fd1498Szrj
509*38fd1498Szrj *ptr = addr;
510*38fd1498Szrj }
511*38fd1498Szrj else
512*38fd1498Szrj wi->changed = save_changed;
513*38fd1498Szrj
514*38fd1498Szrj return NULL_TREE;
515*38fd1498Szrj }
516*38fd1498Szrj
517*38fd1498Szrj t = TREE_OPERAND (t, 0);
518*38fd1498Szrj is_addr = true;
519*38fd1498Szrj /* FALLTHRU */
520*38fd1498Szrj
521*38fd1498Szrj case VAR_DECL:
522*38fd1498Szrj if (!DECL_THREAD_LOCAL_P (t))
523*38fd1498Szrj return NULL_TREE;
524*38fd1498Szrj break;
525*38fd1498Szrj
526*38fd1498Szrj default:
527*38fd1498Szrj /* We're not interested in other decls or types, only subexpressions. */
528*38fd1498Szrj if (EXPR_P (t))
529*38fd1498Szrj *walk_subtrees = 1;
530*38fd1498Szrj /* FALLTHRU */
531*38fd1498Szrj
532*38fd1498Szrj case SSA_NAME:
533*38fd1498Szrj /* Special-case the return of SSA_NAME, since it's so common. */
534*38fd1498Szrj return NULL_TREE;
535*38fd1498Szrj }
536*38fd1498Szrj
537*38fd1498Szrj addr = gen_emutls_addr (t, d);
538*38fd1498Szrj if (is_addr)
539*38fd1498Szrj {
540*38fd1498Szrj /* Replace "&var" with "addr" in the statement. */
541*38fd1498Szrj *ptr = addr;
542*38fd1498Szrj }
543*38fd1498Szrj else
544*38fd1498Szrj {
545*38fd1498Szrj /* Replace "var" with "*addr" in the statement. */
546*38fd1498Szrj t = build2 (MEM_REF, TREE_TYPE (t), addr,
547*38fd1498Szrj build_int_cst (TREE_TYPE (addr), 0));
548*38fd1498Szrj *ptr = t;
549*38fd1498Szrj }
550*38fd1498Szrj
551*38fd1498Szrj wi->changed = true;
552*38fd1498Szrj return NULL_TREE;
553*38fd1498Szrj }
554*38fd1498Szrj
555*38fd1498Szrj /* Lower all of the operands of STMT. */
556*38fd1498Szrj
557*38fd1498Szrj static void
lower_emutls_stmt(gimple * stmt,struct lower_emutls_data * d)558*38fd1498Szrj lower_emutls_stmt (gimple *stmt, struct lower_emutls_data *d)
559*38fd1498Szrj {
560*38fd1498Szrj struct walk_stmt_info wi;
561*38fd1498Szrj
562*38fd1498Szrj d->loc = gimple_location (stmt);
563*38fd1498Szrj
564*38fd1498Szrj memset (&wi, 0, sizeof (wi));
565*38fd1498Szrj wi.info = d;
566*38fd1498Szrj wi.val_only = true;
567*38fd1498Szrj walk_gimple_op (stmt, lower_emutls_1, &wi);
568*38fd1498Szrj
569*38fd1498Szrj if (wi.changed)
570*38fd1498Szrj update_stmt (stmt);
571*38fd1498Szrj }
572*38fd1498Szrj
573*38fd1498Szrj /* Lower the I'th operand of PHI. */
574*38fd1498Szrj
575*38fd1498Szrj static void
lower_emutls_phi_arg(gphi * phi,unsigned int i,struct lower_emutls_data * d)576*38fd1498Szrj lower_emutls_phi_arg (gphi *phi, unsigned int i,
577*38fd1498Szrj struct lower_emutls_data *d)
578*38fd1498Szrj {
579*38fd1498Szrj struct walk_stmt_info wi;
580*38fd1498Szrj struct phi_arg_d *pd = gimple_phi_arg (phi, i);
581*38fd1498Szrj
582*38fd1498Szrj /* Early out for a very common case we don't care about. */
583*38fd1498Szrj if (TREE_CODE (pd->def) == SSA_NAME)
584*38fd1498Szrj return;
585*38fd1498Szrj
586*38fd1498Szrj d->loc = pd->locus;
587*38fd1498Szrj
588*38fd1498Szrj memset (&wi, 0, sizeof (wi));
589*38fd1498Szrj wi.info = d;
590*38fd1498Szrj wi.val_only = true;
591*38fd1498Szrj walk_tree (&pd->def, lower_emutls_1, &wi, NULL);
592*38fd1498Szrj
593*38fd1498Szrj /* For normal statements, we let update_stmt do its job. But for phi
594*38fd1498Szrj nodes, we have to manipulate the immediate use list by hand. */
595*38fd1498Szrj if (wi.changed)
596*38fd1498Szrj {
597*38fd1498Szrj gcc_assert (TREE_CODE (pd->def) == SSA_NAME);
598*38fd1498Szrj link_imm_use_stmt (&pd->imm_use, pd->def, phi);
599*38fd1498Szrj }
600*38fd1498Szrj }
601*38fd1498Szrj
602*38fd1498Szrj /* Reset access variable for a given TLS variable data DATA. */
603*38fd1498Szrj
604*38fd1498Szrj bool
reset_access(varpool_node * const &,tls_var_data * data,void *)605*38fd1498Szrj reset_access (varpool_node * const &, tls_var_data *data, void *)
606*38fd1498Szrj {
607*38fd1498Szrj data->access = NULL;
608*38fd1498Szrj
609*38fd1498Szrj return true;
610*38fd1498Szrj }
611*38fd1498Szrj
612*38fd1498Szrj /* Clear the access variables, in order to begin a new block. */
613*38fd1498Szrj
614*38fd1498Szrj static inline void
clear_access_vars(void)615*38fd1498Szrj clear_access_vars (void)
616*38fd1498Szrj {
617*38fd1498Szrj tls_map->traverse<void *, reset_access> (NULL);
618*38fd1498Szrj }
619*38fd1498Szrj
620*38fd1498Szrj /* Lower the entire function NODE. */
621*38fd1498Szrj
622*38fd1498Szrj static void
lower_emutls_function_body(struct cgraph_node * node)623*38fd1498Szrj lower_emutls_function_body (struct cgraph_node *node)
624*38fd1498Szrj {
625*38fd1498Szrj struct lower_emutls_data d;
626*38fd1498Szrj bool any_edge_inserts = false;
627*38fd1498Szrj
628*38fd1498Szrj push_cfun (DECL_STRUCT_FUNCTION (node->decl));
629*38fd1498Szrj
630*38fd1498Szrj d.cfun_node = node;
631*38fd1498Szrj d.builtin_decl = builtin_decl_explicit (BUILT_IN_EMUTLS_GET_ADDRESS);
632*38fd1498Szrj /* This is where we introduce the declaration to the IL and so we have to
633*38fd1498Szrj create a node for it. */
634*38fd1498Szrj d.builtin_node = cgraph_node::get_create (d.builtin_decl);
635*38fd1498Szrj
636*38fd1498Szrj FOR_EACH_BB_FN (d.bb, cfun)
637*38fd1498Szrj {
638*38fd1498Szrj unsigned int i, nedge;
639*38fd1498Szrj
640*38fd1498Szrj /* Lower each of the PHI nodes of the block, as we may have
641*38fd1498Szrj propagated &tlsvar into a PHI argument. These loops are
642*38fd1498Szrj arranged so that we process each edge at once, and each
643*38fd1498Szrj PHI argument for that edge. */
644*38fd1498Szrj if (!gimple_seq_empty_p (phi_nodes (d.bb)))
645*38fd1498Szrj {
646*38fd1498Szrj nedge = EDGE_COUNT (d.bb->preds);
647*38fd1498Szrj for (i = 0; i < nedge; ++i)
648*38fd1498Szrj {
649*38fd1498Szrj edge e = EDGE_PRED (d.bb, i);
650*38fd1498Szrj
651*38fd1498Szrj /* We can re-use any SSA_NAME created on this edge. */
652*38fd1498Szrj clear_access_vars ();
653*38fd1498Szrj d.seq = NULL;
654*38fd1498Szrj
655*38fd1498Szrj for (gphi_iterator gsi = gsi_start_phis (d.bb);
656*38fd1498Szrj !gsi_end_p (gsi);
657*38fd1498Szrj gsi_next (&gsi))
658*38fd1498Szrj lower_emutls_phi_arg (gsi.phi (), i, &d);
659*38fd1498Szrj
660*38fd1498Szrj /* Insert all statements generated by all phi nodes for this
661*38fd1498Szrj particular edge all at once. */
662*38fd1498Szrj if (d.seq)
663*38fd1498Szrj {
664*38fd1498Szrj gsi_insert_seq_on_edge (e, d.seq);
665*38fd1498Szrj any_edge_inserts = true;
666*38fd1498Szrj }
667*38fd1498Szrj }
668*38fd1498Szrj }
669*38fd1498Szrj
670*38fd1498Szrj /* We can re-use any SSA_NAME created during this basic block. */
671*38fd1498Szrj clear_access_vars ();
672*38fd1498Szrj
673*38fd1498Szrj /* Lower each of the statements of the block. */
674*38fd1498Szrj for (gimple_stmt_iterator gsi = gsi_start_bb (d.bb); !gsi_end_p (gsi);
675*38fd1498Szrj gsi_next (&gsi))
676*38fd1498Szrj {
677*38fd1498Szrj d.seq = NULL;
678*38fd1498Szrj lower_emutls_stmt (gsi_stmt (gsi), &d);
679*38fd1498Szrj
680*38fd1498Szrj /* If any new statements were created, insert them immediately
681*38fd1498Szrj before the first use. This prevents variable lifetimes from
682*38fd1498Szrj becoming unnecessarily long. */
683*38fd1498Szrj if (d.seq)
684*38fd1498Szrj gsi_insert_seq_before (&gsi, d.seq, GSI_SAME_STMT);
685*38fd1498Szrj }
686*38fd1498Szrj }
687*38fd1498Szrj
688*38fd1498Szrj if (any_edge_inserts)
689*38fd1498Szrj gsi_commit_edge_inserts ();
690*38fd1498Szrj
691*38fd1498Szrj pop_cfun ();
692*38fd1498Szrj }
693*38fd1498Szrj
694*38fd1498Szrj /* Create emutls variable for VAR, DATA is pointer to static
695*38fd1498Szrj ctor body we can add constructors to.
696*38fd1498Szrj Callback for varpool_for_variable_and_aliases. */
697*38fd1498Szrj
698*38fd1498Szrj static bool
create_emultls_var(varpool_node * var,void * data)699*38fd1498Szrj create_emultls_var (varpool_node *var, void *data)
700*38fd1498Szrj {
701*38fd1498Szrj tree cdecl;
702*38fd1498Szrj tls_var_data value;
703*38fd1498Szrj
704*38fd1498Szrj cdecl = new_emutls_decl (var->decl,
705*38fd1498Szrj var->alias && var->analyzed
706*38fd1498Szrj ? var->get_alias_target ()->decl : NULL);
707*38fd1498Szrj
708*38fd1498Szrj varpool_node *cvar = varpool_node::get (cdecl);
709*38fd1498Szrj
710*38fd1498Szrj if (!var->alias)
711*38fd1498Szrj {
712*38fd1498Szrj /* Make sure the COMMON block control variable gets initialized.
713*38fd1498Szrj Note that there's no point in doing this for aliases; we only
714*38fd1498Szrj need to do this once for the main variable. */
715*38fd1498Szrj emutls_common_1 (var->decl, cdecl, (tree *)data);
716*38fd1498Szrj }
717*38fd1498Szrj if (var->alias && !var->analyzed)
718*38fd1498Szrj cvar->alias = true;
719*38fd1498Szrj
720*38fd1498Szrj /* Indicate that the value of the TLS variable may be found elsewhere,
721*38fd1498Szrj preventing the variable from re-appearing in the GIMPLE. We cheat
722*38fd1498Szrj and use the control variable here (rather than a full call_expr),
723*38fd1498Szrj which is special-cased inside the DWARF2 output routines. */
724*38fd1498Szrj SET_DECL_VALUE_EXPR (var->decl, cdecl);
725*38fd1498Szrj DECL_HAS_VALUE_EXPR_P (var->decl) = 1;
726*38fd1498Szrj
727*38fd1498Szrj value.control_var = cvar;
728*38fd1498Szrj tls_map->put (var, value);
729*38fd1498Szrj
730*38fd1498Szrj return false;
731*38fd1498Szrj }
732*38fd1498Szrj
733*38fd1498Szrj /* Main entry point to the tls lowering pass. */
734*38fd1498Szrj
735*38fd1498Szrj static unsigned int
ipa_lower_emutls(void)736*38fd1498Szrj ipa_lower_emutls (void)
737*38fd1498Szrj {
738*38fd1498Szrj varpool_node *var;
739*38fd1498Szrj cgraph_node *func;
740*38fd1498Szrj bool any_aliases = false;
741*38fd1498Szrj tree ctor_body = NULL;
742*38fd1498Szrj hash_set <varpool_node *> visited;
743*38fd1498Szrj auto_vec <varpool_node *> tls_vars;
744*38fd1498Szrj
745*38fd1498Szrj /* Examine all global variables for TLS variables. */
746*38fd1498Szrj FOR_EACH_VARIABLE (var)
747*38fd1498Szrj if (DECL_THREAD_LOCAL_P (var->decl)
748*38fd1498Szrj && !visited.add (var))
749*38fd1498Szrj {
750*38fd1498Szrj gcc_checking_assert (TREE_STATIC (var->decl)
751*38fd1498Szrj || DECL_EXTERNAL (var->decl));
752*38fd1498Szrj tls_vars.safe_push (var);
753*38fd1498Szrj if (var->alias && var->definition
754*38fd1498Szrj && !visited.add (var->ultimate_alias_target ()))
755*38fd1498Szrj tls_vars.safe_push (var->ultimate_alias_target ());
756*38fd1498Szrj }
757*38fd1498Szrj
758*38fd1498Szrj /* If we found no TLS variables, then there is no further work to do. */
759*38fd1498Szrj if (tls_vars.is_empty ())
760*38fd1498Szrj {
761*38fd1498Szrj if (dump_file)
762*38fd1498Szrj fprintf (dump_file, "No TLS variables found.\n");
763*38fd1498Szrj return 0;
764*38fd1498Szrj }
765*38fd1498Szrj
766*38fd1498Szrj tls_map = new hash_map <varpool_node *, tls_var_data> ();
767*38fd1498Szrj
768*38fd1498Szrj /* Create the control variables for each TLS variable. */
769*38fd1498Szrj for (unsigned i = 0; i < tls_vars.length (); i++)
770*38fd1498Szrj {
771*38fd1498Szrj var = tls_vars[i];
772*38fd1498Szrj
773*38fd1498Szrj if (var->alias && !var->analyzed)
774*38fd1498Szrj any_aliases = true;
775*38fd1498Szrj else if (!var->alias)
776*38fd1498Szrj var->call_for_symbol_and_aliases (create_emultls_var, &ctor_body, true);
777*38fd1498Szrj }
778*38fd1498Szrj
779*38fd1498Szrj /* If there were any aliases, then frob the alias_pairs vector. */
780*38fd1498Szrj if (any_aliases)
781*38fd1498Szrj {
782*38fd1498Szrj alias_pair *p;
783*38fd1498Szrj unsigned int i;
784*38fd1498Szrj FOR_EACH_VEC_SAFE_ELT (alias_pairs, i, p)
785*38fd1498Szrj if (DECL_THREAD_LOCAL_P (p->decl))
786*38fd1498Szrj {
787*38fd1498Szrj p->decl = tls_map->get
788*38fd1498Szrj (varpool_node::get (p->decl))->control_var->decl;
789*38fd1498Szrj p->target = get_emutls_object_name (p->target);
790*38fd1498Szrj }
791*38fd1498Szrj }
792*38fd1498Szrj
793*38fd1498Szrj /* Adjust all uses of TLS variables within the function bodies. */
794*38fd1498Szrj FOR_EACH_DEFINED_FUNCTION (func)
795*38fd1498Szrj if (func->lowered)
796*38fd1498Szrj lower_emutls_function_body (func);
797*38fd1498Szrj
798*38fd1498Szrj /* Generate the constructor for any COMMON control variables created. */
799*38fd1498Szrj if (ctor_body)
800*38fd1498Szrj cgraph_build_static_cdtor ('I', ctor_body, DEFAULT_INIT_PRIORITY);
801*38fd1498Szrj
802*38fd1498Szrj delete tls_map;
803*38fd1498Szrj
804*38fd1498Szrj return 0;
805*38fd1498Szrj }
806*38fd1498Szrj
807*38fd1498Szrj namespace {
808*38fd1498Szrj
809*38fd1498Szrj const pass_data pass_data_ipa_lower_emutls =
810*38fd1498Szrj {
811*38fd1498Szrj SIMPLE_IPA_PASS, /* type */
812*38fd1498Szrj "emutls", /* name */
813*38fd1498Szrj OPTGROUP_NONE, /* optinfo_flags */
814*38fd1498Szrj TV_IPA_OPT, /* tv_id */
815*38fd1498Szrj ( PROP_cfg | PROP_ssa ), /* properties_required */
816*38fd1498Szrj 0, /* properties_provided */
817*38fd1498Szrj 0, /* properties_destroyed */
818*38fd1498Szrj 0, /* todo_flags_start */
819*38fd1498Szrj 0, /* todo_flags_finish */
820*38fd1498Szrj };
821*38fd1498Szrj
822*38fd1498Szrj class pass_ipa_lower_emutls : public simple_ipa_opt_pass
823*38fd1498Szrj {
824*38fd1498Szrj public:
pass_ipa_lower_emutls(gcc::context * ctxt)825*38fd1498Szrj pass_ipa_lower_emutls (gcc::context *ctxt)
826*38fd1498Szrj : simple_ipa_opt_pass (pass_data_ipa_lower_emutls, ctxt)
827*38fd1498Szrj {}
828*38fd1498Szrj
829*38fd1498Szrj /* opt_pass methods: */
gate(function *)830*38fd1498Szrj virtual bool gate (function *)
831*38fd1498Szrj {
832*38fd1498Szrj /* If the target supports TLS natively, we need do nothing here. */
833*38fd1498Szrj return !targetm.have_tls;
834*38fd1498Szrj }
835*38fd1498Szrj
execute(function *)836*38fd1498Szrj virtual unsigned int execute (function *) { return ipa_lower_emutls (); }
837*38fd1498Szrj
838*38fd1498Szrj }; // class pass_ipa_lower_emutls
839*38fd1498Szrj
840*38fd1498Szrj } // anon namespace
841*38fd1498Szrj
842*38fd1498Szrj simple_ipa_opt_pass *
make_pass_ipa_lower_emutls(gcc::context * ctxt)843*38fd1498Szrj make_pass_ipa_lower_emutls (gcc::context *ctxt)
844*38fd1498Szrj {
845*38fd1498Szrj return new pass_ipa_lower_emutls (ctxt);
846*38fd1498Szrj }
847