Re: a new libgcov interface: __gcov_dump_all

2014-07-21 Thread Nathan Sidwell

On 07/20/14 21:38, Xinliang David Li wrote:

The gcov_info chain is not duplicated -- there is already one chain
(linking only modules of the library) per shared library in current
implementation.  My change does not affect underlying behavior at all
-- it merely introduces a new interface to access private dumper
methods associated with shared libs.


ah, got it.  thanks for clarifying.  Can't help thinking gcov_init should be 
doing this, and wondering about dlload/dlclose.  Let me think


nathan


RE: Re: [MIPS r5900] libgcc floating point fixes

2014-07-21 Thread Matthew Fortune
Jürgen Urban juergenur...@gmx.dewrites:
  Jürgen Urban juergenur...@gmx.de writes:
   Hello Richard,
  
Jürgen Urban juergenur...@gmx.de writes:
  Is this something you
  have recently developed outside of the mainline kernel or does it already
 exist.
  I'm not aware of such logic in the MIPS kernel yet.
 
 Yes, this is developed in my kernel which currently is still based on Linux
 2.6.35.4. I added a TIF_R5900FPU flag to thread_info.h. I plan that this
 will get part of the mainline kernel. As the patch is too large to get
 accepted, I need to change the binutils, so that sync.p will be added after
 or before the right instruction automatically.

Is the TIF_R5900FPU flag to do something more than just change the register
model used by the FPU emulator or does it do something more/less? I'm afraid
I don’t know the significance of the sync.p.

   double the FPU emulator gets activated. Currently it only checks whether
 the
   architecture is mips r5900 or not. For non r5900 the FPU emulator is
   activated. It seems that we also need to add something to the ELF file
 to
   specify the 32 bit or 64 bit for float. It would be good when it is not
 at a
   so complicated position as the soft vs hard float flag, because it needs
 to
   be read by the kernel when starting a ELF file. This way it would also
 be
 
  I have a series of patches that will add this kind of support to the MIPS
  ABI in the coming weeks for similar reasons but relating to O32 and
 double-float
  ABI extensions. You will be able to directly hang off the changes once I
 commit
  (testing is taking some time). There should be no need for extra changes
 to
  gcc or binutils to get the information you need. Kernel changes to respond
  to new ABI information are also in progress and will be easily extendable.
 
   possible to emulate the r5900 FPU on a TX79 system. The TX79 is the same
 as
   r5900, but the FPU is 64 bit and compliant to IEEE 754.
  
Note that this won't really be correct for r5900 anyway because of its
non-IEEE FPU.  E.g. the soft-float routines will treat 0x7f80 as
infinity and 0x7fff as a NaN, whereas for r5900 they should be
 treated
as normal numbers.
  
   The code looked like it uses the configured floating point configuration
 for
   hard float, but you are right the conversion is not working in these
 cases.
  
   I think there is no problem with the second part of the patch which
 disables
   t-mips16 for r5900. So could you commit the last part of the patch?
 
  Are you looking to add support for a single-float FPU to a number of
  packages as part of this? One thing that comes to mind would be libffi but
 the
  double-precision ABIs are assumed to be the only ones used in Linux in a
 number
  of places. Just trying to get a feel for your end goal out of curiosity.
 
 The libffi doesn't look like that there is a change needed for floating
 point.

Libffi and most other hand crafted code for linux are written to follow the
standard double-precision O32/N32 ABI. The single-precision variants are
link-incompatible as they change the calling convention. I.e. when you pass
a double-precision value using a single-precision calling-convention then it
gets passed in GPRs instead of FPRs.

 It is possible that it needs a change for TImode or for 2 or 3 of the other
 co-processors which are currently not under discussion.
 The long term plan is to have 32 bit floating point operations compliant to
 IEEE 754 with ABI o32 and n32. Everything should stay inside gcc, libgcc and
 the kernel (i.e. Linux or PS2SDK). I want to fix it at the lowest level and
 not in any high level library.

Due to the calling convention change you won't be able to restrict the work
to just the toolchain and kernel. MIPS linux theoretically supports two ABI
extensions 'hard-float (double-precision)' and soft-float. I have a feeling
that the soft-float extension is not supported everywhere but may be a better
start point for what you want to achieve, i.e. use a soft-float calling
convention but add support for using FPU instructions at the same time. This
would be akin to arm's softfp float-abi.

 Fixes for high level libraries should also be
 high level (dmult vs __FLT_MAX_EXP__); i.e. there should be no change in a
 different package which is specific for MIPS. The type double should stay
 double and is handled without a problem when the FPU is 32 bit in ABI o32.
 The problem is only with the single/double conversion functions and the ABI
 n32.

I didn't quite follow why you specifically say n32 in the last sentence...
What is harder to fix about n32 than o32?

Thanks,
Matthew


[PATCH] New check and updates in check_GNU_style script

2014-07-21 Thread Yury Gribov

Hi all,

Attached patch adds new check (all blocks of 8 spaces are replaced with 
tabs) to contrib/check_GNU_style.sh. It also changes the script to allow 
reading patches from stdin and improves the Dot, space, space, new 
sentence. check.


-Y
commit 4bc624dcd778e8317a4de620b266c05b55577aad
Author: Yury Gribov y.gri...@samsung.com
Date:   Mon Jul 21 10:12:24 2014 +0400

2014-07-21  Yury Gribov  y.gri...@samsung.com

	check_GNU_style.sh: Support patches coming from stdin,
	check that spaces are converted to tabs and make double-space
	check more precice.

