* [LTO] Fix various compile.exp tests
@ 2007-10-05 21:46 Diego Novillo
0 siblings, 0 replies; only message in thread
From: Diego Novillo @ 2007-10-05 21:46 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1139 bytes --]
I added -flto to compile.exp and got quite a few ICEs. This patch
fixes most of them. I changed the handling of static variables to use
DECL_CONTEXT instead of just checking for "globalness". The thing is
that static variables may be declared locally to a function and have
initializers that reference variables in the function. So I modified
the handler so that they're handled as a regular local variable
instead of the global handler.
Another ICE was related to PR 31899. There already is a fix on
mainline, so I just backported it.
The only ones I still haven't worked on are:
gcc.c-torture/compile/20020109-2.c
We ICE in dwarf2out.c:output_die but I haven't really looked why or how.
gcc.c-torture/compile/init-1.c
We do not write out compund literals yet. Just need to add the
code to handle them.
The rest of compile.exp seems to work with -O2 -flto. Next, I will
see about adding dejagnu support to exercise the whole loop (-flto and
then call lto1 on the generated object). I find this useful to go
through the most obvious problems.
With this patch I get 12 failures on compile.exp. Committed to the branch.
[-- Attachment #2: 20071005-lto-writeout-fixes.txt --]
[-- Type: text/plain, Size: 4716 bytes --]
2007-10-05 Diego Novillo <dnovillo@google.com>
* lto-function-out.c (output_constructor): Handle constructor elts
with NULL indices.
(output_expr_operand): Check whether the variable is in the
global scope.
(lto_output): Only handle statics that are in the global
scope.
* tree-nested.c (get_trampoline_type): Set DECL_CONTEXT for
the new field.
Backport
2007-07-26 Doug Kwan <dougkwan@google.com>
* dwarf2out.c: (may_reference_to_unsued) : Renamed from
reference_to_unsued as it is now more conservative than
before. Replace unreachable assert into a return that tells
caller that tree may reference an unused DECL.
(rtl_for_decl_init): Rename callee to may_reference_to_usused.
testsuite/ChangeLog.lto:
* lib/gcc-dg.exp: Enable -flto at -O2.
Index: lto-function-out.c
===================================================================
--- lto-function-out.c (revision 129034)
+++ lto-function-out.c (working copy)
@@ -1118,7 +1118,7 @@ output_constructor (struct output_block
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (ctor), idx, purpose, value)
{
- if (TREE_CODE (purpose) == RANGE_EXPR)
+ if (purpose && TREE_CODE (purpose) == RANGE_EXPR)
{
output_record_start (ob, NULL, NULL, LTO_constructor_range);
/* Need the types here to reconstruct the ranges. */
@@ -1278,7 +1278,7 @@ output_expr_operand (struct output_block
break;
case VAR_DECL:
- if (TREE_STATIC (expr) || DECL_EXTERNAL (expr))
+ if (DECL_CONTEXT (expr) == NULL_TREE)
{
bool new;
output_record_start (ob, NULL, NULL, LTO_var_decl1);
@@ -2191,10 +2191,11 @@ lto_output (void)
if (node->analyzed && cgraph_is_master_clone (node, false))
output_function (node->decl);
- /* Process the static vars that have initializers or
+ /* Process the global static vars that have initializers or
constructors. */
FOR_EACH_STATIC_INITIALIZER (vnode)
- output_constructor_or_init (vnode->decl);
+ if (DECL_CONTEXT (vnode->decl) == NULL_TREE)
+ output_constructor_or_init (vnode->decl);
/* Put back the assembly section that was there before we started
writing lto info. */
Index: testsuite/lib/gcc-dg.exp
===================================================================
--- testsuite/lib/gcc-dg.exp (revision 129034)
+++ testsuite/lib/gcc-dg.exp (working copy)
@@ -42,7 +42,7 @@ if ![info exists TORTURE_OPTIONS] {
set TORTURE_OPTIONS [list \
{ -O0 } \
{ -O1 } \
- { -O2 } \
+ { -O2 -flto } \
{ -O3 -fomit-frame-pointer } \
{ -O3 -fomit-frame-pointer -funroll-loops } \
{ -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions } \
Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 129034)
+++ dwarf2out.c (working copy)
@@ -10374,9 +10374,10 @@ add_const_value_attribute (dw_die_ref di
/* Determine whether the evaluation of EXPR references any variables
or functions which aren't otherwise used (and therefore may not be
output). */
+
static tree
-reference_to_unused (tree * tp, int * walk_subtrees,
- void * data ATTRIBUTE_UNUSED)
+may_reference_to_unused (tree * tp, int * walk_subtrees,
+ void * data ATTRIBUTE_UNUSED)
{
if (! EXPR_P (*tp) && ! GIMPLE_STMT_P (*tp) && ! CONSTANT_CLASS_P (*tp))
*walk_subtrees = 0;
@@ -10388,7 +10389,12 @@ reference_to_unused (tree * tp, int * wa
return NULL_TREE;
else if (!cgraph_global_info_ready
&& (TREE_CODE (*tp) == VAR_DECL || TREE_CODE (*tp) == FUNCTION_DECL))
- gcc_unreachable ();
+ {
+ /* We don't know if a DECL is really unsued until we have seen
+ the complete call graph. With no reliable information, we need to
+ be conservative. */
+ return *tp;
+ }
else if (DECL_P (*tp) && TREE_CODE (*tp) == VAR_DECL)
{
struct varpool_node *node = varpool_node (*tp);
@@ -10444,7 +10450,7 @@ rtl_for_decl_init (tree init, tree type)
immediate RTL constant, expand it now. We must be careful not to
reference variables which won't be output. */
else if (initializer_constant_valid_p (init, type)
- && ! walk_tree (&init, reference_to_unused, NULL, NULL))
+ && ! walk_tree (&init, may_reference_to_unused, NULL, NULL))
{
/* Convert vector CONSTRUCTOR initializers to VECTOR_CST if
possible. */
Index: tree-nested.c
===================================================================
--- tree-nested.c (revision 129034)
+++ tree-nested.c (working copy)
@@ -429,6 +429,7 @@ get_trampoline_type (void)
TYPE_NAME (record) = get_identifier ("__builtin_trampoline");
TYPE_FIELDS (record) = t;
layout_type (record);
+ DECL_CONTEXT (t) = record;
return record;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-10-05 21:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-05 21:46 [LTO] Fix various compile.exp tests Diego Novillo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).