Re: [PATCH] Fix PR60930

2014-04-25 Thread Jakub Jelinek
On Thu, Apr 24, 2014 at 09:20:50PM -0600, Jeff Law wrote:
  PR tree-optimization/60930
  * gcc.dg/torture/pr60930.c:  New test.
 Doesn't the test depend on long long being at least 64 bits?

But that is guaranteed by C99, isn't it?

5.2.4.2.1 says:

... Their implementation-defined values shall be equal or greater in magnitude
(absolute value) to those shown, with the same sign.
...
- maximum value for an object of type unsigned long long int ULLONG_MAX
  18446744073709551615 // 2 64 − 1
 
 What we've done for these kinds of tests in the past is:
 
 if (sizeof (whatever)  needed size)
   exit (0);
 
 Another approach would be to use an effective target test and skip
 the test if the target doesn't have a suitable long long.  Look  in
 testsuite/lib/target-supports.exp for the various target

If it was some other type, sure, one could use int32plus, lp64, etc.
target, or #if __SIZEOF_type__ == ...

Jakub


[libcpp] use CPP_PEDANTIC

2014-04-25 Thread Prathamesh Kulkarni
Use macro CPP_PEDANTIC (PF) instead of directly using
it's definition: CPP_OPTION (PF, cpp_pedantic).

[libcpp]
* directives.c (_cpp_handle_directive): Use CPP_PEDANTIC macro.
* macro.c (parse_params): Likewise.

Bootstrapped on x86_64-unknown-linux-gnu.
OK for trunk ?

Thanks and Regards,
Prathamesh
Index: libcpp/directives.c
===
--- libcpp/directives.c	(revision 209778)
+++ libcpp/directives.c	(working copy)
@@ -403,7 +403,7 @@ _cpp_handle_directive (cpp_reader *pfile
 
   if (was_parsing_args)
 {
-  if (CPP_OPTION (pfile, cpp_pedantic))
+  if (CPP_PEDANTIC (pfile))
 	cpp_error (pfile, CPP_DL_PEDWARN,
 	 embedding a directive within macro arguments is not portable);
   pfile-state.parsing_args = 0;
Index: libcpp/macro.c
===
--- libcpp/macro.c	(revision 209778)
+++ libcpp/macro.c	(working copy)
@@ -2794,13 +2794,13 @@ parse_params (cpp_reader *pfile, cpp_mac
    pfile-spec_nodes.n__VA_ARGS__);
 	  pfile-state.va_args_ok = 1;
 	  if (! CPP_OPTION (pfile, c99)
-		   CPP_OPTION (pfile, cpp_pedantic)
+		   CPP_PEDANTIC (pfile)
 		   CPP_OPTION (pfile, warn_variadic_macros))
 		cpp_pedwarning
   (pfile, CPP_W_VARIADIC_MACROS,
 		   anonymous variadic macros were introduced in C99);
 	}
-	  else if (CPP_OPTION (pfile, cpp_pedantic)
+	  else if (CPP_PEDANTIC (pfile)
 		CPP_OPTION (pfile, warn_variadic_macros))
 	cpp_pedwarning (pfile, CPP_W_VARIADIC_MACROS,
 		ISO C does not permit named variadic macros);


Re: [C PATCH] Warn about variadic main (PR c/60156)

2014-04-25 Thread Marek Polacek
On Thu, Apr 24, 2014 at 03:11:15PM -0600, Jeff Law wrote:
 OK.  Though in practice I doubt this is going to catch many real
 bugs. Are people still giving main a stdargs style signature?

I doubt too, it's more a matter of QOI.  I've actually never seen
main (int, ...).  But it seemed wrong to not to warn on that.
Thanks,

Marek


Re: [VRP][PATCH] Improve value range for loop index

2014-04-25 Thread Kugan


On 24/04/14 23:05, Richard Biener wrote:
 On Wed, Apr 9, 2014 at 10:07 PM, Kugan
 kugan.vivekanandara...@linaro.org wrote:
 Value range propagation simplifies convergence in vrp_visit_phi_node by
 setting minimum to TYPE_MIN when the computed minimum is smaller than
 the previous minimum. This can however result in pessimistic value
 ranges in some cases.

 for example,

 unsigned int i;
 for (i = 0; i  8; i++)
 {
   
 }

 # ivtmp_19 = PHI ivtmp_17(5), 8(2)
 ...
 bb 5:
 ivtmp_17 = ivtmp_19 - 1;
 if (ivtmp_17 != 0)
 
 goto bb 5;

 min value of ivtmp_19  is simplified to 0 (in tree-vrp.c:8465) where as
 it should have been 1. This prevents correct value ranges being
 calculated for ivtmp_17 in the example.

 We should be able to see the step (the difference from previous minimum
 to computed minimum) and if there is scope for more iterations (computed
 minimum is greater than step), and then we should be able set minimum to
 do one more iteration and converge to the right minimum value.

 Attached patch fixes this. Is this OK for stage-1?
 
 In principle the code in adjust_range_with_scev is supposed to
 fix this up by using number-of-iteration analysis.  I can see this is not
 working for the testcase but I'm curious exactly why.

Thanks for pointing me to adjust_range_with_scev.  I will look into it.


 Your patch basically makes us converge to the correct value by
 iterating (but faster than by just iterating).  That's an interesting
 idea but the way you do it looks very special.  If we really want to
 go down this route (instead of fixing up adjust_range_with_scev for IVs)
 then I'd like to see a more general solution - like by making the code
 skip to TYPE_MIN/MAX_VALUE +-1.  I'm also not sure the case
 handling the supposed bouncing needs to bump to MIN/MAX at all,
 it could simply retain the old values.

TYPE_MIN/MAX_VALUE +-1 might not always work as there might be some
cases where the stride (or the steps in convergence) is not 1 but more
than 1 (?). In those cases, if we set it to TYPE_MIN/MAX_VALUE +-1, they
will not converge from there. therefore should that be,
TYPE_MIN/MAX_VALUE +- stride?


Thanks,
Kugan


Re: [C PATCH] remove goto in c_parser_sizeof_expression

2014-04-25 Thread Marek Polacek
On Thu, Apr 24, 2014 at 03:27:42PM -0600, Jeff Law wrote:
 On 02/24/14 12:28, Marek Polacek wrote:
 On Tue, Feb 25, 2014 at 12:01:25AM +0530, Prathamesh Kulkarni wrote:
 Replaced tab by 4 spaces before error_at.
 * c-parser.c (c_parser_sizeof_expression): Remove goto sizeof_expr.
 
 Looks good now, but I can't approve it.  Thanks,
 Applied to the trunk.  Thanks and sorry for the delays.

Hold on, I thought that in the end we don't want this.  I wanted to
point out formatting issues, and it seemed good to go, but after
Joseph's mail I have changed my mind; goto seems clearer here (to me).

Marek


Re: [PATCH] Fix PR60911

2014-04-25 Thread Richard Biener
On Thu, 24 Apr 2014, Jan Hubicka wrote:

  
  Simple IPA passes are supposed to see function bodies with IPA transforms 
  applied - this is what the code in execute_one_pass tries to ensure.
  But that doesn't work anymore with on-demand function-body loading.
  The following addresses this in the least intrusive way - inlining
  do_per_function (apply_ipa_transforms) and adjusting it accordingly.
  
  This IMHO is definitely the solution for the 4.9 branch (and for
  the time being on trunk).
  
  Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
  
  Ok for trunk and branch?
 
 I think it is fine for both 4.9 and mainline. I will try to make better 
 version
 for mainline as explained in PR hortly.
 
 Can you, please, double check that it won't load all bodies prior late 
 optimization by default? Looking at gate of pass_omp_simd_clone, perhaps 

Well, first of all it will only load bodies with IPA transforms to apply
(yeah, that includes inlining, right?).  Then it's only executed if
a small IPA pass actually executes, but ...

 it actually kills late loading of bodies and perhaps we need to mark in 
 cgraph node whether the given node needs clonning and page the gate 
 return false if partition has no such unit? bool 
 pass_omp_simd_clone::gate (function *) {
   return ((flag_openmp || flag_openmp_simd
|| flag_cilkplus
|| (in_lto_p  !flag_wpa))
(targetm.simd_clone.compute_vecsize_and_simdlen != NULL));
 }
 
 I did not see there the in_lto_p previously.

... this is IIRC because you can't rely on -fopenmp/-fopenmp-simd/-fcilk+
to be present on the LTO commandline.

Richard.

 Honza
  
  Thanks,
  Richard.
  
  2014-04-24  Richard Biener  rguent...@suse.de
  
  PR ipa/60911
  * passes.c (apply_ipa_transforms): Inline into only caller ...
  (execute_one_pass): ... here.  Properly bring in function
  bodies for nodes we want to apply IPA transforms to.
  
  * gcc.dg/lto/pr60911_0.c: New testcase.
  
  Index: gcc/passes.c
  ===
  --- gcc/passes.c(revision 209742)
  +++ gcc/passes.c(working copy)
  @@ -2109,20 +2109,6 @@ execute_all_ipa_transforms (void)
   }
   }
   
  -/* Callback for do_per_function to apply all IPA transforms.  */
  -
  -static void
  -apply_ipa_transforms (void *data)
  -{
  -  struct cgraph_node *node = cgraph_get_node (current_function_decl);
  -  if (!node-global.inlined_to  node-ipa_transforms_to_apply.exists ())
  -{
  -  *(bool *)data = true;
  -  execute_all_ipa_transforms ();
  -  rebuild_cgraph_edges ();
  -}
  -}
  -
   /* Check if PASS is explicitly disabled or enabled and return
  the gate status.  FUNC is the function to be processed, and
  GATE_STATUS is the gate status determined by pass manager by
  @@ -2194,8 +2180,26 @@ execute_one_pass (opt_pass *pass)
Apply all trnasforms first.  */
 if (pass-type == SIMPLE_IPA_PASS)
   {
  +  struct cgraph_node *node;
 bool applied = false;
  -  do_per_function (apply_ipa_transforms, (void *)applied);
  +  FOR_EACH_DEFINED_FUNCTION (node)
  +   if (node-analyzed
  +cgraph_function_with_gimple_body_p (node)
  +(!node-clone_of || node-decl != node-clone_of-decl))
  + {
  +   if (!node-global.inlined_to
  +node-ipa_transforms_to_apply.exists ())
  + {
  +   cgraph_get_body (node);
  +   push_cfun (DECL_STRUCT_FUNCTION (node-decl));
  +   execute_all_ipa_transforms ();
  +   rebuild_cgraph_edges ();
  +   free_dominance_info (CDI_DOMINATORS);
  +   free_dominance_info (CDI_POST_DOMINATORS);
  +   pop_cfun ();
  +   applied = true;
  + }
  + }
 if (applied)
   symtab_remove_unreachable_nodes (true, dump_file);
 /* Restore current_pass.  */
  Index: gcc/testsuite/gcc.dg/lto/pr60911_0.c
  ===
  --- gcc/testsuite/gcc.dg/lto/pr60911_0.c(revision 0)
  +++ gcc/testsuite/gcc.dg/lto/pr60911_0.c(working copy)
  @@ -0,0 +1,21 @@
  +// { dg-lto-do run }
  +// { dg-lto-options { { -O2 -flto -fipa-pta } } }
  +
  +int __attribute__ ((__noinline__)) f (unsigned *p, int *x)
  +{
  +  int y = *p++  0xfff;
  +  *x++ = y;
  +  *x = *p;
  +  return y;
  +}
  +
  +int
  +main ()
  +{
  +  unsigned u[2] = { 0x3aad, 0x5ad1 };
  +  int x[2] = { 17689, 23456 };
  +
  +  if (f (u, x) != 0xaad || x[0] != 0xaad || x[1] != 0x5ad1)
  +__builtin_abort ();
  +  return 0;
  +}
 
 

-- 
Richard Biener rguent...@suse.de
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imendorffer


Re: [VRP][PATCH] Improve value range for loop index

2014-04-25 Thread Richard Biener
On Fri, Apr 25, 2014 at 9:13 AM, Kugan
kugan.vivekanandara...@linaro.org wrote:


 On 24/04/14 23:05, Richard Biener wrote:
 On Wed, Apr 9, 2014 at 10:07 PM, Kugan
 kugan.vivekanandara...@linaro.org wrote:
 Value range propagation simplifies convergence in vrp_visit_phi_node by
 setting minimum to TYPE_MIN when the computed minimum is smaller than
 the previous minimum. This can however result in pessimistic value
 ranges in some cases.

 for example,

 unsigned int i;
 for (i = 0; i  8; i++)
 {
   
 }

 # ivtmp_19 = PHI ivtmp_17(5), 8(2)
 ...
 bb 5:
 ivtmp_17 = ivtmp_19 - 1;
 if (ivtmp_17 != 0)
 
 goto bb 5;

 min value of ivtmp_19  is simplified to 0 (in tree-vrp.c:8465) where as
 it should have been 1. This prevents correct value ranges being
 calculated for ivtmp_17 in the example.

 We should be able to see the step (the difference from previous minimum
 to computed minimum) and if there is scope for more iterations (computed
 minimum is greater than step), and then we should be able set minimum to
 do one more iteration and converge to the right minimum value.

 Attached patch fixes this. Is this OK for stage-1?

 In principle the code in adjust_range_with_scev is supposed to
 fix this up by using number-of-iteration analysis.  I can see this is not
 working for the testcase but I'm curious exactly why.

 Thanks for pointing me to adjust_range_with_scev.  I will look into it.


 Your patch basically makes us converge to the correct value by
 iterating (but faster than by just iterating).  That's an interesting
 idea but the way you do it looks very special.  If we really want to
 go down this route (instead of fixing up adjust_range_with_scev for IVs)
 then I'd like to see a more general solution - like by making the code
 skip to TYPE_MIN/MAX_VALUE +-1.  I'm also not sure the case
 handling the supposed bouncing needs to bump to MIN/MAX at all,
 it could simply retain the old values.

 TYPE_MIN/MAX_VALUE +-1 might not always work as there might be some
 cases where the stride (or the steps in convergence) is not 1 but more
 than 1 (?). In those cases, if we set it to TYPE_MIN/MAX_VALUE +-1, they
 will not converge from there. therefore should that be,
 TYPE_MIN/MAX_VALUE +- stride?

I don't see how stride matters here.  Surely with any value you choose you
will never converge to the exact optimal minimum/maximum value.  But
a more conservative range is always also a convergence point (otherwise
VRPs correctness would fall apart).

Richard.


 Thanks,
 Kugan


Re: Remove obsolete Solaris 9 support

2014-04-25 Thread Rainer Orth
Rainer Orth r...@cebitec.uni-bielefeld.de writes:

 Uros Bizjak ubiz...@gmail.com writes:

 It looks to me that one part was left in libgcc/config/i386/crtfastmath.c:

 #if !defined __x86_64__  defined __sun__  defined __svr4__
 #include signal.h
 #include ucontext.h
 ...
 #endif

 Right, missed it because it carried no Solaris 9 comment.  I'll remove
 it after a round of testing.

Here's what I installed after successful bootstraps on
i386-pc-solaris2.1[01].

Rainer


2014-04-23  Rainer Orth  r...@cebitec.uni-bielefeld.de

* config/i386/crtfastmath.c [!__x86_64__  __sun__  __svr4__]
(sigill_caught, sigill_hdlr): Remove.

# HG changeset patch
# Parent 150c9610f7b0bfa684db0601a5f026e13ed1d30e
Remove SSE execution test in crtfastmath.c

diff --git a/libgcc/config/i386/crtfastmath.c b/libgcc/config/i386/crtfastmath.c
--- a/libgcc/config/i386/crtfastmath.c
+++ b/libgcc/config/i386/crtfastmath.c
@@ -31,26 +31,6 @@
 #include cpuid.h
 #endif
 
-#if !defined __x86_64__  defined __sun__  defined __svr4__
-#include signal.h
-#include ucontext.h
-
-static volatile sig_atomic_t sigill_caught;
-
-static void
-sigill_hdlr (int sig __attribute((unused)),
-	 siginfo_t *sip __attribute__((unused)),
-	 ucontext_t *ucp)
-{
-  sigill_caught = 1;
-  /* Set PC to the instruction after the faulting one to skip over it,
- otherwise we enter an infinite loop.  3 is the size of the movaps
- instruction.  */
-  ucp-uc_mcontext.gregs[EIP] += 3;
-  setcontext (ucp);
-}
-#endif
-
 static void __attribute__((constructor))
 #ifndef __x86_64__
 /* The i386 ABI only requires 4-byte stack alignment, so this is necessary

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


[build] Remove LIB_TLS_SPEC on Solaris

2014-04-25 Thread Rainer Orth
When looking at badly formatted output from gcc/configure, I noticed
that all of LIB_TLS_SPEC on Solaris can go: since Solaris 10,
__tls_get_addr/___tls_get_addr live in libc, no need for a separate
support library.

Bootstrapped without regressions on i386-pc-solaris2.1[01] and
sparc-sun-solaris2.1[01], installed on mainline.

Rainer


2014-04-24  Rainer Orth  r...@cebitec.uni-bielefeld.de

* configure.ac (tga_func): Remove.
(LIB_TLS_SPEC): Remove.
* configure: Regenerate.
* config.in: Regenerate.
* config/sol2.h (LIB_SPEC): Don't use LIB_TLS_SPEC.

# HG changeset patch
# Parent 91f6c1404a228a21bd83ab9be036268f35573daa
Remove LIB_TLS_SPEC on Solaris

diff --git a/gcc/config.in b/gcc/config.in
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1697,12 +1697,6 @@
 #endif
 
 
-/* Define to the library containing __tls_get_addr/___tls_get_addr. */
-#ifndef USED_FOR_TARGET
-#undef LIB_TLS_SPEC
-#endif
-
-
 /* The linker hash style */
 #ifndef USED_FOR_TARGET
 #undef LINKER_HASH_STYLE
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -115,7 +115,6 @@ along with GCC; see the file COPYING3.  
 #define LIB_SPEC \
   %{!symbolic:\
  %{pthreads|pthread:-lpthread} \
- %{pthreads|pthread|fprofile-generate*: LIB_TLS_SPEC } \
  %{p|pg:-ldl} -lc}
 
 #ifndef CROSS_DIRECTORY_STRUCTURE
diff --git a/gcc/configure b/gcc/configure
--- a/gcc/configure
+++ b/gcc/configure
@@ -23306,13 +23306,8 @@ foo:	.long	25
 	;;
   i[34567]86-*-* | x86_64-*-*)
 case $target in
-  i[34567]86-*-solaris2.*)
+  i[34567]86-*-solaris2.* | x86_64-*-solaris2.1[0-9]*)
 	on_solaris=yes
-	tga_func=___tls_get_addr
-	;;
-  x86_64-*-solaris2.1[0-9]*)
-	on_solaris=yes
-	tga_func=__tls_get_addr
 ;;
   *)
 	on_solaris=no
@@ -23587,7 +23582,6 @@ foo:	.long	25
 case $target in
   sparc*-sun-solaris2.*)
 	on_solaris=yes
-	tga_func=__tls_get_addr
 	;;
   *)
 	on_solaris=no
@@ -23711,101 +23705,6 @@ if test $gcc_cv_as_tls = yes; then
   set_have_as_tls=yes
 fi
 fi
-case $target in
-  # TLS was introduced in the Solaris 9 FCS release.  Support for GNU-style
-  # TLS on x86 was only introduced in Solaris 9 4/04, replacing the earlier
-  # Sun style that Sun ld and GCC don't support any longer.
-  *-*-solaris2.*)
-ld_tls_support=yes
-
-save_LIBS=$LIBS
-save_LDFLAGS=$LDFLAGS
-LIBS=
-LDFLAGS=
-
-{ $as_echo $as_me:${as_lineno-$LINENO}: checking library containing $tga_func 5
-$as_echo_n checking library containing $tga_func...  6; }
-# Before Solaris 10, __tls_get_addr (SPARC/x64) resp. ___tls_get_addr
-# (32-bit x86) only lived in libthread, so check for that.  Keep
-# set_have_as_tls if found, disable if not.
-as_ac_Search=`$as_echo ac_cv_search_$tga_func | $as_tr_sh`
-{ $as_echo $as_me:${as_lineno-$LINENO}: checking for library containing $tga_func 5
-$as_echo_n checking for library containing $tga_func...  6; }
-if { as_var=$as_ac_Search; eval test \\${$as_var+set}\ = set; }; then :
-  $as_echo_n (cached)  6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - _ACEOF conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern C
-#endif
-char $tga_func ();
-int
-main ()
-{
-return $tga_func ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' thread; do
-  if test -z $ac_lib; then
-ac_res=none required
-  else
-ac_res=-l$ac_lib
-LIBS=-l$ac_lib  $ac_func_search_save_LIBS
-  fi
-  if ac_fn_c_try_link $LINENO; then :
-  eval $as_ac_Search=\$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-conftest$ac_exeext
-  if { as_var=$as_ac_Search; eval test \\${$as_var+set}\ = set; }; then :
-  break
-fi
-done
-if { as_var=$as_ac_Search; eval test \\${$as_var+set}\ = set; }; then :
-
-else
-  eval $as_ac_Search=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-eval ac_res=\$$as_ac_Search
-	   { $as_echo $as_me:${as_lineno-$LINENO}: result: $ac_res 5
-$as_echo $ac_res 6; }
-eval ac_res=\$$as_ac_Search
-if test $ac_res != no; then :
-  test $ac_res = none required || LIBS=$ac_res $LIBS
-
-else
-  set_have_as_tls=no
-fi
-
-ld_tls_libs=$LIBS
-# Clear LIBS if we cannot support TLS.
-if test $set_have_as_tls = no; then
-  LIBS=
-fi
-# Always define LIB_TLS_SPEC, even without TLS support.
-
-cat confdefs.h _ACEOF
-#define LIB_TLS_SPEC $LIBS
-_ACEOF
-
-{ $as_echo $as_me:${as_lineno-$LINENO}: result: $LIBS 5
-$as_echo $LIBS 6; }
-
-LIBS=$save_LIBS
-LDFLAGS=$save_LDFLAGS
-;;
-esac
 if test $set_have_as_tls = yes ; then
 
 $as_echo #define HAVE_AS_TLS 1 confdefs.h
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2935,13 +2935,8 @@ foo:	.long	25
 	;;
   i[34567]86-*-* | 

Re: [PATCH 00/89] Compile-time gimple-checking

2014-04-25 Thread Richard Biener
On Thu, Apr 24, 2014 at 4:49 PM, Michael Matz m...@suse.de wrote:
 Hi,

 On Thu, 24 Apr 2014, Andrew MacLeod wrote:

 Well, we ought to settle on one... either use the is_a, as_a, and
 dyn_cast paradigm as they exist today, or we use the cast_as_method
 approach everywhere.  I'm not fond of each potential project having a
 different approach...  I'd like to see a consistent look throughout.

 I suspect the cast_as_method has compile time advantages, as well as
 error reporting ones (have you seen the kind of message you get when
 the template instantiation doesn't work right? ick!)  , but it suffers
 from having to modify the base class whenever a new derived class is
 added...

 Well, when adding new derived classes is such a frequent event that this
 would be of any worry, then we have much more difficult problems.  Adding
 types should be a well thought out and hence rare event.

 (which seems a little dirty and could impact possible future
 enhancements).

 Perhaps dirty from some artificial language cleanliness perspective
 (although why would methods be regarded as dirty?).  I call it pragmatic
 and visually undisturbing.

Btw, I agree we should stick to one style throughout the code-base.
The advantage of the cast variant is that it can be made work with
NULL pointers (in the dyn_cast  case).

Oh, and you could avoid all the base-class changing stuff if you'd
do the method like

class Foo
{
  template class T T *as () { return as_a T (this); }
}

Best (or worst) of both worlds.

  gimple_cond c = g-asgimple_cond ();

;)  (you can even put those methods in a separate feature class you
can simply inherit from)

Richard.


 Ciao,
 Michael.


Re: version typeinfo for 128bit types

2014-04-25 Thread Marc Glisse

On Fri, 25 Apr 2014, Jonathan Wakely wrote:


On 24/04/14 20:03 +0200, Marc Glisse wrote:
Grep seems to indicate that the manual is the only other place that needs 
updating, but that can wait.


Is this patch ok, assuming the tests pass?


OK, and sorry for forgetting about that file in the testsuite!


Done.

You might also want to update the latestp check to GLIBCXX_3.4.21 and 
CXXABI_TM_2 since I think adding symbols to GLIBCXX_3.4.20 or CXXABI_TM_1 
at this point should make a noisy error.


--
Marc Glisse


Re: [4.9.1 RFA] [tree-optimization/60902] Invalidate outputs of GIMPLE_ASMs when threading around loops

2014-04-25 Thread Richard Biener
On Thu, Apr 24, 2014 at 5:34 PM, Jeff Law l...@redhat.com wrote:
 On 04/24/14 02:22, Richard Biener wrote:

 +
 + if (backedge_seen)
 +   FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_ALL_DEFS)


 You only need SSA_OP_DEF here, no need to process virtual
 operands.

 I went back and forth on this.  I couldn't come up with a case where we'd do
 the wrong thing with virtuals, but processing all the DEFs is conservatively
 correct, so I left it.

 If you'd like to see this changed to only walk the real defs, I'm happy to
 make that change.

Well, it's cheaper.  And we don't (and can't) record equivalencies on
virtuals.

So, yes please.

Richard.

 jeff




Re: Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.)

2014-04-25 Thread Richard Biener
On Thu, Apr 24, 2014 at 4:59 PM, David Malcolm dmalc...@redhat.com wrote:
 On Thu, 2014-04-24 at 09:09 -0400, Andrew MacLeod wrote:
 On 04/24/2014 04:33 AM, Richard Biener wrote:
  On Wed, Apr 23, 2014 at 11:23 PM, Jeff Law l...@redhat.com wrote:
  On 04/23/14 15:13, David Malcolm wrote:
  On Wed, 2014-04-23 at 15:04 -0600, Jeff Law wrote:
  On 04/21/14 10:56, David Malcolm wrote:
  This updates all of the gimple_bind_* accessors in gimple.h from taking
  a
  plain gimple to taking a gimple_bind (or const_gimple_bind), with the
  checking happening at the point of cast.
 
  Various other types are strengthened from gimple to gimple_bind, and
  from
  plain vecgimple to vecgimple_bind.
 
  [...]
 
  This is fine, with the same requested changes as #2; specifically using
  an explicit cast rather than hiding the conversion in a method.  Once
  those changes are in place, it's good for 4.9.1.
  Thanks - presumably you mean
  good for *trunk* after 4.9.1 is released
  Right.  Sorry for the confusion.
  Note I still want that less-typedefs (esp. the const_*) variants to be 
  explored.
  Changing this will touch all the code again, so I'd like to avoid that.
 
  That is, shouldn't we go back to 'gimple' being 'gimple_statement_base'
  and not 'gimple_statement_base *'?  The main reason that we have so
  many typedefs is that in C you had to use 'struct foo' each time you
  refer to foo as a type - I suppose it was then convenient to do the
  typedef to the pointer type.  With 'gimple' being not a pointer type
  we get const correctness in the way people would expect it to work.
  [no, I don't suggest you change 'tree' or 'const_tree' at this point, just
  gimple (and maybe gimple_seq) as you are working on the 'gimple'
  type anyway].
 
 

 So if we change 'gimple' everywhere to be 'gimple *', can we just
 abandon the 'gimple' typedef completely and go directly to using
 something like gimple_stmt, or some other agreeable name instead?

 I think its more descriptive and then frees up the generic 'gimple' name
 should we decide to do something more with namespaces in the future...

 There have been a few different proposals as to what the resulting
 gimple API might look like, in various subthreads of this discusssion,
 so I thought it might help the discussion to gather up the proposals,
 and to apply them to some specific code examples, to see what the
 results might look like.

 So here are a couple of code fragments, from gcc/graphite-sese-to-poly.c
 and gcc/tree-ssa-uninit.c respectively:

 Status quo
 ==