diff --git a/contrib/check_GNU_style.sh b/contrib/check_GNU_style.sh
index ef8fdda..d61dc96 100755
--- a/contrib/check_GNU_style.sh
+++ b/contrib/check_GNU_style.sh
@@ -23,6 +23,8 @@ usage() {
 check_GNU_style.sh [patch]...
 
 Checks the patches for some of the GNU style formatting problems.
+When FILE is -, read standard input.
+
 Please note that these checks are not always accurate, and
 complete.  The reference documentation of the GNU Coding Standards
 can be found here: http://www.gnu.org/prep/standards_toc.html
@@ -35,19 +37,22 @@ EOF
 
 test $# -eq 0  usage
 
+inp=check_GNU_style.inp
 tmp=check_GNU_style.tmp
 
 # Remove $tmp on exit and various signals.
-trap rm -f $tmp 0
-trap rm -f $tmp ; exit 1 1 2 3 5 9 13 15
+trap rm -f $inp $tmp 0
+trap rm -f $inp $tmp ; exit 1 1 2 3 5 9 13 15
+
+grep -nH '^+' $* \
+	| grep -v ':+++' \
+	 $inp
 
 # Grep
 g (){
 msg=$1
 arg=$2
-shift 2
-grep -nH '^+' $* \
-	| grep -v ':+++' \
+cat $inp \
 	| egrep --color=always -- $arg \
 	 $tmp  printf \n$msg\n
 cat $tmp
@@ -58,9 +63,7 @@ ag (){
 msg=$1
 arg1=$2
 arg2=$3
-shift 3
-grep -nH '^+' $* \
-	| grep -v ':+++' \
+cat $inp \
 	| egrep --color=always -- $arg1 \
 	| egrep --color=always -- $arg2 \
 	 $tmp  printf \n$msg\n
@@ -72,9 +75,7 @@ vg (){
 msg=$1
 varg=$2
 arg=$3
-shift 3
-grep -nH '^+' $* \
-	| grep -v ':+++' \
+cat $inp \
 	| egrep -v -- $varg \
 	| egrep --color=always -- $arg \
 	 $tmp  printf \n$msg\n
@@ -83,9 +84,7 @@ vg (){
 
 col (){
 msg=$1
-shift 1
-grep -nH '^+' $* \
-	| grep -v ':+++' \
+cat $inp \
 	| cut -f 2 -d '+' \
 	| awk '{ if (length ($0)  80) print $0 }' \
 	 $tmp
@@ -95,30 +94,32 @@ col (){
 fi
 }
 
-col 'Lines should not exceed 80 characters.' $*
+col 'Lines should not exceed 80 characters.'
+
+g 'Blocks of 8 spaces should be replaced with tabs.' \
+' {8}'
 
 g 'Trailing whitespace.' \
-'[[:space:]]$' $*
+'[[:space:]]$'
 
 g 'Space before dot.' \
-'[[:alnum:]][[:blank:]]+\.' $*
+'[[:alnum:]][[:blank:]]+\.'
 
 g 'Dot, space, space, new sentence.' \
-'[[:alnum:]]\.([[:blank:]]|[[:blank:]]{3,})[[:alnum:]]' $*
+'[[:alnum:]]\.([[:blank:]]|[[:blank:]]{3,})[A-Z0-9]'
 
 g 'Dot, space, space, end of comment.' \
-'[[:alnum:]]\.([[:blank:]]{0,1}|[[:blank:]]{3,})\*/' $*
+'[[:alnum:]]\.([[:blank:]]{0,1}|[[:blank:]]{3,})\*/'
 
 g 'Sentences should end with a dot.  Dot, space, space, end of the comment.' \
-'[[:alnum:]][[:blank:]]*\*/' $*
+'[[:alnum:]][[:blank:]]*\*/'
 
 vg 'There should be exactly one space between function name and parentheses.' \
-'\#define' '[[:alnum:]]([^[:blank:]]|[[:blank:]]{2,})\(' $*
+'\#define' '[[:alnum:]]([^[:blank:]]|[[:blank:]]{2,})\('
 
 g 'There should be no space before closing parentheses.' \
-'[[:graph:]][[:blank:]]+\)' $*
+'[[:graph:]][[:blank:]]+\)'
 
 ag 'Braces should be on a separate line.' \
-'\{' 'if[[:blank:]]\(|while[[:blank:]]\(|switch[[:blank:]]\(' $*
-
+'\{' 'if[[:blank:]]\(|while[[:blank:]]\(|switch[[:blank:]]\('
 


Re: [PATCH, i386, PR61827] Fix fuse-caller-save-xmm.c test-case

2014-07-21 Thread Uros Bizjak
On Sun, Jul 20, 2014 at 12:25 PM, Tom de Vries tom_devr...@mentor.com wrote:

 this patch fixes the problems in test-case
 gcc.target/i386/fuse-caller-save-xmm.c reported in PR 61827. I've removed
 the checks for cfi_def_cfa_offset, which were not robust enough for the
 different configurations.

 Furthermore, I've:
 - added checks for all insns that handle the xmm registers, to make sure
 we're
   actually using the xmm1 register.
 - fixed the scan-assembler-not lines to allow both %esp and %rsp.

You can use %\[re\]?sp here. We know that only r and e are valid.

 - removed main, which was really only intended for the
   fuse-caller-save-xmm-run.c test-case.

 Tested with -m32 and -m64.

Probably you should also add -fomit-frame-pointer, otherwise the test
(that checks for SP based address) will fail on Darwin and Solaris
that default to frame pointers.

 OK for trunk?

OK with the above changes.

Thanks,
Uros.


Re: [PATCH 2/2] allow running mklog as a filter

2014-07-21 Thread Yury Gribov

On 05/09/2014 07:09 PM, Diego Novillo wrote:
 I slightly prefer the semantics that gets me just the ChangeLog.
 The workflow I'm envisioning is:

I've commited both patches in r212883 and r12884. Mklog now runs as a 
filter and prints generated ChangeLog to stdout instead of modifying the 
patchfile.


 OK with Yuri's suggestion of assuming '-' when ARGV is empty.

I didn't change this because currently empty ARGV is used for printing 
help message (similar to some other scripts in contrib/ folder).


-Y


Re: [GSoC] generation of Gimple code from isl_ast_node_user

2014-07-21 Thread Roman Gareev
Maybe we should  temporary postpone this and add a FIXME that says:

“We should remove iv_map.create (loop-num + 1), if it is possible.”

What do you think about this?

--
   Cheers, Roman Gareev.


[PATCH] Fix mklog to support running from arbitrary folder

2014-07-21 Thread Yury Gribov

Hi all,

Current mklog works only if run from GCC top-level folder. The patch 
allows running from arbitrary directory.


I've used Linux directory separators which is probably ok because script 
already expects Linux environment (dirname, basename, etc.).


Ok to commit?

-Y
commit aa8d7cd3db1f1eba8ee77b902cff1b2ab2a3f83a
Author: Yury Gribov y.gri...@samsung.com
Date:   Mon Jul 21 12:05:10 2014 +0400

2014-07-21  Yury Gribov  y.gri...@samsung.com

	* mklog: Allow running from arbitrary folder.

diff --git a/contrib/mklog b/contrib/mklog
index cdc6455..3d17dc5 100755
--- a/contrib/mklog
+++ b/contrib/mklog
@@ -30,16 +30,15 @@
 $username = $ENV{'USER'};
 $name = `finger $username | grep -o 'Name: .*'`;
 @n = split(/: /, $name);
-$name = @n[1]; chop($name);
+$name = $n[1]; chop($name);
 $addr = $username . \@my.domain.org;
 $date = `date +%Y-%m-%d`; chop ($date);
 
 $gcc_root = $0;
 $gcc_root =~ s/[^\\\/]+$/../;
-chdir $gcc_root;
 
 # if this is a git tree then take name and email from the git configuration
-if (-d .git) {
+if (-d $gcc_root/.git) {
   $gitname = `git config user.name`;
   chomp($gitname);
   if ($gitname) {
@@ -80,7 +79,7 @@ sub get_clname ($) {
 	my $dirname = $_[0];
 	while ($dirname) {
 		my $clname = $dirname/ChangeLog;
-		if (-f $clname) {
+		if (-f $gcc_root/$clname) {
 			my $relname = substr ($_[0], length ($dirname) + 1);
 			return ($clname, $relname);
 		} else {


[PATCH, i386]: Fix PR 61855, _MM_MANTISSA_NORM_ENUM in avx512intrin.h disabled when optimization off

2014-07-21 Thread Uros Bizjak
Hello!

2014-07-21  Uros Bizjak  ubiz...@gmail.com

PR target/61855
* config/i386/avx512fintrin.h: Move constants for mantissa extraction
out of #ifdef __OPTIMIZE__.

testsuite/ChangeLog:

2014-07-21  Uros Bizjak  ubiz...@gmail.com

PR target/61855
* gcc.target/i386/pr61855.c: New test.

Tested on x86_64-linux-gnu and committed to mainline SVN and 4.9 branch.

Uros.
Index: config/i386/avx512fintrin.h
===
--- config/i386/avx512fintrin.h (revision 212882)
+++ config/i386/avx512fintrin.h (working copy)
@@ -8103,6 +8103,22 @@
   return __builtin_ia32_movntdqa512 ((__v8di *)__P);
 }
 
+/* Constants for mantissa extraction */
+typedef enum
+{
+  _MM_MANT_NORM_1_2,   /* interval [1, 2)  */
+  _MM_MANT_NORM_p5_2,  /* interval [0.5, 2)*/
+  _MM_MANT_NORM_p5_1,  /* interval [0.5, 1)*/
+  _MM_MANT_NORM_p75_1p5/* interval [0.75, 1.5) */
+} _MM_MANTISSA_NORM_ENUM;
+
+typedef enum
+{
+  _MM_MANT_SIGN_src,   /* sign = sign(SRC) */
+  _MM_MANT_SIGN_zero,  /* sign = 0 */
+  _MM_MANT_SIGN_nan/* DEST = NaN if sign(SRC) = 1 */
+} _MM_MANTISSA_SIGN_ENUM;
+
 #ifdef __OPTIMIZE__
 extern __inline __m128
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
@@ -8182,22 +8198,6 @@
(__mmask8) __U, __R);
 }
 
-/* Constants for mantissa extraction */
-typedef enum
-{
-  _MM_MANT_NORM_1_2,   /* interval [1, 2)  */
-  _MM_MANT_NORM_p5_2,  /* interval [0.5, 2)*/
-  _MM_MANT_NORM_p5_1,  /* interval [0.5, 1)*/
-  _MM_MANT_NORM_p75_1p5/* interval [0.75, 1.5) */
-} _MM_MANTISSA_NORM_ENUM;
-
-typedef enum
-{
-  _MM_MANT_SIGN_src,   /* sign = sign(SRC) */
-  _MM_MANT_SIGN_zero,  /* sign = 0 */
-  _MM_MANT_SIGN_nan/* DEST = NaN if sign(SRC) = 1 */
-} _MM_MANTISSA_SIGN_ENUM;
-
 extern __inline __m512d
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
 _mm512_getmant_round_pd (__m512d __A, _MM_MANTISSA_NORM_ENUM __B,
Index: testsuite/gcc.target/i386/pr61855.c
===
--- testsuite/gcc.target/i386/pr61855.c (revision 0)
+++ testsuite/gcc.target/i386/pr61855.c (working copy)
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options -mavx512f } */
+
+#include x86intrin.h
+
+__m512 test (__m512 x)
+{
+  return _mm512_getmant_ps(x, _MM_MANT_NORM_1_2, _MM_MANT_SIGN_zero);
+}
+


Re: [GSoC] generation of Gimple code from isl_ast_node_user

2014-07-21 Thread Tobias Grosser

On 21/07/2014 10:25, Roman Gareev wrote:

Maybe we should  temporary postpone this and add a FIXME that says:

“We should remove iv_map.create (loop-num + 1), if it is possible.”

What do you think about this?


Fine with me. Please post a question on gcc devel to see if someone can 
explain us the vec.h implementation.


Cheers,
Tobias


Re: [PATCH 2/2] allow running mklog as a filter

2014-07-21 Thread Trevor Saunders
On Mon, Jul 21, 2014 at 11:49:05AM +0400, Yury Gribov wrote:
 On 05/09/2014 07:09 PM, Diego Novillo wrote:
  I slightly prefer the semantics that gets me just the ChangeLog.
  The workflow I'm envisioning is:
 
 I've commited both patches in r212883 and r12884. Mklog now runs as a filter
 and prints generated ChangeLog to stdout instead of modifying the patchfile.

thanks for taking care of it!

  OK with Yuri's suggestion of assuming '-' when ARGV is empty.
 
 I didn't change this because currently empty ARGV is used for printing help
 message (similar to some other scripts in contrib/ folder).

I'm not really sure which is the better UI, but I'd rather time be spent
on better automatic change log generation.  I may or may not hope we'll
eventually have a mklog that can autogenerate most ChangeLogs and then
people will have a hard time arguing they're useful.

Trev

 
 -Y


Re: [PATH] Intel offload library

2014-07-21 Thread Andrey Turetskiy
Ping.

On Wed, Jul 2, 2014 at 3:13 PM, Andrey Turetskiy
andrey.turets...@gmail.com wrote:
 * Don't duplicate the logic for what's a hosted POSIX system; refactor it
 to a common fragment in config/ (I guess it needs to be a shell script
 fragment there rather than an actual autoconf macro, since you're using
 that logic in configure.tgt which is itself such a fragment).

 I've attached the patch with changes related to the point.
 Do you mean something like this?

 --
 Best regards,
 Andrey Turetskiy



-- 
Best regards,
Andrey Turetskiy


Fwd: [PATCH 1/3]Improve induction variable elimination

2014-07-21 Thread Bin.Cheng
Hi, forward to Zdenek for the review.

Thanks,
bin


-- Forwarded message --
From: Bin Cheng bin.ch...@arm.com
Date: Thu, Jul 17, 2014 at 10:07 AM
Subject: [PATCH 1/3]Improve induction variable elimination
To: gcc-patches@gcc.gnu.org


Hi,
This is a series of three patches improving induction variable elimination.
Currently GCC only eliminates iv for very specific case when the loop's
latch could run zero times, i.e., when may_be_zero field of loop niter
information evaluates to true.  In fact, it's so specific that
iv_elimination_compare_lt rarely succeeds during either GCC bootstrap or
spec2000/spec2006 compilation.  Though intrusive data shows these patches
don't help iv elimination that much for GCC bootstrap, they do capture
5%~15% more eliminations for compiling spec2000/2006.  Detailed numbers are
like:
  2k/int   2k/fp   2k6/int   2k6/fp
improve ~9.6%  ~4.8%  ~5.5%~14.4%

All patches pass bootstrap and regression test on x86_64/x86.  I will
bootstrap and test them on aarch64/arm platforms too.

The first patch turns to tree operand_equal_p to check the number of
iterations in iv_elimination_lt.  Though I think this change isn't necessary
for current code, it's needed if we further relax iv elimination for cases
in which sign/unsigned conversion is involved.

Thanks,
bin

2014-07-17  Bin Cheng  bin.ch...@arm.com

* tree-ssa-loop-ivopts.c (iv_elimination_compare_lt): Check number
of iteration using tree comparison.
Index: gcc/tree-ssa-loop-ivopts.c
===
--- gcc/tree-ssa-loop-ivopts.c  (revision 212387)
+++ gcc/tree-ssa-loop-ivopts.c  (working copy)
@@ -4605,7 +4605,7 @@ iv_elimination_compare_lt (struct ivopts_data *dat
   struct tree_niter_desc *niter)
 {
   tree cand_type, a, b, mbz, nit_type = TREE_TYPE (niter-niter), offset;
-  struct aff_tree nit, tmpa, tmpb;
+  struct aff_tree nit, tmp1, tmpa, tmpb;
   enum tree_code comp;
   HOST_WIDE_INT step;
 
@@ -4661,15 +4661,19 @@ iv_elimination_compare_lt (struct ivopts_data *dat
 return false;
 
   /* Expected number of iterations is B - A - 1.  Check that it matches
- the actual number, i.e., that B - A - NITER = 1.  */
+ the actual number, i.e., that B - A = NITER + 1.  */
   tree_to_aff_combination (niter-niter, nit_type, nit);
-  tree_to_aff_combination (fold_convert (nit_type, a), nit_type, tmpa);
-  tree_to_aff_combination (fold_convert (nit_type, b), nit_type, tmpb);
-  aff_combination_scale (nit, -1);
-  aff_combination_scale (tmpa, -1);
-  aff_combination_add (tmpb, tmpa);
-  aff_combination_add (tmpb, nit);
-  if (tmpb.n != 0 || tmpb.offset != 1)
+  aff_combination_const (tmp1, nit_type, 1);
+  tree_to_aff_combination (b, TREE_TYPE (b), tmpb);
+  aff_combination_add (nit, tmp1);
+  if (a != integer_zero_node)
+{
+  tree_to_aff_combination (a, TREE_TYPE (b), tmpa);
+  aff_combination_scale (tmpa, -1);
+  aff_combination_add (tmpb, tmpa);
+}
+  if (!operand_equal_p (aff_combination_to_tree (nit),
+   aff_combination_to_tree (tmpb), 0))
 return false;
 
   /* Finally, check that CAND-IV-BASE - CAND-IV-STEP * A does not


Fwd: [PATCH 3/3]Improve induction variable elimination

2014-07-21 Thread Bin.Cheng
Forward to Zdenek for the review.

Thanks,
bin



-- Forwarded message --
From: Bin Cheng bin.ch...@arm.com
Date: Thu, Jul 17, 2014 at 10:09 AM
Subject: [PATCH 3/3]Improve induction variable elimination
To: gcc-patches@gcc.gnu.org


Hi,
Function iv_elimination_compare_lt is used to eliminate induction variable
when the loop's latch could run for zero time (i.e., may_be_zero in loop
niter information evaluates to true).  As stated in the first message, it
only handles very specific case that rarely happens for either GCC bootstrap
or spec2k/spec2k6 compilation.  The function has two restrictions which
could be improved:
  a) When checking that candidate iv doesn't overflow, it only handles
candidates that are computed in a type that guarantees no overflows.  More
complex analysis can be used to prove the non-overflow ness,  as in this
patch.
  b) The function only handles the original form of may_be_zero like a + 1
 b, but that expression could have been folded into other forms.  This
patch handles three folded forms and does iv elimination as well.  I think
this isn't a very corner case, because for many loops iterating from 0
(i.e., we have a == 0), the expression will be folded.

I also refactored period check from may_eliminate_iv into a single function
so that it can be reused.

Thanks,
bin


2014-07-17  Bin Cheng  bin.ch...@arm.com

* tree-ssa-loop-ivopts.c (iv_nowrap_period)
(nowrap_cand_for_loop_niter_p): New functions.
(period_greater_niter_exit): New function refactored from
may_eliminate_iv.
(iv_elimination_compare_lt): New parameter.  Check wrapping
behavior for candidate of wrapping type.  Handle folded forms
of may_be_zero expression.
(may_eliminate_iv): Call period_greater_niter_exit.  Pass new
argument for iv_elimination_compare_lt.

gcc/testsuite/ChangeLog
2014-07-17  Bin Cheng  bin.ch...@arm.com

* gcc.dg/tree-ssa/ivopts-lt-3.c: New test.
* gcc.dg/tree-ssa/ivopts-lt-4.c: New test.
Index: gcc/tree-ssa-loop-ivopts.c
===
--- gcc/tree-ssa-loop-ivopts.c  (revision 212387)
+++ gcc/tree-ssa-loop-ivopts.c  (working copy)
@@ -4432,6 +4432,44 @@ iv_period (struct iv *iv)
   return period;
 }
 
+/* Returns no wrapping period of induction variable IV.  For now
+   only unsigned type IV is handled, we could extend it in case
+   of non-overflow for signed ones.  Return zero if it can't be
+   decided.  */
+
+static tree
+iv_nowrap_period (struct iv *iv)
+{
+  bool overflow;
+  tree type;
+  tree base = iv-base, step = iv-step;
+  widest_int base_val, step_val, max_val, span, period;
+
+  gcc_assert (step  TREE_CODE (step) == INTEGER_CST);
+
+  type = TREE_TYPE (base);
+  if (!TYPE_UNSIGNED (type) || TREE_CODE (base) != INTEGER_CST)
+return integer_zero_node;
+
+  base_val = wi::to_widest (base);
+  step_val = wi::to_widest (step);
+  if (!POINTER_TYPE_P (type)  TYPE_MAX_VALUE (type)
+   TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
+max_val = wi::to_widest (TYPE_MAX_VALUE (type));
+  else
+{
+  wide_int max_wi = wi::max_value (TYPE_PRECISION (type), UNSIGNED);
+  max_val = wi::to_widest (wide_int_to_tree (type, max_wi));
+}
+
+  span = max_val - base_val + step_val - 1;
+  period = wi::div_trunc (span, step_val, UNSIGNED, overflow);
+  if (overflow)
+return integer_zero_node;
+
+  return wide_int_to_tree (type, period);
+}
+
 /* Returns the comparison operator used when eliminating the iv USE.  */
 
 static enum tree_code
@@ -4560,7 +4598,84 @@ difference_cannot_overflow_p (tree base, tree offs
 }
 }
 
-/* Tries to replace loop exit by one formulated in terms of a LT_EXPR
+/* Check whether PERIOD of CAND is greater than the number of iterations
+   described by DESC for which the exit condition is true.  The exit
+   condition is comparison against USE.  */
+
+static bool
+period_greater_niter_exit (struct ivopts_data *data,
+  struct iv_use *use, struct iv_cand *cand,
+  tree period, struct tree_niter_desc *desc)
+{
+  struct loop *loop = data-current_loop;
+
+  /* If the number of iterations is constant, compare against it directly.  */
+  if (TREE_CODE (desc-niter) == INTEGER_CST)
+{
+  /* See cand_value_at.  */
+  if (stmt_after_increment (loop, cand, use-stmt))
+{
+  if (!tree_int_cst_lt (desc-niter, period))
+return false;
+}
+  else
+{
+  if (tree_int_cst_lt (period, desc-niter))
+return false;
+}
+}
+
+  /* If not, and if this is the only possible exit of the loop, see whether
+ we can get a conservative estimate on the number of iterations of the
+ entire loop and compare against that instead.  */
+  else
+{
+  widest_int period_value, max_niter;
+
+  max_niter = desc-max;
+  if (stmt_after_increment (loop, cand, use-stmt))
+   

Fwd: [PATCH 3/3]Improve induction variable elimination

2014-07-21 Thread Bin.Cheng
Hi, forward to Zdenek for the review.

Thanks,
bin



-- Forwarded message --
From: Bin Cheng bin.ch...@arm.com
Date: Thu, Jul 17, 2014 at 10:09 AM
Subject: [PATCH 3/3]Improve induction variable elimination
To: gcc-patches@gcc.gnu.org


Hi,
Function iv_elimination_compare_lt is used to eliminate induction variable
when the loop's latch could run for zero time (i.e., may_be_zero in loop
niter information evaluates to true).  As stated in the first message, it
only handles very specific case that rarely happens for either GCC bootstrap
or spec2k/spec2k6 compilation.  The function has two restrictions which
could be improved:
  a) When checking that candidate iv doesn't overflow, it only handles
candidates that are computed in a type that guarantees no overflows.  More
complex analysis can be used to prove the non-overflow ness,  as in this
patch.
  b) The function only handles the original form of may_be_zero like a + 1
 b, but that expression could have been folded into other forms.  This
patch handles three folded forms and does iv elimination as well.  I think
this isn't a very corner case, because for many loops iterating from 0
(i.e., we have a == 0), the expression will be folded.

I also refactored period check from may_eliminate_iv into a single function
so that it can be reused.

Thanks,
bin


2014-07-17  Bin Cheng  bin.ch...@arm.com

* tree-ssa-loop-ivopts.c (iv_nowrap_period)
(nowrap_cand_for_loop_niter_p): New functions.
(period_greater_niter_exit): New function refactored from
may_eliminate_iv.
(iv_elimination_compare_lt): New parameter.  Check wrapping
behavior for candidate of wrapping type.  Handle folded forms
of may_be_zero expression.
(may_eliminate_iv): Call period_greater_niter_exit.  Pass new
argument for iv_elimination_compare_lt.

gcc/testsuite/ChangeLog
2014-07-17  Bin Cheng  bin.ch...@arm.com

* gcc.dg/tree-ssa/ivopts-lt-3.c: New test.
* gcc.dg/tree-ssa/ivopts-lt-4.c: New test.
Index: gcc/tree-ssa-loop-ivopts.c
===
--- gcc/tree-ssa-loop-ivopts.c  (revision 212387)
+++ gcc/tree-ssa-loop-ivopts.c  (working copy)
@@ -4432,6 +4432,44 @@ iv_period (struct iv *iv)
   return period;
 }
 
+/* Returns no wrapping period of induction variable IV.  For now
+   only unsigned type IV is handled, we could extend it in case
+   of non-overflow for signed ones.  Return zero if it can't be
+   decided.  */
+
+static tree
+iv_nowrap_period (struct iv *iv)
+{
+  bool overflow;
+  tree type;
+  tree base = iv-base, step = iv-step;
+  widest_int base_val, step_val, max_val, span, period;
+
+  gcc_assert (step  TREE_CODE (step) == INTEGER_CST);
+
+  type = TREE_TYPE (base);
+  if (!TYPE_UNSIGNED (type) || TREE_CODE (base) != INTEGER_CST)
+return integer_zero_node;
+
+  base_val = wi::to_widest (base);
+  step_val = wi::to_widest (step);
+  if (!POINTER_TYPE_P (type)  TYPE_MAX_VALUE (type)
+   TREE_CODE (TYPE_MAX_VALUE (type)) == INTEGER_CST)
+max_val = wi::to_widest (TYPE_MAX_VALUE (type));
+  else
+{
+  wide_int max_wi = wi::max_value (TYPE_PRECISION (type), UNSIGNED);
+  max_val = wi::to_widest (wide_int_to_tree (type, max_wi));
+}
+
+  span = max_val - base_val + step_val - 1;
+  period = wi::div_trunc (span, step_val, UNSIGNED, overflow);
+  if (overflow)
+return integer_zero_node;
+
+  return wide_int_to_tree (type, period);
+}
+
 /* Returns the comparison operator used when eliminating the iv USE.  */
 
 static enum tree_code
@@ -4560,7 +4598,84 @@ difference_cannot_overflow_p (tree base, tree offs
 }
 }
 
-/* Tries to replace loop exit by one formulated in terms of a LT_EXPR
+/* Check whether PERIOD of CAND is greater than the number of iterations
+   described by DESC for which the exit condition is true.  The exit
+   condition is comparison against USE.  */
+
+static bool
+period_greater_niter_exit (struct ivopts_data *data,
+  struct iv_use *use, struct iv_cand *cand,
+  tree period, struct tree_niter_desc *desc)
+{
+  struct loop *loop = data-current_loop;
+
+  /* If the number of iterations is constant, compare against it directly.  */
+  if (TREE_CODE (desc-niter) == INTEGER_CST)
+{
+  /* See cand_value_at.  */
+  if (stmt_after_increment (loop, cand, use-stmt))
+{
+  if (!tree_int_cst_lt (desc-niter, period))
+return false;
+}
+  else
+{
+  if (tree_int_cst_lt (period, desc-niter))
+return false;
+}
+}
+
+  /* If not, and if this is the only possible exit of the loop, see whether
+ we can get a conservative estimate on the number of iterations of the
+ entire loop and compare against that instead.  */
+  else
+{
+  widest_int period_value, max_niter;
+
+  max_niter = desc-max;
+  if (stmt_after_increment (loop, cand, use-stmt))

Re: [GSoC] generation of Gimple code from isl_ast_node_user

2014-07-21 Thread Roman Gareev
I've asked the community about this.

The patch below contains the FIXME.

--
   Cheers, Roman Gareev.
2014-07-12  Roman Gareev  gareevro...@gmail.com

gcc/
* graphite-isl-ast-to-gimple.c:
Add inclusion of gimple-ssa.h, tree-into-ssa.h.
(ivs_params_clear):
(build_iv_mapping): New function.
(translate_isl_ast_node_user): Likewise.
(translate_isl_ast): Add calling of translate_isl_ast_node_user.

gcc/testsuite/gcc.dg/graphite/
* isl-ast-gen-single-loop-1.c: New testcase.
* isl-ast-gen-single-loop-2.c: New testcase.
* isl-ast-gen-single-loop-3.c: New testcase.
Index: gcc/graphite-isl-ast-to-gimple.c
===
--- gcc/graphite-isl-ast-to-gimple.c(revision 212888)
+++ gcc/graphite-isl-ast-to-gimple.c(working copy)
@@ -51,6 +51,8 @@
 #include sese.h
 #include tree-ssa-loop-manip.h
 #include tree-scalar-evolution.h
+#include gimple-ssa.h
+#include tree-into-ssa.h
 #include map
 
 #ifdef HAVE_cloog
@@ -547,6 +549,73 @@
   return last_e;
 }
 
+/* Inserts in iv_map a tuple (OLD_LOOP-num, NEW_NAME) for the induction
+   variables of the loops around GBB in SESE.
+ 
+   FIXME: Instead of using a vectree that maps each loop id to a possible
+   chrec, we could consider using a mapint, tree that maps loop ids to the
+   corresponding tree expressions.  */
+
+static void
+build_iv_mapping (vectree iv_map, gimple_bb_p gbb,
+ __isl_keep isl_ast_expr *user_expr, ivs_params ip,
+ sese region)
+{
+  gcc_assert (isl_ast_expr_get_type (user_expr) == isl_ast_expr_op 
+  isl_ast_expr_get_op_type (user_expr) == isl_ast_op_call);
+  int i;
+  isl_ast_expr *arg_expr;
+  for (i = 1; i  isl_ast_expr_get_op_n_arg (user_expr); i++)
+{
+  arg_expr = isl_ast_expr_get_op_arg (user_expr, i);
+  tree type =
+build_nonstandard_integer_type (graphite_expression_type_precision, 0);
+  tree t = gcc_expression_from_isl_expression (type, arg_expr, ip);
+  loop_p old_loop = gbb_loop_at_index (gbb, region, i - 1);
+  iv_map[old_loop-num] = t;
+}
+
+}
+
+/* Translates an isl_ast_node_user to Gimple.
+
+   FIXME: We should remove iv_map.create (loop-num + 1), if it is possible.  
*/
+
+static edge
+translate_isl_ast_node_user (__isl_keep isl_ast_node *node,
+edge next_e, ivs_params ip)
+{
+  gcc_assert (isl_ast_node_get_type (node) == isl_ast_node_user);
+  isl_ast_expr *user_expr = isl_ast_node_user_get_expr (node);
+  isl_ast_expr *name_expr = isl_ast_expr_get_op_arg (user_expr, 0);
+  gcc_assert (isl_ast_expr_get_type (name_expr) == isl_ast_expr_id);
+  isl_id *name_id = isl_ast_expr_get_id (name_expr);
+  poly_bb_p pbb = (poly_bb_p) isl_id_get_user (name_id);
+  gcc_assert (pbb);
+  gimple_bb_p gbb = PBB_BLACK_BOX (pbb);
+  vectree iv_map;
+  isl_ast_expr_free (name_expr);
+  isl_id_free (name_id);
+
+  gcc_assert (GBB_BB (gbb) != ENTRY_BLOCK_PTR_FOR_FN (cfun) 
+ The entry block should not even appear within a scop);
+
+  loop_p loop = gbb_loop (gbb);
+  iv_map.create (loop-num + 1);
+  iv_map.safe_grow_cleared (loop-num + 1);
+
+  build_iv_mapping (iv_map, gbb, user_expr, ip, SCOP_REGION (pbb-scop));
+  isl_ast_expr_free (user_expr);
+  next_e = copy_bb_and_scalar_dependences (GBB_BB (gbb),
+  SCOP_REGION (pbb-scop), next_e,
+  iv_map,
+  graphite_regenerate_error);
+  iv_map.release ();
+  mark_virtual_operands_for_renaming (cfun);
+  update_ssa (TODO_update_ssa);
+  return next_e;
+}
+
 /* Translates an ISL AST node NODE to GCC representation in the
context of a SESE.  */
 
@@ -567,7 +636,7 @@
   return next_e;
 
 case isl_ast_node_user:
-  return next_e;
+  return translate_isl_ast_node_user (node, next_e, ip);
 
 case isl_ast_node_block:
   return next_e;
Index: gcc/testsuite/gcc.dg/graphite/isl-ast-gen-single-loop-1.c
===
--- gcc/testsuite/gcc.dg/graphite/isl-ast-gen-single-loop-1.c   (revision 0)
+++ gcc/testsuite/gcc.dg/graphite/isl-ast-gen-single-loop-1.c   (working copy)
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+/* { dg-options -O2 -fgraphite-identity -fgraphite-code-generator=isl } */
+
+int
+foo ()
+{
+  int i, res;
+
+  for (i = 0, res = 0; i  50; i++)
+  res += i;
+
+  return res;
+}
+
+extern void abort ();
+
+int
+main (void)
+{ 
+  int res = foo ();
+
+  if (res != 1225)
+abort ();
+
+  return 0;
+}
Index: gcc/testsuite/gcc.dg/graphite/isl-ast-gen-single-loop-2.c
===
--- gcc/testsuite/gcc.dg/graphite/isl-ast-gen-single-loop-2.c   (revision 0)
+++ gcc/testsuite/gcc.dg/graphite/isl-ast-gen-single-loop-2.c   (working copy)
@@ -0,0 +1,34 @@
+/* { dg-do run } 

Re: [PATCH, i386, PR61827] Fix fuse-caller-save-xmm.c test-case

2014-07-21 Thread Tom de Vries

On 21-07-14 09:31, Uros Bizjak wrote:

On Sun, Jul 20, 2014 at 12:25 PM, Tom de Vries tom_devr...@mentor.com wrote:


this patch fixes the problems in test-case
gcc.target/i386/fuse-caller-save-xmm.c reported in PR 61827. I've removed
the checks for cfi_def_cfa_offset, which were not robust enough for the
different configurations.

Furthermore, I've:
- added checks for all insns that handle the xmm registers, to make sure
we're
   actually using the xmm1 register.
- fixed the scan-assembler-not lines to allow both %esp and %rsp.


You can use %\[re\]?sp here. We know that only r and e are valid.


- removed main, which was really only intended for the
   fuse-caller-save-xmm-run.c test-case.

Tested with -m32 and -m64.


Probably you should also add -fomit-frame-pointer, otherwise the test
(that checks for SP based address) will fail on Darwin and Solaris
that default to frame pointers.


OK for trunk?


OK with the above changes.



Uros,

Dominique noticed that the .LC0 check failed on darwin, since the label LC0 is 
used. This follow-up patch fixes that (and I see now you already Ok-ed this change).


Furthermore, I've realized from the comments in the PR that for solaris/sun-as 
and darwin no cfi directives are generated. There are two other i386 
fuse-caller-save tests which test cfi directives. The reason these tests aren't 
failing for solaris/sun-as and darwin like the fuse-caller-save-xmm test did, is 
because they test for the absence of specific cfi directives, which will always 
pass if no cfi directives are generated. So I've removed the cfi directive 
checks (and removed superfluous mains) and added tests on instructions.


Tested with -m32 and -m64.

OK for trunk?

Thanks,
- Tom

2014-07-21  Tom de Vries  t...@codesourcery.com

	PR target/61827
	* gcc.target/i386/fuse-caller-save-xmm.c: Allow LC0 without dot prefix
	for darwin in scan-assembler-times check.
	* gcc.target/i386/fuse-caller-save.c: Remove cfi-related
	scan-assembler-not checks.  Add checks for insns.
	(main): Remove.
	* gcc.target/i386/fuse-caller-save-rec.c: Remove cfi-related
	scan-assembler-not checks.  Copy checks from i386/fuse-caller-save.c.
	(main): Remove.

diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c
index b30a0b4..d1441bc 100644
--- a/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c
+++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c
@@ -18,14 +18,12 @@ foo (int y)
   return y + bar (y);
 }
 
-int
-main (void)
-{
-  return !(foo (5) == 13);
-}
+/* Check that no registers are saved/restored. */
+/* { dg-final { scan-assembler-not push  } } */
+/* { dg-final { scan-assembler-not pop  } } */
 
-/* Verify that no registers where saved on stack.  */
-/* { dg-final { scan-assembler-not \.cfi_offset  } } */
+/* Check that addition uses dx. */
+/* { dg-final { scan-assembler-times addl\t%\[re\]?dx, %\[re\]?ax 1 } } */
 
 /* Verify that bar is self-recursive.  */
 /* { dg-final { scan-assembler-times call\tbar 2 } } */
diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c
index c639936..4211a89 100644
--- a/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c
+++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save-xmm.c
@@ -17,7 +17,7 @@ foo (v2df y)
 
 /* Check presence of all insns on xmm registers.  These checks are expected to
pass with both -fuse-caller-save and -fno-use-caller-save.  */
-/* { dg-final { scan-assembler-times addpd\t\\.LC0.*, %xmm0 1 } } */
+/* { dg-final { scan-assembler-times addpd\t\\.?LC0.*, %xmm0 1 } } */
 /* { dg-final { scan-assembler-times addpd\t%xmm1, %xmm0 1 } } */
 /* { dg-final { scan-assembler-times movapd\t%xmm0, %xmm1 1 } } */
 
diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save.c
index 4ec4995..7e2b11d 100644
--- a/gcc/testsuite/gcc.target/i386/fuse-caller-save.c
+++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save.c
@@ -16,12 +16,9 @@ foo (int y)
   return y + bar (y);
 }
 
-int
-main (void)
-{
-  return !(foo (5) == 13);
-}
-
-/* { dg-final { scan-assembler-not \.cfi_def_cfa_offset  } } */
-/* { dg-final { scan-assembler-not \.cfi_offset  } } */
+/* Check that no registers are saved/restored. */
+/* { dg-final { scan-assembler-not push  } } */
+/* { dg-final { scan-assembler-not pop  } } */
 
+/* Check that addition uses dx. */
+/* { dg-final { scan-assembler-times addl\t%\[re\]?dx, %\[re\]?ax 1 } } */



Re: [PATCH, i386, PR61827] Fix fuse-caller-save-xmm.c test-case

2014-07-21 Thread Uros Bizjak
On Mon, Jul 21, 2014 at 12:34 PM, Tom de Vries tom_devr...@mentor.com wrote:

 Dominique noticed that the .LC0 check failed on darwin, since the label LC0
 is used. This follow-up patch fixes that (and I see now you already Ok-ed
 this change).

 Furthermore, I've realized from the comments in the PR that for
 solaris/sun-as and darwin no cfi directives are generated. There are two
 other i386 fuse-caller-save tests which test cfi directives. The reason
 these tests aren't failing for solaris/sun-as and darwin like the
 fuse-caller-save-xmm test did, is because they test for the absence of
 specific cfi directives, which will always pass if no cfi directives are
 generated. So I've removed the cfi directive checks (and removed superfluous
 mains) and added tests on instructions.


 Tested with -m32 and -m64.

 OK for trunk?

This is OK.

Thanks,
Uros.


Re: [PATCH, i386, PR61827] Fix fuse-caller-save-xmm.c test-case

2014-07-21 Thread Tom de Vries

On 21-07-14 12:40, Uros Bizjak wrote:

On Mon, Jul 21, 2014 at 12:34 PM, Tom de Vries tom_devr...@mentor.com wrote:


Dominique noticed that the .LC0 check failed on darwin, since the label LC0
is used. This follow-up patch fixes that (and I see now you already Ok-ed
this change).

Furthermore, I've realized from the comments in the PR that for
solaris/sun-as and darwin no cfi directives are generated. There are two
other i386 fuse-caller-save tests which test cfi directives. The reason
these tests aren't failing for solaris/sun-as and darwin like the
fuse-caller-save-xmm test did, is because they test for the absence of
specific cfi directives, which will always pass if no cfi directives are
generated. So I've removed the cfi directive checks (and removed superfluous
mains) and added tests on instructions.


Tested with -m32 and -m64.

OK for trunk?


This is OK.



Dominique noticed a symbol matching problem on darwin for 
fuse-caller-save-rec.c.

I've committed this followup patch that fixes that problem.

Thanks,
- Tom

2014-07-21  Tom de Vries  t...@codesourcery.com

	PR target/61827
	* gcc.target/i386/fuse-caller-save-rec.c: Allow underscore prefix to bar
	symbol in scan-assembler-times call check.

diff --git a/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c b/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c
index d1441bc..a0fcf9c 100644
--- a/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c
+++ b/gcc/testsuite/gcc.target/i386/fuse-caller-save-rec.c
@@ -26,5 +26,4 @@ foo (int y)
 /* { dg-final { scan-assembler-times addl\t%\[re\]?dx, %\[re\]?ax 1 } } */
 
 /* Verify that bar is self-recursive.  */
-/* { dg-final { scan-assembler-times call\tbar 2 } } */
-
+/* { dg-final { scan-assembler-times call\t_?bar 2 } } */


Re: Patch for constexpr variable templates

2014-07-21 Thread Ed Smith-Rowland

Braden,

I've played with this and it seems to work nicely.
Only one comment:  Could you put the test cases in the C++14 subdirectory?

g++.dg/template/cpp1y/var-templ1.C

^
We should CC Jason on all this.

Also, do you have your FSF paperwork in place?

Thanks,

Ed



Re: [GSoC] generation of Gimple code from isl_ast_node_user

2014-07-21 Thread Tobias Grosser

On 21/07/2014 12:25, Roman Gareev wrote:

I've asked the community about this.

The patch below contains the FIXME.


LGTM. Feel free to commit.

Thanks,
Tobias



Re: PR 60414: Patch proposal

2014-07-21 Thread Dominique d'Humières

Le 21 juil. 2014 à 15:03, Andre Vehreschild ve...@gmx.de a écrit :

 Hi Dominique,
 
 thank you very much for your comments. I really appreciate them.

;-)

 Unfortunately I am contracted only for a limited number of around 6 bugs. The
 control on which bugs to pick is done by compiling a project and resolving the
 bugs that occur in order of their appearance.

If so, you should resolve (with your client) the legal issues as soon as 
possible.

 I have reworked the test:
 
 - results are now checked automatically against their expected value, and
 - unexpected results lead to an abort.
 
 I hope this will do. The test for sure can be made more elegant, but my 
 Fortran
 is to limited for that. I consider it pays more to invest my time into 
 resolving
 bugs, then into writing most elegant test. What do you think?

The test is fine with me (I have regtested it). You don’t need the line

+! { dg-final { cleanup-modules m } }

This is done automatically by the gfortran testing machinery (I have checked 
it).

 The comment in interface.c is changed to:
 
  /* Only check ranks compatibility, when the actual argument is not a
 reference of an array (foo(i)). A reference into an array is assumed
 when actual-ref is non null. */
  if (actual-ts.type == BT_CLASS  CLASS_DATA (actual)-as
 !actual-ref
CLASS_DATA (actual)-as-rank == symbol_rank (formal))
return 1;

Although English is not my native language, I would prefer

/* Check ranks compatibility only when the actual argument is not a
   a reference to an element of the array, i.e., when actual-ref is null. */

Someone else should give you the formal approval.

Thanks for the patch,

Dominique

 The complete patch with the changes advised is attached in pr60414_3.patch.
 
 Again, Bootstrapped and regextested on x86_64-unknown-linux-gnu w/o any
 regressions.
 
 Regards,
   Andre
 -- 
 Andre Vehreschild * Kreuzherrenstr. 8 * 52062 Aachen
 Tel.: +49 241 9291018 * Email: ve...@gmx.de 
 pr60414_3.patch



[PATCH] gcc/toplev.c: Avoid to close 'asm_out_file' when it is 'stdout'

2014-07-21 Thread Chen Gang
'asm_out_file' may be 'stdout', so need check this case before close it.
Or 'stdout' may be closed -- since need not open 'stdout', either need
not close it.

ChangLog:

  * topleve.c (finalize): Avoid to close 'asm_out_file' when it is
  'stdout'.

Signed-off-by: Chen Gang gang.chen.5...@gmail.com
---
 gcc/toplev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/toplev.c b/gcc/toplev.c
index 1c9befd..5fc11ae 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1878,7 +1878,7 @@ finalize (bool no_backend)
 {
   if (ferror (asm_out_file) != 0)
fatal_error (error writing to %s: %m, asm_file_name);
-  if (fclose (asm_out_file) != 0)
+  if (asm_out_file != stdout  fclose (asm_out_file) != 0)
fatal_error (error closing %s: %m, asm_file_name);
 }
 
-- 
1.7.11.7


Re: [PATCH v3 3/3] Port libstdc++ pretty-printers to Python 2 + Python 3

2014-07-21 Thread Tom Tromey
 Samuel == Samuel Bronson naes...@gmail.com writes:

Samuel +# FIXME: The handling of e.g. std::basic_string (at least on char)
Samuel +# probably needs updating to work with Python 3's new string rules.
Samuel +#
Samuel +# In particular, Python 3 has a separate type (called byte) for
Samuel +# bytestrings, and a special b syntax for the byte literals; the old
Samuel +# str() type has been redefined to always store Unicode text.
Samuel +#
Samuel +# We probably can't do much about this until GDB get their act
Samuel +# together: https://sourceware.org/bugzilla/show_bug.cgi?id=17138

I don't think this comment is applicable.
The libstdc++ pretty-printers use gdb.Value.lazy_string, not the
built-in Python types.

Tom


[PATCH, PR61776] verify_flow_info failed: control flow in the middle of basic block with -fprofile-generate

2014-07-21 Thread Wei Mi
Hi,

This patch is to fix:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61776

It records func decls whose const/pure flags are reset during
instrumentation. After the loop resetting const/pure flags, find out
stmts calling those recorded funcs and perform cfg fixup on them.

bootstrap and regression test pass on x86_64-linux-gnu. ok for trunk
and gcc-4_9?

Thanks,
Wei.

ChangeLog:

2014-07-21  Wei Mi  w...@google.com

PR middle-end/61776
* tree-profile.c (tree_profiling): Fix cfg after the const/pure
flags of some funcs are reset after instrumentation.

2014-07-21  Wei Mi  w...@google.com

PR middle-end/61776
* testsuite/gcc.dg/pr61776.c: New test.

Index: tree-profile.c
===
--- tree-profile.c  (revision 212442)
+++ tree-profile.c  (working copy)
@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3.
 #include target.h
 #include tree-cfgcleanup.h
 #include tree-nested.h
+#include pointer-set.h

 static GTY(()) tree gcov_type_node;
 static GTY(()) tree tree_interval_profiler_fn;
@@ -562,6 +563,9 @@ static unsigned int
 tree_profiling (void)
 {
   struct cgraph_node *node;
+  int i;
+  struct pointer_set_t *modified_constpure_decls;
+  vecgimple modified_constpure_stmts;

   /* This is a small-ipa pass that gets called only once, from
  cgraphunit.c:ipa_passes().  */
@@ -603,6 +607,9 @@ tree_profiling (void)
   pop_cfun ();
 }

+  modified_constpure_decls = pointer_set_create ();
+  modified_constpure_stmts.create (0);
+
   /* Drop pure/const flags from instrumented functions.  */
   FOR_EACH_DEFINED_FUNCTION (node)
 {
@@ -615,6 +622,11 @@ tree_profiling (void)
   if (DECL_SOURCE_LOCATION (node-decl) == BUILTINS_LOCATION)
continue;

+  /* If the const/pure flag of node is about to change, record
+node-decl in modified_constpure_decls.  */
+  if (DECL_PURE_P (node-decl) || TREE_READONLY (node-decl))
+   pointer_set_insert (modified_constpure_decls, node-decl);
+
   cgraph_set_const_flag (node, false, false);
   cgraph_set_pure_flag (node, false, false);
 }
@@ -623,6 +635,7 @@ tree_profiling (void)
   FOR_EACH_DEFINED_FUNCTION (node)
 {
   basic_block bb;
+  gimple stmt;

   if (!gimple_has_body_p (node-decl)
  || !(!node-clone_of
@@ -642,10 +655,29 @@ tree_profiling (void)
{
  gimple stmt = gsi_stmt (gsi);
  if (is_gimple_call (stmt))
-   update_stmt (stmt);
+   {
+ tree decl = gimple_call_fndecl(stmt);
+ if (decl  pointer_set_contains (modified_constpure_decls,
+   decl))
+   modified_constpure_stmts.safe_push (stmt);
+ update_stmt (stmt);
+   }
}
}

+  /* The const/pure flag of the decl of call stmt in
modified_constpure_stmts
+is changed because of instrumentation. Split block if the
call stmt is not
+the last stmt of bb and the call stmt ends bb.  */
+  FOR_EACH_VEC_ELT (modified_constpure_stmts, i, stmt)
+   {
+ basic_block bb = gimple_bb (stmt);
+
+ if (stmt != gsi_stmt (gsi_last_bb (bb))
+  stmt_ends_bb_p (stmt))
+   split_block (bb, stmt);
+   }
+  modified_constpure_stmts.release ();
+
   /* re-merge split blocks.  */
   cleanup_tree_cfg ();
   update_ssa (TODO_update_ssa);
@@ -657,6 +689,7 @@ tree_profiling (void)

   handle_missing_profiles ();

+  pointer_set_destroy (modified_constpure_decls);
   del_node_map ();
   return 0;
 }
Index: testsuite/gcc.dg/pr61776.c
===
--- testsuite/gcc.dg/pr61776.c  (revision 0)
+++ testsuite/gcc.dg/pr61776.c  (revision 0)
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options -O2 -fprofile-generate } */
+
+#include setjmp.h
+
+int cond1, cond2;
+
+int goo() __attribute__((noinline));
+
+int goo() {
+ if (cond1)
+   return 1;
+ else
+   return 2;
+}
+
+jmp_buf env;
+int foo() {
+ int a;
+
+ setjmp(env);
+ if (cond2)
+   a = goo();
+ else
+   a = 3;
+ return a;
+}


Re: [PATCH, PR61776] verify_flow_info failed: control flow in the middle of basic block with -fprofile-generate

2014-07-21 Thread Wei Mi
By the way, the resetting of const/pure flags loop is also executed
during profile-use, but if there is no instrumentation, the reset is
unnecessary. The flags are kept until pass_ipa_pure_const fixes them.
And because of non-instantaneous ssa update,  the fixes are reflected
on ssa only after ipa passes finish.

If it is agreed that this is a problem, I will address the
conservativeness in a separate patch.

Regards,
Wei.


[PATCH, libffi, alpha]: Use FFI_ASSERT in ffi_closure_osf_inner

2014-07-21 Thread Uros Bizjak
Hello!

Attached patch fixes libgo reflect test failure with libffi closures.
The gccgo compiler started to use FFI closures recently; the compiler
passes ffi_type_void for structures with zero members.

ffi_call form src/alpha/ffi.c allows FFI_TYPE_VOID arguments in
non-debug mode through the default: case, but ffi_closure_osf_inner
aborts with this type of argument.

The patch changes the default case in ffi_closure_osf_inner from abort
to FFI_ASSERT, an this way synchronizes argument handling in both
cases.

2014-07-21  Uros Bizjak  ubiz...@gmail.com

* src/alpha/ffi.c: Do not include stdlib.h.
(ffi_closure_osf_inner) default: Use FFI_ASSERT instead of abort.

Patch was tested with libffi testsuite on alphaev6-linux-gnu.
Additionally, the patch fixed reflect test from the libgo testsuite
and go.test/test/recover.go test from the gcc testsuite.

Uros.
Index: src/alpha/ffi.c
===
--- src/alpha/ffi.c (revision 212882)
+++ src/alpha/ffi.c (working copy)
@@ -27,7 +27,6 @@
 
 #include ffi.h
 #include ffi_common.h
-#include stdlib.h
 
 /* Force FFI_TYPE_LONGDOUBLE to be different than FFI_TYPE_DOUBLE;
all further uses in this file will refer to the 128-bit type.  */
@@ -273,7 +272,7 @@ ffi_closure_osf_inner(ffi_closure *closure, void *
  break;
 
default:
- abort ();
+ FFI_ASSERT (0);
}
 
   argn += ALIGN(size, FFI_SIZEOF_ARG) / FFI_SIZEOF_ARG;


[PATCH v2] RTEMS: Add multilibs for ARM

2014-07-21 Thread Sebastian Huber
This change is necessary to support Cortex-M4 and Cortex-R based chips
in RTEMS.

This patch should be applied to GCC 4.8, 4.9 and mainline.  I do not
have write access, so in case this gets approved, please commit it for
me.

gcc/ChangeLog
2014-07-21  Sebastian Huber  sebastian.hu...@embedded-brains.de

* config/arm/t-rtems-eabi: Add
mthumb/march=armv7-r/mfpu=vfpv3-d16/mfloat-abi=hard,
mthumb/march=armv7-m/mfpu=fpv4-sp-d16/mfloat-abi=hard,
mbig-endian/mthumb/march=armv7-r, and
mbig-endian/mthumb/march=armv7-r/mfpu=vfpv3-d16/mfloat-abi=hard
multilibs.
---
 gcc/config/arm/t-rtems-eabi | 124 +++-
 1 file changed, 122 insertions(+), 2 deletions(-)

diff --git a/gcc/config/arm/t-rtems-eabi b/gcc/config/arm/t-rtems-eabi
index d81fbf7..92c4dcb 100644
--- a/gcc/config/arm/t-rtems-eabi
+++ b/gcc/config/arm/t-rtems-eabi
@@ -1,47 +1,167 @@
 # Custom RTEMS EABI multilibs
 
-MULTILIB_OPTIONS  = mthumb 
march=armv6-m/march=armv7-a/march=armv7-r/march=armv7-m mfpu=neon 
mfloat-abi=hard
-MULTILIB_DIRNAMES = thumb armv6-m armv7-a armv7-r armv7-m neon hard
+MULTILIB_OPTIONS  = mbig-endian mthumb 
march=armv6-m/march=armv7-a/march=armv7-r/march=armv7-m 
mfpu=neon/mfpu=vfpv3-d16/mfpu=fpv4-sp-d16 mfloat-abi=hard
+MULTILIB_DIRNAMES = eb thumb armv6-m armv7-a armv7-r armv7-m neon vfpv3-d16 
fpv4-sp-d16 hard
 
 # Enumeration of multilibs
 
 MULTILIB_EXCEPTIONS =
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv6-m/mfpu=neon/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv6-m/mfpu=neon
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv6-m/mfpu=vfpv3-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv6-m/mfpu=vfpv3-d16
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv6-m/mfpu=fpv4-sp-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv6-m/mfpu=fpv4-sp-d16
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv6-m/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv6-m
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv7-a/mfpu=neon/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-a/mfpu=neon
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv7-a/mfpu=vfpv3-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-a/mfpu=vfpv3-d16
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv7-a/mfpu=fpv4-sp-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-a/mfpu=fpv4-sp-d16
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-a/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-a
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv7-r/mfpu=neon/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-r/mfpu=neon
+# MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv7-r/mfpu=vfpv3-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-r/mfpu=vfpv3-d16
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv7-r/mfpu=fpv4-sp-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-r/mfpu=fpv4-sp-d16
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-r/mfloat-abi=hard
+# MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-r
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv7-m/mfpu=neon/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-m/mfpu=neon
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv7-m/mfpu=vfpv3-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-m/mfpu=vfpv3-d16
+MULTILIB_EXCEPTIONS += 
mbig-endian/mthumb/march=armv7-m/mfpu=fpv4-sp-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-m/mfpu=fpv4-sp-d16
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-m/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/march=armv7-m
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/mfpu=neon/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/mfpu=neon
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/mfpu=vfpv3-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/mfpu=vfpv3-d16
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/mfpu=fpv4-sp-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/mfpu=fpv4-sp-d16
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/mthumb
+MULTILIB_EXCEPTIONS += mbig-endian/march=armv6-m/mfpu=neon/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/march=armv6-m/mfpu=neon
+MULTILIB_EXCEPTIONS += mbig-endian/march=armv6-m/mfpu=vfpv3-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/march=armv6-m/mfpu=vfpv3-d16
+MULTILIB_EXCEPTIONS += 
mbig-endian/march=armv6-m/mfpu=fpv4-sp-d16/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/march=armv6-m/mfpu=fpv4-sp-d16
+MULTILIB_EXCEPTIONS += mbig-endian/march=armv6-m/mfloat-abi=hard
+MULTILIB_EXCEPTIONS += mbig-endian/march=armv6-m
+MULTILIB_EXCEPTIONS += mbig-endian/march=armv7-a/mfpu=neon/mfloat-abi=hard

[PATCH] Support asan-fixed-shadow-offset in GCC

2014-07-21 Thread Alexey Preobrazhensky
Hi all,

This patch adds support for non-fixed shadow in asan stack instrumentation.

It is required for Kernel AddressSanitizer, as the shadow offset is
not known at the compile time, and the shadow may not be allocated
during the early boot stages.

This option is intended to be triggered by -fsanitize=kernel-address
option, together with enabling instrumentation with calls.

Bootstrappedregtested on x86_64.

Codereview: https://codereview.appspot.com/118040043/

--
Alexey
2014-07-21  Yury Gribov  y.gri...@samsung.com
Alexey Preobrazhensky  pre...@google.com

New asan-fixed-shadow-offset parameter.

gcc/
* asan.c (asan_emit_stack_protection): Add support for new parameter.
* params.def: Define new parameter.
* params.h: Likewise.

gcc/testsuite/
* c-c++-common/asan/no-fixed-shadow-offset.c: New.

Index: gcc/asan.c
===
--- gcc/asan.c  (revision 212896)
+++ gcc/asan.c  (working copy)
@@ -979,6 +979,8 @@
HOST_WIDE_INT *offsets, tree *decls, int length)
 {
   rtx shadow_base, shadow_mem, ret, mem, orig_base, lab;
+  rtx shadow_start = NULL_RTX;
+  rtx skip_prologue_lab = NULL_RTX, skip_epilogue_lab = NULL_RTX;
   char buf[30];
   unsigned char shadow_bytes[4];
   HOST_WIDE_INT base_offset = offsets[length - 1];
@@ -1112,10 +1114,26 @@
   shadow_base = expand_binop (Pmode, lshr_optab, base,
  GEN_INT (ASAN_SHADOW_SHIFT),
  NULL_RTX, 1, OPTAB_DIRECT);
-  shadow_base
-= plus_constant (Pmode, shadow_base,
-targetm.asan_shadow_offset ()
-+ (base_align_bias  ASAN_SHADOW_SHIFT));
+  if (ASAN_FIXED_SHADOW_OFFSET)
+{
+  shadow_base
+= plus_constant (Pmode, shadow_base,
+targetm.asan_shadow_offset ()
++ (base_align_bias  ASAN_SHADOW_SHIFT));
+}
+  else
+{
+  ret = init_one_libfunc (__asan_get_shadow_ptr);
+  shadow_start = gen_reg_rtx (ptr_mode);
+  emit_library_call_value (ret, shadow_start, LCT_NORMAL, ptr_mode, 0);
+  skip_prologue_lab = gen_label_rtx ();
+  emit_cmp_and_jump_insns (shadow_start, const0_rtx, EQ, NULL_RTX, 
VOIDmode,
+  0, skip_prologue_lab, PROB_VERY_UNLIKELY);
+  shadow_base = expand_binop (Pmode, add_optab, shadow_base, shadow_start,
+ NULL_RTX, 1, OPTAB_DIRECT);
+  shadow_base = plus_constant (Pmode, shadow_base,
+  base_align_bias  ASAN_SHADOW_SHIFT);
+}
   gcc_assert (asan_shadow_set != -1
   (ASAN_RED_ZONE_SIZE  ASAN_SHADOW_SHIFT) == 4);
   shadow_mem = gen_rtx_MEM (SImode, shadow_base);
@@ -1165,17 +1183,19 @@
 }
   do_pending_stack_adjust ();
 
+  if (skip_prologue_lab)
+emit_label (skip_prologue_lab);
+
   /* Construct epilogue sequence.  */
   start_sequence ();
 
-  lab = NULL_RTX;  
   if (use_after_return_class != -1)
 {
-  rtx lab2 = gen_label_rtx ();
   char c = (char) ASAN_STACK_MAGIC_USE_AFTER_RET;
   int very_likely = REG_BR_PROB_BASE - (REG_BR_PROB_BASE / 2000 - 1);
+  lab = gen_label_rtx ();
   emit_cmp_and_jump_insns (orig_base, base, EQ, NULL_RTX,
-  VOIDmode, 0, lab2, very_likely);
+  VOIDmode, 0, lab, very_likely);
   shadow_mem = gen_rtx_MEM (BLKmode, shadow_base);
   set_mem_alias_set (shadow_mem, asan_shadow_set);
   mem = gen_rtx_MEM (ptr_mode, base);
@@ -1204,11 +1224,19 @@
 TYPE_MODE (pointer_sized_int_node),
 orig_addr, ptr_mode);
}
-  lab = gen_label_rtx ();
-  emit_jump (lab);
-  emit_label (lab2);
+  skip_epilogue_lab = gen_label_rtx ();
+  emit_jump (skip_epilogue_lab);
+  emit_label (lab);
 }
 
+  if (!ASAN_FIXED_SHADOW_OFFSET)
+{
+  if (!skip_epilogue_lab)
+   skip_epilogue_lab = gen_label_rtx ();
+  emit_cmp_and_jump_insns (shadow_start, const0_rtx, EQ, NULL_RTX, 
VOIDmode,
+  0, skip_epilogue_lab, PROB_VERY_UNLIKELY);
+}
+
   shadow_mem = gen_rtx_MEM (BLKmode, shadow_base);
   set_mem_alias_set (shadow_mem, asan_shadow_set);
 
@@ -1245,9 +1273,10 @@
 }
 
   do_pending_stack_adjust ();
-  if (lab)
-emit_label (lab);
 
+  if (skip_epilogue_lab)
+emit_label (skip_epilogue_lab);
+
   ret = get_insns ();
   end_sequence ();
   return ret;
Index: gcc/params.def
===
--- gcc/params.def  (revision 212896)
+++ gcc/params.def  (working copy)
@@ -1081,6 +1081,11 @@
   in function becomes greater or equal than this threshold,
  1, 0, INT_MAX)
 
