aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraphunit.c
diff options
context:
space:
mode:
authorAlexander Monakov <amonakov@ispras.ru>2016-07-15 14:01:23 +0300
committerAlexander Monakov <amonakov@gcc.gnu.org>2016-07-15 14:01:23 +0300
commit3ef4678208cb06208343de776ad96de2db4de25c (patch)
tree652086436fa04743a73656233cc4b3f5c0a32a3a /gcc/cgraphunit.c
parenta8e15f9074d70cf2b029e04f3f56ed64e5171556 (diff)
downloadgcc-3ef4678208cb06208343de776ad96de2db4de25c.zip
gcc-3ef4678208cb06208343de776ad96de2db4de25c.tar.gz
gcc-3ef4678208cb06208343de776ad96de2db4de25c.tar.bz2
handle undefined extern vars in output_in_order
* cgraphunit.c (cgraph_order_sort_kind): New entry ORDER_VAR_UNDEF. (output_in_order): Loop over undefined variables too. Output them via assemble_undefined_decl. Skip variables that correspond to hard registers or have value-exprs. * varpool.c (symbol_table::output_variables): Handle undefined variables together with defined ones. From-SVN: r238371
Diffstat (limited to 'gcc/cgraphunit.c')
-rw-r--r--gcc/cgraphunit.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 4bfcad7..e30fe6e 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2141,6 +2141,7 @@ enum cgraph_order_sort_kind
ORDER_UNDEFINED = 0,
ORDER_FUNCTION,
ORDER_VAR,
+ ORDER_VAR_UNDEF,
ORDER_ASM
};
@@ -2187,16 +2188,20 @@ output_in_order (bool no_reorder)
}
}
- FOR_EACH_DEFINED_VARIABLE (pv)
- if (!DECL_EXTERNAL (pv->decl))
- {
- if (no_reorder && !pv->no_reorder)
- continue;
- i = pv->order;
- gcc_assert (nodes[i].kind == ORDER_UNDEFINED);
- nodes[i].kind = ORDER_VAR;
- nodes[i].u.v = pv;
- }
+ /* There is a similar loop in symbol_table::output_variables.
+ Please keep them in sync. */
+ FOR_EACH_VARIABLE (pv)
+ {
+ if (no_reorder && !pv->no_reorder)
+ continue;
+ if (DECL_HARD_REGISTER (pv->decl)
+ || DECL_HAS_VALUE_EXPR_P (pv->decl))
+ continue;
+ i = pv->order;
+ gcc_assert (nodes[i].kind == ORDER_UNDEFINED);
+ nodes[i].kind = pv->definition ? ORDER_VAR : ORDER_VAR_UNDEF;
+ nodes[i].u.v = pv;
+ }
for (pa = symtab->first_asm_symbol (); pa; pa = pa->next)
{
@@ -2222,16 +2227,13 @@ output_in_order (bool no_reorder)
break;
case ORDER_VAR:
-#ifdef ACCEL_COMPILER
- /* Do not assemble "omp declare target link" vars. */
- if (DECL_HAS_VALUE_EXPR_P (nodes[i].u.v->decl)
- && lookup_attribute ("omp declare target link",
- DECL_ATTRIBUTES (nodes[i].u.v->decl)))
- break;
-#endif
nodes[i].u.v->assemble_decl ();
break;
+ case ORDER_VAR_UNDEF:
+ assemble_undefined_decl (nodes[i].u.v->decl);
+ break;
+
case ORDER_ASM:
assemble_asm (nodes[i].u.a->asm_str);
break;