static gimple
detect_commutative_reduction (scop_p scop, gimple stmt, vecgimple *in,
  vecgimple *out)
{
  if (scalar_close_phi_node_p (stmt))
{
  gimple def, loop_phi, phi, close_phi = stmt;
  tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);

  if (TREE_CODE (arg) != SSA_NAME)

/* ...etc... */

static unsigned int
execute_late_warn_uninitialized (void)
{
  basic_block bb;
  gimple_stmt_iterator gsi;
  vecgimple worklist = vNULL;
  pointer_set_t *added_to_worklist;

 The currently-posted patch series
 =
 Here's the cumulative effect of the patch series I posted, using the
 casting methods of the base class (the stmt-as_a_gimple_phi call):

   -static gimple
   +static gimple_phi
detect_commutative_reduction (scop_p scop, gimple stmt, vecgimple *in,
 vecgimple *out)
{
  if (scalar_close_phi_node_p (stmt))
{
   -  gimple def, loop_phi, phi, close_phi = stmt;
   +  gimple def;
   +  gimple_phi loop_phi, phi, close_phi = stmt-as_a_gimple_phi ();
  tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);

  if (TREE_CODE (arg) != SSA_NAME)

/* ...etc... */

execute_late_warn_uninitialized (void)
{
  basic_block bb;
   -  gimple_stmt_iterator gsi;
   -  vecgimple worklist = vNULL;
   +  gimple_phi_iterator gsi;
   +  vecgimple_phi worklist = vNULL;
  pointer_set_t *added_to_worklist;

 Direct use of is-a.h, retaining typedefs of pointers
 
 The following patch shows what the above might look like using the patch
 series as posted, but eliminating the casting methods  in favor of
 direct use of the is-a.h API (but still using lots of typedefs of
 pointers):

   -static gimple
   +static gimple_phi
detect_commutative_reduction (scop_p scop, gimple stmt, vecgimple *in,
  vecgimple *out)
{
  if (scalar_close_phi_node_p (stmt))
{
   -  gimple def, loop_phi, phi, close_phi = stmt;
   -  tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
   +  gimple def;
   +  gimple_phi loop_phi, phi, close_phi = as_a gimple_phi (stmt);
  tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);

  if (TREE_CODE (arg) != SSA_NAME)

   

Re: wide-int, cfg

2014-04-25 Thread Richard Biener
On Thu, Apr 24, 2014 at 9:02 PM, Mike Stump mikest...@comcast.net wrote:
 On Nov 25, 2013, at 2:57 AM, Richard Biener richard.guent...@gmail.com 
 wrote:
 On Sat, Nov 23, 2013 at 8:21 PM, Mike Stump mikest...@comcast.net wrote:
 Richi has asked the we break the wide-int patch so that the individual port 
 and front end maintainers can review their parts without have to go through 
 the entire patch.This patch covers the cfg code.

 Ok?

 Hmm, this is an example of a wide_int (a widest_int) being used inside
 a structure with long lifetime.  With the patch there are two of those
 per loop plus up to one per statement in a loop body (quadratic in
 the loop depth).


 Now, for the number-of-iterations stuff I really would like to keep things
 cheaper in some way or another.  Shrinking MAX_BITSIZE_MODE_ANY_INT
 would be the easiest improvement for x86_64.

 That said, I'd like this to be addressed.

 The port can limit the size like so:

 /* Keep the OI and XI modes from confusing the compiler into thinking
that these modes could actually be used for computation.  They are
only holders for vectors during data movement.  */
 #define MAX_BITSIZE_MODE_ANY_INT (128)

 and that is now done on x86.

 Ok?

Ok ... but would it be possible to use the wide_int kind with embedded
variable-length array here as well (like for range_info?).

Thanks,
Richard.

 A copy of the patch is below (unchanged)...



Re: wide-int, ada

2014-04-25 Thread Eric Botcazou
 So, given the last change, the remaining bit is:
 
 Index: gcc/ada/gcc-interface/cuintp.c
 ===
 --- gcc/ada/gcc-interface/cuintp.c(revision 209754)
 +++ gcc/ada/gcc-interface/cuintp.c(working copy)
 @@ -160,7 +160,11 @@ UI_From_gnu (tree Input)
   in a signed 64-bit integer.  */
if (tree_fits_shwi_p (Input))
  return UI_From_Int (tree_to_shwi (Input));
 -  else if (wi::neg_p (Input)  TYPE_UNSIGNED (gnu_type))
 +
 +  gcc_assert (TYPE_PRECISION (gnu_type) = 64);
 +  if (TYPE_UNSIGNED (gnu_type)
 +   TYPE_PRECISION (gnu_type) == 64
 +   wi::neg_p (Input, SIGNED))
  return No_Uint;
  #endif
 
 We need this to ensure that 32 to 63 bit values with the high bit set don’t
 return No_Uint.  This should also address the performance concerns as well.

OK, thanks.

-- 
Eric Botcazou


*ping*: [patch, fortran] Fix PR 59604

2014-04-25 Thread Thomas Koenig
OK for trunk?

Full patch at

http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00616.html

 Hello world,
 
 please find attached a patch for PR 59604.
 
 The patch makes sure that, if -fno-range-check is specified,
 using int on an overflowing boz constant yields the same
 result for compile-time simplification and run-time
 execution.
 
 OK for trunk?
 
   Thomas
 
 2014-03-12  Thomas Koenig  tkoe...@gcc.gnu.org
 
 PR fortran/59604
 * gfortran.h (gfc_convert_mpz_to_signed):  Add prototype.
 * arith.c (gfc_int2int):  Convert number to signed if
 arithmetic overflow is not checked.
 * simplify.c (convert_mpz_to_unsigned): Only trigger assert for
 size if range checking is in force.
 (convert_mpz_to_signed):  Make non-static, rename to
 (gfc_convert_mpz_to_signed).
 (simplify_dshift): Use gfc_convert_mpz_to_signed.
 (gfc_simplify_ibclr):  Likewise.
 (gfc_simplify_ibits):  Likewise.
 (gfc_simplify_ibset):  Likewise.
 (simplify_shift):  Likewise.
 (gfc_simplify_ishiftc):  Likewise.
 (gfc_simplify_maskr):  Likewise.
 (gfc_simplify_maskl):  Likewise.
 
 2014-03-12  Thomas Koenig  tkoe...@gcc.gnu.org
 
 PR fortran/59604
 * gfortran.dg/no_range_check_3.f90:  New test.
 



Re: [wide-int] tree-ssa-ccp fix

2014-04-25 Thread Richard Biener
On Thu, Apr 24, 2014 at 11:54 PM, Richard Sandiford
rdsandif...@googlemail.com wrote:
 The asm comparison showed a problem with my r204593 change, which dropped
 a val.mask  in the second hunk below.

 Seeing that the problem was in ccp made me look at the whole file again.
 I noticed that we'd changed the VARYING mask value from -1 to 1, which
 didn't look intentional.

 Tested on x86_64-linux-gnu.  OK to install?

Ok.

Thanks,
Richard.

 Thanks,
 Richard


 Index: gcc/tree-ssa-ccp.c
 ===
 --- gcc/tree-ssa-ccp.c  2014-04-23 19:13:20.488547331 +0100
 +++ gcc/tree-ssa-ccp.c  2014-04-23 19:30:07.025416946 +0100
 @@ -607,7 +607,7 @@ get_value_for_expr (tree expr, bool for_
else
  {
val.lattice_val = VARYING;
 -  val.mask = 1;
 +  val.mask = -1;
val.value = NULL_TREE;
  }
return val;
 @@ -1848,7 +1848,7 @@ evaluate_stmt (gimple stmt)
   if (nonzero_bits == 0)
 val.mask = 0;
   else
 -   val.mask = extend_mask (nonzero_bits);
 +   val.mask = val.mask  extend_mask (nonzero_bits);
 }
 }
  }


Re: [PATCH] Fix PR60930

2014-04-25 Thread Richard Biener
On Fri, 25 Apr 2014, Jakub Jelinek wrote:

 On Thu, Apr 24, 2014 at 09:20:50PM -0600, Jeff Law wrote:
 PR tree-optimization/60930
 * gcc.dg/torture/pr60930.c:  New test.
  Doesn't the test depend on long long being at least 64 bits?
 
 But that is guaranteed by C99, isn't it?

But the testcase isn't built with -std=c99.

 5.2.4.2.1 says:
 
 ... Their implementation-defined values shall be equal or greater in magnitude
 (absolute value) to those shown, with the same sign.
 ...
 - maximum value for an object of type unsigned long long int ULLONG_MAX
   18446744073709551615 // 2 64 − 1
  
  What we've done for these kinds of tests in the past is:
  
  if (sizeof (whatever)  needed size)
exit (0);
  
  Another approach would be to use an effective target test and skip
  the test if the target doesn't have a suitable long long.  Look  in
  testsuite/lib/target-supports.exp for the various target
 
 If it was some other type, sure, one could use int32plus, lp64, etc.
 target, or #if __SIZEOF_type__ == ...

I suggest the latter (#if).

Ok with that change.

Thanks,
Richard.

emit __float128 typeinfo

2014-04-25 Thread Marc Glisse

Hello,

the previous patch had to be reverted as it broke the strange handling of 
vectors in the ARM target. This new patch should be much more conservative 
I hope. Instead of adding this typeinfo to libsupc++, I am letting the FE 
know that it isn't available in libsupc++. There are 2 versions, both 
regtested fine.


Does this approach seem ok, or do we need to try harder to find a way to 
get this typeinfo into libsupc++?


2014-04-25  Marc Glisse  marc.gli...@inria.fr

PR libstdc++/43622
* rtti.c (emit_support_tinfos): Move the array...
(fundamentals): ... and make it global.
(typeinfo_in_lib_p): Use it.

2014-04-25  Marc Glisse  marc.gli...@inria.fr

PR libstdc++/43622
* rtti.c (typeinfo_in_lib_p) [REAL_TYPE]: Check against a
hardcoded list of available types.

--
Marc GlisseIndex: gcc/cp/rtti.c
===
--- gcc/cp/rtti.c   (revision 209787)
+++ gcc/cp/rtti.c   (working copy)
@@ -1042,42 +1042,68 @@ class_initializer (tinfo_s *ti, tree tar
   for (i = 0; i  n; i++)
 CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, va_arg (extra_inits, tree));
   va_end (extra_inits);
 
   init = build_constructor (init_list_type_node, v);
   TREE_CONSTANT (init) = 1;
   TREE_STATIC (init) = 1;
   return init;
 }
 
+/* List of types for which the typeinfo should be placed in the
+   runtime library.
+   Dummy static variable so we can put nullptr in the array; it will be
+   set before we actually start to walk the array.  */
+static tree *const fundamentals[] =
+{
+  void_type_node,
+  boolean_type_node,
+  wchar_type_node, char16_type_node, char32_type_node,
+  char_type_node, signed_char_type_node, unsigned_char_type_node,
+  short_integer_type_node, short_unsigned_type_node,
+  integer_type_node, unsigned_type_node,
+  long_integer_type_node, long_unsigned_type_node,
+  long_long_integer_type_node, long_long_unsigned_type_node,
+  int128_integer_type_node, int128_unsigned_type_node,
+  float_type_node, double_type_node, long_double_type_node,
+  dfloat32_type_node, dfloat64_type_node, dfloat128_type_node,
+  nullptr_type_node,
+  0
+};
+
 /* Returns true if the typeinfo for type should be placed in
the runtime library.  */
 
 static bool
 typeinfo_in_lib_p (tree type)
 {
   /* The typeinfo objects for `T*' and `const T*' are in the runtime
  library for simple types T.  */
   if (TYPE_PTR_P (type)
(cp_type_quals (TREE_TYPE (type)) == TYPE_QUAL_CONST
  || cp_type_quals (TREE_TYPE (type)) == TYPE_UNQUALIFIED))
 type = TREE_TYPE (type);
 
   switch (TREE_CODE (type))
 {
-case INTEGER_TYPE:
 case BOOLEAN_TYPE:
-case REAL_TYPE:
 case VOID_TYPE:
 case NULLPTR_TYPE:
   return true;
 
+case INTEGER_TYPE:
+case REAL_TYPE:
+  for (int ix = 0; fundamentals[ix]; ix++)
+   if (*fundamentals[ix] == type)
+ return true;
+  return false;
+
 case LANG_TYPE:
   /* fall through.  */
 
 default:
   return false;
 }
 }
 
 /* Generate the initializer for the type info describing TYPE.  TK_INDEX is
the index of the descriptor in the tinfo_desc vector. */
@@ -1505,38 +1531,20 @@ emit_support_tinfo_1 (tree bltn)
 
 /* Emit the type_info descriptors which are guaranteed to be in the runtime
support.  Generating them here guarantees consistency with the other
structures.  We use the following heuristic to determine when the runtime
is being generated.  If std::__fundamental_type_info is defined, and its
destructor is defined, then the runtime is being built.  */
 
 void
 emit_support_tinfos (void)
 {
-  /* Dummy static variable so we can put nullptr in the array; it will be
- set before we actually start to walk the array.  */
-  static tree *const fundamentals[] =
-  {
-void_type_node,
-boolean_type_node,
-wchar_type_node, char16_type_node, char32_type_node,
-char_type_node, signed_char_type_node, unsigned_char_type_node,
-short_integer_type_node, short_unsigned_type_node,
-integer_type_node, unsigned_type_node,
-long_integer_type_node, long_unsigned_type_node,
-long_long_integer_type_node, long_long_unsigned_type_node,
-int128_integer_type_node, int128_unsigned_type_node,
-float_type_node, double_type_node, long_double_type_node,
-dfloat32_type_node, dfloat64_type_node, dfloat128_type_node,
-nullptr_type_node,
-0
-  };
   int ix;
   tree bltn_type, dtor;
 
   push_abi_namespace ();
   bltn_type = xref_tag (class_type,
get_identifier (__fundamental_type_info),
/*tag_scope=*/ts_current, false);
   pop_abi_namespace ();
   if (!COMPLETE_TYPE_P (bltn_type))
 return;
Index: gcc/cp/rtti.c
===
--- gcc/cp/rtti.c   (revision 209787)
+++ gcc/cp/rtti.c   (working copy)
@@ -1059,25 +1059,32 @@ typeinfo_in_lib_p (tree type)
  

Re: [PATCH] Fix web/60933

2014-04-25 Thread Eric Botcazou
 Ah, I didn't see that.  So the issue here is that the host compiler
 miscompiles the in-tree copy?  Maybe we should compile host libraries with
 -O0 during stage1 (and require recent host GCC for compiling
 cross compilers - which we probably do anyway).

In-tree is a red herring, very few people do that.  People download libraries, 
compile them with the base compiler, install them and bootstrap the compiler.

 It's an issue anyway as soon as we bump the versions downloaded
 by contrib/download_prerequesites.  What newer versions are
 affected, btw?  Are very newer versions fixed maybe?

GMP 5.x is known to be problematic on SPARC, I don't know for 6.x.

 Generally we have conflicting goals - we want to make sure
 GCC works with system supplied versions of the libraries
 (thus the configure version checks), and we want to specify
 versions that work for the in-tree builds (because of the
 somewhat awkward setup of the build because of their inter-dependencies
 and not doing intermediate installs).

Agreed, but the current situation is relatively satisfactory if you ask me.
If something needs to be changed because of web/60933, then it's probably the 
versions provided at ftp://gcc.gnu.org/pub/gcc/infrastructure/

-- 
Eric Botcazou


Re: [PATCH] Fix PR60930

2014-04-25 Thread Jakub Jelinek
On Fri, Apr 25, 2014 at 10:59:19AM +0200, Richard Biener wrote:
 On Fri, 25 Apr 2014, Jakub Jelinek wrote:
 
  On Thu, Apr 24, 2014 at 09:20:50PM -0600, Jeff Law wrote:
PR tree-optimization/60930
* gcc.dg/torture/pr60930.c:  New test.
   Doesn't the test depend on long long being at least 64 bits?
  
  But that is guaranteed by C99, isn't it?
 
 But the testcase isn't built with -std=c99.

It could, but it really doesn't matter.  For C89 we provide long long
as an extension on all targets, and I'm not aware of any target supported by
GCC where long long type precision would be different between C89 and C99
mode, that would be an ABI nightmare.
AVR has a non-default -mint8 option that makes it C incompatible (e.g. 8-bit
int, 16-bit long and 32-bit long long), but I guess nobody sane would try to
run the full gcc testsuite with that option, that would break 50% of tests
at least.

I think we have plenty of testcases which just assume long long is at least
64-bit.

Jakub


RE: [Testsuite] getpid in gcc.c-torture/execute/pr58419.c

2014-04-25 Thread Dhakshinamoorthy, Soundararajan
Hi, 

I have attached a patch based on the recommendation. Can you please review and 
apply, if it looks ok ?. I don't have commit access.


gcc/testsuite/ChangeLog

2014-04-25  Soundararajan Dhakshinamoorthy  sounderaraja...@atmel.com

* gcc.c-torture/execute/pr58419.c: Adjust the test to work with bare 
metal targets. The 
   test code references to functions that is not implemented for the 
avr target (getpid()).

Thanks,
Soundararajan


From: Jeff Law [l...@redhat.com]
Sent: 23 April 2014 21:59:52
To: Dhakshinamoorthy, Soundararajan; gcc-ow...@gcc.gnu.org
Subject: Re: [Testsuite] getpid in gcc.c-torture/execute/pr58419.c

On 04/23/14 05:50, Dhakshinamoorthy, Soundararajan wrote:
 Hi all,

 The test mentioned in the link had a call to getpid which causes the test to 
 fail for bare metal targets. Is it ok to replace it with
 printf(\0) ?

 which seems to be the first version of the test.
You want to avoid the printf.  Instead I think a dummy function that is
marked as noinline should be sufficient -- I just haven't had the time
to verify that myself.

Jeff

diff --git a/gcc/testsuite/gcc.c-torture/execute/pr58419.c b/gcc/testsuite/gcc.c-torture/execute/pr58419.c
index 69cc040..78bf437 100644
--- a/gcc/testsuite/gcc.c-torture/execute/pr58419.c
+++ b/gcc/testsuite/gcc.c-torture/execute/pr58419.c
@@ -1,4 +1,9 @@
-int printf(const char *, ...);
+__attribute__((__noinline__))
+void
+dummy ()
+{
+  asm volatile();
+}
 
 int a, g, i, k, *p;
 signed char b;
@@ -31,6 +36,6 @@ main ()
   *l = a;
   g = foo (*m = k  *d, 1  i) || bar (); 
 }
-  getpid();
+  dummy();
   return 0;
 }


Re: [Committed][ARM][AArch64] Patches previously ok'd for stage1

2014-04-25 Thread Ramana Radhakrishnan
On Thu, Apr 24, 2014 at 5:50 PM, Kyrill Tkachov kyrylo.tkac...@arm.com wrote:
 On 24/04/14 17:46, Ryan Mansfield wrote:

 On 14-04-24 12:12 PM, Kyrill Tkachov wrote:

 On 24/04/14 14:44, Ryan Mansfield wrote:

 On 14-04-23 11:38 AM, Kyrill Tkachov wrote:

 http://gcc.gnu.org/ml/gcc-patches/2014-03/msg00934.html
 (http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01634.html)

 This patch breaks building arm-eabi with a 32bit host gcc.

 Hi Ryan,

 Does this patch fix it for you?
 I'll test and bootstrap it on arm.

Ok - can people remember to build and test before applying their
patches even though they are OK'd ?

Ramana


 Kyrill

 2014-04-24  Kyrylo Tkachov  kyrylo.tkac...@arm.com

   * config/arm/aarch-common.c (aarch_rev16_shright_mask_imm_p):
   Use HOST_WIDE_INT_C for mask literal.
   (aarch_rev16_shleft_mask_imm_p): Likewise.

 Yes, your patch resolves the build issues. Thanks.


 Thanks for testing.
 Regtest on cross arm-none-eabi passes. Bootstrap in progress.
 Ok to commit if no issues then?

 Kyrill

 Regards,

 Ryan Mansfield






Re: [PATCH] Fix web/60933

2014-04-25 Thread Richard Biener
On Fri, 25 Apr 2014, Eric Botcazou wrote:

  Ah, I didn't see that.  So the issue here is that the host compiler
  miscompiles the in-tree copy?  Maybe we should compile host libraries with
  -O0 during stage1 (and require recent host GCC for compiling
  cross compilers - which we probably do anyway).
 
 In-tree is a red herring, very few people do that.  People download 
 libraries, 
 compile them with the base compiler, install them and bootstrap the compiler.

I'm not sure about that.  In fact I'm always suggesting the in-tree
variant to people (because then they don't need to fiddle with
LD_LIBRARY_PATH).  After suggesting to simply install the requirements
from vendor provided packages, of course.

Maybe we should simply import the requirements into our tree
and use them unless the system provides what we need (or
--with/without-system-FOO is supplied).  We do that for other
stuff like zlib, intl, boehm, etc..  gmp 6.0 now has 'mini-gmp'
which is a slow but very small variant for example.  Not sure
if that's enough for our gmp needs for example.

  It's an issue anyway as soon as we bump the versions downloaded
  by contrib/download_prerequesites.  What newer versions are
  affected, btw?  Are very newer versions fixed maybe?
 
 GMP 5.x is known to be problematic on SPARC, I don't know for 6.x.

Ok, 6.x is know to be problematic on *BSD.

  Generally we have conflicting goals - we want to make sure
  GCC works with system supplied versions of the libraries
  (thus the configure version checks), and we want to specify
  versions that work for the in-tree builds (because of the
  somewhat awkward setup of the build because of their inter-dependencies
  and not doing intermediate installs).
 
 Agreed, but the current situation is relatively satisfactory if you ask me.
 If something needs to be changed because of web/60933, then it's probably the 
 versions provided at ftp://gcc.gnu.org/pub/gcc/infrastructure/

Well, if 5.x doesnt' work for SPARC and 6.x doesn't work for *BSD
that leaves us with 4.x, exactly what is already present there.

Richard.


[PATCH, testsuite]: Require vect_simd_clones effective target for c-c++-common/gomp/pr60823-2.c

2014-04-25 Thread Uros Bizjak
Hello!

This is a runtime test, so check if we are able to at least compile the source.

2014-04-25  Uros Bizjak  ubiz...@gmail.com

* c-c++-common/gomp/pr60823-2.c: Require effective target
vect_simd_clones.

Tested on x86_64 CentOS 5.10.

OK for mainline?

Uros.

Index: c-c++-common/gomp/pr60823-2.c
===
--- c-c++-common/gomp/pr60823-2.c   (revision 209778)
+++ c-c++-common/gomp/pr60823-2.c   (working copy)
@@ -1,5 +1,6 @@
 /* PR tree-optimization/60823 */
 /* { dg-do run } */
+/* { dg-require-effective-target vect_simd_clones } */
 /* { dg-options -O2 -fopenmp-simd } */

 #pragma omp declare simd simdlen(4) notinbranch


Re: [PATCH] Fix web/60933

2014-04-25 Thread Eric Botcazou
 I'm not sure about that.  In fact I'm always suggesting the in-tree
 variant to people (because then they don't need to fiddle with
 LD_LIBRARY_PATH).  After suggesting to simply install the requirements
 from vendor provided packages, of course.

The proper fix to the LD_LIBRARY_PATH issue is rather --disable-shared in my 
opinion...

 Maybe we should simply import the requirements into our tree
 and use them unless the system provides what we need (or
 --with/without-system-FOO is supplied).  We do that for other
 stuff like zlib, intl, boehm, etc..  gmp 6.0 now has 'mini-gmp'
 which is a slow but very small variant for example.  Not sure
 if that's enough for our gmp needs for example.

That would clearly be the definitive answer, but I don't know if it's 
doable in practice.

-- 
Eric Botcazou


RE: [patch] Shorten Windows path

2014-04-25 Thread Joey Ye
Ping

 -Original Message-
 From: Joey Ye [mailto:joey...@arm.com]
 Sent: Tuesday, April 01, 2014 6:18 PM
 To: 'Ian Lance Taylor'
 Cc: gcc-patches
 Subject: RE: [patch] Shorten Windows path
 
 Ian, thanks for your comments. Please find answers and new version below:
 
  -Original Message-
  From: Ian Lance Taylor [mailto:i...@google.com]
  Sent: 25 March 2014 21:09
  To: Joey Ye
  Cc: gcc-patches
  Subject: Re: [patch] Shorten Windows path
 
  On Tue, Mar 25, 2014 at 1:58 AM, Joey Ye joey...@arm.com wrote:
   Ping
 
  This code looks different on mainline.
 
  Writing if ( do_canonical ) is not GCC style.
 Fixed
 
  This patch does not respect the configure option --disable-canonical-
 system-
  headers.
 Solved by put is under the control of default
 ENABLE_CANONICAL_SYSTEM_HEADERS
 
  Also I personally don't actually know what the consequences would be.
  Are there any downsides to canonicalizing header names?
 Since 4.8 system headers are by default canonicalized. This version only
 additionally canonical non-system headers. I can't think of any downsides.
 
 
  Ian
 
 ChangeLog.libcpp:
 
 * files.c (find_file_in_dir): Always try to shorten for DOS non-system
 headers.
 * init.c (ENABLE_CANONICAL_SYSTEM_HEADERS): Default enabled for DOS.
 
 diff --git a/libcpp/files.c b/libcpp/files.c
 index 7e88778..ad68682 100644
 --- a/libcpp/files.c
 +++ b/libcpp/files.c
 @@ -387,8 +387,14 @@ find_file_in_dir (cpp_reader *pfile, _cpp_file *file,
 bool *invalid_pch)
char *copy;
void **pp;
 
 -  /* We try to canonicalize system headers.  */
 -  if (CPP_OPTION (pfile, canonical_system_headers)  file-dir-sysp)
 +  /* We try to canonicalize system headers.  For DOS based file
 +   * system, we always try to shorten non-system headers, as DOS
 +   * has a tighter constraint on max path length.  */
 +  if (CPP_OPTION (pfile, canonical_system_headers)  file-dir-sysp
 +#ifdef HAVE_DOS_BASED_FILE_SYSTEM
 +   || !file-dir-sysp
 +#endif
 +  )
   {
 char * canonical_path = maybe_shorter_path (path);
 if (canonical_path)
 diff --git a/libcpp/init.c b/libcpp/init.c
 index f10413a..b809515 100644
 --- a/libcpp/init.c
 +++ b/libcpp/init.c
 @@ -27,8 +27,12 @@ along with this program; see the file COPYING3.  If not
 see
  #include filenames.h
 
  #ifndef ENABLE_CANONICAL_SYSTEM_HEADERS
 +#ifdef HAVE_DOS_BASED_FILE_SYSTEM
 +#define ENABLE_CANONICAL_SYSTEM_HEADERS 1
 +#else
  #define ENABLE_CANONICAL_SYSTEM_HEADERS 0
  #endif
 +#endif
 
  static void init_library (void);
  static void mark_named_operators (cpp_reader *, int);




Re: [PATCH, testsuite]: Require vect_simd_clones effective target for c-c++-common/gomp/pr60823-2.c

2014-04-25 Thread Jakub Jelinek
On Fri, Apr 25, 2014 at 11:51:06AM +0200, Uros Bizjak wrote:
 Hello!
 
 This is a runtime test, so check if we are able to at least compile the 
 source.
 
 2014-04-25  Uros Bizjak  ubiz...@gmail.com
 
 * c-c++-common/gomp/pr60823-2.c: Require effective target
 vect_simd_clones.
 
 Tested on x86_64 CentOS 5.10.
 
 OK for mainline?

Ok, but please commit it to 4.9 as well.

 --- c-c++-common/gomp/pr60823-2.c   (revision 209778)
 +++ c-c++-common/gomp/pr60823-2.c   (working copy)
 @@ -1,5 +1,6 @@
  /* PR tree-optimization/60823 */
  /* { dg-do run } */
 +/* { dg-require-effective-target vect_simd_clones } */
  /* { dg-options -O2 -fopenmp-simd } */
 
  #pragma omp declare simd simdlen(4) notinbranch

Jakub


[SPARC] Fix PR target/60941

2014-04-25 Thread Eric Botcazou
This is a regression present on all active branches.  The first pattern added 
by http://gcc.gnu.org/ml/gcc-patches/2011-10/msg00060.html is wrong since, as 
counter-intuitive as it may seem, sll also does a full 64-bit shift.

Tested on SPARC/Solaris, applied on all active branches.


2014-04-25  Eric Botcazou  ebotca...@adacore.com

PR target/60941
* config/sparc/sparc.md (ashlsi3_extend): Delete.


2014-04-25  Eric Botcazou  ebotca...@adacore.com

* gcc.c-torture/execute/20140425-1.c: New test.

-- 
Eric BotcazouIndex: config/sparc/sparc.md
===
--- config/sparc/sparc.md	(revision 209778)
+++ config/sparc/sparc.md	(working copy)
@@ -5795,19 +5795,6 @@ (define_insn ashlsi3
 }
   [(set_attr type shift)])
 
-(define_insn *ashlsi3_extend
-  [(set (match_operand:DI 0 register_operand =r)
-	(zero_extend:DI
-	  (ashift:SI (match_operand:SI 1 register_operand r)
-		 (match_operand:SI 2 arith_operand rI]
-  TARGET_ARCH64
-{
-  if (GET_CODE (operands[2]) == CONST_INT)
-operands[2] = GEN_INT (INTVAL (operands[2])  0x1f);
-  return sll\t%1, %2, %0;
-}
-  [(set_attr type shift)])
-
 (define_expand ashldi3
   [(set (match_operand:DI 0 register_operand =r)
 	(ashift:DI (match_operand:DI 1 register_operand r)/* PR target/60941 */
/* Reported by Martin Husemann mar...@netbsd.org */

extern void abort (void);

static void __attribute__((noinline))
set (unsigned long *l)
{
  *l = 31;
}

int main (void)
{
  unsigned long l;
  int i;

  set (l);
  i = (int) l;
  l = (unsigned long)(2U  i);
  if (l != 0)
abort ();
  return 0;
}

Re: [C PATCH] Improve column info of initializers (PR c/60114)

2014-04-25 Thread Marek Polacek
On Tue, Feb 11, 2014 at 12:09:39AM +, Joseph S. Myers wrote:
 On Mon, 10 Feb 2014, Marek Polacek wrote:
 
  This patch improves location information in a bunch of various
  initializers; see the testcase.  Main issue was that digest_init
  was getting only input_location.
  
  Regtested/bootstrapped on x86_64-linux, ok for trunk at this stage
  or should I queue it for 5.0?
 
 OK for after 4.9 branches.

I've committed the patch (after another regtest/bootstrap).

Marek


Re: [SPARC] Fix PR target/60941

2014-04-25 Thread Jakub Jelinek
On Fri, Apr 25, 2014 at 12:47:32PM +0200, Eric Botcazou wrote:
 /* PR target/60941 */
 /* Reported by Martin Husemann mar...@netbsd.org */
 
 extern void abort (void);
 
 static void __attribute__((noinline))
 set (unsigned long *l)
 {
   *l = 31;
 }
 
 int main (void)
 {
   unsigned long l;
   int i;
 
   set (l);
   i = (int) l;
   l = (unsigned long)(2U  i);
   if (l != 0)
 abort ();
   return 0;
 }

I'm afraid the testcase will fail on int16 targets, so perhaps
you should guard the body of main other than return 0; with
#if __INT_MAX__ = 2147483647ULL
or
#if __SIZEOF_INT__ = 4
or similar (or require int32plus target, but gcc.c-torture/execute/
is not a good place for that and *.x files are terribly ugly, so
better would be to move the test to gcc.dg/torture/ in that case).

Jakub


Re: emit __float128 typeinfo

2014-04-25 Thread Marc Glisse

On Fri, 25 Apr 2014, Marc Glisse wrote:

the previous patch had to be reverted as it broke the strange handling of 
vectors in the ARM target. This new patch should be much more conservative I 
hope. Instead of adding this typeinfo to libsupc++, I am letting the FE know 
that it isn't available in libsupc++. There are 2 versions, both regtested 
fine.


Does this approach seem ok, or do we need to try harder to find a way to get 
this typeinfo into libsupc++?


2014-04-25  Marc Glisse  marc.gli...@inria.fr

PR libstdc++/43622
* rtti.c (emit_support_tinfos): Move the array...
(fundamentals): ... and make it global.
(typeinfo_in_lib_p): Use it.

2014-04-25  Marc Glisse  marc.gli...@inria.fr

PR libstdc++/43622
* rtti.c (typeinfo_in_lib_p) [REAL_TYPE]: Check against a
hardcoded list of available types.


It seems better with a TYPE_CANONICAL in there. It passed bootstrap and 
the testsuite is running.


--
Marc GlisseIndex: gcc/cp/rtti.c
===
--- gcc/cp/rtti.c   (revision 209789)
+++ gcc/cp/rtti.c   (working copy)
@@ -1042,42 +1042,69 @@ class_initializer (tinfo_s *ti, tree tar
   for (i = 0; i  n; i++)
 CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, va_arg (extra_inits, tree));
   va_end (extra_inits);
 
   init = build_constructor (init_list_type_node, v);
   TREE_CONSTANT (init) = 1;
   TREE_STATIC (init) = 1;
   return init;
 }
 
+/* List of types for which the typeinfo should be placed in the
+   runtime library.
+   Dummy static variable so we can put nullptr in the array; it will be
+   set before we actually start to walk the array.  */
+static tree *const fundamentals[] =
+{
+  void_type_node,
+  boolean_type_node,
+  wchar_type_node, char16_type_node, char32_type_node,
+  char_type_node, signed_char_type_node, unsigned_char_type_node,
+  short_integer_type_node, short_unsigned_type_node,
+  integer_type_node, unsigned_type_node,
+  long_integer_type_node, long_unsigned_type_node,
+  long_long_integer_type_node, long_long_unsigned_type_node,
+  int128_integer_type_node, int128_unsigned_type_node,
+  float_type_node, double_type_node, long_double_type_node,
+  dfloat32_type_node, dfloat64_type_node, dfloat128_type_node,
+  nullptr_type_node,
+  0
+};
+
 /* Returns true if the typeinfo for type should be placed in
the runtime library.  */
 
 static bool
 typeinfo_in_lib_p (tree type)
 {
   /* The typeinfo objects for `T*' and `const T*' are in the runtime
  library for simple types T.  */
   if (TYPE_PTR_P (type)
(cp_type_quals (TREE_TYPE (type)) == TYPE_QUAL_CONST
  || cp_type_quals (TREE_TYPE (type)) == TYPE_UNQUALIFIED))
 type = TREE_TYPE (type);
 
   switch (TREE_CODE (type))
 {
-case INTEGER_TYPE:
 case BOOLEAN_TYPE:
-case REAL_TYPE:
 case VOID_TYPE:
 case NULLPTR_TYPE:
   return true;
 
+case INTEGER_TYPE:
+case REAL_TYPE:
+  type = TYPE_CANONICAL (type);
+  for (int ix = 0; fundamentals[ix]; ix++)
+   if (*fundamentals[ix] == type)
+ return true;
+  return false;
+
 case LANG_TYPE:
   /* fall through.  */
 
 default:
   return false;
 }
 }
 
 /* Generate the initializer for the type info describing TYPE.  TK_INDEX is
the index of the descriptor in the tinfo_desc vector. */
@@ -1505,38 +1532,20 @@ emit_support_tinfo_1 (tree bltn)
 
 /* Emit the type_info descriptors which are guaranteed to be in the runtime
support.  Generating them here guarantees consistency with the other
structures.  We use the following heuristic to determine when the runtime
is being generated.  If std::__fundamental_type_info is defined, and its
destructor is defined, then the runtime is being built.  */
 
 void
 emit_support_tinfos (void)
 {
-  /* Dummy static variable so we can put nullptr in the array; it will be
- set before we actually start to walk the array.  */
-  static tree *const fundamentals[] =
-  {
-void_type_node,
-boolean_type_node,
-wchar_type_node, char16_type_node, char32_type_node,
-char_type_node, signed_char_type_node, unsigned_char_type_node,
-short_integer_type_node, short_unsigned_type_node,
-integer_type_node, unsigned_type_node,
-long_integer_type_node, long_unsigned_type_node,
-long_long_integer_type_node, long_long_unsigned_type_node,
-int128_integer_type_node, int128_unsigned_type_node,
-float_type_node, double_type_node, long_double_type_node,
-dfloat32_type_node, dfloat64_type_node, dfloat128_type_node,
-nullptr_type_node,
-0
-  };
   int ix;
   tree bltn_type, dtor;
 
   push_abi_namespace ();
   bltn_type = xref_tag (class_type,
get_identifier (__fundamental_type_info),
/*tag_scope=*/ts_current, false);
   pop_abi_namespace ();
   if (!COMPLETE_TYPE_P (bltn_type))
 return;
Index: gcc/cp/rtti.c

Re: [SPARC] Fix PR target/60941

2014-04-25 Thread Eric Botcazou
 I'm afraid the testcase will fail on int16 targets, so perhaps
 you should guard the body of main other than return 0; with
 #if __INT_MAX__ = 2147483647ULL
 or
 #if __SIZEOF_INT__ = 4
 or similar (or require int32plus target, but gcc.c-torture/execute/
 is not a good place for that and *.x files are terribly ugly, so
 better would be to move the test to gcc.dg/torture/ in that case).

Not clear to me, (2U  i) should be zero if the shift count is masked.

-- 
Eric Botcazou


Re: [SPARC] Fix PR target/60941

2014-04-25 Thread Jakub Jelinek
On Fri, Apr 25, 2014 at 01:24:13PM +0200, Eric Botcazou wrote:
  I'm afraid the testcase will fail on int16 targets, so perhaps
  you should guard the body of main other than return 0; with
  #if __INT_MAX__ = 2147483647ULL
  or
  #if __SIZEOF_INT__ = 4
  or similar (or require int32plus target, but gcc.c-torture/execute/
  is not a good place for that and *.x files are terribly ugly, so
  better would be to move the test to gcc.dg/torture/ in that case).
 
 Not clear to me, (2U  i) should be zero if the shift count is masked.

2U  31 is undefined behavior on those targets.

Jakub


Re: [PING^8][PATCH] Add a couple of dialect and warning options regarding Objective-C instance variable scope

2014-04-25 Thread Dimitris Papavasiliou

On 04/25/2014 03:54 AM, Mike Stump wrote:

On Apr 24, 2014, at 4:16 PM, Dimitris Papavasilioudpapa...@gmail.com  wrote:

On 04/24/2014 11:17 PM, Jakub Jelinek wrote:

How has this been tested?

I'm seeing:

+FAIL: obj-c++.dg/local-decl-1.mm -fgnu-runtime  (test for warnings, line 39)
+FAIL: obj-c++.dg/local-decl-1.mm -fgnu-runtime  (test for warnings, line 41)
+FAIL: obj-c++.dg/private-2.mm -fgnu-runtime  (test for warnings, line 32)
+FAIL: obj-c++.dg/private-2.mm -fgnu-runtime  (test for warnings, line 33)
+FAIL: obj-c++.dg/private-2.mm -fgnu-runtime  (test for warnings, line 34)
+FAIL: obj-c++.dg/private-2.mm -fgnu-runtime  (test for warnings, line 53)
+FAIL: obj-c++.dg/private-2.mm -fgnu-runtime  (test for warnings, line 54)
+FAIL: objc.dg/local-decl-1.m -fgnu-runtime  (test for warnings, line 23)
+FAIL: objc.dg/local-decl-2.m -fgnu-runtime  (test for warnings, line 37)
+FAIL: objc.dg/local-decl-2.m -fgnu-runtime  (test for warnings, line 39)
+FAIL: objc.dg/private-2.m -fgnu-runtime  (test for warnings, line 30)
+FAIL: objc.dg/private-2.m -fgnu-runtime  (test for warnings, line 31)
+FAIL: objc.dg/private-2.m -fgnu-runtime  (test for warnings, line 32)
+FAIL: objc.dg/private-2.m -fgnu-runtime  (test for warnings, line 51)
+FAIL: objc.dg/private-2.m -fgnu-runtime  (test for warnings, line 52)

regressions compared to a bootstrap/regtest from a few hours ago on
i686-linux (x86_64-linux still regtesting, but the objc.dg/ failures
can be seen in the logs already).

Jakub



These failures are due to the fact that the patch made -Wshadow control the warnings 
related to instance variable hiding.  These were before enabled by default 
although they were clearly cases of variable shadowing.


So, in general, to contribute patches, you will want to run the test suite to 
ensure quality.  We don’t want to remove warnings without good reason…  so I’m 
defaulting them back to on.  In your text, you didn’t seem to cover this, other 
than to note what we do and to say some might want to turn them off.

Now, if clang turned them off by default, we can go that way, but I’d like to 
maintain users expectations of those on.  I’m anticipating they have them on by 
default still.


I tried to implement all changes in such a way that the default behavior 
of GCC wouldn't be changed but this side-effect slipped my attention.  I 
also tried to run the test suite but, as I recall, I was getting errors 
even on the freshly checked out sources, so I got lazy and gave up on 
that until the proposed changes were actually approved for merging. 
Sorry about that.



Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 209755)
+++ gcc/c-family/c.opt  (working copy)
@@ -685,7 +685,7 @@ ObjC ObjC++ Var(warn_selector) Warning
  Warn if a selector has multiple methods

  Wshadow-ivar
-ObjC ObjC++ Var(warn_shadow_ivar) Init(-1) Warning
+ObjC ObjC++ Var(warn_shadow_ivar) Init(1) Warning
  Warn if a local declaration hides an instance variable

  Wsequence-point

Committed revision 209774.

Thanks Jakub for pointing it out.


Although this will work to get the expected behavior back it has the 
slightly annoying side-effect that specifying -Wno-shadow explicitly 
will *not* turn this particular form of variable shadowing warning off. 
 Might I suggest the following change?


Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 209787)
+++ gcc/c-family/c.opt  (working copy)
@@ -685,7 +685,7 @@
 Warn if a selector has multiple methods

 Wshadow-ivar
-ObjC ObjC++ Var(warn_shadow_ivar) Init(1) Warning
+ObjC ObjC++ Var(warn_shadow_ivar) EnabledBy(Wshadow) Init(1) Warning
 Warn if a local declaration hides an instance variable

 Wsequence-point

The GCC Internals documentation is a little vague as to what the value 
of warn_shadow_ivar will be if Init and EnabledBy are both specified, 
and -Wshadow is *not* explicitly specified, but tests indicate that we 
get the desired behavior.  That is, the warning is enabled by default 
but can be disabled both by -Wno-shadow and by -Wno-shadow-ivar.


If you adopt this change, let me know so that I can add a testcase for 
-Wno-shadow as well.


Dimitris


Re: [GSoC] use obstack in parse_c_expr

2014-04-25 Thread Prathamesh Kulkarni
On Thu, Apr 24, 2014 at 9:18 PM, Diego Novillo dnovi...@google.com wrote:
 Please remember to send patches to gcc-patches.

 I'm wondering if you couldn't just use std::string here.  No need to change
 one complicated allocation scheme with another.
Since we were using c-styled strings throughout genmatch, I thought of
using obstack instead of std::string.
This patch uses std::string in parse_c_expr to build c-code string.
Should we also change AST (operand and subclasses) to use std::string
instead of c-styled strings ?

Thanks and Regards,
Prathamesh


 Diego.


 On Thu, Apr 24, 2014 at 8:15 AM, Prathamesh Kulkarni
 bilbotheelffri...@gmail.com wrote:

 Hi,
There was a comment in parse_c_expr, mentioning to use obstack to
 build c-code string. I have attached patch for the same.
 OK to commit ?

 * genmatch.c (parse_c_expr): Use obstack to build c code string.

 Thanks and Regards,
 Prathamesh


Index: gcc/genmatch.c
===
--- gcc/genmatch.c	(revision 209470)
+++ gcc/genmatch.c	(working copy)
@@ -29,7 +29,7 @@ along with GCC; see the file COPYING3.
 #include hashtab.h
 #include hash-table.h
 #include vec.h
-
+#include string
 
 /* Grammar
 
@@ -689,15 +689,17 @@ parse_c_expr (cpp_reader *r, cpp_ttype s
   cpp_ttype end;
   unsigned opencnt;
   char *code;
+  std::string cstr;
+
   eat_token (r, start);
   if (start == CPP_OPEN_PAREN)
 {
-  code = xstrdup (();
+  cstr += (; 
   end = CPP_CLOSE_PAREN;
 }
   else if (start == CPP_OPEN_BRACE)
 {
-  code = xstrdup (({);
+  cstr += ({;
   end = CPP_CLOSE_BRACE;
 }
   else
@@ -714,13 +716,9 @@ parse_c_expr (cpp_reader *r, cpp_ttype s
 	  if (n-type == CPP_NUMBER
 	   !(n-flags  PREV_WHITE))
 	{
-	  code = (char *)xrealloc (code, strlen (code)
-   + strlen (captures[) + 4);
 	  if (token-flags  PREV_WHITE)
-		strcat (code,  );
-	  strcat (code, captures[);
-	  strcat (code, get_number (r));
-	  strcat (code, ]);
+		cstr +=  ;	
+	  cstr.append (captures[).append (get_number (r)).append (]);
 	  continue;
 	}
 	}
@@ -734,24 +732,19 @@ parse_c_expr (cpp_reader *r, cpp_ttype s
 
   /* Output the token as string.  */
   char *tk = (char *)cpp_token_as_text (r, token);
-  code = (char *)xrealloc (code, strlen (code) + strlen (tk) + 2);
   if (token-flags  PREV_WHITE)
-	strcat (code,  );
-  strcat (code, tk);
+	cstr +=  ;	
+  cstr += tk;
 }
   while (1);
   if (end == CPP_CLOSE_PAREN)
-{
-  code = (char *)xrealloc (code, strlen (code) + 1 + 1);
-  strcat (code, ));
-}
+cstr += );
   else if (end == CPP_CLOSE_BRACE)
-{
-  code = (char *)xrealloc (code, strlen (code) + 1 + 2);
-  strcat (code, }));
-}
+cstr += }); 
   else
 gcc_unreachable ();
+
+  code = (char *) xstrdup (cstr.c_str ());
   return new c_expr (code);
 }
 