+DEFPARAM (PARAM_ASAN_FIXED_SHADOW_OFFSET,
+ asan-fixed-shadow-offset,
+ Use fixed offset of shadow memory region,
+  

Re: [PATCH, rs6000, 4.8] Fix many powerpc*-linux ASAN test suite failures

2014-07-21 Thread Peter Bergner
On Fri, 2014-07-18 at 17:53 +0200, Jakub Jelinek wrote:
 On Fri, Jul 18, 2014 at 11:40:31AM -0400, David Edelsohn wrote:
  This patch is okay with me if it is okay with the Release Managers.
 
 Ok.

Ok, I committed this as revision 212899.  Thanks!

Peter




Re: [PATCH, rs6000, 4.9] Fix many powerpc*-linux ASAN test suite failures

2014-07-21 Thread Peter Bergner
On Fri, 2014-07-18 at 17:54 +0200, Jakub Jelinek wrote:
 On Fri, Jul 18, 2014 at 11:38:22AM -0400, David Edelsohn wrote:
  This is okay with me if it is okay with the Release Managers.
 
 Ok.

Ok, I committed this as revision 212898.  Thanks!

Peter




Re: [PATCH] New check and updates in check_GNU_style script

2014-07-21 Thread Sebastian Pop
What about getting clang-format to GNU format instead of improving
this ad-hoc script?
http://clang.llvm.org/docs/ClangFormatStyleOptions.html
http://reviews.llvm.org/D2371

Thanks,
Sebastian

PS: Please do not use my @codeaurora.org email address:
I do not have access to that email anymore.
You can use either my gmail address or the one @samsung.com

On Mon, Jul 21, 2014 at 1:25 AM, Yury Gribov y.gri...@samsung.com wrote:
 Hi all,

 Attached patch adds new check (all blocks of 8 spaces are replaced with
 tabs) to contrib/check_GNU_style.sh. It also changes the script to allow
 reading patches from stdin and improves the Dot, space, space, new
 sentence. check.

 -Y


Re: Patch for constexpr variable templates

2014-07-21 Thread Braden Obrzut

Sure, test cases moved.

My FSF paperwork is in place.  I don't have write access to the 
repository though of course.


- Braden Obrzut

2014-07-21  Braden Obrzut  ad...@maniacsvault.net

* decl.c (grokvardecl): Handle specializations of variable templates.
(grokdeclarator): Handle variable template id expressions.
* decl2.c (check_member_template): Allow declaration of template member
variables.
(grokfield): Assign class context to template member variables in order
that variable_template_p to detect them properly.
* parser.c (cp_parser_postfix_expression): Resolve VAR_DECLs from
TEMPLATE_ID_EXPRs.
(cp_parser_template_id): Build a TEMPLATE_ID_EXPR for variable 
templates.

* pt.c (register_specialization): Accept variable templates.
(determine_specialization): Accept variable templates.
(check_template_variable): Fixed wanted template header count.
(lookup_template_variable): New.
(do_decl_instantiation): Handle templat variables.
(instantiate_decl): Handle template variables.
* semantics.c (finish_template_variable): New.

2014-07-21  Braden Obrzut  ad...@maniacsvault.net

* g++.dg/cpp1y/var-templ1.C: New.
* g++.dg/cpp1y/var-templ2.C: New.
* g++.dg/cpp1y/var-templ3.C: New.
* g++.dg/cpp1y/var-templ4.C: New.
* g++.dg/cpp1y/var-templ5.C: New.

2013-03-29  Gabriel Dos Reis  g...@integrable-solutions.net

* cp-tree.h (variable_template_p): Do not check scope.
* pt.c (check_template_variable): Fix thinko from previous change.
(push_template_decl_real): Fix formatting.


2013-03-29  Gabriel Dos Reis  g...@integrable-solutions.net

* cp-tree.h (variable_template_p): New.
* pt.c (check_template_variable): Accept variable temploids at
non-class scope.
(push_template_decl_real): The current instantiation of a template
can be a VAR_DECL.

On 07/21/2014 07:39 AM, Ed Smith-Rowland wrote:

Braden,

I've played with this and it seems to work nicely.
Only one comment:  Could you put the test cases in the C++14 
subdirectory?


g++.dg/template/cpp1y/var-templ1.C

^
We should CC Jason on all this.

Also, do you have your FSF paperwork in place?

Thanks,

Ed



diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 4a5cb98..c6c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5027,6 +5027,17 @@ class_of_this_parm (const_tree fntype)
   return TREE_TYPE (type_of_this_parm (fntype));
 }
 
