diff mbox

[PTX] toplevel-reorder and no-common flags

Message ID 67f73f65-32fd-a312-84d9-dfd6ec9c4f0e@acm.org
State New
Headers show

Commit Message

Nathan Sidwell May 20, 2016, 7:56 p.m. UTC
This patch stops us unconditionally setting the toplevel-reorder flag.  It's 
mostly needed but a couple of testcase rely on it being unset.   Those now pass.

Also force -fno-common, unless explicitly specified.  As the comment says, we 
fudge common by using .weak, and that's not quite the right thing.  So only 
provide common storage when the user explicitly asks for it.  The 
ssa-store-ccp-2.c testcase is checking some semantics that are only applicable 
to common storage, so enable that flag.

applied to trunk.

nathan
diff mbox

Patch

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.

	testsuite/
	* gcc.target/nvptx/uninit-decl.c: Force common storage,  add
	non-common cases.
	* gcc.dg/tree-ssa/ssa-store-ccp-2.c: Add -fcommon.

Index: config/nvptx/nvptx.c
===================================================================
--- config/nvptx/nvptx.c	(revision 236392)
+++ config/nvptx/nvptx.c	(working copy)
@@ -155,8 +155,19 @@  static void
 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;
 
Index: testsuite/gcc.target/nvptx/uninit-decl.c
===================================================================
--- testsuite/gcc.target/nvptx/uninit-decl.c	(revision 236392)
+++ testsuite/gcc.target/nvptx/uninit-decl.c	(working copy)
@@ -1,7 +1,21 @@ 
 /* { 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" } } */
Index: testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c
===================================================================
--- testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c	(revision 236392)
+++ testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c	(working copy)
@@ -1,5 +1,5 @@ 
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized -fcommon" } */
 
 const int conststaticvariable;