[PATCH] Add support for GNU/Hurd in gnat-4.9

2014-04-25 Thread Svante Signell
Hello,

Attached is a patch for support of GNU/Hurd in gnat-4.9. This patch has
been used and updated in Debian since gnat-4.6, and is currently used to
build gnat-4.9. Now when the body file s-osinte-posix.adb in gcc-4.9
defines tv_nsec in timespec POSIX-correctly as long again, we think it
is time that it goes upstream. The patch contains two parts:

src/gcc/ada/gcc-interface/Makefile.in:
Defines LIBGNAT_TARGET_PAIRS for GNU/Hurd

src/gcc/ada/s-osinte-gnu.ads:
A new file giving the OS interface specification for GNU/Hurd. This file
is a modification of the already existing s-osinte-*.ads files.

Regarding copyright assignment, if needed, I've already signed the
papers for gcc (and other GNU packages).

Thanks!
Index: b/src/gcc/ada/s-osinte-gnu.ads
===
--- /dev/null
+++ b/src/gcc/ada/s-osinte-gnu.ads
@@ -0,0 +1,816 @@
+--
+--  --
+--GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS   --
+--  --
+--   S Y S T E M . O S _ I N T E R F A C E  --
+--  --
+--  S p e c --
+--  --
+-- Copyright (C) 1991-1994, Florida State University--
+--  Copyright (C) 1995-2011, Free Software Foundation, Inc. --
+--  --
+-- GNARL is free software; you can  redistribute it  and/or modify it under --
+-- terms of the  GNU General Public License as published  by the Free Soft- --
+-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
+-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
+-- for  more details.  You should have  received  a copy of the GNU General --
+-- Public License  distributed with GNARL; see file COPYING.  If not, write --
+-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
+-- Boston, MA 02110-1301, USA.  --
+--  --
+-- As a special exception,  if other files  instantiate  generics from this --
+-- unit, or you link  this unit with other files  to produce an executable, --
+-- this  unit  does not  by itself cause  the resulting  executable  to  be --
+-- covered  by the  GNU  General  Public  License.  This exception does not --
+-- however invalidate  any other reasons why  the executable file  might be --
+-- covered by the  GNU Public License.  --
+--  --
+-- GNARL was developed by the GNARL team at Florida State University.   --
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
+--  --
+--
+
+--  This is the GNU/Hurd version of this package
+
+--  This package encapsulates all direct interfaces to OS services
+--  that are needed by children of System.
+
+--  PLEASE DO NOT add any with-clauses to this package or remove the pragma
+--  Preelaborate. This package is designed to be a bottom-level (leaf) package
+
+with Interfaces.C;
+with Unchecked_Conversion;
+
+package System.OS_Interface is
+   pragma Preelaborate;
+
+   pragma Linker_Options (-lpthread);
+   pragma Linker_Options (-lrt);
+
+   subtype intis Interfaces.C.int;
+   subtype char   is Interfaces.C.char;
+   subtype short  is Interfaces.C.short;
+   subtype long   is Interfaces.C.long;
+   subtype unsigned   is Interfaces.C.unsigned;
+   subtype unsigned_short is Interfaces.C.unsigned_short;
+   subtype unsigned_long  is Interfaces.C.unsigned_long;
+   subtype unsigned_char  is Interfaces.C.unsigned_char;
+   subtype plain_char is Interfaces.C.plain_char;
+   subtype size_t is Interfaces.C.size_t;
+
+   ---
+   -- Errno --
+   ---
+   --  From /usr/include/i386-gnu/bits/errno.h
+
+   function errno return int;
+   pragma Import (C, errno, __get_errno);
+
+   EAGAIN   : constant := 1073741859;
+   EINTR: constant := 1073741828;
+   EINVAL   : constant := 1073741846;
+   ENOMEM   : constant := 1073741836;
+   EPERM: constant := 1073741825;
+   ETIMEDOUT: constant := 1073741884;
+
+   

Re: [gomp4] Add tables generation

2014-04-25 Thread Ilya Verbin
On 17 Apr 22:33, Ilya Verbin wrote:
 Hi Jakub,
 
 Could you please take a look at this patch?  It fixes the ordering issue in 
 the
 tables stated above, and passes all the tests that I have.  But I'm not sure
 about its correctness from the architectural point of view.
 
 Thanks,
   -- Ilya

Ping.


Re: [GSoC] use obstack in parse_c_expr

2014-04-25 Thread Trevor Saunders
On Fri, Apr 25, 2014 at 05:09:57PM +0530, Prathamesh Kulkarni wrote:
 On Thu, Apr 24, 2014 at 9:18 PM, Diego Novillo dnovi...@google.com wrote:
  Please remember to send patches to gcc-patches.
 
  I'm wondering if you couldn't just use std::string here.  No need to change
  one complicated allocation scheme with another.

I was thinking about suggesting that too, a real string APi (and
std::string is the easiest to hand) seems much less error prone.

 Since we were using c-styled strings throughout genmatch, I thought of
 using obstack instead of std::string.
 This patch uses std::string in parse_c_expr to build c-code string.
 Should we also change AST (operand and subclasses) to use std::string
 instead of c-styled strings ?

it might make things nicer, and it would save you the strdup at the end
of this function, not that performance matters here.  So I'd approve of
doing that.

Trev

 
 Thanks and Regards,
 Prathamesh
 
 
  Diego.
 
 
  On Thu, Apr 24, 2014 at 8:15 AM, Prathamesh Kulkarni
  bilbotheelffri...@gmail.com wrote:
 
  Hi,
 There was a comment in parse_c_expr, mentioning to use obstack to
  build c-code string. I have attached patch for the same.
  OK to commit ?
 
  * genmatch.c (parse_c_expr): Use obstack to build c code string.
 
  Thanks and Regards,
  Prathamesh
 
 

 Index: gcc/genmatch.c
 ===
 --- gcc/genmatch.c(revision 209470)
 +++ gcc/genmatch.c(working copy)
 @@ -29,7 +29,7 @@ along with GCC; see the file COPYING3.
  #include hashtab.h
  #include hash-table.h
  #include vec.h
 -
 +#include string
  
  /* Grammar
  
 @@ -689,15 +689,17 @@ parse_c_expr (cpp_reader *r, cpp_ttype s
cpp_ttype end;
unsigned opencnt;
char *code;
 +  std::string cstr;
 +
eat_token (r, start);
if (start == CPP_OPEN_PAREN)
  {
 -  code = xstrdup (();
 +  cstr += (; 
end = CPP_CLOSE_PAREN;
  }
else if (start == CPP_OPEN_BRACE)
  {
 -  code = xstrdup (({);
 +  cstr += ({;
end = CPP_CLOSE_BRACE;
  }
else
 @@ -714,13 +716,9 @@ parse_c_expr (cpp_reader *r, cpp_ttype s
 if (n-type == CPP_NUMBER
  !(n-flags  PREV_WHITE))
   {
 -   code = (char *)xrealloc (code, strlen (code)
 -+ strlen (captures[) + 4);
 if (token-flags  PREV_WHITE)
 - strcat (code,  );
 -   strcat (code, captures[);
 -   strcat (code, get_number (r));
 -   strcat (code, ]);
 + cstr +=  ;
 +   cstr.append (captures[).append (get_number (r)).append (]);
 continue;
   }
   }
 @@ -734,24 +732,19 @@ parse_c_expr (cpp_reader *r, cpp_ttype s
  
/* Output the token as string.  */
char *tk = (char *)cpp_token_as_text (r, token);
 -  code = (char *)xrealloc (code, strlen (code) + strlen (tk) + 2);
if (token-flags  PREV_WHITE)
 - strcat (code,  );
 -  strcat (code, tk);
 + cstr +=  ;
 +  cstr += tk;
  }
while (1);
if (end == CPP_CLOSE_PAREN)
 -{
 -  code = (char *)xrealloc (code, strlen (code) + 1 + 1);
 -  strcat (code, ));
 -}
 +cstr += );
else if (end == CPP_CLOSE_BRACE)
 -{
 -  code = (char *)xrealloc (code, strlen (code) + 1 + 2);
 -  strcat (code, }));
 -}
 +cstr += }); 
else
  gcc_unreachable ();
 +
 +  code = (char *) xstrdup (cstr.c_str ());
return new c_expr (code);
  }
  



signature.asc
Description: Digital signature


Re: [GSoC] use obstack in parse_c_expr

2014-04-25 Thread Richard Biener
On Fri, Apr 25, 2014 at 2:01 PM, Trevor Saunders tsaund...@mozilla.com
wrote:
 On Fri, Apr 25, 2014 at 05:09:57PM +0530, Prathamesh Kulkarni wrote:
 On Thu, Apr 24, 2014 at 9:18 PM, Diego Novillo dnovi...@google.com wrote:
  Please remember to send patches to gcc-patches.
 
  I'm wondering if you couldn't just use std::string here.  No need to change
  one complicated allocation scheme with another.

 I was thinking about suggesting that too, a real string APi (and
 std::string is the easiest to hand) seems much less error prone.

 Since we were using c-styled strings throughout genmatch, I thought of
 using obstack instead of std::string.
 This patch uses std::string in parse_c_expr to build c-code string.
 Should we also change AST (operand and subclasses) to use std::string
 instead of c-styled strings ?

 it might make things nicer, and it would save you the strdup at the end
 of this function, not that performance matters here.  So I'd approve of
 doing that.

Indeed.  It's only a generator program, so using std::string is fine.

Thanks,
Richard.

 Trev


 Thanks and Regards,
 Prathamesh
 
 
  Diego.
 
 
  On Thu, Apr 24, 2014 at 8:15 AM, Prathamesh Kulkarni
  bilbotheelffri...@gmail.com wrote:
 
  Hi,
 There was a comment in parse_c_expr, mentioning to use obstack to
  build c-code string. I have attached patch for the same.
  OK to commit ?
 
  * genmatch.c (parse_c_expr): Use obstack to build c code string.
 
  Thanks and Regards,
  Prathamesh
 
 

 Index: gcc/genmatch.c
 ===
 --- gcc/genmatch.c(revision 209470)
 +++ gcc/genmatch.c(working copy)
 @@ -29,7 +29,7 @@ along with GCC; see the file COPYING3.
  #include hashtab.h
  #include hash-table.h
  #include vec.h
 -
 +#include string

  /* Grammar

 @@ -689,15 +689,17 @@ parse_c_expr (cpp_reader *r, cpp_ttype s
cpp_ttype end;
unsigned opencnt;
char *code;
 +  std::string cstr;
 +
eat_token (r, start);
if (start == CPP_OPEN_PAREN)
  {
 -  code = xstrdup (();
 +  cstr += (;
end = CPP_CLOSE_PAREN;
  }
else if (start == CPP_OPEN_BRACE)
  {
 -  code = xstrdup (({);
 +  cstr += ({;
end = CPP_CLOSE_BRACE;
  }
else
 @@ -714,13 +716,9 @@ parse_c_expr (cpp_reader *r, cpp_ttype s
 if (n-type == CPP_NUMBER
  !(n-flags  PREV_WHITE))
   {
 -   code = (char *)xrealloc (code, strlen (code)
 -+ strlen (captures[) + 4);
 if (token-flags  PREV_WHITE)
 - strcat (code,  );
 -   strcat (code, captures[);
 -   strcat (code, get_number (r));
 -   strcat (code, ]);
 + cstr +=  ;
 +   cstr.append (captures[).append (get_number (r)).append (]);
 continue;
   }
   }
 @@ -734,24 +732,19 @@ parse_c_expr (cpp_reader *r, cpp_ttype s

/* Output the token as string.  */
char *tk = (char *)cpp_token_as_text (r, token);
 -  code = (char *)xrealloc (code, strlen (code) + strlen (tk) + 2);