+/* True if T designates a variable template declaration.  */
+inline bool
+variable_template_p (tree t)
+{
+  if (TREE_CODE (t) != TEMPLATE_DECL)
+return false;
+  if (tree r = DECL_TEMPLATE_RESULT (t))
+return VAR_P (r);
+  return false;
+}
+
 /* A parameter list indicating for a function with no parameters,
e.g  int f(void).  */
 extern cp_parameter_declarator *no_parameters;
@@ -5554,6 +5565,7 @@ extern bool redeclare_class_template		(tree, tree);
 extern tree lookup_template_class		(tree, tree, tree, tree,
 		 int, tsubst_flags_t);
 extern tree lookup_template_function		(tree, tree);
+extern tree lookup_template_variable		(tree, tree);
 extern int uses_template_parms			(tree);
 extern int uses_template_parms_level		(tree, int);
 extern bool in_template_function		(void);
@@ -5816,6 +5828,7 @@ extern tree perform_koenig_lookup		(tree, vectree, va_gc *,
 		 tsubst_flags_t);
 extern tree finish_call_expr			(tree, vectree, va_gc **, bool,
 		 bool, tsubst_flags_t);
+extern tree finish_template_variable	(tree);
 extern tree finish_increment_expr		(tree, enum tree_code);
 extern tree finish_this_expr			(void);
 extern tree finish_pseudo_destructor_expr   (tree, tree, tree, location_t);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index dae85c2..0b6fa54 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -80,8 +80,8 @@ static int ambi_op_p (enum tree_code);
 static int unary_op_p (enum tree_code);
 static void push_local_name (tree);
 static tree grok_reference_init (tree, tree, tree, int);
