From: Nathan Sidwell Date: Fri, 20 May 2016 19:52:50 +0000 (+0000) Subject: nptx.c (nvptx_option_override): Only set flag_toplevel_reorder, if not explicitly... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ae578943c00e669b6b18ce2588a29efcfb74ae19;p=gcc.git nptx.c (nvptx_option_override): Only set flag_toplevel_reorder, if not explicitly specified. * 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. From-SVN: r236532 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 32813b45a12..3f65d05f699 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-05-20 Nathan Sidwell + + * 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 * calls.c (can_implement_as_sibling_call_p): Mark param diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index d4a8f29a21c..1bd18710245 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -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; diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c index cdc042061ec..51fc1b3d261 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-2.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 -fdump-tree-optimized -fcommon" } */ const int conststaticvariable; diff --git a/gcc/testsuite/gcc.target/nvptx/uninit-decl.c b/gcc/testsuite/gcc.target/nvptx/uninit-decl.c index 65c44f5b0f7..115d7036fb6 100644 --- a/gcc/testsuite/gcc.target/nvptx/uninit-decl.c +++ b/gcc/testsuite/gcc.target/nvptx/uninit-decl.c @@ -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" } } */