]> git.pld-linux.org Git - packages/crossppc-gcc.git/blame - gcc-pr20218.patch
- updated.
[packages/crossppc-gcc.git] / gcc-pr20218.patch
CommitLineData
72062f27 12006-12-07 H.J. Lu <hongjiu.lu@intel.com>
abe7f82e 2
72062f27
AM
3 Backport from mainline:
4 2006-12-11 H.J. Lu <hongjiu.lu@intel.com>
6e260766
PS
5 PR middle-end/17982
6 PR middle-end/20218
72062f27
AM
7 * cgraphunit.c (cgraph_optimize): Remove call to
8 process_pending_assemble_externals.
abe7f82e 9
6e260766
PS
10 * config/elfos.h (ASM_OUTPUT_EXTERNAL): New.
11
12 * config/ia64/hpux.h (TARGET_ASM_FILE_END): Removed.
13
14 * config/ia64/ia64.c (ia64_asm_output_external): Rewritten.
15 (ia64_hpux_add_extern_decl): Removed.
16 (ia64_hpux_file_end): Likewise.
17 (extern_func_list): Likewise.
18 (extern_func_head): Likewise.
19
20 * output.h (assemble_external): Update comments.
21 (default_elf_asm_output_external): New.
22 (maybe_assemble_visibility): New.
23
72062f27
AM
24 * toplev.c (compile_file): Update comment.
25
26 * varasm.c (assemble_external): Always put it on
27 pending_assemble_externals.
28 (maybe_assemble_visibility): Make it extern and return int.
6e260766
PS
29 (default_elf_asm_output_external): New.
30
72062f27
AM
31--- gcc/cgraphunit.c.global 2006-12-07 05:45:18.000000000 -0800
32+++ gcc/cgraphunit.c 2006-12-07 05:47:22.000000000 -0800
33@@ -1536,8 +1536,6 @@ cgraph_optimize (void)
6e260766
PS
34 return;
35 }
36
72062f27
AM
37- process_pending_assemble_externals ();
38-
6e260766
PS
39 /* Frontend may output common variables after the unit has been finalized.
40 It is safe to deal with them here as they are always zero initialized. */
72062f27
AM
41 cgraph_varpool_analyze_pending_decls ();
42--- gcc/config/elfos.h.global 2006-11-30 12:45:20.000000000 -0800
43+++ gcc/config/elfos.h 2006-12-07 05:47:22.000000000 -0800
6e260766 44@@ -499,3 +499,13 @@ Boston, MA 02110-1301, USA. */
2d49f59d
PS
45 fprintf ((FILE), "\"\n"); \
46 } \
47 while (0)
48+
49+/* A C statement (sans semicolon) to output to the stdio stream STREAM
50+ any text necessary for declaring the name of an external symbol
51+ named NAME whch is referenced in this compilation but not defined.
52+ It is needed to properly support non-default visibility. */
53+
54+#ifndef ASM_OUTPUT_EXTERNAL
55+#define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME) \
56+ default_elf_asm_output_external (FILE, DECL, NAME)
57+#endif
72062f27
AM
58--- gcc/config/ia64/hpux.h.global 2006-10-29 17:03:12.000000000 -0800
59+++ gcc/config/ia64/hpux.h 2006-12-07 05:47:22.000000000 -0800
6e260766
PS
60@@ -144,10 +144,6 @@ do { \
61 definitions, so do not use them in gthr-posix.h. */
62 #define GTHREAD_USE_WEAK 0
0fe1531c 63
6e260766
PS
64-/* Put out the needed function declarations at the end. */
65-
66-#define TARGET_ASM_FILE_END ia64_hpux_file_end
67-
68 #undef CTORS_SECTION_ASM_OP
69 #define CTORS_SECTION_ASM_OP "\t.section\t.init_array,\t\"aw\",\"init_array\""
abe7f82e 70
72062f27
AM
71--- gcc/config/ia64/ia64.c.global 2006-12-07 05:45:17.000000000 -0800
72+++ gcc/config/ia64/ia64.c 2006-12-07 05:47:22.000000000 -0800
6e260766
PS
73@@ -255,10 +255,6 @@ static section *ia64_rwreloc_select_rtx_
74 unsigned HOST_WIDE_INT)
75 ATTRIBUTE_UNUSED;
76 static unsigned int ia64_section_type_flags (tree, const char *, int);
77-static void ia64_hpux_add_extern_decl (tree decl)
78- ATTRIBUTE_UNUSED;
79-static void ia64_hpux_file_end (void)
80- ATTRIBUTE_UNUSED;
81 static void ia64_init_libfuncs (void)
82 ATTRIBUTE_UNUSED;
83 static void ia64_hpux_init_libfuncs (void)
84@@ -5021,49 +5017,6 @@ ia64_secondary_reload_class (enum reg_cl
85 }
0fe1531c 86
6e260766
PS
87 \f
88-/* Emit text to declare externally defined variables and functions, because
89- the Intel assembler does not support undefined externals. */
90-
91-void
92-ia64_asm_output_external (FILE *file, tree decl, const char *name)
93-{
94- int save_referenced;
95-
96- /* GNU as does not need anything here, but the HP linker does need
97- something for external functions. */
98-
99- if (TARGET_GNU_AS
100- && (!TARGET_HPUX_LD
101- || TREE_CODE (decl) != FUNCTION_DECL
102- || strstr (name, "__builtin_") == name))
103- return;
104-
105- /* ??? The Intel assembler creates a reference that needs to be satisfied by
106- the linker when we do this, so we need to be careful not to do this for
107- builtin functions which have no library equivalent. Unfortunately, we
108- can't tell here whether or not a function will actually be called by
109- expand_expr, so we pull in library functions even if we may not need
110- them later. */
111- if (! strcmp (name, "__builtin_next_arg")
112- || ! strcmp (name, "alloca")
113- || ! strcmp (name, "__builtin_constant_p")
114- || ! strcmp (name, "__builtin_args_info"))
115- return;
116-
117- if (TARGET_HPUX_LD)
118- ia64_hpux_add_extern_decl (decl);
119- else
120- {
121- /* assemble_name will set TREE_SYMBOL_REFERENCED, so we must save and
122- restore it. */
123- save_referenced = TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl));
124- if (TREE_CODE (decl) == FUNCTION_DECL)
125- ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
126- (*targetm.asm_out.globalize_label) (file, name);
127- TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) = save_referenced;
128- }
129-}
130-\f
131 /* Parse the -mfixed-range= option string. */
0fe1531c 132
6e260766
PS
133 static void
134@@ -9174,55 +9127,33 @@ ia64_hpux_function_arg_padding (enum mac
135 return DEFAULT_FUNCTION_ARG_PADDING (mode, type);
0fe1531c
PS
136 }
137
6e260766
PS
138-/* Linked list of all external functions that are to be emitted by GCC.
139- We output the name if and only if TREE_SYMBOL_REFERENCED is set in
140- order to avoid putting out names that are never really used. */
141-
142-struct extern_func_list GTY(())
143-{
144- struct extern_func_list *next;
145- tree decl;
146-};
147-
148-static GTY(()) struct extern_func_list *extern_func_head;
149-
150-static void
151-ia64_hpux_add_extern_decl (tree decl)
152-{
153- struct extern_func_list *p = ggc_alloc (sizeof (struct extern_func_list));
154-
155- p->decl = decl;
156- p->next = extern_func_head;
157- extern_func_head = p;
158-}
159-
160-/* Print out the list of used global functions. */
161+/* Emit text to declare externally defined variables and functions, because
162+ the Intel assembler does not support undefined externals. */
163
164-static void
165-ia64_hpux_file_end (void)
166+void
167+ia64_asm_output_external (FILE *file, tree decl, const char *name)
0fe1531c 168 {
6e260766
PS
169- struct extern_func_list *p;
170-
171- for (p = extern_func_head; p; p = p->next)
172- {
173- tree decl = p->decl;
174- tree id = DECL_ASSEMBLER_NAME (decl);
175-
176- gcc_assert (id);
177-
178- if (!TREE_ASM_WRITTEN (decl) && TREE_SYMBOL_REFERENCED (id))
179- {
180- const char *name = XSTR (XEXP (DECL_RTL (decl), 0), 0);
181-
182- TREE_ASM_WRITTEN (decl) = 1;
183- (*targetm.asm_out.globalize_label) (asm_out_file, name);
184- fputs (TYPE_ASM_OP, asm_out_file);
185- assemble_name (asm_out_file, name);
186- fprintf (asm_out_file, "," TYPE_OPERAND_FMT "\n", "function");
187- }
188+ /* We output the name if and only if TREE_SYMBOL_REFERENCED is
189+ set in order to avoid putting out names that are never really
190+ used. */
191+ if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
192+ {
193+ /* maybe_assemble_visibility will return 1 if the assembler
194+ visibility directive is outputed. */
195+ int need_visibility = ((*targetm.binds_local_p) (decl)
196+ && maybe_assemble_visibility (decl));
197+
198+ /* GNU as does not need anything here, but the HP linker does
199+ need something for external functions. */
200+ if ((TARGET_HPUX_LD || !TARGET_GNU_AS)
201+ && TREE_CODE (decl) == FUNCTION_DECL)
202+ {
203+ ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function");
204+ (*targetm.asm_out.globalize_label) (file, name);
205+ }
206+ else if (need_visibility && !TARGET_GNU_AS)
207+ (*targetm.asm_out.globalize_label) (file, name);
208 }
209-
210- extern_func_head = 0;
0fe1531c 211 }
0fe1531c 212
6e260766 213 /* Set SImode div/mod functions, init_integral_libfuncs only initializes
72062f27
AM
214--- gcc/output.h.global 2006-10-21 13:45:54.000000000 -0700
215+++ gcc/output.h 2006-12-07 05:47:22.000000000 -0800
6e260766
PS
216@@ -204,9 +204,9 @@ extern void assemble_variable (tree, int
217 DONT_OUTPUT_DATA is from assemble_variable. */
218 extern void align_variable (tree decl, bool dont_output_data);
219
220-/* Output something to declare an external symbol to the assembler.
221- (Most assemblers don't need this, so we normally output nothing.)
222- Do nothing if DECL is not external. */
223+/* Queue for outputing something to declare an external symbol to the
224+ assembler. (Most assemblers don't need this, so we normally output
225+ nothing.) Do nothing if DECL is not external. */
226 extern void assemble_external (tree);
227
228 /* Assemble code to leave SIZE bytes of zeros. */
229@@ -619,6 +619,10 @@ extern void default_file_start (void);
2d49f59d
PS
230 extern void file_end_indicate_exec_stack (void);
231 extern bool default_valid_pointer_mode (enum machine_mode);
232
233+extern void default_elf_asm_output_external (FILE *file, tree,
234+ const char *);
2d49f59d
PS
235+extern int maybe_assemble_visibility (tree);
236+
237 extern int default_address_cost (rtx);
238
239 /* dbxout helper functions */
72062f27
AM
240--- gcc/toplev.c.global 2006-12-07 05:45:18.000000000 -0800
241+++ gcc/toplev.c 2006-12-07 05:58:23.000000000 -0800
242@@ -1076,9 +1076,7 @@ compile_file (void)
243
244 dw2_output_indirect_constants ();
245
246- /* Flush any pending external directives. cgraph did this for
247- assemble_external calls from the front end, but the RTL
248- expander can also generate them. */
249+ /* Flush any pending external directives. */
250 process_pending_assemble_externals ();
251
252 /* Attach a special .ident directive to the end of the file to identify
253--- gcc/varasm.c.global 2006-12-07 05:45:18.000000000 -0800
254+++ gcc/varasm.c 2006-12-07 05:49:16.000000000 -0800
2d49f59d
PS
255@@ -126,7 +126,6 @@ static unsigned HOST_WIDE_INT array_size
256 static unsigned min_align (unsigned, unsigned);
257 static void output_constructor (tree, unsigned HOST_WIDE_INT, unsigned int);
258 static void globalize_decl (tree);
259-static void maybe_assemble_visibility (tree);
abe7f82e
PS
260 #ifdef BSS_SECTION_ASM_OP
261 #ifdef ASM_OUTPUT_BSS
262 static void asm_output_bss (FILE *, tree, const char *,
72062f27
AM
263@@ -1964,11 +1963,10 @@ assemble_external (tree decl ATTRIBUTE_U
264 if (!DECL_P (decl) || !DECL_EXTERNAL (decl) || !TREE_PUBLIC (decl))
265 return;
266
267- if (flag_unit_at_a_time)
268- pending_assemble_externals = tree_cons (0, decl,
269- pending_assemble_externals);
270- else
271- assemble_external_real (decl);
272+ /* We want to output external symbols at very last to check if they
273+ are references or not. */
274+ pending_assemble_externals = tree_cons (0, decl,
275+ pending_assemble_externals);
276 #endif
277 }
278
279@@ -5071,13 +5069,18 @@ default_assemble_visibility (tree decl,
2d49f59d
PS
280
281 /* A helper function to call assemble_visibility when needed for a decl. */
282
283-static void
284+int
285 maybe_assemble_visibility (tree decl)
286 {
287 enum symbol_visibility vis = DECL_VISIBILITY (decl);
288
289 if (vis != VISIBILITY_DEFAULT)
290- targetm.asm_out.visibility (decl, vis);
291+ {
292+ targetm.asm_out.visibility (decl, vis);
293+ return 1;
294+ }
295+ else
296+ return 0;
297 }
298
299 /* Returns 1 if the target configuration supports defining public symbols
72062f27
AM
300@@ -6327,4 +6330,19 @@ elf_record_gcc_switches (print_switch_ty
301 return 0;
2d49f59d
PS
302 }
303
2d49f59d
PS
304+/* Emit text to declare externally defined symbols. It is needed to
305+ properly support non-default visibility. */
2d49f59d
PS
306+void
307+default_elf_asm_output_external (FILE *file ATTRIBUTE_UNUSED,
308+ tree decl,
6e260766 309+ const char *name ATTRIBUTE_UNUSED)
2d49f59d 310+{
6e260766
PS
311+ /* We output the name if and only if TREE_SYMBOL_REFERENCED is
312+ set in order to avoid putting out names that are never really
313+ used. */
314+ if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
315+ && targetm.binds_local_p (decl))
316+ maybe_assemble_visibility (decl);
2d49f59d
PS
317+}
318+
319 #include "gt-varasm.h"
This page took 0.153762 seconds and 4 git commands to generate.