-static tree grokvardecl (tree, tree, const cp_decl_specifier_seq *,
-			 int, int, tree);
+static tree grokvardecl (tree, tree, tree, const cp_decl_specifier_seq *,
+			 int, int, int, tree);
 static int check_static_variable_definition (tree, tree);
 static void record_unknown_type (tree, const char *);
 static tree builtin_function_1 (tree, tree, bool);
@@ -7943,9 +7943,11 @@ set_linkage_for_static_data_member (tree decl)
 static tree
 grokvardecl (tree type,
 	 tree name,
+		 tree orig_declarator,
 	 const cp_decl_specifier_seq *declspecs,
 	 int initialized,
 	 int constp,
+		 int template_count,
 	 tree scope)
 {
   tree decl;
@@ -7975,7 +7977,9 @@ grokvardecl (tree type,
 	  || (TREE_CODE (scope) == NAMESPACE_DECL
 	   current_lang_name != lang_name_cplusplus)
 	  /* Similarly for static data members.  */
-	  || TYPE_P (scope)))
+	  || TYPE_P (scope)
+	  /* Similarly for explicit specializations.  */
+	  || TREE_CODE (orig_declarator) == TEMPLATE_ID_EXPR))

[PATCH] rs6000: fix for PR61396 (wide-int fallout)