if (token-flags  PREV_WHITE)
 - strcat (code,  );
 -  strcat (code, tk);
 + cstr +=  ;
 +  cstr += tk;
  }
while (1);
if (end == CPP_CLOSE_PAREN)
 -{
 -  code = (char *)xrealloc (code, strlen (code) + 1 + 1);
 -  strcat (code, ));
 -}
 +cstr += );
else if (end == CPP_CLOSE_BRACE)
 -{
 -  code = (char *)xrealloc (code, strlen (code) + 1 + 2);
 -  strcat (code, }));
 -}
 +cstr += });
else
  gcc_unreachable ();
 +
 +  code = (char *) xstrdup (cstr.c_str ());
return new c_expr (code);
  }




[C PATCH] Better column info for shift warnings (PR c/60351)

2014-04-25 Thread Marek Polacek
A trivial patch to improve column info of warnings about shift count.

Tested x86_64-linux, ok for trunk?

2014-04-25  Marek Polacek  pola...@redhat.com

PR c/60351
* c-typeck.c (build_binary_op): Use location when warning about
shift count.

* gcc.dg/pr60351.c: New test.

diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 62c72df..e23c6db 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -10402,7 +10402,7 @@ build_binary_op (location_t location, enum tree_code 
code,
{
  int_const = false;
  if (c_inhibit_evaluation_warnings == 0)
-   warning (0, right shift count is negative);
+   warning_at (location, 0, right shift count is negative);
}
  else
{
@@ -10413,7 +10413,8 @@ build_binary_op (location_t location, enum tree_code 
code,
{
  int_const = false;
  if (c_inhibit_evaluation_warnings == 0)
-   warning (0, right shift count = width of type);
+   warning_at (location, 0, right shift count = width 
+   of type);
}
}
}
@@ -10455,14 +10456,15 @@ build_binary_op (location_t location, enum tree_code 
code,
{
  int_const = false;
  if (c_inhibit_evaluation_warnings == 0)
-   warning (0, left shift count is negative);
+   warning_at (location, 0, left shift count is negative);
}
 
  else if (compare_tree_int (op1, TYPE_PRECISION (type0)) = 0)
{
  int_const = false;
  if (c_inhibit_evaluation_warnings == 0)
-   warning (0, left shift count = width of type);
+   warning_at (location, 0, left shift count = width of 
+   type);
}
}
 
diff --git gcc/testsuite/gcc.dg/pr60351.c gcc/testsuite/gcc.dg/pr60351.c
index e69de29..29184d9 100644
--- gcc/testsuite/gcc.dg/pr60351.c
+++ gcc/testsuite/gcc.dg/pr60351.c
@@ -0,0 +1,11 @@
+/* PR c/60351 */
+/* { dg-do compile } */
+
+void
+f (int i)
+{
+  i  -1; /* { dg-warning 5:right shift count is negative } */
+  i  250; /* { dg-warning 5:right shift count = width of type } */
+  i  -1; /* { dg-warning 5:left shift count is negative } */
+  i  250; /* { dg-warning 5:left shift count = width of type } */
+}

Marek


-fuse-caller-save - Enable for MIPS

2014-04-25 Thread Tom de Vries

On 22-04-14 17:05, Tom de Vries wrote:

I've updated the fuse-caller-save patch series to model non-callee call clobbers
in CALL_INSN_FUNCTION_USAGE.



Richard,

this patch enables the fuse-caller-save optimization for MIPS.

It adds the $6 clobber in CALL_INSN_FUNCTION_USAGE when required, and sets 
TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS to true.


I've done a minimal rebuild for mips, ran the fuse-caller-save testcase and 
checked with -dP that I can find $6 in the C_I_F_U.


ok for trunk if a full MIPS build and test cycle succeeds?

Thanks,
- Tom

2014-01-12  Radovan Obradovic  robrado...@mips.com
Tom de Vries  t...@codesourcery.com

* config/mips/mips.h (POST_CALL_TMP_REG): Define.
* config/mips/mips.c (mips_split_call): Use POST_CALL_TMP_REG.
(TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS): Redefine to true.
(mips_expand_call): Add POST_CALL_TMP_REG clobber.
* config/mips/mips.md (define_expand untyped_call): Add
POST_CALL_TMP_REG clobber.

* gcc.target/mips/mips.exp: Add use-caller-save to -ffoo/-fno-foo
options.
* gcc.target/mips/fuse-caller-save.c: New test.
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 45256e9..b61cd44 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -7027,11 +7027,17 @@ mips_expand_call (enum mips_call_type type, rtx result, rtx addr,
 {
   rtx orig_addr, pattern, insn;
   int fp_code;
+  rtx post_call_tmp_reg = gen_rtx_REG (word_mode, POST_CALL_TMP_REG);
 
   fp_code = aux == 0 ? 0 : (int) GET_MODE (aux);
   insn = mips16_build_call_stub (result, addr, args_size, fp_code);
   if (insn)
 {
+  if (TARGET_EXPLICIT_RELOCS
+	   TARGET_CALL_CLOBBERED_GP
+	   !find_reg_note (insn, REG_NORETURN, 0))
+	clobber_reg (CALL_INSN_FUNCTION_USAGE (insn), post_call_tmp_reg);
+
   gcc_assert (!lazy_p  type == MIPS_CALL_NORMAL);
   return insn;
 }
@@ -7087,7 +7093,13 @@ mips_expand_call (enum mips_call_type type, rtx result, rtx addr,
   pattern = fn (result, addr, args_size);
 }
 
-  return mips_emit_call_insn (pattern, orig_addr, addr, lazy_p);
+  insn = mips_emit_call_insn (pattern, orig_addr, addr, lazy_p);
+  if (TARGET_EXPLICIT_RELOCS
+   TARGET_CALL_CLOBBERED_GP
+   !find_reg_note (insn, REG_NORETURN, 0))
+clobber_reg (CALL_INSN_FUNCTION_USAGE (insn), post_call_tmp_reg);
+
+  return insn;
 }
 
 /* Split call instruction INSN into a $gp-clobbering call and
@@ -7099,10 +7111,8 @@ mips_split_call (rtx insn, rtx call_pattern)
 {
   emit_call_insn (call_pattern);
   if (!find_reg_note (insn, REG_NORETURN, 0))
-/* Pick a temporary register that is suitable for both MIPS16 and
-   non-MIPS16 code.  $4 and $5 are used for returning complex double
-   values in soft-float code, so $6 is the first suitable candidate.  */
-mips_restore_gp_from_cprestore_slot (gen_rtx_REG (Pmode, GP_ARG_FIRST + 2));
+mips_restore_gp_from_cprestore_slot (gen_rtx_REG (Pmode,
+		  POST_CALL_TMP_REG));
 }
 
 /* Return true if a call to DECL may need to use JALX.  */
@@ -19134,6 +19144,9 @@ mips_atomic_assign_expand_fenv (tree *hold, tree *clear, tree *update)
 #undef TARGET_ATOMIC_ASSIGN_EXPAND_FENV
 #define TARGET_ATOMIC_ASSIGN_EXPAND_FENV mips_atomic_assign_expand_fenv
 
+#undef TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS
+#define TARGET_CALL_FUSAGE_CONTAINS_NON_CALLEE_CLOBBERS true
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include gt-mips.h
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index b25865b..8c5498a 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -2212,6 +2212,11 @@ enum reg_class
 #define FP_ARG_FIRST (FP_REG_FIRST + 12)
 #define FP_ARG_LAST  (FP_ARG_FIRST + MAX_ARGS_IN_REGISTERS - 1)
 
+/* Temporary register that is used after a call, and suitable for both
+   MIPS16 and non-MIPS16 code.  $4 and $5 are used for returning complex double
+   values in soft-float code, so $6 is the first suitable candidate.  */
+#define POST_CALL_TMP_REG (GP_ARG_FIRST + 2)
+
 /* 1 if N is a possible register number for function argument passing.
We have no FP argument registers when soft-float.  When FP registers
are 32 bits, we can't directly reference the odd numbered ones.  */
diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md
index f914ab6..e333c42 100644
--- a/gcc/config/mips/mips.md
+++ b/gcc/config/mips/mips.md
@@ -6787,8 +6787,15 @@
   
 {
   int i;
+  rtx insn;
+  rtx post_call_tmp_reg = gen_rtx_REG (word_mode, POST_CALL_TMP_REG);
 
-  emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
+  insn = emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx));
+
+  if (TARGET_EXPLICIT_RELOCS
+   TARGET_CALL_CLOBBERED_GP
+   !find_reg_note (insn, REG_NORETURN, 0))
+clobber_reg (CALL_INSN_FUNCTION_USAGE (insn), post_call_tmp_reg);
 
   for (i = 0; i  XVECLEN (operands[2], 0); i++)
 {
diff --git 

[PATCH] Fix test for PR18079

2014-04-25 Thread Marek Polacek
A while ago I committed a fix for PR18079, but only later on discovered
that the test fails because of wrong quoting in dg-warning.  Sorry.

Committed.

2014-04-25  Marek Polacek  pola...@redhat.com

* gcc.dg/pr18079-2.c: Fix quoting in dg-warning.

diff --git gcc/testsuite/gcc.dg/pr18079-2.c gcc/testsuite/gcc.dg/pr18079-2.c
index 5091dd41b..2c83b70 100644
--- gcc/testsuite/gcc.dg/pr18079-2.c
+++ gcc/testsuite/gcc.dg/pr18079-2.c
@@ -3,14 +3,14 @@
 /* { dg-options -Wall } */
 
 __attribute__ ((always_inline)) void fndecl1 (void);
-__attribute__ ((noinline)) void fndecl1 (void); /* { dg-warning attribute 
noinline follows declaration with attribute always_inline } */
+__attribute__ ((noinline)) void fndecl1 (void); /* { dg-warning attribute 
'noinline' follows declaration with attribute 'always_inline' } */
 
 __attribute__ ((noinline)) void fndecl2 (void);
-__attribute__ ((always_inline)) void fndecl2 (void); /* { dg-warning 
attribute always_inline follows declaration with attribute noinline } */
+__attribute__ ((always_inline)) void fndecl2 (void); /* { dg-warning 
attribute 'always_inline' follows declaration with attribute 'noinline' } */
 
 
 __attribute__ ((hot)) void fndecl3 (void);
-__attribute__ ((cold)) void fndecl3 (void); /* { dg-warning attribute cold 
follows declaration with attribute hot } */
+__attribute__ ((cold)) void fndecl3 (void); /* { dg-warning attribute 'cold' 
follows declaration with attribute 'hot' } */
 
 __attribute__ ((cold)) void fndecl4 (void);
-__attribute__ ((hot)) void fndecl4 (void); /* { dg-warning attribute hot 
follows declaration with attribute cold } */
+__attribute__ ((hot)) void fndecl4 (void); /* { dg-warning attribute 'hot' 
follows declaration with attribute 'cold' } */

Marek


Re: -fuse-caller-save - Enable for MIPS

2014-04-25 Thread Richard Sandiford
Tom de Vries tom_devr...@mentor.com writes:
 diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
 index 45256e9..b61cd44 100644
 --- a/gcc/config/mips/mips.c
 +++ b/gcc/config/mips/mips.c
 @@ -7027,11 +7027,17 @@ mips_expand_call (enum mips_call_type type, rtx 
 result, rtx addr,
  {
rtx orig_addr, pattern, insn;
int fp_code;
 +  rtx post_call_tmp_reg = gen_rtx_REG (word_mode, POST_CALL_TMP_REG);
  
fp_code = aux == 0 ? 0 : (int) GET_MODE (aux);
insn = mips16_build_call_stub (result, addr, args_size, fp_code);
if (insn)
  {
 +  if (TARGET_EXPLICIT_RELOCS
 +TARGET_CALL_CLOBBERED_GP
 +!find_reg_note (insn, REG_NORETURN, 0))
 + clobber_reg (CALL_INSN_FUNCTION_USAGE (insn), post_call_tmp_reg);
 +

I think this condition should go in mips_emit_call_insn instead,
so that we don't have 4 instances of it.  untyped_call could then
use mips_expand_call as well.

Until now there was no real downside to using $6 for non-MIPS16 code.
Now that there is, it would probably be worth making it:

+#define POST_CALL_TMP_REG \
  (TARGET_MIPS16 ? GP_ARG_FIRST + 2 : PIC_OFFSET_TABLE_REGNUM)

and only adding the clobber for MIPS16.

 diff --git a/gcc/testsuite/gcc.target/mips/fuse-caller-save.c 
 b/gcc/testsuite/gcc.target/mips/fuse-caller-save.c
 new file mode 100644
 index 000..1fd6c7d
 --- /dev/null
 +++ b/gcc/testsuite/gcc.target/mips/fuse-caller-save.c
 @@ -0,0 +1,30 @@
 +/* { dg-do compile } */
 +/* { dg-options -fuse-caller-save } */
 +/* { dg-skip-if  { *-*-* }  { * } { -Os } } */

I might have asked this before, sorry, but why this skip?  Please add a brief
comment (in the string, if short enough).

 +/* Testing -fuse-caller-save optimization option.  */
 +
 +static int __attribute__((noinline)) NOCOMPRESSION
 +bar (int x)
 +{
 +  return x + 3;
 +}
 +
 +int __attribute__((noinline)) NOCOMPRESSION
 +foo (int y)
 +{
 +  return y + bar (y);
 +}
 +
 +int NOCOMPRESSION
 +main (void)
 +{
 +  return !(foo (5) == 13);
 +}
 +
 +/* Check that there are only 2 stack-saves: r31 in main and foo.  */
 +
 +/* Check that there only 2 sw/sd.  */
 +/* { dg-final { scan-assembler-times (?n)s\[wd\]\t\\\$.*,.*\\(\\\$sp\\) 2 
 } } */
 +
 +/* Check that the first caller-save register is unused.  */
 +/* { dg-final { scan-assembler-not \\\$16 } } */

It'd be good to avoid NOCOMPRESSION because the only case that really
needs the temporary register is MIPS16.  Please try putting the test
in a header file and reusing it for three tests, one each of MIPS16,
microMIPS and uncompressed.

Thanks,
Richard


[PATCH] Make SRA create statements with the correct alias type

2014-04-25 Thread Martin Jambor
Hi,

the patch below is inspired by PR 57297 (the most relevant comments
are #4 and #5).  The problem is that currently SRA creates memory
loads and stores with alias type of whatever happens to be in
access-base.  However, at least when using placement or some nasty
type-casting, it is possible that the same aggregate, represented by
the same access structure, is accessed using different alias types in
one function.  This might lead to bogus memory access reordering, at
least in theory.  This patch therefore makes sure all SRA created
accesses have the same alias type as the load/store they originated
from.

Because load_assign_lhs_subreplacements did not look like it could
accept one more parameter, I encapsulated all of them in a structure.
I wrote this patch in December, I admit I don't remember what the new
testcase aims for, but I assume I added it for a reason :-)

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin


2014-04-24  Martin Jambor  mjam...@suse.cz

* tree-sra.c (sra_modify_expr): Generate new memory accesses with
same alias type as the original statement.
(subreplacement_assignment_data): New type.
(handle_unscalarized_data_in_subtree): New type of parameter,
generate new memory accesses with same alias type as the original
statement.
(load_assign_lhs_subreplacements): Likewise.
(sra_modify_constructor_assign): Generate new memory accesses with
same alias type as the original statement.

testsuite/
* gcc.dg/tree-ssa/sra-14.c: New test.

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/sra-14.c 
b/gcc/testsuite/gcc.dg/tree-ssa/sra-14.c
new file mode 100644
index 000..6cbc0b4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/sra-14.c
@@ -0,0 +1,70 @@
+/* { dg-do run } */
+/* { dg-options -O1 } */
+
+struct S
+{
+  int i, j;
+};
+
+struct Z
+{
+  struct S d, s;
+};
+
+struct S __attribute__ ((noinline, noclone))
+get_s (void)
+{
+  struct S s;
+  s.i = 5;
+  s.j = 6;
+
+  return s;
+}
+
+struct S __attribute__ ((noinline, noclone))
+get_d (void)
+{
+  struct S d;
+  d.i = 0;
+  d.j = 0;
+
+  return d;
+}
+
+int __attribute__ ((noinline, noclone))
+get_c (void)
+{
+  return 1;
+}
+
+int __attribute__ ((noinline, noclone))
+my_nop (int i)
+{
+  return i;
+}
+
+int __attribute__ ((noinline, noclone))
+foo (void)
+{
+  struct Z z;
+  int i, c = get_c ();
+
+  z.d = get_d ();
+  z.s = get_s ();
+
+  for (i = 0; i  c; i++)
+{
+  z.s.i = my_nop (z.s.i);
+  z.s.j = my_nop (z.s.j);
+}
+
+  return z.s.i + z.s.j;
+}
+
+int main (int argc, char *argv[])
+{
+  if (foo () != 11)
+__builtin_abort ();
+  return 0;
+}
+
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 49bbee3..4a24e6a 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -2769,7 +2769,7 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, 
bool write)
 {
   location_t loc;
   struct access *access;
-  tree type, bfr;
+  tree type, bfr, orig_expr;
 
   if (TREE_CODE (*expr) == BIT_FIELD_REF)
 {
@@ -2785,6 +2785,7 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, 
bool write)
   if (!access)
 return false;
   type = TREE_TYPE (*expr);
+  orig_expr = *expr;
 
   loc = gimple_location (gsi_stmt (*gsi));
   gimple_stmt_iterator alt_gsi = gsi_none ();
@@ -2811,8 +2812,7 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, 
bool write)
{
  tree ref;
 
- ref = build_ref_for_model (loc, access-base, access-offset, access,
-NULL, false);
+ ref = build_ref_for_model (loc, orig_expr, 0, access, NULL, false);
 
  if (write)
{
@@ -2863,7 +2863,7 @@ sra_modify_expr (tree *expr, gimple_stmt_iterator *gsi, 
bool write)
   else
start_offset = chunk_size = 0;
 
-  generate_subtree_copies (access-first_child, access-base, 0,
+  generate_subtree_copies (access-first_child, orig_expr, access-offset,
   start_offset, chunk_size, gsi, write, write,
   loc);
 }
@@ -2877,53 +2877,70 @@ enum unscalarized_data_handling { SRA_UDH_NONE,  /* 
Nothing done so far. */
  SRA_UDH_RIGHT, /* Data flushed to the RHS. */
  SRA_UDH_LEFT }; /* Data flushed to the LHS. */
 
+struct subreplacement_assignment_data
+{
+  /* Offset of the access representing the lhs of the assignment.  */
+  HOST_WIDE_INT left_offset;
+
+  /* LHS and RHS of the original assignment.  */
+  tree assignment_lhs, assignment_rhs;
+
+  /* Access representing the rhs of the whole assignment.  */
+  struct access *top_racc;
+
+  /* Stmt iterator used for statement insertions after the original assignment.
+   It points to the main GSI used to traverse a BB during function body
+   modification.  */
+  gimple_stmt_iterator *new_gsi;
+
+  /* Stmt iterator used for statement insertions before the original
+   assignment.  Keeps on 

[PATCH] Fix vector division lowering (PR tree-optimization/60960)

2014-04-25 Thread Jakub Jelinek
Hi!

If a vector type has scalar mode, such as 4xchar vector in the testcase
SImode, then unfortunately various optabs checks in expand_vector_divmod
and functions it calls can succeed, but the operation is actually not
a vector operation (e.g. a SImode shift is very different from
V4QImode shift with scalar shift count).

The following patch fixes this by not calling expand_vector_divmod
at all if the type doesn't have a vector mode.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.9?

2014-04-25  Jakub Jelinek  ja...@redhat.com

PR tree-optimization/60960
* tree-vect-generic.c (expand_vector_operation): Only call
expand_vector_divmod if type's mode satisfies VECTOR_MODE_P.

* gcc.c-torture/execute/pr60960.c: New test.

--- gcc/tree-vect-generic.c.jj  2014-04-17 14:49:04.0 +0200
+++ gcc/tree-vect-generic.c 2014-04-25 09:27:31.689530647 +0200
@@ -971,7 +971,8 @@ expand_vector_operation (gimple_stmt_ite
 
  if (!optimize
  || !VECTOR_INTEGER_TYPE_P (type)
- || TREE_CODE (rhs2) != VECTOR_CST)
+ || TREE_CODE (rhs2) != VECTOR_CST
+ || !VECTOR_MODE_P (TYPE_MODE (type)))
break;
 
  ret = expand_vector_divmod (gsi, type, rhs1, rhs2, code);
--- gcc/testsuite/gcc.c-torture/execute/pr60960.c.jj2014-04-25 
09:30:10.891687231 +0200
+++ gcc/testsuite/gcc.c-torture/execute/pr60960.c   2014-04-25 
09:29:50.0 +0200
@@ -0,0 +1,38 @@
+/* PR tree-optimization/60960 */
+
+typedef unsigned char v4qi __attribute__ ((vector_size (4)));
+
+__attribute__((noinline, noclone)) v4qi
+f1 (v4qi v)
+{
+  return v / 2;
+}
+
+__attribute__((noinline, noclone)) v4qi
+f2 (v4qi v)
+{
+  return v / (v4qi) { 2, 2, 2, 2 };
+}
+
+__attribute__((noinline, noclone)) v4qi
+f3 (v4qi x, v4qi y)
+{
+  return x / y;
+}
+
+int
+main ()
+{
+  v4qi x = { 5, 5, 5, 5 };
+  v4qi y = { 2, 2, 2, 2 };
+  v4qi z = f1 (x);
+  if (__builtin_memcmp (y, z, sizeof (y)) != 0)
+__builtin_abort ();
+  z = f2 (x);
+  if (__builtin_memcmp (y, z, sizeof (y)) != 0)
+__builtin_abort ();
+  z = f3 (x, y);
+  if (__builtin_memcmp (y, z, sizeof (y)) != 0)
+__builtin_abort ();
+  return 0;
+}

Jakub


[wide-int 2/5] Fix large widths in shifted_mask

2014-04-25 Thread Richard Sandiford
shifted_mask would mishandle cases where the start bit is in the middle
of a HWI and the end bit is in a different HWI.  The 000111000 case
needs to check that the start and end are in the same block.

In the changed lines, shift is the position of the lowest mask bit
in its containing HWI.  The end is in the same HWI if shift + width
 HOST_BITS_PER_WIDE_INT.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


Index: gcc/wide-int.cc
===
--- gcc/wide-int.cc 2014-04-25 09:50:37.850073188 +0100
+++ gcc/wide-int.cc 2014-04-25 09:51:05.992292099 +0100
@@ -768,8 +768,8 @@ wi::shifted_mask (HOST_WIDE_INT *val, un
   if (shift)
 {
   HOST_WIDE_INT block = ((unsigned HOST_WIDE_INT) 1  shift) - 1;
-  shift = end  (HOST_BITS_PER_WIDE_INT - 1);
-  if (shift)
+  shift += width;
+  if (shift  HOST_BITS_PER_WIDE_INT)
{
  /* case 000111000 */
  block = ((unsigned HOST_WIDE_INT) 1  shift) - block - 1;


[wide-int 3/5] Fix large widths in shifted_mask

2014-04-25 Thread Richard Sandiford
Very minor, but since shifted_mask copes with out-of-range widths,
I think mask should too.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


Index: gcc/wide-int.cc
===
--- gcc/wide-int.cc 2014-04-25 09:26:57.025944460 +0100
+++ gcc/wide-int.cc 2014-04-25 09:37:16.873811137 +0100
@@ -716,7 +716,7 @@ wi::mask (HOST_WIDE_INT *val, unsigned i
   gcc_assert (width  4 * MAX_BITSIZE_MODE_ANY_INT);
   gcc_assert (prec = 4 * MAX_BITSIZE_MODE_ANY_INT);
 
-  if (width == prec)
+  if (width = prec)
 {
   val[0] = negate ? 0 : -1;
   return 1;


[wide-int 1/5] Cosmetic fixes to wide-int.{cc,h}

2014-04-25 Thread Richard Sandiford
This series of patches is from a read-through of wide-int.h and wide-int.cc.
(The series from earlier in the week was from a diff of preexisting files.)

This first patch fixes some comments, typos and formatting.  It also
removes some dead code.  I'll follow up with a gdb-friendly replacement
for the old dump function.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


Index: gcc/wide-int.cc
===
--- gcc/wide-int.cc 2014-04-25 11:33:57.809153807 +0100
+++ gcc/wide-int.cc 2014-04-25 12:33:59.202021025 +0100
@@ -37,12 +37,6 @@ typedef unsigned int UDItype __attribute
 #include longlong.h
 #endif
 
-/* This is the maximal size of the buffer needed for dump.  */
-const unsigned int MAX_SIZE = (4 * (MAX_BITSIZE_MODE_ANY_INT / 4
-   + (MAX_BITSIZE_MODE_ANY_INT
-  / HOST_BITS_PER_WIDE_INT)
-   + 32));
-
 static const HOST_WIDE_INT zeros[WIDE_INT_MAX_ELTS] = {};
 
 /*
@@ -51,7 +45,7 @@ static const HOST_WIDE_INT zeros[WIDE_IN
 
 /* Quantities to deal with values that hold half of a wide int.  Used
in multiply and divide.  */
-#define HALF_INT_MASK (((HOST_WIDE_INT)1  HOST_BITS_PER_HALF_WIDE_INT) - 1)
+#define HALF_INT_MASK (((HOST_WIDE_INT) 1  HOST_BITS_PER_HALF_WIDE_INT) - 1)
 
 #define BLOCK_OF(TARGET) ((TARGET) / HOST_BITS_PER_WIDE_INT)
 #define BLOCKS_NEEDED(PREC) \
@@ -129,8 +123,8 @@ wi::from_array (HOST_WIDE_INT *val, cons
 
 /* Construct a wide int from a buffer of length LEN.  BUFFER will be
read according to byte endianess and word endianess of the target.
-   Only the lower LEN bytes of the result are set; the remaining high
-   bytes are cleared.  */
+   Only the lower BUFFER_LEN bytes of the result are set; the remaining
+   high bytes are cleared.  */
 wide_int
 wi::from_buffer (const unsigned char *buffer, unsigned int buffer_len)
 {
@@ -212,7 +206,7 @@ wi::to_mpz (const wide_int_ref x, mpz_t
 mpz_import (result, len, -1, sizeof (HOST_WIDE_INT), 0, 0, v);
 }
 
-/* Returns VAL converted to TYPE.  If WRAP is true, then out-of-range
+/* Returns X converted to TYPE.  If WRAP is true, then out-of-range
values of VAL will be wrapped; otherwise, they will be set to the
appropriate minimum or maximum TYPE bound.  */
 wide_int
@@ -243,8 +237,8 @@ wi::from_mpz (const_tree type, mpz_t x,
  for representing the value.  The code to calculate count is
  extracted from the GMP manual, section Integer Import and Export:
  http://gmplib.org/manual/Integer-Import-and-Export.html  */
-  numb = 8*sizeof(HOST_WIDE_INT);
-  count = (mpz_sizeinbase (x, 2) + numb-1) / numb;
+  numb = 8 * sizeof(HOST_WIDE_INT);
+  count = (mpz_sizeinbase (x, 2) + numb - 1) / numb;
   HOST_WIDE_INT *val = res.write_val ();
   mpz_export (val, count, -1, sizeof (HOST_WIDE_INT), 0, 0, x);
   if (count  1)
@@ -352,9 +346,8 @@ wi::force_to_size (HOST_WIDE_INT *val, c
where we do allow comparisons of values of different precisions.  */
 static inline HOST_WIDE_INT
 selt (const HOST_WIDE_INT *a, unsigned int len,
- unsigned int blocks_needed,
- unsigned int small_prec,
- unsigned int index, signop sgn)
+  unsigned int blocks_needed, unsigned int small_prec,
+  unsigned int index, signop sgn)
 {
   HOST_WIDE_INT val;
   if (index  len)
@@ -388,7 +381,7 @@ top_bit_of (const HOST_WIDE_INT *a, unsi
 
 /*
  * Comparisons, note that only equality is an operator.  The other
- * comparisons cannot be operators since they are inherently singed or
+ * comparisons cannot be operators since they are inherently signed or
  * unsigned and C++ has no such operators.
  */
 
@@ -401,7 +394,7 @@ wi::eq_p_large (const HOST_WIDE_INT *op0
   int l0 = op0len - 1;
   unsigned int small_prec = prec  (HOST_BITS_PER_WIDE_INT - 1);
 
-  while (op0len != op1len)
+  if (op0len != op1len)
 return false;
 
   if (op0len == BLOCKS_NEEDED (prec)  small_prec)
@@ -741,7 +734,7 @@ wi::mask (HOST_WIDE_INT *val, unsigned i
   unsigned int shift = width  (HOST_BITS_PER_WIDE_INT - 1);
   if (shift != 0)
 {
-  HOST_WIDE_INT last = (((unsigned HOST_WIDE_INT) 1)  shift) - 1;
+  HOST_WIDE_INT last = ((unsigned HOST_WIDE_INT) 1  shift) - 1;
   val[i++] = negate ? ~last : last;
 }
   else
@@ -774,12 +767,12 @@ wi::shifted_mask (HOST_WIDE_INT *val, un
   unsigned int shift = start  (HOST_BITS_PER_WIDE_INT - 1);
   if (shift)
 {
-  HOST_WIDE_INT block = (((unsigned HOST_WIDE_INT) 1)  shift) - 1;
+  HOST_WIDE_INT block = ((unsigned HOST_WIDE_INT) 1  shift) - 1;
   shift = end  (HOST_BITS_PER_WIDE_INT - 1);
   if (shift)
{
  /* case 000111000 */
- block = (((unsigned HOST_WIDE_INT) 1)  shift) - block - 1;
+ block = ((unsigned HOST_WIDE_INT) 1  shift) - block - 1;
  val[i++] = negate ? ~block : block;
  return i;
}
@@ -796,7 +789,7 @@ wi::shifted_mask 

[ada, build] Ignore cp -p failures during Ada make install

2014-04-25 Thread Rainer Orth
When trying to install a freshly built gcc 4.9.0 on Solaris 9 and 10, I
ran into make install failures when using INSTALL_DATA_DATE:

cp: preserving permissions for 
'/vol/gcc-4.9/lib/gcc/i386-pc-solaris2.10/4.9.0/adalib/a-assert.ali': Operation 
not supported on transport endpoint

The problem is that the source filesystem is either UFS (supporting
POSIX ACLs) or ZFS (supporting NFSv4 ACLs), while the destination is an
NFS-mounted (NFSv3, which doesn't include support for NFSv4 ACLs) ZFS
filesystem (which cannot support UFS ACLs even if NFSv3 could), so cp -p
errors as above although the timestamps are preserved.

It seems to me that (as already done in one of three cases in the
install-gnatlib target) $(INSTALL_DATA_DATE) errors should be ignored,
to allow for such a case.

The following patch does just that and allowed the make install to
complete.

Ok for mainline?

Rainer


2014-04-25  Rainer Orth  r...@cebitec.uni-bielefeld.de

* gcc-interface/Makefile.in (install-gnatlib): Ignore
$(INSTALL_DATA_DATE) errors.

===
RCS file: gcc/ada/gcc-interface/RCS/Makefile,v
retrieving revision 1.1
diff -u -r1.1 gcc/ada/gcc-interface/Makefile
--- gcc/ada/gcc-interface/Makefile	2014/04/23 15:14:11	1.1
+++ gcc/ada/gcc-interface/Makefile	2014/04/23 18:56:47
@@ -2613,7 +2613,7 @@
 	$(RMDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
 	-$(MKDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR)
 	-$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR)
-	for file in $(RTSDIR)/*.ali; do \
+	-for file in $(RTSDIR)/*.ali; do \
 	$(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
 	done
 	-cd $(RTSDIR); for file in *$(arext);do \
@@ -2644,7 +2644,7 @@
 	   fi; \
 	done
 # This copy must be done preserving the date on the original file.
-	for file in $(RTSDIR)/*.ad?; do \
+	-for file in $(RTSDIR)/*.ad?; do \
 	$(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_INCLUDE_DIR); \
 	done
 	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


[wide-int 4/5] Fix canonize handling of small_prec case

2014-04-25 Thread Richard Sandiford
We should write back the sign-extended value.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


Index: gcc/wide-int.cc
===
--- gcc/wide-int.cc 2014-04-25 09:15:14.297359380 +0100
+++ gcc/wide-int.cc 2014-04-25 09:15:50.755637670 +0100
@@ -81,7 +81,7 @@ canonize (HOST_WIDE_INT *val, unsigned i
 
   top = val[len - 1];
   if (len * HOST_BITS_PER_WIDE_INT  precision)
-top = sext_hwi (top, precision % HOST_BITS_PER_WIDE_INT);
+val[len - 1] = top = sext_hwi (top, precision % HOST_BITS_PER_WIDE_INT);
   if (top != 0  top != (HOST_WIDE_INT)-1)
 return len;
 


Re: [PATCH] Fix vector division lowering (PR tree-optimization/60960)

2014-04-25 Thread Richard Biener
On April 25, 2014 3:39:29 PM CEST, Jakub Jelinek ja...@redhat.com wrote:
Hi!

If a vector type has scalar mode, such as 4xchar vector in the testcase
SImode, then unfortunately various optabs checks in
expand_vector_divmod
and functions it calls can succeed, but the operation is actually not
a vector operation (e.g. a SImode shift is very different from
V4QImode shift with scalar shift count).

The following patch fixes this by not calling expand_vector_divmod
at all if the type doesn't have a vector mode.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk/4.9?

OK,
Thanks,
Richard.

2014-04-25  Jakub Jelinek  ja...@redhat.com

   PR tree-optimization/60960
   * tree-vect-generic.c (expand_vector_operation): Only call
   expand_vector_divmod if type's mode satisfies VECTOR_MODE_P.

   * gcc.c-torture/execute/pr60960.c: New test.

--- gcc/tree-vect-generic.c.jj 2014-04-17 14:49:04.0 +0200
+++ gcc/tree-vect-generic.c2014-04-25 09:27:31.689530647 +0200
@@ -971,7 +971,8 @@ expand_vector_operation (gimple_stmt_ite
 
 if (!optimize
 || !VECTOR_INTEGER_TYPE_P (type)
-|| TREE_CODE (rhs2) != VECTOR_CST)
+|| TREE_CODE (rhs2) != VECTOR_CST
+|| !VECTOR_MODE_P (TYPE_MODE (type)))
   break;
 
 ret = expand_vector_divmod (gsi, type, rhs1, rhs2, code);
--- gcc/testsuite/gcc.c-torture/execute/pr60960.c.jj   2014-04-25
09:30:10.891687231 +0200
+++ gcc/testsuite/gcc.c-torture/execute/pr60960.c  2014-04-25
09:29:50.0 +0200
@@ -0,0 +1,38 @@
+/* PR tree-optimization/60960 */
+
+typedef unsigned char v4qi __attribute__ ((vector_size (4)));
+
+__attribute__((noinline, noclone)) v4qi
+f1 (v4qi v)
+{
+  return v / 2;
+}
+
+__attribute__((noinline, noclone)) v4qi
+f2 (v4qi v)
+{
+  return v / (v4qi) { 2, 2, 2, 2 };
+}
+
+__attribute__((noinline, noclone)) v4qi
+f3 (v4qi x, v4qi y)
+{
+  return x / y;
+}
+
+int
+main ()
+{
+  v4qi x = { 5, 5, 5, 5 };
+  v4qi y = { 2, 2, 2, 2 };
+  v4qi z = f1 (x);
+  if (__builtin_memcmp (y, z, sizeof (y)) != 0)
+__builtin_abort ();
+  z = f2 (x);
+  if (__builtin_memcmp (y, z, sizeof (y)) != 0)
+__builtin_abort ();
+  z = f3 (x, y);
+  if (__builtin_memcmp (y, z, sizeof (y)) != 0)
+__builtin_abort ();
+  return 0;
+}

   Jakub




Re: [patch] Shorten Windows path

2014-04-25 Thread Ian Lance Taylor
On Fri, Apr 25, 2014 at 3:16 AM, Joey Ye joey...@arm.com wrote:
 Ping

To be clear, I am not a libcpp maintainer and I don't plan to approve
this patch.  This should be reviewed by a libcpp maintainer or a C or
C++ frontend maintainer.

Ian


 -Original Message-
 From: Joey Ye [mailto:joey...@arm.com]
 Sent: Tuesday, April 01, 2014 6:18 PM
 To: 'Ian Lance Taylor'
 Cc: gcc-patches
 Subject: RE: [patch] Shorten Windows path

 Ian, thanks for your comments. Please find answers and new version below:

  -Original Message-
  From: Ian Lance Taylor [mailto:i...@google.com]
  Sent: 25 March 2014 21:09
  To: Joey Ye
  Cc: gcc-patches
  Subject: Re: [patch] Shorten Windows path
 
  On Tue, Mar 25, 2014 at 1:58 AM, Joey Ye joey...@arm.com wrote:
   Ping
 
  This code looks different on mainline.
 
  Writing if ( do_canonical ) is not GCC style.
 Fixed
 
  This patch does not respect the configure option --disable-canonical-
 system-
  headers.
 Solved by put is under the control of default
 ENABLE_CANONICAL_SYSTEM_HEADERS
 
  Also I personally don't actually know what the consequences would be.
  Are there any downsides to canonicalizing header names?
 Since 4.8 system headers are by default canonicalized. This version only
 additionally canonical non-system headers. I can't think of any downsides.

 
  Ian

 ChangeLog.libcpp:

 * files.c (find_file_in_dir): Always try to shorten for DOS non-system
 headers.
 * init.c (ENABLE_CANONICAL_SYSTEM_HEADERS): Default enabled for DOS.

 diff --git a/libcpp/files.c b/libcpp/files.c
 index 7e88778..ad68682 100644
 --- a/libcpp/files.c
 +++ b/libcpp/files.c
 @@ -387,8 +387,14 @@ find_file_in_dir (cpp_reader *pfile, _cpp_file *file,
 bool *invalid_pch)
char *copy;
void **pp;

 -  /* We try to canonicalize system headers.  */
 -  if (CPP_OPTION (pfile, canonical_system_headers)  file-dir-sysp)
 +  /* We try to canonicalize system headers.  For DOS based file
 +   * system, we always try to shorten non-system headers, as DOS
 +   * has a tighter constraint on max path length.  */
 +  if (CPP_OPTION (pfile, canonical_system_headers)  file-dir-sysp
 +#ifdef HAVE_DOS_BASED_FILE_SYSTEM
 +   || !file-dir-sysp
 +#endif
 +  )
   {
 char * canonical_path = maybe_shorter_path (path);
 if (canonical_path)
 diff --git a/libcpp/init.c b/libcpp/init.c
 index f10413a..b809515 100644
 --- a/libcpp/init.c
 +++ b/libcpp/init.c
 @@ -27,8 +27,12 @@ along with this program; see the file COPYING3.  If not
 see
  #include filenames.h

  #ifndef ENABLE_CANONICAL_SYSTEM_HEADERS
 +#ifdef HAVE_DOS_BASED_FILE_SYSTEM
 +#define ENABLE_CANONICAL_SYSTEM_HEADERS 1
 +#else
  #define ENABLE_CANONICAL_SYSTEM_HEADERS 0
  #endif
 +#endif

  static void init_library (void);
  static void mark_named_operators (cpp_reader *, int);




[wide-int 5/5] Add dump () method for gdb debugging

2014-04-25 Thread Richard Sandiford
This patch adds a dump () method so that it's easier to read the
contents of the various wide-int types in gdb.  I've deliberately not
done any extension for small_prec cases because I think here
we want to see the raw values as much as possible.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


Index: gcc/wide-int.cc
===
--- gcc/wide-int.cc 2014-04-25 14:48:03.263213403 +0100
+++ gcc/wide-int.cc 2014-04-25 14:48:25.186333842 +0100
@@ -2130,3 +2130,9 @@ wi::only_sign_bit_p (const wide_int_ref
 void gt_ggc_mx (widest_int *) { }
 void gt_pch_nx (widest_int *, void (*) (void *, void *), void *) { }
 void gt_pch_nx (widest_int *) { }
+
+template void wide_int::dump () const;
+template void generic_wide_int wide_int_ref_storage false ::dump () const;
+template void generic_wide_int wide_int_ref_storage true ::dump () const;
+template void offset_int::dump () const;
+template void widest_int::dump () const;
Index: gcc/wide-int.h
===
--- gcc/wide-int.h  2014-04-25 14:34:54.823652619 +0100
+++ gcc/wide-int.h  2014-04-25 14:48:06.218229309 +0100
@@ -709,6 +709,9 @@ #define INCDEC_OPERATOR(OP, DELTA) \
 #undef ASSIGNMENT_OPERATOR
 #undef INCDEC_OPERATOR
 
+  /* Debugging functions.  */
+  void dump () const;
+
   static const bool is_sign_extended
 = wi::int_traits generic_wide_int storage ::is_sign_extended;
 };
@@ -859,6 +862,23 @@ generic_wide_int storage::operator = (
   return *this;
 }
 
+/* Dump the contents of the integer to stderr, for debugging.  */
+template typename storage
+void
+generic_wide_int storage::dump () const
+{
+  unsigned int len = this-get_len ();
+  const HOST_WIDE_INT *val = this-get_val ();
+  unsigned int precision = this-get_precision ();
+  fprintf (stderr, [);
+  if (len * HOST_BITS_PER_WIDE_INT  precision)
+fprintf (stderr, ...,);
+  for (unsigned int i = 0; i  len - 1; ++i)
+fprintf (stderr, HOST_WIDE_INT_PRINT_HEX ,, val[len - 1 - i]);
+  fprintf (stderr, HOST_WIDE_INT_PRINT_HEX ], precision = %d\n,
+  val[0], precision);
+}
+
 namespace wi
 {
   template 


Re: [wide-int 1/5] Cosmetic fixes to wide-int.{cc,h}

2014-04-25 Thread Kenneth Zadeck

i see nothing in this patch that requires a review.
On 04/25/2014 09:35 AM, Richard Sandiford wrote:

This series of patches is from a read-through of wide-int.h and wide-int.cc.
(The series from earlier in the week was from a diff of preexisting files.)

This first patch fixes some comments, typos and formatting.  It also
removes some dead code.  I'll follow up with a gdb-friendly replacement
for the old dump function.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


Index: gcc/wide-int.cc
===
--- gcc/wide-int.cc 2014-04-25 11:33:57.809153807 +0100
+++ gcc/wide-int.cc 2014-04-25 12:33:59.202021025 +0100
@@ -37,12 +37,6 @@ typedef unsigned int UDItype __attribute
  #include longlong.h
  #endif
  
-/* This is the maximal size of the buffer needed for dump.  */

-const unsigned int MAX_SIZE = (4 * (MAX_BITSIZE_MODE_ANY_INT / 4
-   + (MAX_BITSIZE_MODE_ANY_INT
-  / HOST_BITS_PER_WIDE_INT)
-   + 32));
-
  static const HOST_WIDE_INT zeros[WIDE_INT_MAX_ELTS] = {};
  
  /*

@@ -51,7 +45,7 @@ static const HOST_WIDE_INT zeros[WIDE_IN
  
  /* Quantities to deal with values that hold half of a wide int.  Used

 in multiply and divide.  */
-#define HALF_INT_MASK (((HOST_WIDE_INT)1  HOST_BITS_PER_HALF_WIDE_INT) - 1)
+#define HALF_INT_MASK (((HOST_WIDE_INT) 1  HOST_BITS_PER_HALF_WIDE_INT) - 1)
  
  #define BLOCK_OF(TARGET) ((TARGET) / HOST_BITS_PER_WIDE_INT)

  #define BLOCKS_NEEDED(PREC) \
@@ -129,8 +123,8 @@ wi::from_array (HOST_WIDE_INT *val, cons
  
  /* Construct a wide int from a buffer of length LEN.  BUFFER will be

 read according to byte endianess and word endianess of the target.
-   Only the lower LEN bytes of the result are set; the remaining high
-   bytes are cleared.  */
+   Only the lower BUFFER_LEN bytes of the result are set; the remaining
+   high bytes are cleared.  */
  wide_int
  wi::from_buffer (const unsigned char *buffer, unsigned int buffer_len)
  {
@@ -212,7 +206,7 @@ wi::to_mpz (const wide_int_ref x, mpz_t
  mpz_import (result, len, -1, sizeof (HOST_WIDE_INT), 0, 0, v);
  }
  
-/* Returns VAL converted to TYPE.  If WRAP is true, then out-of-range

+/* Returns X converted to TYPE.  If WRAP is true, then out-of-range
 values of VAL will be wrapped; otherwise, they will be set to the
 appropriate minimum or maximum TYPE bound.  */
  wide_int
@@ -243,8 +237,8 @@ wi::from_mpz (const_tree type, mpz_t x,
   for representing the value.  The code to calculate count is
   extracted from the GMP manual, section Integer Import and Export:
   http://gmplib.org/manual/Integer-Import-and-Export.html  */
-  numb = 8*sizeof(HOST_WIDE_INT);
-  count = (mpz_sizeinbase (x, 2) + numb-1) / numb;
+  numb = 8 * sizeof(HOST_WIDE_INT);
+  count = (mpz_sizeinbase (x, 2) + numb - 1) / numb;
HOST_WIDE_INT *val = res.write_val ();
mpz_export (val, count, -1, sizeof (HOST_WIDE_INT), 0, 0, x);
if (count  1)
@@ -352,9 +346,8 @@ wi::force_to_size (HOST_WIDE_INT *val, c
 where we do allow comparisons of values of different precisions.  */
  static inline HOST_WIDE_INT
  selt (const HOST_WIDE_INT *a, unsigned int len,
- unsigned int blocks_needed,
- unsigned int small_prec,
- unsigned int index, signop sgn)
+  unsigned int blocks_needed, unsigned int small_prec,
+  unsigned int index, signop sgn)
  {
HOST_WIDE_INT val;
if (index  len)
@@ -388,7 +381,7 @@ top_bit_of (const HOST_WIDE_INT *a, unsi
  
  /*

   * Comparisons, note that only equality is an operator.  The other
- * comparisons cannot be operators since they are inherently singed or
+ * comparisons cannot be operators since they are inherently signed or
   * unsigned and C++ has no such operators.
   */
  
@@ -401,7 +394,7 @@ wi::eq_p_large (const HOST_WIDE_INT *op0

int l0 = op0len - 1;
unsigned int small_prec = prec  (HOST_BITS_PER_WIDE_INT - 1);
  
-  while (op0len != op1len)

+  if (op0len != op1len)
  return false;
  
if (op0len == BLOCKS_NEEDED (prec)  small_prec)

@@ -741,7 +734,7 @@ wi::mask (HOST_WIDE_INT *val, unsigned i
unsigned int shift = width  (HOST_BITS_PER_WIDE_INT - 1);
if (shift != 0)
  {
-  HOST_WIDE_INT last = (((unsigned HOST_WIDE_INT) 1)  shift) - 1;
+  HOST_WIDE_INT last = ((unsigned HOST_WIDE_INT) 1  shift) - 1;
val[i++] = negate ? ~last : last;
  }
else
@@ -774,12 +767,12 @@ wi::shifted_mask (HOST_WIDE_INT *val, un
unsigned int shift = start  (HOST_BITS_PER_WIDE_INT - 1);
if (shift)
  {
-  HOST_WIDE_INT block = (((unsigned HOST_WIDE_INT) 1)  shift) - 1;
+  HOST_WIDE_INT block = ((unsigned HOST_WIDE_INT) 1  shift) - 1;
shift = end  (HOST_BITS_PER_WIDE_INT - 1);
if (shift)
{
  /* case 000111000 */
- block = (((unsigned HOST_WIDE_INT) 1)  shift) - block - 1;
+ block = 

Re: [PATCH] Fix PR60930

2014-04-25 Thread Bill Schmidt
On Fri, 2014-04-25 at 10:59 +0200, Richard Biener wrote:
 On Fri, 25 Apr 2014, Jakub Jelinek wrote:
 
  On Thu, Apr 24, 2014 at 09:20:50PM -0600, Jeff Law wrote:
PR tree-optimization/60930
* gcc.dg/torture/pr60930.c:  New test.
   Doesn't the test depend on long long being at least 64 bits?
  
  But that is guaranteed by C99, isn't it?
 
 But the testcase isn't built with -std=c99.
 
  5.2.4.2.1 says:
  
  ... Their implementation-defined values shall be equal or greater in 
  magnitude
  (absolute value) to those shown, with the same sign.
  ...
  - maximum value for an object of type unsigned long long int ULLONG_MAX
18446744073709551615 // 2 64 − 1
   
   What we've done for these kinds of tests in the past is:
   
   if (sizeof (whatever)  needed size)
 exit (0);
   
   Another approach would be to use an effective target test and skip
   the test if the target doesn't have a suitable long long.  Look  in
   testsuite/lib/target-supports.exp for the various target
  
  If it was some other type, sure, one could use int32plus, lp64, etc.
  target, or #if __SIZEOF_type__ == ...
 
 I suggest the latter (#if).
 
 Ok with that change.

OK, agreed.  I'll add the __SIZEOF_LONG_LONG__ check.

I'll give it a week before backporting to 4.8 and 4.9.

Thanks,
Bill
 
 Thanks,
 Richard.



[PING*2][C++ Patch, 4.8] Backport fix for c++/54537 to FSF 4.8

2014-04-25 Thread Peter Bergner
I'd like to ping*2 the following backport patch for the fix for PR54537.
This did bootstrap and regtest with no regressions on powerpc64-linux.

  http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01148.html

Jonathan approved the library part, so I just need the front-end
change approved.

Peter




[PATCH][ARM][committed] Fix bootstrap: Initialise fields in Cortex-A8 tuning struct

2014-04-25 Thread Kyrill Tkachov

Hi all,

As mentioned in http://gcc.gnu.org/ml/gcc/2014-04/msg00227.html we need to 
initialise the two fields recently added to the tuning structs for the recently 
added Cortex-A8 structs.


I've committed the attached patch as an obvious fix as r209806.

Tested and bootstrapped on arm-none-linux-gnueabihf.

Thanks,
Kyrill

2014-04-25  Kyrylo Tkachov  kyrylo.tkac...@arm.com

* config/arm/arm.c (arm_cortex_a8_tune): Initialise
T16-related fields.diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 240d9b9..3af46f4 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -1715,7 +1715,8 @@ const struct tune_params arm_cortex_a8_tune =
   false,	/* Prefer LDRD/STRD.  */
   {true, true},	/* Prefer non short circuit.  */
   arm_default_vec_cost,/* Vectorizer costs.  */
-  false /* Prefer Neon for 64-bits bitops.  */
+  false,/* Prefer Neon for 64-bits bitops.  */
+  false, false  /* Prefer 32-bit encodings.  */
 };
 
 const struct tune_params arm_cortex_a7_tune =

[PATCH] Typofixes and a trivial change

2014-04-25 Thread Patrick Palka
Hi,

This patch fixes a couple of typos in tree-vrp.c and one in
invoke.texi.  The patch also reorders the operands of an  condition in
infer_nonnull_range() under the assumption that operand_equal_p() is
much more costly than a simple TREE_TYPE() equality test.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.

Cheers,
Patrick

---
 gcc/doc/invoke.texi | 2 +-
 gcc/gimple.c| 4 ++--
 gcc/tree-vrp.c  | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 8004da8..d6580e4 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -4729,7 +4729,7 @@ Warn if a global function is defined without a previous 
declaration.
 Do so even if the definition itself provides a prototype.
 Use this option to detect global functions that are not declared in
 header files.  In C, no warnings are issued for functions with previous
-non-prototype declarations; use @option{-Wmissing-prototype} to detect
+non-prototype declarations; use @option{-Wmissing-prototypes} to detect
 missing prototypes.  In C++, no warnings are issued for function templates,
 or for inline functions, or for functions in anonymous namespaces.
 
diff --git a/gcc/gimple.c b/gcc/gimple.c
index 2a278e4..e60da00 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -2565,8 +2565,8 @@ infer_nonnull_range (gimple stmt, tree op, bool 
dereference, bool attribute)
{
  for (unsigned int i = 0; i  gimple_call_num_args (stmt); i++)
{
- if (operand_equal_p (op, gimple_call_arg (stmt, i), 0)
-  POINTER_TYPE_P (TREE_TYPE (gimple_call_arg (stmt, i
+ if (POINTER_TYPE_P (TREE_TYPE (gimple_call_arg (stmt, i)))
+  operand_equal_p (op, gimple_call_arg (stmt, i), 0))
return true;
}
  return false;
diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c
index 8a31e59..94d7419 100644
--- a/gcc/tree-vrp.c
+++ b/gcc/tree-vrp.c
@@ -4478,7 +4478,7 @@ debug_all_value_ranges (void)
 
 /* Given a COND_EXPR COND of the form 'V OP W', and an SSA name V,
create a new SSA name N and return the assertion assignment
-   'V = ASSERT_EXPR V, V OP W'.  */
+   'N = ASSERT_EXPR V, V OP W'.  */
 
 static gimple
 build_assert_expr_for (tree cond, tree v)
@@ -6159,7 +6159,7 @@ process_assert_insertions (void)
 }
else
 {
-  y = ASSERT_EXPR y, x = y
+  y = ASSERT_EXPR y, x = y
   x = y + 3
 }
 
-- 
1.9.2



[Patch, PR 60158] Generate .fixup sections for .data.rel.ro.local entries.

2014-04-25 Thread rohitarul...@freescale.com
Hello All,

This is related to the following bug:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60158

Test case: Refer below
Target: e500v2
Command line options: -Os -fdata-sections -fpic -mrelocatable -mno-spe
Notes:
 GCC v4.7.3 puts the address of abc into the GOT directly
 GCC v4.8.2 is generating a pointer to the string and putting the 
address of that in the GOT.  But it doesn't generate the required .fixup 
table entries.


asm code generated:

...
.section.data.rel.ro.local,aw,@progbits
.align 2
.LC5:
.4byte  .LC0

...
.section.rodata.str1.4,aMS,@progbits,1
.align 2
.LC0:
.string abc
.LC1:
.string def

..
1) Compared to GCC v4.7.3, with GCC v4.8 series, there is a new flag 
'-fira-hoist-pressure' which is enabled by default at -Os.
Disabling this optimization '-fno-ira-hoist-pressure' generates similar 
code as in GCC v4.7.3

2) The actual issue is that with GCC v4.8.2, the move instruction of that 
string constant .LC0 is getting spilled. The reload pass, for any constants 
that aren't allowed and can't be reloaded in to registers tries to change them 
into memory references. Then while emitting that string constant to asm code 
(A:varasm.c: output_constant_pool_1), it explicitly passes the alignment as 1 
which prevents the generation of fix-up table entries in  'B: 
rs6000.c:rs6000_assemble_integer' because the data is considered unaligned now.

Source file: gcc-4.8.2/gcc/varasm.c
@@ -7120,7 +7120,7 @@
   if (CONSTANT_POOL_ADDRESS_P (symbol))
{
  desc = SYMBOL_REF_CONSTANT (symbol);
  output_constant_pool_1 (desc, 1); 
- (A)
  offset += GET_MODE_SIZE (desc-mode);
}
   else if (TREE_CONSTANT_POOL_ADDRESS_P (symbol))

Source file: gcc-4.8.2/gcc/config/rs6000.c
static bool
rs6000_assemble_integer (rtx x, unsigned int size, int aligned_p)
{
#ifdef RELOCATABLE_NEEDS_FIXUP
  /* Special handling for SI values.  */
  if (RELOCATABLE_NEEDS_FIXUP  size == 4  aligned_p)
--- (B)
{


Ideally, passing proper alignment to (A) should have worked. But if we pass the 
proper alignment to (A) output_constant_pool_1, .align directive gets emitted 
twice. Is that the actual purpose of explicitly passing '1' as alignment to 
output_constant_pool_1?
- output_constant_pool_1 (desc, 1);
+output_constant_pool_1 (desc, desc-align);


Generated asm with this change:
.section.data.rel.ro.local,aw,@progbits  
.align 2  
.align 2  
.LC5:  
.LCP0:
.long   (.LC0)@fixup  

Adding a similar change to its helper function output_constant_pool_2 does 
generate the expected code.

[gcc]
2014-04-22  Rohit  rohitarul...@freescale.com

PR target/60158
* varasm.c (output_constant_pool_1): Pass actual alignment value to 
output_constant_pool_2
  to emit .fixup section.

[gcc/testsuite]
2014-04-22  Rohit  rohitarul...@freescale.com

PR target/60158
* gcc.target/powerpc/pr60158.c: New test.  Check if .fixup section gets 
emitted for
 .data.rel.ro.local section.


Index: gcc/varasm.c
===
--- gcc/varasm.c(revision 209534)
+++ gcc/varasm.c(working copy)
@@ -3771,7 +3771,7 @@ output_constant_pool_1 (struct constant_
   targetm.asm_out.internal_label (asm_out_file, LC, desc-labelno);

   /* Output the data.  */
-  output_constant_pool_2 (desc-mode, x, align);
+  output_constant_pool_2 (desc-mode, x, desc-align);

   /* Make sure all constants in SECTION_MERGE and not SECTION_STRINGS
  sections have proper size.  */
Index: gcc/testsuite/gcc.target/powerpc/pr60158.c
===
--- gcc/testsuite/gcc.target/powerpc/pr60158.c  (revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr60158.c  (revision 0)
@@ -0,0 +1,91 @@
+/* { dg-do compile } */
+/* { dg-skip-if not an SPE target { ! powerpc_spe_nocache } { * } {  } } 
*/
+/* { dg-options -mcpu=8548 -mno-spe -mfloat-gprs=double -Os -fdata-sections 
-fpic -mrelocatable } */
+
+#define NULL 0
+int func (int val);
+void *func2 (void *ptr);
+
+static const char *ifs;
+static char map[256];
+
+typedef struct {
+/*
+ * None of these fields are used, but removing any
+ * of them makes the problem go away.
+ */
+  char *data;
+  int length;
+  int maxlen;
+  int quote;
+} o_string;
+
+#define NULL_O_STRING {NULL,0,0,0}
+
+static int parse_stream (void *dest, void *ctx)
+{
+  int ch = func (0), m;
+
+  while (ch != -1) {
+m = map[ch];
+if (ch != '\n')
+func2(dest);
+
+ctx = func2 (ctx);
+if (!func (0))
+  return 0;
+if (m != ch) {
+  func2 (htns);
+   

Re: [PATCH] Typofixes and a trivial change

2014-04-25 Thread Patrick Palka
I forgot the ChangeLog entry:

2014-04-25  Patrick Palka  patr...@parcs.ath.cx

* doc/invoke.texi: Fix typo.
* tree-vrp.c: Fix typos.
* gimple.c (infer_nonnull_range): Reorder operands of an 
condition.


[PATCH] Make ipa-prop analyze BBs in DOM order

2014-04-25 Thread Martin Jambor
Hi,

the following patch deals with requested propagation in PR 53787 in
the real benchmark (as opposed to the original simple testcase) by
analyzing individual BBs in ipa-prop.c in dominator order.

Currently we do the analysis in two loops, in the first the order is
given by FOR_EACH_BB_FN and in the second the order is the order of
call graph edges (which in practice is quite bad because we tend to
start with BBs towards the end).  When analysis determines that a
non-SSA parameter or that data pointed to by a parameter are modified,
this is marked into a function wide flag (describing the parameter)
and we always consider the data clobbered from that moment on in order
to save AA walking.

This patch changes the analysis into dominator order and data is
considered clobbered only in dominator children of a block where it
was determined to be possibly clobbered, not in the whole function.
This was confirmed to help in the aforementioned PR.

The patch also, enforces a cap on the number of statements walked
(approx. 4 times the highest I have ever seen).  On the other hand it
gives up trying to cache the bitmap of visited memory-SSAs.  The
per-BB information had to be put somewhere and I took this opportunity
to cram a lot of commonly used per-function data into the same
structure, which is then passed among various functions.  The new
structure replaces the struct param_analysis_info.

Bootstrapped and tested on x86_64-linux, I have also LTO-built Firefox
at -O3 with it.  OK for trunk?

Thanks,

Martin


2014-02-12  Martin Jambor  mjam...@suse.cz

PR tree-optimization/53787
* params.def (PARAM_IPA_CP_LOOP_HINT_BONUS): New param.
* ipa-prop.h (ipa_node_params): Rename uses_analysis_done to
analysis_done, update all uses.
* ipa-prop.c: Include domwalk.h
(param_analysis_info): Removed.
(param_aa_status): New type.
(ipa_bb_info): Likewise.
(func_body_info): Likewise.
(ipa_get_bb_info): New function.
(aa_overwalked): Likewise.
(find_dominating_aa_status): Likewise.
(parm_bb_aa_status_for_bb): Likewise.
(parm_preserved_before_stmt_p): Changed to use new param AA info.
(load_from_unmodified_param): Accept func_body_info as a parameter
instead of parms_ainfo.
(parm_ref_data_preserved_p): Changed to use new param AA info.
(parm_ref_data_pass_through_p): Likewise.
(ipa_load_from_parm_agg_1): Likewise.  Update callers.
(compute_complex_assign_jump_func): Changed to use new param AA info.
(compute_complex_ancestor_jump_func): Likewise.
(ipa_compute_jump_functions_for_edge): Likewise.
(ipa_compute_jump_functions): Removed.
(ipa_compute_jump_functions_for_bb): New function.
(ipa_analyze_indirect_call_uses): Likewise, moved variable
declarations down.
(ipa_analyze_virtual_call_uses): Accept func_body_info instead of node
and info, moved variable declarations down.
(ipa_analyze_call_uses): Accept and pass on func_body_info instead of
node and info.
(ipa_analyze_stmt_uses): Likewise.
(ipa_analyze_params_uses): Removed.
(ipa_analyze_params_uses_in_bb): New function.
(ipa_analyze_controlled_uses): Likewise.
(free_ipa_bb_info): Likewise.
(analysis_dom_walker): New class.
(ipa_analyze_node): Handle node-specific forbidden analysis,
initialize and free func_body_info, use dominator walker.
(ipcp_modif_dom_walker): New class.
(ipcp_transform_function): Create and free func_body_info, use
ipcp_modif_dom_walker, moved a lot of functionality there.

Index: src/gcc/ipa-prop.c
===
*** src.orig/gcc/ipa-prop.c
--- src/gcc/ipa-prop.c
*** along with GCC; see the file COPYING3.
*** 59,72 
  #include ipa-utils.h
  #include stringpool.h
  #include tree-ssanames.h
  
! /* Intermediate information about a parameter that is only useful during the
!run of ipa_analyze_node and is not kept afterwards.  */
  
! struct param_analysis_info
  {
bool parm_modified, ref_modified, pt_modified;
!   bitmap parm_visited_statements, pt_visited_statements;
  };
  
  /* Vector where the parameter infos are actually stored. */
--- 59,111 
  #include ipa-utils.h
  #include stringpool.h
  #include tree-ssanames.h
+ #include domwalk.h
  
! /* Intermediate information that we get from AA analysis about a parameter.  
*/
  
! struct param_aa_status
  {
+   /* If not true, look at the dominator parent instead.  */
+   bool valid;
+ 
+   /* Whether we have seen something which might have modified the data in
+  question.  Parm is for the parameter itself, ref is for data it points to
+  but using the alias type of individual accesses and pt is the same thing
+  but for computing aggregate pass-through functions using a very inclusive
+  

Re: [PATCH, ARM] Fix PR60609 (Error: value of 256 too large for field of 1 bytes)

2014-04-25 Thread Charles Baylis
This doesn't seem to have shown problems on trunk/4.9.

I have bootstrapped and checked the patch on 4.8
arm-unknown-linux-gnueabihf (Thumb-2) on qemu.

I have checked the patch on 4.7 arm-unknown-linux-gnueabihf (Thumb-2) on qemu.

OK to backport to 4.8 and 4.7?

On 7 April 2014 16:02, Charles Baylis charles.bay...@linaro.org wrote:
 On 4 April 2014 15:50, Ramana Radhakrishnan ramana@googlemail.com wrote:
 Additionally the testing has only considered Thumb2 - since we also do
 jumptable shortening for Thumb1 and given this late change it's worth
 also testing this on Thumb1 and making sure there are no regressions.
 Maybe Joey can help there if you aren't set up to do this.

 Ok if no regressions and modulo RM objections.

 I have tested v5t Thumb-1 with no regressions on qemu.

 One minor Changelog nit.

 2014-04-02  Charles Baylis  charles.bay...@linaro.org

 PR target/60609
 * config/arm/arm.h (ASM_OUTPUT_CASE_END) Remove.
 (LABEL_ALIGN_AFTER_BARRIER) Align barriers which occur after
 ADDR_DIFF_VEC.

 s/)/):/g above.

 Noted.


Re: [PATCH, ARM] Fix PR60609 (Error: value of 256 too large for field of 1 bytes)

2014-04-25 Thread Ramana Radhakrishnan
On Fri, Apr 25, 2014 at 4:29 PM, Charles Baylis
charles.bay...@linaro.org wrote:
 This doesn't seem to have shown problems on trunk/4.9.

 I have bootstrapped and checked the patch on 4.8
 arm-unknown-linux-gnueabihf (Thumb-2) on qemu.

 I have checked the patch on 4.7 arm-unknown-linux-gnueabihf (Thumb-2) on qemu.

 OK to backport to 4.8 and 4.7?

Ok by me but give 24 working hours for an RM to object.

Ramana


 On 7 April 2014 16:02, Charles Baylis charles.bay...@linaro.org wrote:
 On 4 April 2014 15:50, Ramana Radhakrishnan ramana@googlemail.com 
 wrote:
 Additionally the testing has only considered Thumb2 - since we also do
 jumptable shortening for Thumb1 and given this late change it's worth
 also testing this on Thumb1 and making sure there are no regressions.
 Maybe Joey can help there if you aren't set up to do this.

 Ok if no regressions and modulo RM objections.

 I have tested v5t Thumb-1 with no regressions on qemu.

 One minor Changelog nit.

 2014-04-02  Charles Baylis  charles.bay...@linaro.org

 PR target/60609
 * config/arm/arm.h (ASM_OUTPUT_CASE_END) Remove.
 (LABEL_ALIGN_AFTER_BARRIER) Align barriers which occur after
 ADDR_DIFF_VEC.

 s/)/):/g above.

 Noted.


[PATCH] Optionally trap on impossible devirtualization

2014-04-25 Thread Martin Jambor
Hi,

the patch below might be useful for testcase preparation and debugging
compiler bugs such as PR 60965.  When
-ftrap-on-impossible-devirtualization is supplied on the command line,
it makes the devirtualization produce __builtin_trap instead of
__builtin_unreachable when it comes to the conclusion that there is no
legal target of a virtual call.

Apart from dealing with our bugs, it may be even useful to debug
compiled programs when a user triggers some sort of illegal
devirtualization, typically by missing a type check somewhere.
Currently the compiled program might simply take a wrong branch, with
the patch it will abort.

Bootstrapped and tested (with the option on) on x86_64-linux, I have
also successfully LTO built Firefox with it.  If I add some
documentation, would like to see this in trunk?

Thanks,

Martin


2014-04-03  Martin Jambor  mjam...@suse.cz

* cgraph.c (verify_edge_corresponds_to_fndecl): Also always accept
builtin_trap.
* cgraphclones.c (cgraph_clone_node): Do not redirect calls to
builtin_trap.
* cgraphunit.c (walk_polymorphic_call_targets): Use
ipa_impossible_devirt_target_node.
* common.opt (ftrap-on-impossible-devirtualization): New option.
* gimple-fold.c (fold_gimple_assign): Use
ipa_impossible_devirt_target_decl.
(gimple_fold_call): Likewise.
(gimple_get_virt_method_for_vtable): Likewise.
* ipa-cp.c (ipa_get_indirect_edge_target_1): Check also for
builtin_trap, use ipa_impossible_devirt_target_decl.
* ipa-devirt.c (ipa_impossible_devirt_target_decl): New function.
(ipa_impossible_devirt_target_node): Likewise.
* ipa-prop.c (ipa_make_edge_direct_to_target): Use
ipa_impossible_devirt_target_decl.
(try_make_edge_direct_virtual_call): Check also for builtin_trap, use
ipa_impossible_devirt_target_decl.
* ipa-utils.h (ipa_impossible_devirt_target_decl): Declare.
(ipa_impossible_devirt_target_node): Likewise.
* ipa.c (walk_polymorphic_call_targets): Use
ipa_impossible_devirt_target_node.


diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index be3661a..25e0775 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -2664,9 +2664,10 @@ verify_edge_corresponds_to_fndecl (struct cgraph_edge 
*e, tree decl)
 return false;
 
   /* Optimizers can redirect unreachable calls or calls triggering undefined
- behaviour to builtin_unreachable.  */
+ behaviour to builtin_unreachable or builtin_trap.  */
   if (DECL_BUILT_IN_CLASS (e-callee-decl) == BUILT_IN_NORMAL
-   DECL_FUNCTION_CODE (e-callee-decl) == BUILT_IN_UNREACHABLE)
+   (DECL_FUNCTION_CODE (e-callee-decl) == BUILT_IN_UNREACHABLE
+ || DECL_FUNCTION_CODE (e-callee-decl) == BUILT_IN_TRAP))
 return false;
   node = cgraph_function_or_thunk_node (node, NULL);
 
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index cd2d73d..e7bebe3 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -449,8 +449,9 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, 
gcov_type count, int freq,
 be unreachable during the clonning procedure.  */
   if (!e-callee
  || DECL_BUILT_IN_CLASS (e-callee-decl) != BUILT_IN_NORMAL
- || DECL_FUNCTION_CODE (e-callee-decl) != BUILT_IN_UNREACHABLE)
-redirect_edge_duplicating_thunks (e, new_node, args_to_skip);
+ || (DECL_FUNCTION_CODE (e-callee-decl) != BUILT_IN_UNREACHABLE
+  DECL_FUNCTION_CODE (e-callee-decl) != BUILT_IN_TRAP))
+cgraph_redirect_edge_callee (e, new_node);
 }
 
 
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 06283fc..6c56c90 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -892,8 +892,7 @@ walk_polymorphic_call_targets (pointer_set_t 
*reachable_call_targets,
  if (targets.length () == 1)
target = targets[0];
  else
-   target = cgraph_get_create_node
-  (builtin_decl_implicit (BUILT_IN_UNREACHABLE));
+   target = ipa_impossible_devirt_target_node ();
 
  if (cgraph_dump_file)
{
diff --git a/gcc/common.opt b/gcc/common.opt
index da275e5..3e8b359 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1019,6 +1019,10 @@ fdevirtualize
 Common Report Var(flag_devirtualize) Optimization
 Try to convert virtual calls to direct ones.
 
+ftrap-on-impossible-devirtualization
+Common Report Var(flag_trap_impossible_devirt)
+Convert virtual calls that cannot have any target to builtin_trap.
+
 fdiagnostics-show-location=
 Common Joined RejectNegative Enum(diagnostic_prefixing_rule)
 -fdiagnostics-show-location=[once|every-line]  How often to emit source 
location at the beginning of line-wrapped diagnostics
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 6402cce..e0dfcb9 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -392,7 +392,7 @@ fold_gimple_assign (gimple_stmt_iterator *si)
if (targets.length () == 

[C PATCH] Better column info for initializers (PR c/60139)

2014-04-25 Thread Marek Polacek
Another minor fix: use loc instead of input_location.  Also add
missing OPT_Wpedantic. 

After this is in, my plan is to make pedwarn_init and error_init
static (I already have a patch for that) and then add location
argument to error_init and pass proper location to it, and to
pedwarn_init as well -- that should greatly improve initializer
warnings/errors.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2014-04-25  Marek Polacek  pola...@redhat.com

PR c/60139
* c-typeck.c (output_init_element): Pass OPT_Wpedantic to pedwarn
and pedwarn_init.  Use loc insted of input_location.

* gcc.dg/pr60139.c: New test.

diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index 62c72df..a82801f 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -8255,12 +8255,12 @@ output_init_element (location_t loc, tree value, tree 
origtype,
  value = error_mark_node;
}
   else if (require_constant_elements)
-   pedwarn (input_location, 0,
+   pedwarn (loc, OPT_Wpedantic,
 initializer element is not computable at load time);
 }
   else if (!maybe_const
(require_constant_value || require_constant_elements))
-pedwarn_init (input_location, 0,
+pedwarn_init (loc, OPT_Wpedantic,
  initializer element is not a constant expression);
 
   /* Issue -Wc++-compat warnings about initializing a bitfield with
diff --git gcc/testsuite/gcc.dg/pr60139.c gcc/testsuite/gcc.dg/pr60139.c
index e69de29..a63d8b5 100644
--- gcc/testsuite/gcc.dg/pr60139.c
+++ gcc/testsuite/gcc.dg/pr60139.c
@@ -0,0 +1,14 @@
+/* PR c/60139 */
+/* { dg-do compile } */
+/* { dg-options -Wpedantic } */
+/* { dg-prune-output .*near initialization for.* } */
+
+double sin (double);
+void
+fn (int *p)
+{
+  int **a[] = { p, /* { dg-warning 17:initializer element is not computable 
at load time } */
+   (void *) 0, p }; /* { dg-warning 28:initializer element is 
not computable at load time } */
+  double d[] = { sin (1.0), /* { dg-warning 18:initializer element is not a 
constant expression } */
+ 8.8, sin (1.0), 2.6 }; /* { dg-warning 23:initializer 
element is not a constant expression } */
+}

Marek


Re: [DOC PATCH] Rewrite docs for inline asm

2014-04-25 Thread Andrew Haley
On 04/25/2014 04:43 PM, James Greenhalgh wrote:
 Beyond comments on ChangeLog formatting, the review for this patch seems
 to have stalled again.
 
 The patch has been in review for two months now, with broadly positive 
 comments
 and all suggestions made thus far have been incorporated. I'd therefore like
 to
 
 *ping*
 
 this on David's behalf and try to get the review moving again.

We're waiting for Joseph Myers or, at a pinch, a maintainer with global
write privs.

Andrew.




ALL_COMPILERFLAGS used instead of ALL_LINKERFLAGS in gcc/Makefile.in

2014-04-25 Thread Antonio Diaz Diaz

Hello.

I think ALL_COMPILERFLAGS is incorrectly used instead of ALL_LINKERFLAGS 
in line 1909 of gcc/Makefile.in[1].


[1]http://gcc.gnu.org/viewcvs/gcc/trunk/gcc/Makefile.in?view=markup#l1909

I attach a trivial patch.


Best regards,
Antonio.
--- Makefile.in~2014-04-25 17:40:32.0 +0200
+++ Makefile.in 2014-04-25 17:43:56.0 +0200
@@ -1906,7 +1906,7 @@
@TARGET_SYSTEM_ROOT_DEFINE@
 
 lto-wrapper$(exeext): lto-wrapper.o ggc-none.o libcommon-target.a $(LIBDEPS)
-   +$(LINKER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o T$@ \
+   +$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o T$@ \
lto-wrapper.o ggc-none.o libcommon-target.a $(LIBS)
mv -f T$@ $@
 


[C PATCH] Some c-typeck.c TLC

2014-04-25 Thread Marek Polacek
error_init and pedwarn_init aren't used outside of c-typeck.c, thus
can be made static.  (maybe_warn_string_init is used in the parser.)
As they're small, I suspect they will be inlined now.
I had to move the functions a little bit above so we don't need a
prototypes for them.

Bootstrapped on x86_64-linux, ok for trunk?

2014-04-25  Marek Polacek  pola...@redhat.com

* c-tree.h (error_init): Remove declaration.
(pedwarn_init): Likewise.
* c-typeck.c (error_init): Make static and move above.
(pedwarn_init): Likewise.
(warning_init): Move above.
(maybe_warn_string_init): Likewise.

diff --git gcc/c/c-tree.h gcc/c/c-tree.h
index 53768d6..a6e7327 100644
--- gcc/c/c-tree.h
+++ gcc/c/c-tree.h
@@ -602,8 +602,6 @@ extern tree build_compound_expr (location_t, tree, tree);
 extern tree c_cast_expr (location_t, struct c_type_name *, tree);
 extern tree build_c_cast (location_t, tree, tree);
 extern void store_init_value (location_t, tree, tree, tree);
-extern void error_init (const char *);
-extern void pedwarn_init (location_t, int opt, const char *);
 extern void maybe_warn_string_init (tree, struct c_expr);
 extern void start_init (tree, tree, int);
 extern void finish_init (void);
diff --git gcc/c/c-typeck.c gcc/c/c-typeck.c
index a82801f..cbe9798 100644
--- gcc/c/c-typeck.c
+++ gcc/c/c-typeck.c
@@ -5540,6 +5540,72 @@ convert_to_anonymous_field (location_t location, tree 
type, tree rhs)
   return ret;
 }
 
+/* Issue an error message for a bad initializer component.
+   GMSGID identifies the message.
+   The component name is taken from the spelling stack.  */
+
+static void
+error_init (const char *gmsgid)
+{
+  char *ofwhat;
+
+  /* The gmsgid may be a format string with % and %. */
+  error (gmsgid);
+  ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
+  if (*ofwhat)
+error ((near initialization for %qs), ofwhat);
+}
+
+/* Issue a pedantic warning for a bad initializer component.  OPT is
+   the option OPT_* (from options.h) controlling this warning or 0 if
+   it is unconditionally given.  GMSGID identifies the message.  The
+   component name is taken from the spelling stack.  */
+
+static void
+pedwarn_init (location_t location, int opt, const char *gmsgid)
+{
+  char *ofwhat;
+
+  /* The gmsgid may be a format string with % and %. */
+  pedwarn (location, opt, gmsgid);
+  ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
+  if (*ofwhat)
+pedwarn (location, opt, (near initialization for %qs), ofwhat);
+}
+
+/* Issue a warning for a bad initializer component.
+
+   OPT is the OPT_W* value corresponding to the warning option that
+   controls this warning.  GMSGID identifies the message.  The
+   component name is taken from the spelling stack.  */
+
+static void
+warning_init (int opt, const char *gmsgid)
+{
+  char *ofwhat;
+
+  /* The gmsgid may be a format string with % and %. */
+  warning (opt, gmsgid);
+  ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
+  if (*ofwhat)
+warning (opt, (near initialization for %qs), ofwhat);
+}
+
+/* If TYPE is an array type and EXPR is a parenthesized string
+   constant, warn if pedantic that EXPR is being used to initialize an
+   object of type TYPE.  */
+
+void
+maybe_warn_string_init (tree type, struct c_expr expr)
+{
+  if (pedantic
+   TREE_CODE (type) == ARRAY_TYPE
+   TREE_CODE (expr.value) == STRING_CST
+   expr.original_code != STRING_CST)
+pedwarn_init (input_location, OPT_Wpedantic,
+ array initialized from parenthesized string constant);
+}
+
 /* Convert value RHS to type TYPE as preparation for an assignment to
an lvalue of type TYPE.  If ORIGTYPE is not NULL_TREE, it is the
original type of RHS; this differs from TREE_TYPE (RHS) for enum
@@ -6405,72 +6471,6 @@ print_spelling (char *buffer)
   return buffer;
 }
 
-/* Issue an error message for a bad initializer component.
-   GMSGID identifies the message.
-   The component name is taken from the spelling stack.  */
-
-void
-error_init (const char *gmsgid)
-{
-  char *ofwhat;
-
-  /* The gmsgid may be a format string with % and %. */
-  error (gmsgid);
-  ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
-  if (*ofwhat)
-error ((near initialization for %qs), ofwhat);
-}
-
-/* Issue a pedantic warning for a bad initializer component.  OPT is
-   the option OPT_* (from options.h) controlling this warning or 0 if
-   it is unconditionally given.  GMSGID identifies the message.  The
-   component name is taken from the spelling stack.  */
-
-void
-pedwarn_init (location_t location, int opt, const char *gmsgid)
-{
-  char *ofwhat;
-
-  /* The gmsgid may be a format string with % and %. */
-  pedwarn (location, opt, gmsgid);
-  ofwhat = print_spelling ((char *) alloca (spelling_length () + 1));
-  if (*ofwhat)
-pedwarn (location, opt, (near initialization for %qs), ofwhat);
-}
-
-/* Issue a warning for a bad initializer 

[patch] libstdc++/60958 disable invalid code in tr1/regex

2014-04-25 Thread Jonathan Wakely
 (match_operand:SI 1 register_operand r)
-		 (match_operand:SI 2 arith_operand rI]
-  TARGET_ARCH64
-{
-  if (GET_CODE (operands[2]) == CONST_INT)
-operands[2] = GEN_INT (INTVAL (operands[2])  0x1f);
-  return sll\t%1, %2, %0;
-}
-  [(set_attr type shift)])
-
 (define_expand ashldi3
   [(set (match_operand:DI 0 register_operand =r)
 	(ashift:DI (match_operand:DI 1 register_operand r)
diff --git a/gcc/testsuite/gcc.c-torture/execute/20140425-1.c b/gcc/testsuite/gcc.c-torture/execute/20140425-1.c
new file mode 100644
index 000..c447ef9
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20140425-1.c
@@ -0,0 +1,23 @@
+/* PR target/60941 */
+/* Reported by Martin Husemann mar...@netbsd.org */
+
+extern void abort (void);
+
+static void __attribute__((noinline))
+set (unsigned long *l)
+{
+  *l = 31;
+}
+
+int main (void)
+{
+  unsigned long l;
+  int i;
+
+  set (l);
+  i = (int) l;
+  l = (unsigned long)(2U  i);
+  if (l != 0)
+abort ();
+  return 0;
+}


Re: [PATCH] Add a couple of dialect and warning options regarding Objective-C instance variable scope

2014-04-25 Thread Dimitris Papavasiliou

On 04/25/2014 04:07 AM, Mike Stump wrote:

On Apr 24, 2014, at 4:09 PM, Dimitris Papavasilioudpapa...@gmail.com  wrote:

On 04/24/2014 07:00 PM, Mike Stump wrote:

On Feb 6, 2014, at 1:25 AM, Dimitris Papavasilioudpapa...@gmail.com  wrote:

This is a patch regarding a couple of Objective-C related dialect options and 
warning switches.


Ok.

Committed revision 209753.

If you could, please add documentation and a test case.


Thanks for taking the time to look at this, although to be honest I didn't 
expect a straight merge into the trunk.


Don’t submit changes you don’t want!  :-)


I'll add documentation and test cases as soon as I figure out how.


Just copy testsuite/objc.dg/private-2.m into shadow-1.m and then `fix’ it to 
test what you want.  If you need one with and one without a flag, copy it twice 
and use something like:

// { dg-options -Wshadow }

on it.  Type make RUNTESTFLAGS=dg.exp=shadow-1.m check-objc to test it.

For the doc, just find a simple option in the part of the manual you want to 
put it in, and copy it.  We document the non-default, (Wno-shadow-ivar for 
example) options.


I'm attaching three additional patches:

documentation.patch:  This adds documentation for the three additional 
switches plus a small change to reflect the fact that -Wshadow now 
controls instance variable shadowing as well.


tests.patch:  This adds 9 test cases that test both the intended 
behavior of the added switches as well as the default behavior in their 
absence.


enabledby_wshadow.patch:  This adds the proposed change to allow 
specifying -Wno-shadow to turn off -Wshadow-ivar as well plus one more 
test to make sure that it happens.


I've run make check-objc with all these changes and everything seems to 
be fine.  Let me know if you need anything else and thanks again for 
your time.


Dimitris
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 209787)
+++ gcc/doc/invoke.texi	(working copy)
@@ -216,6 +216,8 @@
 -fobjc-gc @gol
 -fobjc-nilcheck @gol
 -fobjc-std=objc1 @gol
+-fno-local-ivars @gol
+-fivar-visibility=@var{public|protected|private|package} @gol
 -freplace-objc-classes @gol
 -fzero-link @gol
 -gen-decls @gol
@@ -261,7 +263,7 @@
 -Wparentheses  -Wpedantic-ms-format -Wno-pedantic-ms-format @gol
 -Wpointer-arith  -Wno-pointer-to-int-cast @gol
 -Wredundant-decls  -Wno-return-local-addr @gol
--Wreturn-type  -Wsequence-point  -Wshadow @gol
+-Wreturn-type  -Wsequence-point  -Wshadow  -Wshadow-ivar @gol
 -Wsign-compare  -Wsign-conversion -Wfloat-conversion @gol
 -Wsizeof-pointer-memaccess @gol
 -Wstack-protector -Wstack-usage=@var{len} -Wstrict-aliasing @gol
@@ -2975,6 +2977,21 @@
 The GNU runtime currently always retains calls to @code{objc_get_class(@dots{})}
 regardless of command-line options.
 
+@item -fno-local-ivars
+@opindex fno-local-ivars
+By default instance variables in Objective-C can be accessed as if
+they were local variables from within the methods of the class they're
+declared in.  This can lead to shadowing between instance variables
+and other variables declared either locally inside a class method or
+globally with the same name.  Specifying the @option{-fno-local-ivars}
+flag disables this behavior thus avoiding variable shadowing issues.
+
+@item -fivar-visibility=@var{public|protected|private|package}
+@opindex fivar-visibility
+Set the default instance variable visibility to the specified option
+so that instance variables declared outside the scope of any access
+modifier directives default to the specified visibility.
+
 @item -gen-decls
 @opindex gen-decls
 Dump interface declarations for all classes seen in the source file to a
@@ -4349,11 +4366,18 @@
 @item -Wshadow
 @opindex Wshadow
 @opindex Wno-shadow
-Warn whenever a local variable or type declaration shadows another variable,
-parameter, type, or class member (in C++), or whenever a built-in function
-is shadowed. Note that in C++, the compiler warns if a local variable
-shadows an explicit typedef, but not if it shadows a struct/class/enum.
+Warn whenever a local variable or type declaration shadows another
+variable, parameter, type, class member (in C++), or instance variable
+(in Objective-C) or whenever a built-in function is shadowed. Note
+that in C++, the compiler warns if a local variable shadows an
+explicit typedef, but not if it shadows a struct/class/enum.
 
+@item -Wshadow-ivar @r{(Objective-C only)}
+@opindex Wshadow-ivar
+@opindex Wno-shadow-ivar
+Warn whenever a local variable shadows an instance variable in an
+Objective-C method.
+
 @item -Wlarger-than=@var{len}
 @opindex Wlarger-than=@var{len}
 @opindex Wlarger-than-@var{len}
Index: gcc/testsuite/objc.dg/shadow-2.m
===
--- gcc/testsuite/objc.dg/shadow-2.m	(revision 0)
+++ gcc/testsuite/objc.dg/shadow-2.m	(revision 0)
@@ -0,0 +1,33 @@
+/* Test disabling of warnings for shadowing instance 

Re: [PATCH] Add a couple of dialect and warning options regarding Objective-C instance variable scope

2014-04-25 Thread Mike Stump
On Apr 25, 2014, at 9:34 AM, Dimitris Papavasiliou dpapa...@gmail.com wrote:

 --Wreturn-type  -Wsequence-point  -Wshadow @gol
 +-Wreturn-type  -Wsequence-point  -Wshadow  -Wshadow-ivar @gol

This has to be -Wno-shadow-ivar, we document the non-default…

 +@item -Wshadow-ivar @r{(Objective-C only)}

Likewise.

 +  /* Check wheter the local variable hides the instance variable. */

spelling, whether...

 +  a = private;/* { dg-warning hides instance variable  { xfail *-*-* 
 } } */
 +  a = protected;  /* { dg-warning hides instance variable  { xfail *-*-* 
 } } */
 +  a = public; /* { dg-warning hides instance variable  { xfail *-*-* 
 } } */

No, we don’t expect failures.  We makes the compiler do what we wants or it 
gets the hose again.  Then, we expect it to be perfect.  If you won’t want 
warning, and non are produces, then just remove the /* … */, or write /* no 
warning */.

Also, synth up the ChnageLogs… :-), they are trivial enough.

And, just pop them all into one patch (cd ..; svn diff), 3 is 3x the work for 
me.

Once we resolve the 3 warning tests above, this will be ok.



Re: [PATCH 2/2] Windows libcpp: Make path-exists semantics more Posix-like

2014-04-25 Thread Pedro Alves
On 04/19/2014 09:41 PM, Kai Tietz wrote:

 Isn't this function something better placed in libiberty?  Also this name 
 looks a bit confusing.  Wouldn't be a an function calling for _WIN32 case 
 also stat, and just overrides the st_mode member, if it is a link better.  So 
 I would put this function to the file_... API of libiberty.

I'd even suspect that e.g., GNU Make / Makefiles would be likewise affected
by this.  A solution for this in gcc, or in a few selected programs
only, looks brittle to me.  Perhaps it should be mingw itself that provides
a _non-default_ replacement as option (similarly to __mingw_printf).

Can't glibc be changed to not rely on this?  /me hides.

-- 
Pedro Alves



Re: [ada, build] Ignore cp -p failures during Ada make install

2014-04-25 Thread Mike Stump
On Apr 25, 2014, at 6:41 AM, Rainer Orth r...@cebitec.uni-bielefeld.de wrote:
 When trying to install a freshly built gcc 4.9.0 on Solaris 9 and 10, I
 ran into make install failures when using INSTALL_DATA_DATE:

Ick, I hate this patch.  You kill error checking for all, on something that is 
important, just because someone didn’t use a proper install script.  The proper 
install script would use enough options to tell it to copy all but not the 
things it cannot…  For example, if you actively strip acts from the source and 
then copy, it should not fail.  If it does, then it sounds like a bug in cp.

Re: [ada, build] Ignore cp -p failures during Ada make install

2014-04-25 Thread Rainer Orth
Mike Stump mikest...@comcast.net writes:

 On Apr 25, 2014, at 6:41 AM, Rainer Orth r...@cebitec.uni-bielefeld.de 
 wrote:
 When trying to install a freshly built gcc 4.9.0 on Solaris 9 and 10, I
 ran into make install failures when using INSTALL_DATA_DATE:

 Ick, I hate this patch.  You kill error checking for all, on something
 that is important, just because someone didn’t use a proper install
 script.  The proper install script would use enough options to tell it
 to copy all but not the things it cannot… For example, if you actively
 strip acts from the source and then copy, it should not fail.  If it
 does, then it sounds like a bug in cp.

Agreed that this is ugly: ACL support in GNU coreutils has long been a
total mess; no idea if it has improved very recently.

OTOH, error handling for INSTALL_DATA_DATE is already inconsistent: one
instance ignores errors, two others don't, with no apparent reason for
the difference.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH 2/2] Windows libcpp: Make path-exists semantics more Posix-like

2014-04-25 Thread Pedro Alves
On 04/19/2014 08:40 PM, Ray Donnelly wrote:
 Windows does a short-circuit lookup of paths containing
 ../ which means that:
 
 exists/doesnotexist/../file
 
 is considered to exist, while on Posix it is considered
 not to. The Posix semantics are relied upon when building
 glibc so any paths containing ../ are checked component
 wise.

This looks like to me the sort of thing that potentially can
break Windows build systems that might rely on the Windows
semantics.

If one's running a native Windows program (such as a native
Windows GCC build), I'd expect that native Windows semantics are
followed (lest we end up reinventing Cygwin within GCC).
At least by default.  IMHO.

On 04/19/2014 08:40 PM, Ray Donnelly wrote:
...
 + Only do these slow checks if ../ appears in file-path.
 + Cygwin also suffers from the same problem (but doesn't need
 + a new stat function):
 + http://cygwin.com/ml/cygwin/2013-05/msg00222.html

That looks like a bug in Cygwin itself, and thus not appropriate to
fix or reference here.

 +  */
 +  if (file-fd  0)
 +{

-- 
Pedro Alves



Re: [ada, build] Ignore cp -p failures during Ada make install

2014-04-25 Thread Mike Stump
On Apr 25, 2014, at 10:01 AM, Rainer Orth r...@cebitec.uni-bielefeld.de wrote:
 Agreed that this is ugly: ACL support in GNU coreutils has long been a
 total mess; no idea if it has improved very recently.

So, are there ACLs on these files?  If so, why?  If no ACLs, I fail to see how 
anything can error out no matter how poorly written it is.

What about cp a b  touch -r a b?  Seems safer, seem portable enough.

Re: [ada, build] Ignore cp -p failures during Ada make install

2014-04-25 Thread Rainer Orth
Mike Stump mikest...@comcast.net writes:

 On Apr 25, 2014, at 10:01 AM, Rainer Orth r...@cebitec.uni-bielefeld.de 
 wrote:
 Agreed that this is ugly: ACL support in GNU coreutils has long been a
 total mess; no idea if it has improved very recently.

 So, are there ACLs on these files?  If so, why?  If no ACLs, I fail to see 
 how anything can error out no matter how poorly written it is.

In the ZFS case, there's nothing but ACLs: Unix permissions are just
translated/mapped from them.  Copying ACLs between file systems with
different ACL systems (like POSIX vs. NFSv4) is approximate at best.

 What about cp a b  touch -r a b?  Seems safer, seem portable enough.

I don't see why this shouldn't work.  The Autoconf manual suggests there
are some problems (timestamp resolution) with touch -r, but cp -p is the
same, and no hint that touch -r might not be portable.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] Fix PR60911

2014-04-25 Thread Jan Hubicka
 On Thu, 24 Apr 2014, Jan Hubicka wrote:
 
   
   Simple IPA passes are supposed to see function bodies with IPA transforms 
   applied - this is what the code in execute_one_pass tries to ensure.
   But that doesn't work anymore with on-demand function-body loading.
   The following addresses this in the least intrusive way - inlining
   do_per_function (apply_ipa_transforms) and adjusting it accordingly.
   
   This IMHO is definitely the solution for the 4.9 branch (and for
   the time being on trunk).
   
   Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
   
   Ok for trunk and branch?
  
  I think it is fine for both 4.9 and mainline. I will try to make better 
  version
  for mainline as explained in PR hortly.
  
  Can you, please, double check that it won't load all bodies prior late 
  optimization by default? Looking at gate of pass_omp_simd_clone, perhaps 
 
 Well, first of all it will only load bodies with IPA transforms to apply
 (yeah, that includes inlining, right?).  Then it's only executed if
 a small IPA pass actually executes, but ...

All functions have transforms to apply. They are added to all bodies of
functions that are around when pass is run. Not only to those pass wants to do
something. This is how first cut got implemented in 2004 and it is still the
same. We may want to change this, since the per-function transform lists tends
to be memory consuming these days. The reason why the lists are per-function
was that I expected IPA passes to introduce new functions in the middle of
optimization processing (it now happens for sample with ctor merging) and those
sould not be processed by transforms of IPA passes that never see them.
 
  it actually kills late loading of bodies and perhaps we need to mark in 
  cgraph node whether the given node needs clonning and page the gate 
  return false if partition has no such unit? bool 
  pass_omp_simd_clone::gate (function *) {
return ((flag_openmp || flag_openmp_simd
 || flag_cilkplus
 || (in_lto_p  !flag_wpa))
 (targetm.simd_clone.compute_vecsize_and_simdlen != NULL));
  }
  
  I did not see there the in_lto_p previously.
 
 ... this is IIRC because you can't rely on -fopenmp/-fopenmp-simd/-fcilk+
 to be present on the LTO commandline.

Yep, together with your change it will kill lazy loading, because the pass is
practicaly unconditoinal with LTO and all functions will have transforms on 
them.
Adding simple flag if function needs openmp_simd processing would solve it.

Honza
 
 Richard.
 
  Honza
   
   Thanks,
   Richard.
   
   2014-04-24  Richard Biener  rguent...@suse.de
   
 PR ipa/60911
 * passes.c (apply_ipa_transforms): Inline into only caller ...
 (execute_one_pass): ... here.  Properly bring in function
 bodies for nodes we want to apply IPA transforms to.
   
 * gcc.dg/lto/pr60911_0.c: New testcase.
   
   Index: gcc/passes.c
   ===
   --- gcc/passes.c  (revision 209742)
   +++ gcc/passes.c  (working copy)
   @@ -2109,20 +2109,6 @@ execute_all_ipa_transforms (void)
}
}

   -/* Callback for do_per_function to apply all IPA transforms.  */
   -
   -static void
   -apply_ipa_transforms (void *data)
   -{
   -  struct cgraph_node *node = cgraph_get_node (current_function_decl);
   -  if (!node-global.inlined_to  node-ipa_transforms_to_apply.exists 
   ())
   -{
   -  *(bool *)data = true;
   -  execute_all_ipa_transforms ();
   -  rebuild_cgraph_edges ();
   -}
   -}
   -
/* Check if PASS is explicitly disabled or enabled and return
   the gate status.  FUNC is the function to be processed, and
   GATE_STATUS is the gate status determined by pass manager by
   @@ -2194,8 +2180,26 @@ execute_one_pass (opt_pass *pass)
 Apply all trnasforms first.  */
  if (pass-type == SIMPLE_IPA_PASS)
{
   +  struct cgraph_node *node;
  bool applied = false;
   -  do_per_function (apply_ipa_transforms, (void *)applied);
   +  FOR_EACH_DEFINED_FUNCTION (node)
   + if (node-analyzed
   +  cgraph_function_with_gimple_body_p (node)
   +  (!node-clone_of || node-decl != node-clone_of-decl))
   +   {
   + if (!node-global.inlined_to
   +  node-ipa_transforms_to_apply.exists ())
   +   {
   + cgraph_get_body (node);
   + push_cfun (DECL_STRUCT_FUNCTION (node-decl));
   + execute_all_ipa_transforms ();
   + rebuild_cgraph_edges ();
   + free_dominance_info (CDI_DOMINATORS);
   + free_dominance_info (CDI_POST_DOMINATORS);
   + pop_cfun ();
   + applied = true;
   +   }
   +   }
  if (applied)
symtab_remove_unreachable_nodes (true, dump_file);
  /* Restore current_pass.  */
   Index: gcc/testsuite/gcc.dg/lto/pr60911_0.c
   ===
   --- 

Update doc/gimple.texi to reflect change from union to class hierarchy

2014-04-25 Thread David Malcolm
Commits r205034 (de6bd75e3c9bc1efe8a6387d48eedaa4dafe622d) and r205428
(a90353203da18288cdac1b0b78fe7b22c69fe63f) eliminated the union
gimple_statement_d in favor of a C++ class hierarchy.

I forgot to update gimple.texi in those commits (sorry), which the
following patch belatedly addresses.  It removes an incorrect reference
to the union, replacing it with a diagram showing the C++ inheritance
hierarchy of gimple statement types, and how they relate to GSS_ and
GIMPLE_ values.

As noted in the Compile-time gimple-checking thread, I do want to make
changes to this hierarchy.  This unrelated patch simply updates the docs
to reflect the status quo in trunk (and 4.9).

I used @smallexample for the ASCII art.

Successfully generates HTML, info and pdf via appropriate make
invocations; example of resulting HTML can be seen at the bottom of:

http://dmalcolm.fedorapeople.org/gcc/2014-04-25/Tuple-representation.html

The diagram is split over pages 178-180 of the generated PDF:

http://dmalcolm.fedorapeople.org/gcc/2014-04-25/gccint.pdf

but I don't think there's a good way to avoid page breaks there.

Info page, fwiw:

http://dmalcolm.fedorapeople.org/gcc/2014-04-25/gccint.info

Bootstrap in progress [do pure doc fixes require a bootstrap?]

OK for trunk, assuming bootstraps? (and eventually for the 4.9 branch,
after a few days?)

Thanks
Dave

commit 792a8f512bf51b2210d5f418101d8611c74ecac4
Author: David Malcolm dmalc...@redhat.com
Date:   Fri Apr 25 12:40:36 2014 -0400

Add a class hierarchy diagram to gimple.texi

gcc/
	* doc/gimple.texi: Replace the description of the now-defunct
	union gimple_statement_d with a diagram showing the
	gimple_statement_base class hierarchy and its relationships to
	the GSS_ and GIMPLE_ enums.

diff --git a/gcc/doc/gimple.texi b/gcc/doc/gimple.texi
index 9bb16e8..9dc320c 100644
--- a/gcc/doc/gimple.texi
+++ b/gcc/doc/gimple.texi
@@ -287,35 +287,130 @@ reduce memory utilization further by removing these sets).
 @end itemize
 
 All the other tuples are defined in terms of these three basic
-ones. Each tuple will add some fields. The main gimple type
-is defined to be the union of all these structures (@code{GTY} markers
-elided for clarity):
+ones. Each tuple will add some fields.
+
+The following diagram shows the C++ inheritance hierarchy of statement
+kinds, along with their relationships to @code{GSS_} values (layouts) and
+@code{GIMPLE_} values (codes):
 
 @smallexample
-union gimple_statement_d
-@{
-  struct gimple_statement_base gsbase;
-  struct gimple_statement_with_ops gsops;
-  struct gimple_statement_with_memory_ops gsmem;
-  struct gimple_statement_omp omp;
-  struct gimple_statement_bind gimple_bind;
-  struct gimple_statement_catch gimple_catch;
-  struct gimple_statement_eh_filter gimple_eh_filter;
-  struct gimple_statement_phi gimple_phi;
-  struct gimple_statement_resx gimple_resx;
-  struct gimple_statement_try gimple_try;
-  struct gimple_statement_wce gimple_wce;
-  struct gimple_statement_asm gimple_asm;
-  struct gimple_statement_omp_critical gimple_omp_critical;
-  struct gimple_statement_omp_for gimple_omp_for;
-  struct gimple_statement_omp_parallel gimple_omp_parallel;
-  struct gimple_statement_omp_task gimple_omp_task;
-  struct gimple_statement_omp_sections gimple_omp_sections;
-  struct gimple_statement_omp_single gimple_omp_single;
-  struct gimple_statement_omp_continue gimple_omp_continue;
-  struct gimple_statement_omp_atomic_load gimple_omp_atomic_load;
-  struct gimple_statement_omp_atomic_store gimple_omp_atomic_store;
-@};
++- gimple_statement_base
+ |layout: GSS_BASE
+ |used for 4 codes: GIMPLE_ERROR_MARK
+ |  GIMPLE_NOP
+ |  GIMPLE_OMP_SECTIONS_SWITCH
+ |  GIMPLE_PREDICT
+ |
+ + gimple_statement_with_ops_base
+ |   |(no GSS layout)
+ |   |
+ |   + gimple_statement_with_ops
+ |   |layout: GSS_WITH_OPS
+ |   |Used for 5 codes: GIMPLE_COND
+ |   |  GIMPLE_DEBUG
+ |   |  GIMPLE_GOTO
+ |   |  GIMPLE_LABEL
+ |   |  GIMPLE_SWITCH
+ |   |
+ |   + gimple_statement_with_memory_ops_base
+ |   |layout: GSS_WITH_MEM_OPS_BASE
+ |   |
+ |   + gimple_statement_with_memory_ops
+ |   |layout: GSS_WITH_MEM_OPS.
+ |   |used for codes GIMPLE_ASSIGN and GIMPLE_RETURN.
+ |   |
+ |   + gimple_statement_call
+ |   |layout: GSS_CALL, code: GIMPLE_CALL
+ |   |
+ |   + gimple_statement_asm
+ |   |layout: GSS_ASM, code: GIMPLE_ASM
+ |   |
+ |   + gimple_statement_transaction
+ |layout: GSS_TRANSACTION, code: GIMPLE_TRANSACTION
+ |
+ + gimple_statement_omp
+ |   |layout: GSS_OMP.  Used for code GIMPLE_OMP_SECTION
+   

Re: Examples of gimple statement API (was Re: [PATCH 03/89] Introduce gimple_bind and use it for accessors.)

2014-04-25 Thread David Malcolm
On Fri, 2014-04-25 at 10:37 +0200, Richard Biener wrote:
 On Thu, Apr 24, 2014 at 4:59 PM, David Malcolm dmalc...@redhat.com wrote:
  On Thu, 2014-04-24 at 09:09 -0400, Andrew MacLeod wrote:
  On 04/24/2014 04:33 AM, Richard Biener wrote:
   On Wed, Apr 23, 2014 at 11:23 PM, Jeff Law l...@redhat.com wrote:
   On 04/23/14 15:13, David Malcolm wrote:
   On Wed, 2014-04-23 at 15:04 -0600, Jeff Law wrote:
   On 04/21/14 10:56, David Malcolm wrote:
   This updates all of the gimple_bind_* accessors in gimple.h from 
   taking
   a
   plain gimple to taking a gimple_bind (or const_gimple_bind), with the
   checking happening at the point of cast.
  
   Various other types are strengthened from gimple to gimple_bind, and
   from
   plain vecgimple to vecgimple_bind.
  
   [...]
  
   This is fine, with the same requested changes as #2; specifically 
   using
   an explicit cast rather than hiding the conversion in a method.  Once
   those changes are in place, it's good for 4.9.1.
   Thanks - presumably you mean
   good for *trunk* after 4.9.1 is released
   Right.  Sorry for the confusion.
   Note I still want that less-typedefs (esp. the const_*) variants to be 
   explored.
   Changing this will touch all the code again, so I'd like to avoid that.
  
   That is, shouldn't we go back to 'gimple' being 'gimple_statement_base'
   and not 'gimple_statement_base *'?  The main reason that we have so
   many typedefs is that in C you had to use 'struct foo' each time you
   refer to foo as a type - I suppose it was then convenient to do the
   typedef to the pointer type.  With 'gimple' being not a pointer type
   we get const correctness in the way people would expect it to work.
   [no, I don't suggest you change 'tree' or 'const_tree' at this point, 
   just
   gimple (and maybe gimple_seq) as you are working on the 'gimple'
   type anyway].
  
  
 
  So if we change 'gimple' everywhere to be 'gimple *', can we just
  abandon the 'gimple' typedef completely and go directly to using
  something like gimple_stmt, or some other agreeable name instead?
 
  I think its more descriptive and then frees up the generic 'gimple' name
  should we decide to do something more with namespaces in the future...
 
  There have been a few different proposals as to what the resulting
  gimple API might look like, in various subthreads of this discusssion,
  so I thought it might help the discussion to gather up the proposals,
  and to apply them to some specific code examples, to see what the
  results might look like.
 
  So here are a couple of code fragments, from gcc/graphite-sese-to-poly.c
  and gcc/tree-ssa-uninit.c respectively:
 
  Status quo
  ==
 
 static gimple
 detect_commutative_reduction (scop_p scop, gimple stmt, vecgimple *in,
   vecgimple *out)
 {
   if (scalar_close_phi_node_p (stmt))
 {
   gimple def, loop_phi, phi, close_phi = stmt;
   tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
 
   if (TREE_CODE (arg) != SSA_NAME)
 
 /* ...etc... */
 
 static unsigned int
 execute_late_warn_uninitialized (void)
 {
   basic_block bb;
   gimple_stmt_iterator gsi;
   vecgimple worklist = vNULL;
   pointer_set_t *added_to_worklist;
 
  The currently-posted patch series
  =
  Here's the cumulative effect of the patch series I posted, using the
  casting methods of the base class (the stmt-as_a_gimple_phi call):
 
-static gimple
+static gimple_phi
 detect_commutative_reduction (scop_p scop, gimple stmt, vecgimple *in,
  vecgimple *out)
 {
   if (scalar_close_phi_node_p (stmt))
 {
-  gimple def, loop_phi, phi, close_phi = stmt;
+  gimple def;
+  gimple_phi loop_phi, phi, close_phi = stmt-as_a_gimple_phi ();
   tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
 
   if (TREE_CODE (arg) != SSA_NAME)
 
 /* ...etc... */
 
 execute_late_warn_uninitialized (void)
 {
   basic_block bb;
-  gimple_stmt_iterator gsi;
-  vecgimple worklist = vNULL;
+  gimple_phi_iterator gsi;
+  vecgimple_phi worklist = vNULL;
   pointer_set_t *added_to_worklist;
 
  Direct use of is-a.h, retaining typedefs of pointers
  
  The following patch shows what the above might look like using the patch
  series as posted, but eliminating the casting methods  in favor of
  direct use of the is-a.h API (but still using lots of typedefs of
  pointers):
 
-static gimple
+static gimple_phi
 detect_commutative_reduction (scop_p scop, gimple stmt, vecgimple *in,
   vecgimple *out)
 {
   if (scalar_close_phi_node_p (stmt))
 {
-  gimple def, loop_phi, phi, close_phi = stmt;
-  tree init, lhs, arg = gimple_phi_arg_def (close_phi, 0);
+  

Re: [ada, build] Ignore cp -p failures during Ada make install

2014-04-25 Thread Mike Stump
On Apr 25, 2014, at 10:12 AM, Rainer Orth r...@cebitec.uni-bielefeld.de wrote:
 What about cp a b  touch -r a b?  Seems safer, seem portable enough.
 
 I don't see why this shouldn't work.

It won’t work on a machine from 1982…  Honest.  Life goes on, oh well…  cp a b 
 { touch -r a b || true; } is the portable version, if you want.  :-)

Re: [wide-int 3/5] Fix large widths in shifted_mask

2014-04-25 Thread Kenneth Zadeck

richard,

I think that this patch is fine as is.but in looking at the 
surrounding code, i saw something that appears to be somewhat troubling.


I am worried about the two asserts.   Given that we now require that 
some users write code similar to the code in tree-vrp.c:2628, it seems 
that these asserts are only latent land mines.


kenny
On 04/25/2014 09:40 AM, Richard Sandiford wrote:

Very minor, but since shifted_mask copes with out-of-range widths,
I think mask should too.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


Index: gcc/wide-int.cc
===
--- gcc/wide-int.cc 2014-04-25 09:26:57.025944460 +0100
+++ gcc/wide-int.cc 2014-04-25 09:37:16.873811137 +0100
@@ -716,7 +716,7 @@ wi::mask (HOST_WIDE_INT *val, unsigned i
gcc_assert (width  4 * MAX_BITSIZE_MODE_ANY_INT);
gcc_assert (prec = 4 * MAX_BITSIZE_MODE_ANY_INT);
  
-  if (width == prec)

+  if (width = prec)
  {
val[0] = negate ? 0 : -1;
return 1;




Re: [ada, build] Ignore cp -p failures during Ada make install

2014-04-25 Thread Arnaud Charlet
 It seems to me that (as already done in one of three cases in the
 install-gnatlib target) $(INSTALL_DATA_DATE) errors should be ignored,
 to allow for such a case.
 
 The following patch does just that and allowed the make install to
 complete.
 
 Ok for mainline?

No, it's not OK to ignore all such errors, and the permissions should
really be preserved, so such error really musn't be ignored.

Arno


Re: [libcpp] use CPP_PEDANTIC

2014-04-25 Thread Tom Tromey
 Prathamesh == Prathamesh Kulkarni bilbotheelffri...@gmail.com writes:

Prathamesh Use macro CPP_PEDANTIC (PF) instead of directly using
Prathamesh it's definition: CPP_OPTION (PF, cpp_pedantic).

I'm curious why you want this.

Prathamesh [libcpp]
Prathamesh * directives.c (_cpp_handle_directive): Use CPP_PEDANTIC macro.
Prathamesh * macro.c (parse_params): Likewise.

Prathamesh Bootstrapped on x86_64-unknown-linux-gnu.
Prathamesh OK for trunk ?

Regardless of why, it is ok.

If it is just for clarity, though, I suppose I wonder why CPP_PEDANTIC
and CPP_WTRADITIONAL are given special definitions.  Perhaps instead
they should be removed in favor of just CPP_OPTION everywhere.  Though
this also seems of marginal usefulness.

Tom


Re: [libcpp] use CPP_PEDANTIC

2014-04-25 Thread Prathamesh Kulkarni
On Fri, Apr 25, 2014 at 11:19 PM, Tom Tromey tro...@redhat.com wrote:
 Prathamesh == Prathamesh Kulkarni bilbotheelffri...@gmail.com writes:

 Prathamesh Use macro CPP_PEDANTIC (PF) instead of directly using
 Prathamesh it's definition: CPP_OPTION (PF, cpp_pedantic).

 I'm curious why you want this.
CPP_PEDANTIC is used everywhere else in libcpp, so I thought it would
be better to use CPP_PEDANTIC
in these cases for consistency.

 Prathamesh [libcpp]
 Prathamesh * directives.c (_cpp_handle_directive): Use CPP_PEDANTIC macro.
 Prathamesh * macro.c (parse_params): Likewise.

 Prathamesh Bootstrapped on x86_64-unknown-linux-gnu.
 Prathamesh OK for trunk ?

 Regardless of why, it is ok.

 If it is just for clarity, though, I suppose I wonder why CPP_PEDANTIC
 and CPP_WTRADITIONAL are given special definitions.  Perhaps instead
 they should be removed in favor of just CPP_OPTION everywhere.  Though
 this also seems of marginal usefulness.

 Tom


Re: [ada, build] Ignore cp -p failures during Ada make install

2014-04-25 Thread Rainer Orth
Arnaud Charlet char...@adacore.com writes:

 It seems to me that (as already done in one of three cases in the
 install-gnatlib target) $(INSTALL_DATA_DATE) errors should be ignored,
 to allow for such a case.
 
 The following patch does just that and allowed the make install to
 complete.
 
 Ok for mainline?

 No, it's not OK to ignore all such errors, and the permissions should
 really be preserved, so such error really musn't be ignored.

they are: this is a bug in (it seems) all recent version of coreutils
cp.  How about a version with cp and touch -r as Mike suggested instead?

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [ada, build] Ignore cp -p failures during Ada make install

2014-04-25 Thread Rainer Orth
Arnaud Charlet char...@adacore.com writes:

 It seems to me that (as already done in one of three cases in the
 install-gnatlib target) $(INSTALL_DATA_DATE) errors should be ignored,
 to allow for such a case.
 
 The following patch does just that and allowed the make install to
 complete.
 
 Ok for mainline?

 No, it's not OK to ignore all such errors, and the permissions should
 really be preserved, so such error really musn't be ignored.

Alternatively, one could use tar to do the copy, like gcc/Makefile.in
(install-headers-tar).  It will preserve timestamps, too, and is likely
to be way faster than hundreds of individual invocations of cp -p.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH 2/2] Windows libcpp: Make path-exists semantics more Posix-like

2014-04-25 Thread Kai Tietz
2014-04-25 18:53 GMT+02:00 Pedro Alves pal...@redhat.com:
 On 04/19/2014 09:41 PM, Kai Tietz wrote:

 Isn't this function something better placed in libiberty?  Also this name 
 looks a bit confusing.  Wouldn't be a an function calling for _WIN32 case 
 also stat, and just overrides the st_mode member, if it is a link better.  
 So I would put this function to the file_... API of libiberty.

 I'd even suspect that e.g., GNU Make / Makefiles would be likewise affected
 by this.  A solution for this in gcc, or in a few selected programs
 only, looks brittle to me.  Perhaps it should be mingw itself that provides
 a _non-default_ replacement as option (similarly to __mingw_printf).

Of course we could change default-behavior of stat-function within
mingw.  This would change documented and exprected behavior of
msvcrt's implementation.  And all this for an assumption made by some
ventures.
I think that libiberty is exactly present to unify functionality (and
API) for different operation systems.  Exactly for this libiberty was
made, isn't it?

I agree that there are other venture, which might be affected by same
problem.  So those venture could either use libiberty to solve this
problem too, or need to reimplement it as they do now.

 Can't glibc be changed to not rely on this?  /me hides.

 --
 Pedro Alves

Kai


Re: [PATCH 2/2] Windows libcpp: Make path-exists semantics more Posix-like

2014-04-25 Thread Pedro Alves
On 04/25/2014 08:05 PM, Kai Tietz wrote:
 2014-04-25 18:53 GMT+02:00 Pedro Alves pal...@redhat.com:
 On 04/19/2014 09:41 PM, Kai Tietz wrote:

 Isn't this function something better placed in libiberty?  Also this name 
 looks a bit confusing.  Wouldn't be a an function calling for _WIN32 case 
 also stat, and just overrides the st_mode member, if it is a link better.  
 So I would put this function to the file_... API of libiberty.

 I'd even suspect that e.g., GNU Make / Makefiles would be likewise affected
 by this.  A solution for this in gcc, or in a few selected programs
 only, looks brittle to me.  Perhaps it should be mingw itself that provides
 a _non-default_ replacement as option (similarly to __mingw_printf).
 
 Of course we could change default-behavior of stat-function within
 mingw.

Huh?  I said exactly the opposite.  To expose it as a __non-default__
replacement.  I pointed at __mingw_printf, so to suggest programs
would call it like __mingw_stat or something, or by defining
__USE_MINGW_POSIX_STAT or something, just like one can define
__USE_MINGW_ANSI_STDIO before including stdio.h.  I'll understand
if you wouldn't want to support that as an option, but I did _not_
suggest making it the default.

 This would change documented and exprected behavior of
 msvcrt's implementation.  And all this for an assumption made by some
 ventures.

some ventures here must be the whole toolchain.  Certainly the
whole toolchain needs to agree on path handling.  Makefiles were
an obvious example -- if the preprocessor needs needs to find the
right include files, so must Make need this to pick the right
dependencies, isn't it?

This sort of potencially-needing-to-be-fixed-in-many-places issue is
what makes me believe a much better solution would be to just not
rely on this semantics in the first place.

 I think that libiberty is exactly present to unify functionality (and
 API) for different operation systems.  Exactly for this libiberty was
 made, isn't it?

libiberty is actually a kitchen sink, and specific to gcc and src.
It does more than host abstraction.  Gnulib fills that role much better
nowdays.  I'd be nice if gcc used that instead for the host abstraction
parts (gdb does), but nobody's working on that afaik...

 I agree that there are other venture, which might be affected by same
 problem.  So those venture could either use libiberty to solve this
 problem too, or need to reimplement it as they do now.

And then we'll have reinvented Cygwin all over the map.  ;-)

 Can't glibc be changed to not rely on this?  /me hides.

-- 
Pedro Alves



Re: std::experimental::optional operator!=

2014-04-25 Thread Jonathan Wakely

On 30/03/14 12:54 +0200, Lars Gullik Bjønnes wrote:

When trying to convert some code using boost::optional to using
std::experimental::optional instead if come over the issue that I had to
implement operator!= for the contained types.

When looking at n3793 it states that operator!= should be implemented
with !(t1 == t2), and not t1 != t2 as the implementation in gcc 4.9 is
doing. This is the case for both the operator!= implementation where
optionalT is compared against T.

The other operators look ok, and only operator== and operator are used
in their implementations.

Can this be fixed before 4.9?


I've committed the patch from PR 60710 (attached) and will apply it to
the 4.9 branch too.

Tested x86_64-linux.

commit ca00614d7bca5305905073dd558c6efacfb029ad
Author: Jonathan Wakely jwak...@redhat.com
Date:   Fri Apr 25 20:16:05 2014 +0100

2014-04-25  Lars Gullik Bjønnes  lar...@gullik.org

	PR libstdc++/60710
	* include/experimental/optional (operator!=): Implement in terms of
	operator==.
	* testsuite/experimental/optional/relops/1.cc: Remove operator!=.
	* testsuite/experimental/optional/relops/2.cc: Likewise.
	* testsuite/experimental/optional/relops/3.cc: Likewise.
	* testsuite/experimental/optional/relops/4.cc: Likewise.
	* testsuite/experimental/optional/relops/5.cc: Likewise.
	* testsuite/experimental/optional/relops/6.cc: Likewise.

diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional
index 5f2d93f..2a3f29d 100644
--- a/libstdc++-v3/include/experimental/optional
+++ b/libstdc++-v3/include/experimental/optional
@@ -736,12 +736,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   templatetypename _Tp
 constexpr bool
 operator!=(const optional_Tp __lhs, _Tp const __rhs)
-{ return !__lhs || *__lhs != __rhs; }
+{ return !__lhs || !(*__lhs == __rhs); }
 
   templatetypename _Tp
 constexpr bool
 operator!=(const _Tp __lhs, const optional_Tp __rhs)
-{ return !__rhs || __lhs != *__rhs; }
+{ return !__rhs || !(__lhs == *__rhs); }
 
   templatetypename _Tp
 constexpr bool
diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/1.cc b/libstdc++-v3/testsuite/experimental/optional/relops/1.cc
index f140880..3f1ee9c 100644
--- a/libstdc++-v3/testsuite/experimental/optional/relops/1.cc
+++ b/libstdc++-v3/testsuite/experimental/optional/relops/1.cc
@@ -37,10 +37,6 @@ namespace ns
   { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
 
   bool
-  operator!=(value_type const lhs, value_type const rhs)
-  { return !(lhs == rhs); }
-
-  bool
   operator(value_type const lhs, value_type const rhs)
   { return std::tie(lhs.i, lhs.s)  std::tie(rhs.i, rhs.s); }
 
diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/2.cc b/libstdc++-v3/testsuite/experimental/optional/relops/2.cc
index c7fc848..6ee9cba 100644
--- a/libstdc++-v3/testsuite/experimental/optional/relops/2.cc
+++ b/libstdc++-v3/testsuite/experimental/optional/relops/2.cc
@@ -37,10 +37,6 @@ namespace ns
   { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
 
   bool
-  operator!=(value_type const lhs, value_type const rhs)
-  { return !(lhs == rhs); }
-
-  bool
   operator(value_type const lhs, value_type const rhs)
   { return std::tie(lhs.i, lhs.s)  std::tie(rhs.i, rhs.s); }
 
diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/3.cc b/libstdc++-v3/testsuite/experimental/optional/relops/3.cc
index 9729000..581d016 100644
--- a/libstdc++-v3/testsuite/experimental/optional/relops/3.cc
+++ b/libstdc++-v3/testsuite/experimental/optional/relops/3.cc
@@ -37,10 +37,6 @@ namespace ns
   { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
 
   bool
-  operator!=(value_type const lhs, value_type const rhs)
-  { return !(lhs == rhs); }
-
-  bool
   operator(value_type const lhs, value_type const rhs)
   { return std::tie(lhs.i, lhs.s)  std::tie(rhs.i, rhs.s); }
 
diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/4.cc b/libstdc++-v3/testsuite/experimental/optional/relops/4.cc
index 45378f6..ce16fcb 100644
--- a/libstdc++-v3/testsuite/experimental/optional/relops/4.cc
+++ b/libstdc++-v3/testsuite/experimental/optional/relops/4.cc
@@ -37,10 +37,6 @@ namespace ns
   { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
 
   bool
-  operator!=(value_type const lhs, value_type const rhs)
-  { return !(lhs == rhs); }
-
-  bool
   operator(value_type const lhs, value_type const rhs)
   { return std::tie(lhs.i, lhs.s)  std::tie(rhs.i, rhs.s); }
 
diff --git a/libstdc++-v3/testsuite/experimental/optional/relops/5.cc b/libstdc++-v3/testsuite/experimental/optional/relops/5.cc
index 008409e..c01bba5 100644
--- a/libstdc++-v3/testsuite/experimental/optional/relops/5.cc
+++ b/libstdc++-v3/testsuite/experimental/optional/relops/5.cc
@@ -37,10 +37,6 @@ namespace ns
   { return std::tie(lhs.i, lhs.s) == std::tie(rhs.i, rhs.s); }
 
   bool
-  operator!=(value_type const lhs, value_type 

[jit] Ensure dlerror failures lead to the overall compilation failing

2014-04-25 Thread David Malcolm
Committed to branch dmalcolm/jit:

gcc/jit/
* internal-api.c (gcc::jit::playback::context::compile): Put
any output of dlerror through the add_error method, rather
than merely printing it to stderr, so that the error is also
recorded on the context.
---
 gcc/jit/ChangeLog.jit  | 7 +++
 gcc/jit/internal-api.c | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/jit/ChangeLog.jit b/gcc/jit/ChangeLog.jit
index d4ed6cf..ccf8a10 100644
--- a/gcc/jit/ChangeLog.jit
+++ b/gcc/jit/ChangeLog.jit
@@ -1,3 +1,10 @@
+2014-04-25  David Malcolm  dmalc...@redhat.com
+
+   * internal-api.c (gcc::jit::playback::context::compile): Put
+   any output of dlerror through the add_error method, rather
+   than merely printing it to stderr, so that the error is also
+   recorded on the context.
+
 2014-03-19  Tom Tromey  tro...@redhat.com
 
* internal-api.c (compile): Use auto_timevar.
diff --git a/gcc/jit/internal-api.c b/gcc/jit/internal-api.c
index f9f4d8e..f45595e 100644
--- a/gcc/jit/internal-api.c
+++ b/gcc/jit/internal-api.c
@@ -3771,7 +3771,7 @@ compile ()
 
 handle = dlopen (m_path_so_file, RTLD_NOW | RTLD_LOCAL);
 if ((error = dlerror()) != NULL)  {
-  fprintf(stderr, %s\n, error);
+  add_error (NULL, %s, error);
 }
 if (handle)
   result_obj = new result (handle);
-- 
1.8.5.3



Re: [PATCH] Properly check for _Cilk_spawn in return stmt (PR c/60197)

2014-04-25 Thread Jeff Law

On 02/17/14 10:51, Iyer, Balaji V wrote:

I don't know Cilk stuff at all, but it seems that _Cilk_spawn is forbidden in a
return statement.  But then only checking TREE_CODE (retval) ==
CILK_SPAWN_STMT isn't sufficient, because CILK_SPAWN_STMT can be
wrapped e.g. in MINUS_EXPR, C_MAYBE_CONST_EXPR, EQ_EXPR, and a
bunch of others.  I used walk_tree for checking whether a return statement
contains any CILK_SPAWN_STMT.

Regtested/bootstrapped on x86_64-linux, ok for 5.0?



5.0? you mean 4.9 right?... since this is a minor bug-fix.
Fixes go onto the trunk with selected fixes being backported to the 4.9 
branch at the discretion of the release managers.


jeff




Re: [RFC] Remove PUSH_ARGS_REVERSED from the RTL expander.

2014-04-25 Thread Jeff Law

On 03/24/14 05:44, James Greenhalgh wrote:

Which is much neater.

It seems to me that this would probably be of benefit on all targets.

This would be an argument for setting PUSH_ARGS_REVERSED to 1 by default
for all targets. However, this would have a perceivable impact on argument
evaluation order (which is unspecified in C, but people have shown
sensitivity to it changing in the past and we suspect some people may
have built systems relying on the behviour... ho hum...).

However, now that all side effects are handled when we are in SSA
form, it should be possible to refactor calls.c and expr.c as if
PUSH_ARGS_REVERSED were always defined to 1, without changing the
argument evaluation order in gimplify.c.

In this way, we have the best of both worlds; we maintain argument
evaluation order and gain the optimizations given by removing
overlapping live ranges for parameters.

I've bootstrapped and regression tested this on x86, ARM and AArch64 - but
I am well aware these are fairly standard targets, do you have any
suggestions or comments on which targets this change will affect?

If not, is this OK for stage-1?

Thanks,
James

---
gcc/

2014-03-21  James Greenhalgh  james.greenha...@arm.com

* calls.c (initialize_argument_information): Always treat
PUSH_ARGS_REVERSED as 1, simplify code accordingly.
(expand_call): Likewise.
(emit_library_call_calue_1): Likewise.
* expr.c (PUSH_ARGS_REVERSED): Do not define.
(emit_push_insn): Always treat PUSH_ARGS_REVERSED as 1, simplify
code accordingly.

This is fine for the trunk at this point.

Sorry for the delay.

jeff




Re: [PATCH 2/2] Windows libcpp: Make path-exists semantics more Posix-like

2014-04-25 Thread Kai Tietz
2014-04-25 21:24 GMT+02:00 Pedro Alves pal...@redhat.com:
 On 04/25/2014 08:05 PM, Kai Tietz wrote:
 2014-04-25 18:53 GMT+02:00 Pedro Alves pal...@redhat.com:
 On 04/19/2014 09:41 PM, Kai Tietz wrote:

 Isn't this function something better placed in libiberty?  Also this name 
 looks a bit confusing.  Wouldn't be a an function calling for _WIN32 case 
 also stat, and just overrides the st_mode member, if it is a link better.  
 So I would put this function to the file_... API of libiberty.

 I'd even suspect that e.g., GNU Make / Makefiles would be likewise affected
 by this.  A solution for this in gcc, or in a few selected programs
 only, looks brittle to me.  Perhaps it should be mingw itself that provides
 a _non-default_ replacement as option (similarly to __mingw_printf).

 Of course we could change default-behavior of stat-function within
 mingw.

 Huh?  I said exactly the opposite.  To expose it as a __non-default__
 replacement.  I pointed at __mingw_printf, so to suggest programs
 would call it like __mingw_stat or something, or by defining
 __USE_MINGW_POSIX_STAT or something, just like one can define
 __USE_MINGW_ANSI_STDIO before including stdio.h.  I'll understand
 if you wouldn't want to support that as an option, but I did _not_
 suggest making it the default.

As none-default replacement it makes even less sense in mingw IMO.
the __mingw_printf (and related functions) are there for providing C99
functionality.  What standard shall __mingw_stat satisfy?

 I think that libiberty is exactly present to unify functionality (and
 API) for different operation systems.  Exactly for this libiberty was
 made, isn't it?

 libiberty is actually a kitchen sink, and specific to gcc and src.
Well it is shared with binutils.  And in the past gdb used it too (I
think it still does in some way, as not everything is in glib.  I
might be wrong about this).

 It does more than host abstraction.  Gnulib fills that role much better
 nowdays.  I'd be nice if gcc used that instead for the host abstraction
 parts (gdb does), but nobody's working on that afaik...

That's true for gdb.  I don't see that binutils or gcc use glib.  So I
can only talk in this thread about what gcc/binutils uses right now.
Actually I am not really interested in what kind of compatibility
library is used.
Nevertheless to hi-jack this thread to start a discussion about
preferring glib over other (already existing) library in gcc/binutils
isn't ok.  Please start for such a discussion a separate RFC-thread.

 I agree that there are other venture, which might be affected by same
 problem.  So those venture could either use libiberty to solve this
 problem too, or need to reimplement it as they do now.

 And then we'll have reinvented Cygwin all over the map.  ;-)

Huh?  mingw != cygwin.  and mingw's internal libraries aren't a
kitchen-sink too.

 Can't glibc be changed to not rely on this?  /me hides.

 --
 Pedro Alves

---
Kai Tietz


[Patch 1/3] Use manual regex algorithm switching

2014-04-25 Thread Tim Shen
We used _GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT to control which
algorithm we should use; so when compiling a regex, the number of
quantifiers(*, +, ?) will be counted and will be used for the
algorithm switching.

However, I do think give user the manual switch may make things
simpler: _GLIBCXX_REGEX_USE_THOMPSON_NFA. By default we'll use the DFS
executor, which Boost and libc++ have (only, I believe).

Users who know what they are doing and willing to pay for what they
get may switch to the Thompson NFA (we call it BFS approach) by
defining this macro.

A regex that contains back references will never be executed by a Thompson NFA.

The whole patch series are booted and tested, but this one is not
seperatly tested.

Thanks!


-- 
Regards,
Tim Shen
commit 7375e9662232054465ea5c606c88130e38296ff1
Author: tim timshe...@gmail.com
Date:   Fri Apr 25 01:49:31 2014 -0400

2014-04-25  Tim Shen  timshe...@gmail.com

* include/bits/regex.tcc (__regex_algo_impl): Remove
_GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT and use
_GLIBCXX_REGEX_USE_THOMPSON_NFA instead.
* include/bits/regex_automaton.h: Remove quantifier counting variable.
* include/bits/regex_automaton.tcc (_State_base::_M_dot):
Adjust debug NFA dump.

diff --git a/libstdc++-v3/include/bits/regex.tcc 
b/libstdc++-v3/include/bits/regex.tcc
index 5fa1f01..d4d16a6 100644
--- a/libstdc++-v3/include/bits/regex.tcc
+++ b/libstdc++-v3/include/bits/regex.tcc
@@ -28,12 +28,12 @@
  *  Do not attempt to use it directly. @headername{regex}
  */
 
-// See below __regex_algo_impl to get what this is talking about. The default
-// value 1 indicated a conservative optimization without giving up worst case
-// performance.
-#ifndef _GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT
-#define _GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT 1
-#endif
+// A non-standard switch to let the user pick the matching algorithm.
+// If _GLIBCXX_REGEX_USE_THOMPSON_NFA is defined, the thompson NFA
+// algorithm will be used. This algorithm is not by default, and cannot
+// be used if the regex contains back-references, but has better
+// (polynomial instead of exponential) worst case performace.
+// See __regex_algo_impl below.
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -68,7 +68,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   // This function decide which executor to use under given circumstances.
   // The _S_auto policy now is the following: if a NFA has no
-  // back-references and has more than _GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT
+  // back-references and has more than _GLIBCXX_REGEX_USE_THOMPSON_NFA
   // quantifiers (*, +, ?), the BFS executor will be used, other wise
   // DFS executor. This is because DFS executor has a exponential upper
   // bound, but better best-case performace. Meanwhile, BFS executor can
@@ -82,8 +82,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   bool __ret;
   if (!__re._M_automaton-_M_has_backref
   (__policy == _RegexExecutorPolicy::_S_alternate
- || __re._M_automaton-_M_quant_count
-_GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT))
+#ifdef _GLIBCXX_REGEX_USE_THOMPSON_NFA
+ || true
+#endif
+ ))
{
  _Executor_BiIter, _Alloc, _TraitsT, false
__executor(__s, __e, __m, __re, __flags);
diff --git a/libstdc++-v3/include/bits/regex_automaton.h 
b/libstdc++-v3/include/bits/regex_automaton.h
index a442cfe..64ecd6d 100644
--- a/libstdc++-v3/include/bits/regex_automaton.h
+++ b/libstdc++-v3/include/bits/regex_automaton.h
@@ -74,8 +74,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   size_t _M_backref_index;  // for _S_opcode_backref
   struct
   {
-   // for _S_opcode_alternative.
-   _StateIdT  _M_quant_index;
// for _S_opcode_alternative or _S_opcode_subexpr_lookahead
_StateIdT  _M_alt;
// for _S_opcode_word_boundary or _S_opcode_subexpr_lookahead or
@@ -120,7 +118,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 explicit
 _NFA_base(_FlagT __f)
 : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0),
-_M_quant_count(0), _M_has_backref(false)
+_M_has_backref(false)
 { }
 
 _NFA_base(_NFA_base) = default;
@@ -145,7 +143,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _FlagT_M_flags;
 _StateIdT _M_start_state;
 _SizeT_M_subexpr_count;
-_SizeT_M_quant_count;
 bool  _M_has_backref;
   };
 
@@ -175,7 +172,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_StateT __tmp(_S_opcode_alternative);
// It labels every quantifier to make greedy comparison easier in BFS
// approach.
-   __tmp._M_quant_index = this-_M_quant_count++;
__tmp._M_next = __next;
__tmp._M_alt = __alt;
__tmp._M_neg = __neg;
diff --git a/libstdc++-v3/include/bits/regex_automaton.tcc 
b/libstdc++-v3/include/bits/regex_automaton.tcc
index 1476ae2..38787fa 100644
--- 

[Patch 2/3] Make regex's infinite loop detection accurate

2014-04-25 Thread Tim Shen
regex_match(, regex((?:)*) will cause segfault because the
infinite loop detection (writeen by me) is stupid. :O

Instead of checking begins and ends, now the executor tracks repeating
count for every loop node (typically generated from the Kleene star
*).

It slows down the executor a bit (from 1.8s to 2.0s in my machine),
but it's about the correctness.

The whole patch series are booted and tested, but this one is not
separately tested.

Thanks!


-- 
Regards,
Tim Shen


[Patch 3/3] Separate `repeating` node from `alternative` node in regex

2014-04-25 Thread Tim Shen
Before this patch both alternative operator | and star operator *
generate _S_opcode_alternative node.

Now they generate _S_opcode_alternative and _S_opcode_repeat
respectively, because the alternative handing is simpler comparing to
the repeat node handling introduced by last patch.

The whole patch series are booted and tested, but this one is not
separately tested.

Thanks!


-- 
Regards,
Tim Shen


Re: [jit] Fix state issue in gcse.c

2014-04-25 Thread David Malcolm
On Sat, 2014-04-19 at 15:55 +0200, Steven Bosscher wrote:
 On Sat, Apr 19, 2014 at 3:24 PM, Steven Bosscher wrote:
  On Tue, Mar 11, 2014 at 8:00 PM, David Malcolm wrote:
  Investigation revealed the issue to be a CFG from the previous compile
  being kept alive by this GC root in gcse.c:
static GTY(()) rtx test_insn;
 
  This wouldn't it itself be an issue, but one (or more) of the edges had:
 
  But this is an issue! This is not supposed to be possible.
 
  test_insn is not in the insns chain and also not in a basic block, so
  it should never keep a CFG alive.
 
  Your patch papers over a bigger issue: How does test_insn end up
  preventing the CFG from being garbage-collected.
 
 
 The only way this could happen, that I can think of, is a reference
 from SET_SRC into the insn stream (like a label_ref).
 
 Can you please try and see if the patch below fixes your problem?

Thanks; your patch does indeed fix the issue: with it, I no longer need
the band-aid from my patch to be able to run the jit testsuite with full
optimization.

 
 Ciao!
 Steven
 
 
 
 * gcse.c (can_assign_to_reg_without_clobbers_p): Do not let pointers
 from test_insn into GGC space escape via SET_SRC.
 
 Index: gcse.c
 ===
 --- gcse.c  (revision 209530)
 +++ gcse.c  (working copy)
 @@ -849,6 +849,7 @@ can_assign_to_reg_without_clobbers_p (rtx x)
  {
int num_clobbers = 0;
int icode;
 +  bool can_assign = false;
 
/* If this is a valid operand, we are OK.  If it's VOIDmode, we aren't.  */
if (general_operand (x, GET_MODE (x)))
 @@ -866,6 +867,7 @@ can_assign_to_reg_without_clobbers_p (rtx x)
FIRST_PSEUDO_REGISTER * 2),
   const0_rtx));
NEXT_INSN (test_insn) = PREV_INSN (test_insn) = 0;
 +  INSN_LOCATION (test_insn) = UNKNOWN_LOCATION;
  }
 
/* Now make an insn like the one we would make when GCSE'ing and see if
 @@ -874,16 +876,19 @@ can_assign_to_reg_without_clobbers_p (rtx x)
SET_SRC (PATTERN (test_insn)) = x;
 
icode = recog (PATTERN (test_insn), test_insn, num_clobbers);
 -  if (icode  0)
 -return false;
 -
 -  if (num_clobbers  0  added_clobbers_hard_reg_p (icode))
 -return false;
 -
 -  if (targetm.cannot_copy_insn_p  targetm.cannot_copy_insn_p (test_insn))
 -return false;
 -
 -  return true;
 +
 +  /* If the test insn is valid and doesn't need clobbers, and the target also
 + has no objections, we're good.  */
 +  if (icode != 0
 +   (num_clobbers == 0 || !added_clobbers_hard_reg_p (icode))
 +   ! (targetm.cannot_copy_insn_p
 +targetm.cannot_copy_insn_p (test_insn)))
 +can_assign = true;
 +
 +  /* Make sure test_insn doesn't have any pointers into GC space.  */
 +  SET_SRC (PATTERN (test_insn)) = NULL_RTX;
 +
 +  return can_assign;
  }
 
  /* Return nonzero if the operands of expression X are unchanged from the




PATCH: PR target/60969: [4.9/4.10 Regression] ICE in output_129 in MMXMOV of mode MODE_SF for march=pentium4

2014-04-25 Thread H.J. Lu
I checked this preappoved patch into trunk.  But we generate the wrong
code for the testcase due to mixing XMM and x87 registers.

H.J.
---
Index: ChangeLog
===
--- ChangeLog   (revision 209810)
+++ ChangeLog   (working copy)
@@ -1,3 +1,9 @@
+2014-04-25  H.J. Lu  hongjiu...@intel.com
+
+   PR target/60969
+   * config/i386/i386.md (*movsf_internal): Set MODE to SI for
+   alternative 12.
+
 2014-04-25  Jiong Wang  jiong.w...@arm.com
 
* config/arm/predicates.md (call_insn_operand): Add long_call check.
Index: config/i386/i386.md
===
--- config/i386/i386.md (revision 209810)
+++ config/i386/i386.md (working copy)
@@ -3201,7 +3201,7 @@
(const_string 1)
(const_string *)))
(set (attr mode)
-(cond [(eq_attr alternative 3,4,9,10,13,14,15)
+(cond [(eq_attr alternative 3,4,9,10,12,13,14,15)
 (const_string SI)
   (eq_attr alternative 11)
 (const_string DI)


  1   2   >