+2016-05-20 Nathan Sidwell <nathan@acm.org>
+
+ * config/nvptx/nptx.c (nvptx_option_override): Only set
+ flag_toplevel_reorder, if not explicitly specified. Set
+ flag_no_common, unless explicitly specified.
+
2016-05-20 David Malcolm <dmalcolm@redhat.com>
* calls.c (can_implement_as_sibling_call_p): Mark param
nvptx_option_override (void)
{
init_machine_status = nvptx_init_machine_status;
- /* Gives us a predictable order, which we need especially for variables. */
- flag_toplevel_reorder = 1;
+
+ /* Set toplevel_reorder, unless explicitly disabled. We need
+ reordering so that we emit necessary assembler decls of
+ undeclared variables. */
+ if (!global_options_set.x_flag_toplevel_reorder)
+ flag_toplevel_reorder = 1;
+
+ /* Set flag_no_common, unless explicitly disabled. We fake common
+ using .weak, and that's not entirely accurate, so avoid it
+ unless forced. */
+ if (!global_options_set.x_flag_no_common)
+ flag_no_common = 1;
+
/* Assumes that it will see only hard registers. */
flag_var_tracking = 0;
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fcommon" } */
const int conststaticvariable;
/* { dg-do compile } */
-int __attribute__ ((used)) common;
-static int __attribute__ ((used)) local;
+int __attribute__ ((common)) common;
+static int local;
+extern int external_decl;
+int external_defn;
+
+int foo ()
+{
+ return common + local + external_decl + external_defn;
+}
+
+void bar (int i)
+{
+ common = local = external_decl = external_defn = i;
+}
/* { dg-final { scan-assembler "\[\n\r\]\[\t \]*.weak .global\[^,\n\r\]*common" } } */
/* { dg-final { scan-assembler "\[\n\r\]\[\t \]*.global\[^,\n\r\]*local" } } */
+/* { dg-final { scan-assembler "\[\n\r\]\[\t \]*.extern .global\[^,\n\r\]*external_decl" } } */
+/* { dg-final { scan-assembler "\[\n\r\]\[\t \]*.visible .global\[^,\n\r\]*external_defn" } } */