2014-07-21 Thread Segher Boessenkool
CONSTANT_P is true for more than just all kinds of constant number.
This patch undoes that part of the wide-int patches.

Bootstrapped and tested on powerpc64-linux, -m64,-m32,-m32/-mpowerpc64.
No regressions (and the testcase mentioned in the PR is fixed, of course).

Okay to apply?


Segher


2014-07-21  Segher Boessenkool  seg...@kernel.crashing.org

gcc/
PR target/61396
* config/rs6000/rs6000.c (paired_expand_vector_init): Only allow
constant numbers, not general constants.
(rs6000_expand_vector_init): Ditto.

---
 gcc/config/rs6000/rs6000.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 4547ae5..682fe42 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -5318,7 +5318,7 @@ paired_expand_vector_init (rtx target, rtx vals)
   for (i = 0; i  n_elts; ++i)
 {
   x = XVECEXP (vals, 0, i);
-  if (!CONSTANT_P (x))
+  if (!(CONST_SCALAR_INT_P (x) || CONST_DOUBLE_P (x) || CONST_FIXED_P (x)))
++n_var;
 }
   if (n_var == 0)
@@ -5470,7 +5470,7 @@ rs6000_expand_vector_init (rtx target, rtx vals)
   for (i = 0; i  n_elts; ++i)
 {
   x = XVECEXP (vals, 0, i);
-  if (!CONSTANT_P (x))
+  if (!(CONST_SCALAR_INT_P (x) || CONST_DOUBLE_P (x) || CONST_FIXED_P (x)))
++n_var, one_var = i;
   else if (x != CONST0_RTX (inner_mode))
all_const_zero = false;
-- 
1.8.1.4



Re: [PATCH] Support asan-fixed-shadow-offset in GCC

2014-07-21 Thread Yury Gribov

On 07/21/2014 11:00 PM, Alexey Preobrazhensky wrote:

This patch adds support for non-fixed shadow in asan stack instrumentation.


We probably also need to support non-fixed shadow in the middle-end
(the patch only implements it for RTL stack poisoner).

-Y


Re: [PATCH] New check and updates in check_GNU_style script

2014-07-21 Thread Yury Gribov

On 07/22/2014 02:24 AM, Sebastian Pop wrote:

What about getting clang-format to GNU format instead of improving
this ad-hoc script?


Well, GNU support in clang-format seems to be at it's early days
so improving diagnostic in check_GNU_style does not seem to be totally 
useless.


In general clang-format is probably more capable than simple regexes 
that we have.

BTW can it format patches (i.e. incomplete pieces of code)?

-Y