Re: [PATCH] Simplify -fwhole-program documentation

2013-03-07 Thread Richard Biener
On Wed, 6 Mar 2013, Jan Hubicka wrote:

> > 
> > This removes all encouragement to use -fwhole-program with -flto
> > from the documentation.  As can be seen in PR56533 it can be
> > most confusing ... instead advise to rely on a linker plugin.
> > 
> > Ok?
> 
> Seems resomable thing to do. However I guess a lot of users are still
> have non-linker-plugin enabled setup.  Perhaps we can add a sentence how
> to figure out if your setup is plugin enabled and thus working well
> w/o -fwhole-program?

Do you know one?  Apart from 'gcc -flto ... -v 2>&1 | grep -- 
-fresolution'?

;)

I've installed the patch for now.

Richard.


Re: Convert arm-rtems to EABI on 4.6 and 4.7 branches

2013-03-07 Thread Eric Botcazou
> We would like to get the 4.7 patch applied so arm-rtems is not obsolete.
> 
> If there are any hints of a plan to release another 4.6 version, we would
> like to apply a patch to that branch to switch from arm-elf to arm-eabi
> as our foundation.

Please adjust the ChangeLog entry on the branches, putting 2013-02-22 for a 
patch installed on 2013-03-06 doesn't make much sense.  There is an example 
just below on the 4.7 branch.  TIA.

-- 
Eric Botcazou


Re: [patch] minor bitmap.c GATHER_STATISTICS fix-ups

2013-03-07 Thread Richard Biener
On Thu, Mar 7, 2013 at 12:04 AM, Steven Bosscher  wrote:
> Hello,
>
> This patch fixes a bunch of smaller issues with GATHER_STATISTICS for
> bitmaps: overflows in counters and ugly output format.
>
> Bootstrapped (with and without GATHER_STATISTICS) and regtested on
> powerpc64-unknown-linux-gnu and on x86_64-unknown-linux-gnu. OK for
> trunk?

Ok.

Thanks,
Richard.

> Ciao!
> Steven
>
>
> * bitmap.c (struct bitmap_descriptor_d): Use unsigned HOST_WIDEST_INT
> for all counters.
> (struct output_info): Likewise.
> (register_overhead): Remove bad gcc_assert.
> (bitmap_find_bit): If there is only a single bitmap element, do not
> count a miss as a search.
> (print_statistics): Update for counter type changes.
> (dump_bitmap_statistics): Likewise.  Print headers such that they
> are properly lined up with the printed counters.


Re: [patch testsuite]: Fix some tests for LLP64 targets

2013-03-07 Thread Andreas Schwab
Committed.

Andreas.

* gcc.dg/pr31490.c: Fix last change.

diff --git a/gcc/testsuite/gcc.dg/pr31490.c b/gcc/testsuite/gcc.dg/pr31490.c
index 396ec26..37731b3 100644
--- a/gcc/testsuite/gcc.dg/pr31490.c
+++ b/gcc/testsuite/gcc.dg/pr31490.c
@@ -7,4 +7,4 @@ __extension__ typedef __UINTPTR_TYPE__ uintptr_t;
 
 int cpu (void *attr) {}
 const uintptr_t x __attribute__((section("foo"))) =  (uintptr_t)&cpu;
-const uintptr g __attribute__((section("foo"))) = 0;
+const uintptr_t g __attribute__((section("foo"))) = 0;
-- 
1.8.1.5

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


Re: [Patch, libfortran, 2nd version] PR 48618 - Negative unit number in OPEN(...) is sometimes allowed

2013-03-07 Thread Tilo Schwarz

Hi,

this patch fixes PR 48618.

Built and regtested on Linux 3.2.0-4-686-pae.

Thanks for input and corrections to Tobias Burnus.


Regards,

Tilodiff --git a/gcc/testsuite/gfortran.dg/open_negative_unit_1.f90 b/gcc/testsuite/gfortran.dg/open_negative_unit_1.f90
new file mode 100644
index 000..6446436
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/open_negative_unit_1.f90
@@ -0,0 +1,21 @@
+! { dg-do run }
+! PR48618 - Negative unit number in OPEN(...) is sometimes allowed
+!
+! Test originally from Janne Blomqvist in PR:
+! http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48618
+
+program nutest
+implicit none
+integer id, ios
+
+open(newunit=id, file="foo.txt", iostat=ios)
+if (ios /= 0) call abort
+
+open(id, file="bar.txt", iostat=ios)
+if (ios /= 0) call abort
+
+close(id, status="delete")
+
+open(-10, file="foo.txt", iostat=ios)
+if (ios == 0) call abort
+end program nutest
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 54ac573..f8e3f52 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2013-03-06  Tilo Schwarz  
+
+	PR libfortran/48618
+	* io/open.c (st_open): Raise error for unit number < 0 only if
+	unit number does not exist already.
+
 2013-02-21  Janne Blomqvist  
 
 	PR libfortran/30162
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index d9cfde8..df4808e 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -818,10 +818,6 @@ st_open (st_parameter_open *opp)
 
   flags.convert = conv;
 
-  if (!(opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT) && opp->common.unit < 0)
-generate_error (&opp->common, LIBERROR_BAD_OPTION,
-		"Bad unit number in OPEN statement");
-
   if (flags.position != POSITION_UNSPECIFIED
   && flags.access == ACCESS_DIRECT)
 generate_error (&opp->common, LIBERROR_BAD_OPTION,
@@ -841,6 +837,18 @@ st_open (st_parameter_open *opp)
   flags.position = POSITION_APPEND;
 }
 
+  if (!(opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT) && opp->common.unit < 0)
+{
+  u = find_unit (opp->common.unit);
+  if (u == NULL) /* negative unit and no unit found */
+generate_error (&opp->common, LIBERROR_BAD_OPTION,
+"Bad unit number in OPEN statement");
+  /* check for previous error, otherwise unit won't be unlocked later */
+  else if ((opp->common.flags & IOPARM_LIBRETURN_MASK)
+	   != IOPARM_LIBRETURN_OK)
+	 unlock_unit (u);
+}
+
   if (flags.position == POSITION_UNSPECIFIED)
 flags.position = POSITION_ASIS;
 
@@ -849,7 +857,8 @@ st_open (st_parameter_open *opp)
   if ((opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT))
 	opp->common.unit = get_unique_unit_number(opp);
 
-  u = find_or_create_unit (opp->common.unit);
+  if (u == NULL)
+u = find_or_create_unit (opp->common.unit);
   if (u->s == NULL)
 	{
 	  u = new_unit (opp, u, &flags);


[PATCH] Fix -print-multi-os-directory for aarch64

2013-03-07 Thread Jakub Jelinek
Hi!

AFAIK aarch64 libraries are supposed to go into /usr/lib64 etc.
directories similarly to x86-64 etc., but as aarch64 isn't a true
multilib target (having two different backends for 32-bit vs. 64-bit code),
currently gcc -print-multi-os-directory prints . instead of ../lib64.

The following patch fixes that.  As for --disable-multilib purposes
gcc.c does:
  /* When --disable-multilib was used but target defines
 MULTILIB_OSDIRNAMES, entries starting with .: (and not starting
 with .:: for multiarch configurations) are there just to find
 multilib_os_dir, so skip them from output.  */
  if (this_path[0] == '.' && this_path[1] == ':' && this_path[2] != ':')
skip = 1;
we need to actually emit
static const char *const multilib_raw[] = {
". ;",
".:../lib64 ;",
NULL
};
for --disable-multiarch resp.
static const char *const multilib_raw[] = {
". ;",
".:../lib64:aarch64-linux-gnu ;",
NULL
};
for --enable-multiarch.  Tested (with cross compiler) configured with
--target aarch64-linux --enable-languages=c {,--disable-multilib} 
{,--enable-multarch}
(all 4 combinations) and output of all
./xgcc -B ./ --print-{multiarch,multi-lib,multi-directory,multi-os-directory}
looks good to me with it (i.e. as before the patch, except
--print-multi-so-directory prints ../lib64 instead of . previously.

Ok for trunk?

2013-03-07  Jakub Jelinek  

* config/aarch64/t-aarch64-linux (MULTARCH_DIRNAME): Remove.
(MULTILIB_OSDIRNAMES): Set.
* genmultilib: If defaultosdirname doesn't start with :: , set
defaultosdirname2 instead, clear it and emit two . multilib_raw
entries instead of just one.

--- gcc/config/aarch64/t-aarch64-linux.jj   2013-01-11 09:03:10.0 
+0100
+++ gcc/config/aarch64/t-aarch64-linux  2013-03-07 11:23:07.602568188 +0100
@@ -22,4 +22,4 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
 LIB1ASMFUNCS = _aarch64_sync_cache_range
 
 AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
-MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+MULTILIB_OSDIRNAMES = .=../lib64$(call 
if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
--- gcc/genmultilib.jj  2013-01-13 13:23:38.0 +0100
+++ gcc/genmultilib 2013-03-07 11:35:22.881982721 +0100
@@ -267,6 +267,7 @@ fi
 # names.
 toosdirnames=
 defaultosdirname=
+defaultosdirname2=
 if [ -n "${multiarch}" ]; then
   defaultosdirname=::${multiarch}
 fi
@@ -280,6 +281,13 @@ if [ -n "${osdirnames}" ]; then
if [ -n "${multiarch}" ]; then
  defaultosdirname=${defaultosdirname}:${multiarch}
fi
+   case "$defaultosdirname" in
+ ::*) ;;
+ *)
+   defaultosdirname2=${defaultosdirname}
+   defaultosdirname=
+   ;;
+   esac
shift
;;
   *=*)
@@ -352,6 +360,7 @@ for set in ${options}; do
 done
 optout=`echo ${optout} | sed -e 's/^ //'`
 echo "\".${defaultosdirname} ${optout};\","
+[ -n "${defaultosdirname2}" ] && echo "\".${defaultosdirname2} ${optout};\","
 
 # This part of code convert an option combination to
 # its corresponding directory names.

Jakub


Re: [Patch, libfortran, 2nd version] PR 48618 - Negative unit number in OPEN(...) is sometimes allowed

2013-03-07 Thread Tobias Burnus

Hi,

Tilo Schwarz wrote:

this patch fixes PR 48618.
Built and regtested on Linux 3.2.0-4-686-pae.


Thanks for the patch, which mostly looks okay.

A few remarks:

* Do not create a diff of the ChangeLog but include it separately at the 
top of the patch. Reason: It's easier to read and if another patch has 
been applied before, your patch won't apply.


* A ChangeLog for the testcase is missing.


* Coding style: If 8 spaces have accumulated, replace them by one tab, i.e.
-  u = find_or_create_unit (opp->common.unit);
+  if (u == NULL)
+u = find_or_create_unit (opp->common.unit);

Here, the last line should use a "tab". (The other important rule is to 
have maximally 80 character per source line.)


See also http://gcc.gnu.org/wiki/FormattingCodeForGCC

(Consistent coding styles makes it easier to read the code. The style 
might not always the best or to the personal taste, but still 
consistency helps. For instance, function names always start in column 1 
and have a " " before the "(". Hence, one can do "grep '^funcname ' *.c 
to find the function.)




* Comment style:
+  if (u == NULL) /* negative unit and no unit found */
+generate_error (&opp->common, LIBERROR_BAD_OPTION,
+"Bad unit number in OPEN statement");
+  /* check for previous error, otherwise unit won't be unlocked 
later */


To quote the comment style from 
http://www.gnu.org/prep/standards/html_node/Comments.html:


"Please put two spaces after the end of a sentence in your comments, so 
that the Emacs sentence commands will work. Also, please write complete 
sentences and capitalize the first word. If a lower-case identifier 
comes at the beginning of a sentence, don’t capitalize it! Changing the 
spelling makes it a different identifier. If you don’t like starting a 
sentence with a lower case letter, write the sentence differently (e.g., 
“The identifier lower-case is …”)."


(The existing code does not always follow the style, but one should at 
least try, even if there is some leeway ;-)



* Regarding your patch itself. I think it is easier to read if one moves 
the code a bit further down as I did in the attachment. What do you think?



* Copyright assignment: You mentioned that you have emailed(§) the form 
back to the FSF. Was this the actual copyright-assignment form which the 
FSF sent to you by mail? Or was it 'only' request form? Can you tell us, 
when the FSF has acknowledged the arrival of the copyright assignment?



Tobias


(§) Side note: The FSF now also allows to send the copyright form back 
by FAX or (scanned) by email, but only if you are residing in the USA or 
in Germany. Residents of other countries still have to return it by 
(air,surface) mail. Cf. 
http://www.gnu.org/prep/maintain/html_node/Copyright-Papers.html
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index d9cfde8..19fab1d 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -817,12 +817,8 @@ st_open (st_parameter_open *opp)
 }
 
   flags.convert = conv;
 
-  if (!(opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT) && opp->common.unit < 0)
-generate_error (&opp->common, LIBERROR_BAD_OPTION,
-		"Bad unit number in OPEN statement");
-
   if (flags.position != POSITION_UNSPECIFIED
   && flags.access == ACCESS_DIRECT)
 generate_error (&opp->common, LIBERROR_BAD_OPTION,
 		"Cannot use POSITION with direct access files");
@@ -847,10 +843,18 @@ st_open (st_parameter_open *opp)
   if ((opp->common.flags & IOPARM_LIBRETURN_MASK) == IOPARM_LIBRETURN_OK)
 {
   if ((opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT))
 	opp->common.unit = get_unique_unit_number(opp);
+  else if (opp->common.unit < 0)
+	{
+	  u = find_unit (opp->common.unit);
+	  if (u == NULL) /* Negative unit and no NEWUNIT-created unit found.  */
+	generate_error (&opp->common, LIBERROR_BAD_OPTION,
+			"Bad unit number in OPEN statement");
+	}
 
-  u = find_or_create_unit (opp->common.unit);
+  if (u == NULL)
+	u = find_or_create_unit (opp->common.unit);
   if (u->s == NULL)
 	{
 	  u = new_unit (opp, u, &flags);
 	  if (u != NULL)


[PATCH] track heap usage with -fmem-report

2013-03-07 Thread Richard Biener

This hacky patch tracks per-pass heap usage with -fmem-report
using glibc malloc hooks (which are deprecated!?  eh ...  I can
see no replacement?)

Still somewhat broken accounting for the overall numbers
(and peak memory use, that is).

But it's a start.  And it uses internal glibc allocator
implementation details ... (eh).  At least it's low-overhead.

FYI,
Richard.


Index: gcc/toplev.c
===
*** gcc/toplev.c(revision 196517)
--- gcc/toplev.c(working copy)
*** along with GCC; see the file COPYING3.
*** 74,79 
--- 74,80 
  #include "gimple.h"
  #include "tree-ssa-alias.h"
  #include "plugin.h"
+ #include "tree-pass.h"
  
  #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
  #include "dbxout.h"
*** dump_memory_report (bool final)
*** 1783,1788 
--- 1784,1790 
dump_ggc_loc_statistics (final);
dump_alias_stats (stderr);
dump_pta_stats (stderr);
+   dump_pass_memory_stats (stderr);
  }
  
  /* Clean up: close opened files, etc.  */
Index: gcc/tree-pass.h
===
*** gcc/tree-pass.h (revision 196517)
--- gcc/tree-pass.h (working copy)
*** struct opt_pass
*** 78,83 
--- 78,88 
/* Flags indicating common sets things to do before and after.  */
unsigned int todo_flags_start;
unsigned int todo_flags_finish;
+ 
+   size_t alloc_cnt;
+   size_t alloc_sum;
+   size_t alloc_curr;
+   size_t alloc_peak;
  };
  
  /* Description of GIMPLE pass.  */
*** extern void disable_pass (const char *);
*** 557,560 
--- 562,567 
  extern void enable_pass (const char *);
  extern void dump_passes (void);
  
+ extern void dump_pass_memory_stats (FILE *);
+ 
  #endif /* GCC_TREE_PASS_H */
Index: gcc/passes.c
===
*** gcc/passes.c(revision 196517)
--- gcc/passes.c(working copy)
*** along with GCC; see the file COPYING3.
*** 24,29 
--- 24,30 
  
  #include "config.h"
  #include "system.h"
+ #include 
  #include "coretypes.h"
  #include "tm.h"
  #include "line-map.h"
*** bool in_gimple_form;
*** 105,110 
--- 106,245 
  bool first_pass_instance;
  
  
+ struct malloc_chunk_head {
+size_t x;
+size_t size;
+ };
+ typedef struct malloc_chunk_head* mchunkptr;
+ #define mem2chunk(mem) ((mchunkptr)((char*)(mem) - 2*sizeof(size_t)))
+ 
+ static void (*gcc_old_free_hook) (void *ptr, const void *);
+ static void *(*gcc_old_malloc_hook) (size_t size, const void *);
+ static void *(*gcc_old_realloc_hook) (void *ptr, size_t size, const void *);
+ 
+ static void *gcc_malloc_hook (size_t size, const void *caller);
+ static void *gcc_realloc_hook (void *ptr, size_t size, const void *caller);
+ static void gcc_free_hook (void *ptr, const void *caller);
+ 
+ struct opt_pass rest_of_comp;
+ 
+ static void *
+ gcc_malloc_hook (size_t size, const void *caller)
+ {
+   void *res;
+   __malloc_hook = gcc_old_malloc_hook;
+   __realloc_hook = gcc_old_realloc_hook;
+   __free_hook = gcc_old_free_hook;
+   if (gcc_old_malloc_hook != NULL)
+ res = gcc_old_malloc_hook (size, caller);
+   else
+ res = xmalloc (size);
+   __malloc_hook = gcc_malloc_hook;
+   __realloc_hook = gcc_realloc_hook;
+   __free_hook = gcc_free_hook;
+   struct opt_pass *p = current_pass ? current_pass : &rest_of_comp;
+   /* The allocator allocates a chunk >= size.  */
+   size = res ? mem2chunk (res)->size : 0;
+   p->alloc_cnt++;
+   p->alloc_sum += size;
+   p->alloc_curr += size;
+   if ((ssize_t) p->alloc_curr > (ssize_t) p->alloc_peak)
+ p->alloc_peak = p->alloc_curr;
+   return res;
+ }
+ 
+ static void *
+ gcc_realloc_hook (void *ptr, size_t size, const void *caller)
+ {
+   size_t oldsize = ptr ? mem2chunk (ptr)->size : 0;
+   void *res;
+   __malloc_hook = gcc_old_malloc_hook;
+   __realloc_hook = gcc_old_realloc_hook;
+   __free_hook = gcc_old_free_hook;
+   if (gcc_old_realloc_hook != NULL)
+ res = gcc_old_realloc_hook (ptr, size, caller);
+   else
+ res = xrealloc (ptr, size);
+   __malloc_hook = gcc_malloc_hook;
+   __realloc_hook = gcc_realloc_hook;
+   __free_hook = gcc_free_hook;
+   struct opt_pass *p = current_pass ? current_pass : &rest_of_comp;
+   p->alloc_cnt++;
+   p->alloc_sum += (size - oldsize);
+   p->alloc_curr += (size - oldsize);
+   if ((ssize_t) p->alloc_curr > (ssize_t) p->alloc_peak)
+ p->alloc_peak = p->alloc_curr;
+   return res;
+ }
+ 
+ static void
+ gcc_free_hook (void *ptr, const void *caller)
+ {
+   struct opt_pass *p = current_pass ? current_pass : &rest_of_comp;
+   size_t size = ptr ? mem2chunk (ptr)->size : 0;
+   p->alloc_curr -= size;
+   __malloc_hook = gcc_old_malloc_hook;
+   __realloc_hook = gcc_old_realloc_hook;
+   __free_hook = gcc_old_free_hook;
+   if (gcc_old_free_hook != NULL)
+ gcc_old_free_hook (ptr, caller);
+   el

Re: [PATCH] track heap usage with -fmem-report

2013-03-07 Thread Marek Polacek
On Thu, Mar 07, 2013 at 01:59:31PM +0100, Richard Biener wrote:
> 
> This hacky patch tracks per-pass heap usage with -fmem-report
> using glibc malloc hooks (which are deprecated!?  eh ...  I can
> see no replacement?)

The "replacement" is that we should intercept the malloc calls
instead (as those always use PLT).

Marek


Re: [PATCH] track heap usage with -fmem-report

2013-03-07 Thread Richard Biener
On Thu, 7 Mar 2013, Marek Polacek wrote:

> On Thu, Mar 07, 2013 at 01:59:31PM +0100, Richard Biener wrote:
> > 
> > This hacky patch tracks per-pass heap usage with -fmem-report
> > using glibc malloc hooks (which are deprecated!?  eh ...  I can
> > see no replacement?)
> 
> The "replacement" is that we should intercept the malloc calls
> instead (as those always use PLT).

Sure, though that's not as easy to "disable" that instrumentation
(I assume you mean using strong definitions in the GCC executable).
Also you need to instrument more calls (well, calloc ...).

A nicer replacement would be a way to intercept all mmap/munmap/sbrk
syscalls (as my maxmem script does using strace ...).  Possible
with forking ourselves and stracing.  Or maybe with a newer fancy
kernel interface I don't know of.

Anyway, here's a slightly updated version of the patch.

TODO: also print GC peak memory

Richard.

Index: gcc/toplev.c
===
--- gcc/toplev.c.orig   2013-03-07 14:00:15.739543469 +0100
+++ gcc/toplev.c2013-03-07 14:16:56.609723870 +0100
@@ -74,6 +74,7 @@ along with GCC; see the file COPYING3.
 #include "gimple.h"
 #include "tree-ssa-alias.h"
 #include "plugin.h"
+#include "tree-pass.h"
 
 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
 #include "dbxout.h"
@@ -1783,6 +1784,7 @@ dump_memory_report (bool final)
   dump_ggc_loc_statistics (final);
   dump_alias_stats (stderr);
   dump_pta_stats (stderr);
+  dump_pass_memory_stats (stderr);
 }
 
 /* Clean up: close opened files, etc.  */
@@ -1868,7 +1870,9 @@ do_compile (void)
   init_cgraph ();
   init_final (main_input_filename);
   coverage_init (aux_base_name);
-  statistics_init ();
+ statistics_init ();
+ if (mem_report)
+   instrument_malloc ();
   invoke_plugin_callbacks (PLUGIN_START_UNIT, NULL);
 
   timevar_stop (TV_PHASE_SETUP);
Index: gcc/tree-pass.h
===
--- gcc/tree-pass.h.orig2013-03-07 14:00:15.739543469 +0100
+++ gcc/tree-pass.h 2013-03-07 14:16:03.312127130 +0100
@@ -78,6 +78,11 @@ struct opt_pass
   /* Flags indicating common sets things to do before and after.  */
   unsigned int todo_flags_start;
   unsigned int todo_flags_finish;
+
+  size_t alloc_cnt;
+  size_t alloc_sum;
+  size_t alloc_curr;
+  size_t alloc_peak;
 };
 
 /* Description of GIMPLE pass.  */
@@ -557,4 +562,7 @@ extern void disable_pass (const char *);
 extern void enable_pass (const char *);
 extern void dump_passes (void);
 
+extern void instrument_malloc (void);
+extern void dump_pass_memory_stats (FILE *);
+
 #endif /* GCC_TREE_PASS_H */
Index: gcc/passes.c
===
--- gcc/passes.c.orig   2013-03-07 14:00:15.766543776 +0100
+++ gcc/passes.c2013-03-07 14:15:48.515961538 +0100
@@ -24,6 +24,7 @@ along with GCC; see the file COPYING3.
 
 #include "config.h"
 #include "system.h"
+#include 
 #include "coretypes.h"
 #include "tm.h"
 #include "line-map.h"
@@ -105,6 +106,158 @@ bool in_gimple_form;
 bool first_pass_instance;
 
 
+struct malloc_chunk_head {
+   size_t x;
+   size_t size;
+};
+typedef struct malloc_chunk_head* mchunkptr;
+#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - 2*sizeof(size_t)))
+
+static void (*gcc_old_free_hook) (void *ptr, const void *);
+static void *(*gcc_old_malloc_hook) (size_t size, const void *);
+static void *(*gcc_old_realloc_hook) (void *ptr, size_t size, const void *);
+
+static void *gcc_malloc_hook (size_t size, const void *caller);
+static void *gcc_realloc_hook (void *ptr, size_t size, const void *caller);
+static void gcc_free_hook (void *ptr, const void *caller);
+
+struct opt_pass mem_overall;
+struct opt_pass mem_rest_of_comp;
+
+static void *
+gcc_malloc_hook (size_t size, const void *caller)
+{
+  void *res;
+  __malloc_hook = gcc_old_malloc_hook;
+  __realloc_hook = gcc_old_realloc_hook;
+  __free_hook = gcc_old_free_hook;
+  if (gcc_old_malloc_hook != NULL)
+res = gcc_old_malloc_hook (size, caller);
+  else
+res = xmalloc (size);
+  __malloc_hook = gcc_malloc_hook;
+  __realloc_hook = gcc_realloc_hook;
+  __free_hook = gcc_free_hook;
+  struct opt_pass *p = current_pass ? current_pass : &mem_rest_of_comp;
+  /* The allocator allocates a chunk >= size.  */
+  size = res ? mem2chunk (res)->size : 0;
+  p->alloc_cnt++;
+  p->alloc_sum += size;
+  p->alloc_curr += size;
+  if ((ssize_t) p->alloc_curr > (ssize_t) p->alloc_peak)
+p->alloc_peak = p->alloc_curr;
+  mem_overall.alloc_cnt++;
+  mem_overall.alloc_sum += size;
+  mem_overall.alloc_curr += size;
+  if ((ssize_t) mem_overall.alloc_curr > (ssize_t) mem_overall.alloc_peak)
+mem_overall.alloc_peak = mem_overall.alloc_curr;
+  return res;
+}
+
+static void *
+gcc_realloc_hook (void *ptr, size_t size, const void *caller)
+{
+  size_t oldsize = ptr ? mem2chunk (ptr)->size : 0;

[PATCH] Fix reassoc ICE (PR tree-optimization/56559)

2013-03-07 Thread Jakub Jelinek
Hi!

During zero_one_operation I believe we can count in the chain having single
uses if we go through rhs1s, but the change from last year also added
looking through rhs2, and there I don't see anything that would guarantee
a single use, and the following testcase shows where it has two uses.

If it has more than one use, obviously we can't change the pow call just
because in one of the uses we'd like to remove one multiplication.

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

2013-03-07  Jakub Jelinek  

PR tree-optimization/56559
* tree-ssa-reassoc.c (zero_one_operation): When looking at rhs2,
check that it has only a single use.

* gcc.dg/tree-ssa/reassoc-26.c: New test.

--- gcc/tree-ssa-reassoc.c.jj   2013-02-18 16:39:55.0 +0100
+++ gcc/tree-ssa-reassoc.c  2013-03-07 10:09:22.048925800 +0100
@@ -1107,7 +1107,8 @@ zero_one_operation (tree *def, enum tree
 the operand might be hiding in the rightmost one.  */
   if (opcode == MULT_EXPR
  && gimple_assign_rhs_code (stmt) == opcode
- && TREE_CODE (gimple_assign_rhs2 (stmt)) == SSA_NAME)
+ && TREE_CODE (gimple_assign_rhs2 (stmt)) == SSA_NAME
+ && has_single_use (gimple_assign_rhs2 (stmt)))
{
  gimple stmt2 = SSA_NAME_DEF_STMT (gimple_assign_rhs2 (stmt));
  if (stmt_is_power_of_op (stmt2, op))
--- gcc/testsuite/gcc.dg/tree-ssa/reassoc-26.c.jj   2013-03-07 
10:10:49.400749110 +0100
+++ gcc/testsuite/gcc.dg/tree-ssa/reassoc-26.c  2013-03-07 10:10:18.0 
+0100
@@ -0,0 +1,12 @@
+/* PR tree-optimization/56559 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math" } */
+
+double a, b, c, d, e;
+
+void
+foo ()
+{
+  a = e * e;
+  b = d * e + c * e * a;
+}

Jakub


Re: [PATCH] Fix PR56478

2013-03-07 Thread Jakub Jelinek
On Tue, Mar 05, 2013 at 10:07:50AM +0100, Marek Polacek wrote:
> +  if (compare_count.scmp (double_int_zero) == -1)
> +compare_count = double_int_zero;
> +  if (loop_count.scmp (double_int_zero) == -1)
> +loop_count = double_int_zero;

Use if (compare_count.is_negative ()) etc. instead?

> - probability = (double) REG_BR_PROB_BASE * compare_count / loop_count;
> -  predict_edge (then_edge, PRED_LOOP_IV_COMPARE, probability);
> +{
> +   tem = compare_count.divmod_with_overflow (loop_count,
> +  0, TRUNC_DIV_EXPR,
> +  &mod, &of);

This is wrong.  As compare_count is < loop_count, this will always yield
zero.

I guess you want something like:
  /* If loop_count is too big, such that REG_BR_PROB_BASE * loop_count
 could overflow, shift both loop_count and compare_count right a bit
 so that it doesn't overflow.  Note both counts are known not to be
 negative at this point.  */
  int clz_bits = clz_hwi (loop_count.high);
  gcc_assert (REG_BR_PROB_BASE < 32768);
  if (clz_bits < 16)
{
  loop_count.arshift (16 - clz_bits, HOST_BITS_PER_DOUBLE_INT);
  compare_count.arshift (16 - clz_bits, HOST_BITS_PER_DOUBLE_INT);
}
  tem = loop_count.mul_with_sign (double_int::from_shwi (REG_BR_PROB_BASE),
  true, &of);
  gcc_assert (!of);
  tem = tem.divmod (loop_count, true, TRUNC_DIV_EXPR, &mod);
  probability = tem.to_uhwi ();
  predict_edge (then_edge, PRED_LOOP_IV_COMPARE, probability);

Jakub


Re: [PATCH] Fix reassoc ICE (PR tree-optimization/56559)

2013-03-07 Thread Richard Biener
On Thu, 7 Mar 2013, Jakub Jelinek wrote:

> Hi!
> 
> During zero_one_operation I believe we can count in the chain having single
> uses if we go through rhs1s, but the change from last year also added
> looking through rhs2, and there I don't see anything that would guarantee
> a single use, and the following testcase shows where it has two uses.
> 
> If it has more than one use, obviously we can't change the pow call just
> because in one of the uses we'd like to remove one multiplication.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2013-03-07  Jakub Jelinek  
> 
>   PR tree-optimization/56559
>   * tree-ssa-reassoc.c (zero_one_operation): When looking at rhs2,
>   check that it has only a single use.
> 
>   * gcc.dg/tree-ssa/reassoc-26.c: New test.
> 
> --- gcc/tree-ssa-reassoc.c.jj 2013-02-18 16:39:55.0 +0100
> +++ gcc/tree-ssa-reassoc.c2013-03-07 10:09:22.048925800 +0100
> @@ -1107,7 +1107,8 @@ zero_one_operation (tree *def, enum tree
>the operand might be hiding in the rightmost one.  */
>if (opcode == MULT_EXPR
> && gimple_assign_rhs_code (stmt) == opcode
> -   && TREE_CODE (gimple_assign_rhs2 (stmt)) == SSA_NAME)
> +   && TREE_CODE (gimple_assign_rhs2 (stmt)) == SSA_NAME
> +   && has_single_use (gimple_assign_rhs2 (stmt)))
>   {
> gimple stmt2 = SSA_NAME_DEF_STMT (gimple_assign_rhs2 (stmt));
> if (stmt_is_power_of_op (stmt2, op))
> --- gcc/testsuite/gcc.dg/tree-ssa/reassoc-26.c.jj 2013-03-07 
> 10:10:49.400749110 +0100
> +++ gcc/testsuite/gcc.dg/tree-ssa/reassoc-26.c2013-03-07 
> 10:10:18.0 +0100
> @@ -0,0 +1,12 @@
> +/* PR tree-optimization/56559 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -ffast-math" } */
> +
> +double a, b, c, d, e;
> +
> +void
> +foo ()
> +{
> +  a = e * e;
> +  b = d * e + c * e * a;
> +}
> 
>   Jakub
> 
> 

-- 
Richard Biener 
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend


Re: [patch] Performance patch for MIPS conditional move in expr.c

2013-03-07 Thread Jakub Jelinek
On Wed, Nov 14, 2012 at 02:22:33PM -0800, Andrew Pinski wrote:
> commit 8ca1e58de404bbe82b93bc240ef28c68c681243d
> Author: Andrew Pinski 
> Date:   Thu Jul 26 18:09:34 2012 -0700
> 
> 2012-07-26  Andrew Pinski  
> 
>   Bug #3261
>   * config/mips/mips.md (*mov_on_):
>   Remove mode check from comparisons.
>   (*mov_on_): Likewise.
>   (*mov_on__ne): New pattern to match
>   when (ne A 0) can be just A.

Why aren't you also adding a *mov_on__ne
insn?

Jakub


[PATCH] Update {i386,i486,x86_64,powerpc{,64},s390,s390x}-linux-gnu{,/32} baseline_symbols.txt files

2013-03-07 Thread Jakub Jelinek
Hi!

It is again roughly the season of the year where baselines should be
updated.  These are for the architectures I built gcc on recently.
Ok for trunk?

2013-03-07  Jakub Jelinek  

* config/abi/post/i386-linux-gnu/baseline_symbols.txt: Update.
* config/abi/post/i486-linux-gnu/baseline_symbols.txt: Likewise.
* config/abi/post/powerpc64-linux-gnu/32/baseline_symbols.txt:
Likewise.
* config/abi/post/powerpc64-linux-gnu/baseline_symbols.txt: Likewise.
* config/abi/post/powerpc-linux-gnu/baseline_symbols.txt: Likewise.
* config/abi/post/s390-linux-gnu/baseline_symbols.txt: Likewise.
* config/abi/post/s390x-linux-gnu/baseline_symbols.txt: Likewise.
* config/abi/post/x86_64-linux-gnu/32/baseline_symbols.txt: Likewise.
* config/abi/post/x86_64-linux-gnu/baseline_symbols.txt: Likewise.

--- libstdc++-v3/config/abi/post/i386-linux-gnu/baseline_symbols.txt.jj 
2012-11-15 17:45:56.0 +0100
+++ libstdc++-v3/config/abi/post/i386-linux-gnu/baseline_symbols.txt
2013-03-07 16:01:18.0 +0100
@@ -403,6 +403,7 @@ FUNC:_ZNKSt15basic_streambufIwSt11char_t
 FUNC:_ZNKSt15basic_streambufIwSt11char_traitsIwEE6getlocEv@@GLIBCXX_3.4
 FUNC:_ZNKSt15basic_stringbufIcSt11char_traitsIcESaIcEE3strEv@@GLIBCXX_3.4
 FUNC:_ZNKSt15basic_stringbufIwSt11char_traitsIwESaIwEE3strEv@@GLIBCXX_3.4
+FUNC:_ZNKSt17bad_function_call4whatEv@@GLIBCXX_3.4.18
 FUNC:_ZNKSt18basic_stringstreamIcSt11char_traitsIcESaIcEE3strEv@@GLIBCXX_3.4
 FUNC:_ZNKSt18basic_stringstreamIcSt11char_traitsIcESaIcEE5rdbufEv@@GLIBCXX_3.4
 FUNC:_ZNKSt18basic_stringstreamIwSt11char_traitsIwESaIwEE3strEv@@GLIBCXX_3.4
@@ -590,6 +591,8 @@ FUNC:_ZNKSt7num_putIwSt19ostreambuf_iter
 
FUNC:_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE6do_putES3_RSt8ios_basewm@@GLIBCXX_3.4
 
FUNC:_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE6do_putES3_RSt8ios_basewx@@GLIBCXX_3.4
 
FUNC:_ZNKSt7num_putIwSt19ostreambuf_iteratorIwSt11char_traitsIwEEE6do_putES3_RSt8ios_basewy@@GLIBCXX_3.4
+FUNC:_ZNKSt8__detail20_Prime_rehash_policy11_M_next_bktEj@@GLIBCXX_3.4.18
+FUNC:_ZNKSt8__detail20_Prime_rehash_policy14_M_need_rehashEjjj@@GLIBCXX_3.4.18
 FUNC:_ZNKSt8bad_cast4whatEv@@GLIBCXX_3.4.9
 FUNC:_ZNKSt8ios_base7failure4whatEv@@GLIBCXX_3.4
 FUNC:_ZNKSt8messagesIcE18_M_convert_to_charERKSs@@GLIBCXX_3.4
@@ -1207,6 +1210,7 @@ FUNC:_ZNSt11range_errorD2Ev@@GLIBCXX_3.4
 FUNC:_ZNSt11regex_errorD0Ev@@GLIBCXX_3.4.15
 FUNC:_ZNSt11regex_errorD1Ev@@GLIBCXX_3.4.15
 FUNC:_ZNSt11regex_errorD2Ev@@GLIBCXX_3.4.15
+FUNC:_ZNSt11this_thread11__sleep_forENSt6chrono8durationIxSt5ratioILx1ELx1NS1_IxS2_ILx1ELx10@@GLIBCXX_3.4.18
 FUNC:_ZNSt12__basic_fileIcE2fdEv@@GLIBCXX_3.4
 FUNC:_ZNSt12__basic_fileIcE4fileEv@@GLIBCXX_3.4.1
 FUNC:_ZNSt12__basic_fileIcE4openEPKcSt13_Ios_Openmodei@@GLIBCXX_3.4
@@ -1485,6 +1489,11 @@ FUNC:_ZNSt13basic_ostreamIwSt11char_trai
 FUNC:_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEt@@GLIBCXX_3.4
 FUNC:_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEx@@GLIBCXX_3.4
 FUNC:_ZNSt13basic_ostreamIwSt11char_traitsIwEElsEy@@GLIBCXX_3.4
+FUNC:_ZNSt13random_device14_M_init_pretr1ERKSs@@GLIBCXX_3.4.18
+FUNC:_ZNSt13random_device16_M_getval_pretr1Ev@@GLIBCXX_3.4.18
+FUNC:_ZNSt13random_device7_M_finiEv@@GLIBCXX_3.4.18
+FUNC:_ZNSt13random_device7_M_initERKSs@@GLIBCXX_3.4.18
+FUNC:_ZNSt13random_device9_M_getvalEv@@GLIBCXX_3.4.18
 FUNC:_ZNSt13runtime_errorC1ERKSs@@GLIBCXX_3.4
 FUNC:_ZNSt13runtime_errorC2ERKSs@@GLIBCXX_3.4
 FUNC:_ZNSt13runtime_errorD0Ev@@GLIBCXX_3.4
@@ -2467,6 +2476,7 @@ FUNC:__cxa_guard_acquire@@CXXABI_1.3
 FUNC:__cxa_guard_release@@CXXABI_1.3
 FUNC:__cxa_pure_virtual@@CXXABI_1.3
 FUNC:__cxa_rethrow@@CXXABI_1.3
+FUNC:__cxa_thread_atexit@@CXXABI_1.3.7
 FUNC:__cxa_throw@@CXXABI_1.3
 FUNC:__cxa_tm_cleanup@@CXXABI_TM_1
 FUNC:__cxa_vec_cctor@@CXXABI_1.3
@@ -2491,6 +2501,7 @@ OBJECT:0:CXXABI_1.3.3
 OBJECT:0:CXXABI_1.3.4
 OBJECT:0:CXXABI_1.3.5
 OBJECT:0:CXXABI_1.3.6
+OBJECT:0:CXXABI_1.3.7
 OBJECT:0:CXXABI_TM_1
 OBJECT:0:GLIBCXX_3.4
 OBJECT:0:GLIBCXX_3.4.1
@@ -2502,6 +2513,7 @@ OBJECT:0:GLIBCXX_3.4.14
 OBJECT:0:GLIBCXX_3.4.15
 OBJECT:0:GLIBCXX_3.4.16
 OBJECT:0:GLIBCXX_3.4.17
+OBJECT:0:GLIBCXX_3.4.18
 OBJECT:0:GLIBCXX_3.4.2
 OBJECT:0:GLIBCXX_3.4.3
 OBJECT:0:GLIBCXX_3.4.4
--- libstdc++-v3/config/abi/post/i486-linux-gnu/baseline_symbols.txt.jj 
2012-11-15 17:45:56.0 +0100
+++ libstdc++-v3/config/abi/post/i486-linux-gnu/baseline_symbols.txt
2013-03-07 16:01:18.962953573 +0100
@@ -403,6 +403,7 @@ FUNC:_ZNKSt15basic_streambufIwSt11char_t
 FUNC:_ZNKSt15basic_streambufIwSt11char_traitsIwEE6getlocEv@@GLIBCXX_3.4
 FUNC:_ZNKSt15basic_stringbufIcSt11char_traitsIcESaIcEE3strEv@@GLIBCXX_3.4
 FUNC:_ZNKSt15basic_stringbufIwSt11char_traitsIwESaIwEE3strEv@@GLIBCXX_3.4
+FUNC:_ZNKSt17bad_function_call4whatEv@@GLIBCXX_3.4.18
 FUNC:_ZNKSt18basic_stringstreamIcSt11char_traitsIcESaIcEE3strEv@@GLIBCXX_3.4
 FUNC:_ZNKSt18basic_stringstreamIcSt11char_traitsIcESaIcEE5rdbufEv@@GLIBCXX_3.4
 FUNC:_ZNKSt18bas

Re: Convert arm-rtems to EABI on 4.6 and 4.7 branches

2013-03-07 Thread Joel Sherrill

On 3/7/2013 3:50 AM, Eric Botcazou wrote:

We would like to get the 4.7 patch applied so arm-rtems is not obsolete.

If there are any hints of a plan to release another 4.6 version, we would
like to apply a patch to that branch to switch from arm-elf to arm-eabi
as our foundation.

Please adjust the ChangeLog entry on the branches, putting 2013-02-22 for a
patch installed on 2013-03-06 doesn't make much sense.  There is an example
just below on the 4.7 branch.  TIA.


Done.

Sorry. I used Sebastian's entries without even thinking they were at 
least a week old.


--
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherr...@oarcorp.comOn-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available(256) 722-9985



Re: [PATCH] Update {i386,i486,x86_64,powerpc{,64},s390,s390x}-linux-gnu{,/32} baseline_symbols.txt files

2013-03-07 Thread Jonathan Wakely
On 7 March 2013 15:17, Jakub Jelinek wrote:
> Hi!
>
> It is again roughly the season of the year where baselines should be
> updated.  These are for the architectures I built gcc on recently.
> Ok for trunk?

Looks correct to me, thanks for doing this. OK for trunk.


[PATCH] Fix -Og and TER

2013-03-07 Thread Richard Biener

We need to avoid line-jumps due to TER, like we do for -O0.
This also adjust things to match the 4.8 changes for location
encodings (and the older PHI argument locations).

Bootstrap & regtest pending on x86_64-unknown-linux-gnu.

Does this look ok?

Thanks,
Richard.

2013-03-07  Richard Biener  

* tree-ssa-ter.c (is_replaceable_p): Do not TER across location
or block changes with -Og.  Fix for location / block encoding
changes and PHI arguments with locations.

Index: gcc/tree-ssa-ter.c
===
*** gcc/tree-ssa-ter.c  (revision 196520)
--- gcc/tree-ssa-ter.c  (working copy)
*** is_replaceable_p (gimple stmt, bool ter)
*** 399,420 
  return false;
  
locus1 = gimple_location (stmt);
!   block1 = gimple_block (stmt);
  
if (gimple_code (use_stmt) == GIMPLE_PHI)
! {
!   locus2 = 0;
!   block2 = NULL_TREE;
! }
else
! {
!   locus2 = gimple_location (use_stmt);
!   block2 = gimple_block (use_stmt);
! }
  
!   if (!optimize
&& ter
!   && ((locus1 && locus1 != locus2) || (block1 && block1 != block2)))
  return false;
  
/* Used in this block, but at the TOP of the block, not the end.  */
--- 400,421 
  return false;
  
locus1 = gimple_location (stmt);
!   block1 = LOCATION_BLOCK (locus1);
!   locus1 = LOCATION_LOCUS (locus1);
  
if (gimple_code (use_stmt) == GIMPLE_PHI)
! locus2 = gimple_phi_arg_location (use_stmt, PHI_ARG_INDEX_FROM_USE 
(use_p));
else
! locus2 = gimple_location (use_stmt);
!   block2 = LOCATION_BLOCK (locus2);
!   locus2 = LOCATION_LOCUS (locus2);
  
!   if ((!optimize || optimize_debug)
&& ter
!   && ((locus1 != UNKNOWN_LOCATION
!  && locus1 != locus2)
! || (block1 != NULL_TREE
! && block1 != block2)))
  return false;
  
/* Used in this block, but at the TOP of the block, not the end.  */



Re: [patch] Performance patch for MIPS conditional move in expr.c

2013-03-07 Thread Andrew Pinski
On Thu, Mar 7, 2013 at 7:12 AM, Jakub Jelinek  wrote:
> On Wed, Nov 14, 2012 at 02:22:33PM -0800, Andrew Pinski wrote:
>> commit 8ca1e58de404bbe82b93bc240ef28c68c681243d
>> Author: Andrew Pinski 
>> Date:   Thu Jul 26 18:09:34 2012 -0700
>>
>> 2012-07-26  Andrew Pinski  
>>
>>   Bug #3261
>>   * config/mips/mips.md (*mov_on_):
>>   Remove mode check from comparisons.
>>   (*mov_on_): Likewise.
>>   (*mov_on__ne): New pattern to match
>>   when (ne A 0) can be just A.
>
> Why aren't you also adding a *mov_on__ne
> insn?

Most likely because I only tested performance of this patch on
soft-float and I did not notice a reason for it yet.

Thanks,
Andrew Pinski


Re: [PATCH] Fix -Og and TER

2013-03-07 Thread Jakub Jelinek
On Thu, Mar 07, 2013 at 04:52:15PM +0100, Richard Biener wrote:
> 2013-03-07  Richard Biener  
> 
>   * tree-ssa-ter.c (is_replaceable_p): Do not TER across location
>   or block changes with -Og.  Fix for location / block encoding
>   changes and PHI arguments with locations.

Ok, thanks.

Jakub


Re: [PATCH] Fix -print-multi-os-directory for aarch64

2013-03-07 Thread Andrew Pinski
On Thu, Mar 7, 2013 at 3:15 AM, Jakub Jelinek  wrote:
> Hi!
>
> AFAIK aarch64 libraries are supposed to go into /usr/lib64 etc.
> directories similarly to x86-64 etc., but as aarch64 isn't a true
> multilib target (having two different backends for 32-bit vs. 64-bit code),
> currently gcc -print-multi-os-directory prints . instead of ../lib64.

I think glibc is broken also. So after this change, the build using
the released 2.17 and this new gcc breaks.

Thanks,
Andrew


>
> The following patch fixes that.  As for --disable-multilib purposes
> gcc.c does:
>   /* When --disable-multilib was used but target defines
>  MULTILIB_OSDIRNAMES, entries starting with .: (and not starting
>  with .:: for multiarch configurations) are there just to find
>  multilib_os_dir, so skip them from output.  */
>   if (this_path[0] == '.' && this_path[1] == ':' && this_path[2] != ':')
> skip = 1;
> we need to actually emit
> static const char *const multilib_raw[] = {
> ". ;",
> ".:../lib64 ;",
> NULL
> };
> for --disable-multiarch resp.
> static const char *const multilib_raw[] = {
> ". ;",
> ".:../lib64:aarch64-linux-gnu ;",
> NULL
> };
> for --enable-multiarch.  Tested (with cross compiler) configured with
> --target aarch64-linux --enable-languages=c {,--disable-multilib} 
> {,--enable-multarch}
> (all 4 combinations) and output of all
> ./xgcc -B ./ --print-{multiarch,multi-lib,multi-directory,multi-os-directory}
> looks good to me with it (i.e. as before the patch, except
> --print-multi-so-directory prints ../lib64 instead of . previously.
>
> Ok for trunk?
>
> 2013-03-07  Jakub Jelinek  
>
> * config/aarch64/t-aarch64-linux (MULTARCH_DIRNAME): Remove.
> (MULTILIB_OSDIRNAMES): Set.
> * genmultilib: If defaultosdirname doesn't start with :: , set
> defaultosdirname2 instead, clear it and emit two . multilib_raw
> entries instead of just one.
>
> --- gcc/config/aarch64/t-aarch64-linux.jj   2013-01-11 09:03:10.0 
> +0100
> +++ gcc/config/aarch64/t-aarch64-linux  2013-03-07 11:23:07.602568188 +0100
> @@ -22,4 +22,4 @@ LIB1ASMSRC   = aarch64/lib1funcs.asm
>  LIB1ASMFUNCS = _aarch64_sync_cache_range
>
>  AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
> -MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
> +MULTILIB_OSDIRNAMES = .=../lib64$(call 
> if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
> --- gcc/genmultilib.jj  2013-01-13 13:23:38.0 +0100
> +++ gcc/genmultilib 2013-03-07 11:35:22.881982721 +0100
> @@ -267,6 +267,7 @@ fi
>  # names.
>  toosdirnames=
>  defaultosdirname=
> +defaultosdirname2=
>  if [ -n "${multiarch}" ]; then
>defaultosdirname=::${multiarch}
>  fi
> @@ -280,6 +281,13 @@ if [ -n "${osdirnames}" ]; then
> if [ -n "${multiarch}" ]; then
>   defaultosdirname=${defaultosdirname}:${multiarch}
> fi
> +   case "$defaultosdirname" in
> + ::*) ;;
> + *)
> +   defaultosdirname2=${defaultosdirname}
> +   defaultosdirname=
> +   ;;
> +   esac
> shift
> ;;
>*=*)
> @@ -352,6 +360,7 @@ for set in ${options}; do
>  done
>  optout=`echo ${optout} | sed -e 's/^ //'`
>  echo "\".${defaultosdirname} ${optout};\","
> +[ -n "${defaultosdirname2}" ] && echo "\".${defaultosdirname2} ${optout};\","
>
>  # This part of code convert an option combination to
>  # its corresponding directory names.
>
> Jakub


Re: [Patch, libfortran, 2nd version] PR 48618 - Negative unit number in OPEN(...) is sometimes allowed

2013-03-07 Thread Tilo Schwarz

On Thu, 07 Mar 2013 12:46:10 +0100, Tobias Burnus  wrote:


Hi,

Tilo Schwarz wrote:

this patch fixes PR 48618.
Built and regtested on Linux 3.2.0-4-686-pae.


Thanks for the patch, which mostly looks okay.

A few remarks:


Thank you for the feedback.

I incorporated all remarks into the new attached patch.


* Copyright assignment: You mentioned that you have emailed(§) the form
back to the FSF. Was this the actual copyright-assignment form which the
FSF sent to you by mail? Or was it 'only' request form?


It was the actual copyright-assignment form.


Can you tell us,
when the FSF has acknowledged the arrival of the copyright assignment?


Yes, I'll do.


Regards,
Tilo2013-03-06  Tilo Schwarz  

	PR libfortran/48618
	* io/open.c (st_open): Raise error for unit number < 0 only if
	unit number does not exist already.
	* gcc/testsuite/gfortran.dg/open_negative_unit_1.f90: New.

diff --git a/gcc/testsuite/gfortran.dg/open_negative_unit_1.f90 b/gcc/testsuite/gfortran.dg/open_negative_unit_1.f90
new file mode 100644
index 000..6446436
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/open_negative_unit_1.f90
@@ -0,0 +1,21 @@
+! { dg-do run }
+! PR48618 - Negative unit number in OPEN(...) is sometimes allowed
+!
+! Test originally from Janne Blomqvist in PR:
+! http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48618
+
+program nutest
+implicit none
+integer id, ios
+
+open(newunit=id, file="foo.txt", iostat=ios)
+if (ios /= 0) call abort
+
+open(id, file="bar.txt", iostat=ios)
+if (ios /= 0) call abort
+
+close(id, status="delete")
+
+open(-10, file="foo.txt", iostat=ios)
+if (ios == 0) call abort
+end program nutest
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c
index d9cfde8..19fab1d 100644
--- a/libgfortran/io/open.c
+++ b/libgfortran/io/open.c
@@ -818,10 +818,6 @@ st_open (st_parameter_open *opp)
 
   flags.convert = conv;
 
-  if (!(opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT) && opp->common.unit < 0)
-generate_error (&opp->common, LIBERROR_BAD_OPTION,
-		"Bad unit number in OPEN statement");
-
   if (flags.position != POSITION_UNSPECIFIED
   && flags.access == ACCESS_DIRECT)
 generate_error (&opp->common, LIBERROR_BAD_OPTION,
@@ -848,8 +844,16 @@ st_open (st_parameter_open *opp)
 {
   if ((opp->common.flags & IOPARM_OPEN_HAS_NEWUNIT))
 	opp->common.unit = get_unique_unit_number(opp);
+  else if (opp->common.unit < 0)
+	{
+	  u = find_unit (opp->common.unit);
+	  if (u == NULL) /* Negative unit and no NEWUNIT-created unit found.  */
+	generate_error (&opp->common, LIBERROR_BAD_OPTION,
+			"Bad unit number in OPEN statement");
+	}
 
-  u = find_or_create_unit (opp->common.unit);
+  if (u == NULL)
+	u = find_or_create_unit (opp->common.unit);
   if (u->s == NULL)
 	{
 	  u = new_unit (opp, u, &flags);


Re: [PATCH] Fix up adjust_return_value_with_ops (PR tree-optimization/56539)

2013-03-07 Thread Jeff Law

On 03/06/2013 04:28 PM, Jakub Jelinek wrote:

On Wed, Mar 06, 2013 at 03:00:49PM -0700, Jeff Law wrote:

Doesn't the code in update_accumulator_with_ops need the same
change?


No, the difference is that it uses false as the next to last argument,
i.e. inserts after gsi, in which case GSI_CONTINUE_LINKING is desirable,
so that the stmt is inserted after that.
Thanks.  Just wanted to make sure -- I've never had to ponder how the 
GSI/BSI linking code works much.


Jeff


Re: [PATCH] Fix -print-multi-os-directory for aarch64

2013-03-07 Thread Jakub Jelinek
On Thu, Mar 07, 2013 at 08:29:06AM -0800, Andrew Pinski wrote:
> On Thu, Mar 7, 2013 at 3:15 AM, Jakub Jelinek  wrote:
> > AFAIK aarch64 libraries are supposed to go into /usr/lib64 etc.
> > directories similarly to x86-64 etc., but as aarch64 isn't a true
> > multilib target (having two different backends for 32-bit vs. 64-bit code),
> > currently gcc -print-multi-os-directory prints . instead of ../lib64.
> 
> I think glibc is broken also. So after this change, the build using
> the released 2.17 and this new gcc breaks.

Then glibc will need patching too.  Distros using multiarch aren't affected
by this, others IMHO will want it in */lib64 and for aarch64 IMHO it isn't
still too late for that change.

Jakub


PING: Re: do not pass PR_INSTRUMENTEDCODE if there is no instrumentation

2013-03-07 Thread Aldy Hernandez

PING this, or any of my other revisions :)


On 02/27/13 10:43, Aldy Hernandez wrote:

On 02/26/13 12:24, Richard Henderson wrote:

On 02/25/2013 02:52 PM, Aldy Hernandez wrote:

I think it's best to do this here at tmmark time, instead of at IPA-tm.
   Don't we have problems when ipa inlining runs after ipa_tm, thus
creating more instrumented code later on?


No, I shouldn't think so.  Inlining doesn't change the decision we
made during
IPA_TM about whether or not any one transaction doesGoIrr, which is
the *only*
bit that's relevant to eliding the uninstrumented code path during
IPA_TM, and
thus should be the only bit that's relevant to deciding that the sole
code path
is actually supposed to be instrumented or uninstrumented.


If inlining doesn't change anything then doing it at IPA time is
definitely cleaner.  See attached patch.


I'm not fond of how much extra code and tests this patch is adding.
Is it
really really required?  Is my analysis above wrong in some way?


Well, I know you wanted me to avoid calling ipa_uninstrument_transaction
in ipa_tm_scan_calls_transaction, but the problem is that
ipa_tm_scan_calls_transaction gets called prior to
ipa_tm_transform_transaction which is the one setting the GTMA bits.

If you're ok with this revision, I could commit it, and figure something
out for eliding the call to ipa_uninstrument_transaction as a followup
patch.  I'm thinking either:

a) Something like the previous patch (which you clearly did not like),
where we remove the edges ex post facto.

b) Rearrange things somehow so we do ipa_uninstrument_transaction after
ipa_tm_scan_calls_transaction.

Aldy




Re: [PATCH] track heap usage with -fmem-report

2013-03-07 Thread Steven Bosscher
On Thu, Mar 7, 2013 at 1:59 PM, Richard Biener wrote:
> Index: gcc/toplev.c
> ===
> *** gcc/toplev.c(revision 196517)
> --- gcc/toplev.c(working copy)
> *** along with GCC; see the file COPYING3.
> *** 74,79 
> --- 74,80 
>   #include "gimple.h"
>   #include "tree-ssa-alias.h"
>   #include "plugin.h"
> + #include "tree-pass.h"
>
>   #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
>   #include "dbxout.h"

On the "don't need to know"-principle, can you please not do this, and
instead add the statistic dumper prototypes to statistics.h and
inclode that in toplev.c? Toplev doesn't have to know about passes.

Ciao!
Steven


[patch testsuite]: Skip c-c++-common/pr54486.c test for mingw-targets

2013-03-07 Thread Kai Tietz
Hi,

one small nit for mingw targets without gnu-style printf-formatter.

ChangeLog

2013-03-07  Kai Tietz  

* c-c++-common/pr54486.c: Skip test for mingw-targets.

Ok for apply?

Regards,
Kai

Index: c-c++-common/pr54486.c
===
--- c-c++-common/pr54486.c  (Revision 196507)
+++ c-c++-common/pr54486.c  (Arbeitskopie)
@@ -1,6 +1,7 @@
 /* PR middle-end/54486 */
 /* { dg-do compile } */
 /* { dg-options "-Wformat" } */
+/* { dg-skip-if "no POSIX printf" { *-*-mingw* } { "*" } { "" } } */

 #ifdef __cplusplus
 extern "C" {


Re: [PATCH] Simplify -fwhole-program documentation

2013-03-07 Thread Jan Hubicka
> On Wed, 6 Mar 2013, Jan Hubicka wrote:
> 
> > > 
> > > This removes all encouragement to use -fwhole-program with -flto
> > > from the documentation.  As can be seen in PR56533 it can be
> > > most confusing ... instead advise to rely on a linker plugin.
> > > 
> > > Ok?
> > 
> > Seems resomable thing to do. However I guess a lot of users are still
> > have non-linker-plugin enabled setup.  Perhaps we can add a sentence how
> > to figure out if your setup is plugin enabled and thus working well
> > w/o -fwhole-program?
> 
> Do you know one?  Apart from 'gcc -flto ... -v 2>&1 | grep -- 
> -fresolution'?
> 
> ;)
> 
> I've installed the patch for now.
Hehe, that is precisely what I was thinking about too, except that I would be 
grepping for plugin switch :)

Perhaps we could print this info in human readable form into  gcc --verbose or 
gcc --version or gcc --help?
With --verbose it is the place we ask people to look into expansion of 
-march=native & friends, so it may make sense.

Honza
> 
> Richard.


[patch testsuite]: Fix gcc.target/i386 cases for mingw-targets

2013-03-07 Thread Kai Tietz
Hi,

this patch fixes some testsuite-failures on mingw targets.

ChangeLog

2013-03-07  Kai Tietz  

* gcc.target/i386/movti.c: Adjust for x64 mingw.
* gcc.target/i386/pr20020-1.c: Skip for x64 mingw target.
* gcc.target/i386/pr20020-2.c: Likewise.
* gcc.target/i386/pr20020-3.c: Likewise.
* gcc.target/i386/pr53425-1.c: Likewise.
* gcc.target/i386/pr53425-2.c: Likewise.
* gcc.target/i386/pr55093.c: Likewise.
* gcc.target/i386/pr53907.c: Adjust for LLP64 targets.

Ok to apply?

Kai

Index: gcc.target/i386/movti.c
===
--- gcc.target/i386/movti.c (Revision 196507)
+++ gcc.target/i386/movti.c (Arbeitskopie)
@@ -7,4 +7,4 @@ _Decimal128 test (void)
   return 1234123412341234.123412341234dl;
 }

-/* { dg-final { scan-assembler-not "movabs" } } */
+/* { dg-final { scan-assembler-not "movabs" { target { !
x86_64-*-mingw* } } } } */
Index: gcc.target/i386/pr20020-1.c
===
--- gcc.target/i386/pr20020-1.c (Revision 196507)
+++ gcc.target/i386/pr20020-1.c (Arbeitskopie)
@@ -1,5 +1,6 @@
 /* Check that 128-bit struct's are represented as TImode values.  */
 /* { dg-do compile { target int128 } } */
+/* { dg-skip-if "" { x86_64-*-mingw* } { "*" } { "" } } */
 /* { dg-options "-O2 -fdump-rtl-expand" } */

 struct shared_ptr_struct
Index: gcc.target/i386/pr20020-2.c
===
--- gcc.target/i386/pr20020-2.c (Revision 196507)
+++ gcc.target/i386/pr20020-2.c (Arbeitskopie)
@@ -1,5 +1,6 @@
 /* Check that 128-bit struct's are represented as TImode values.  */
 /* { dg-do compile { target int128 } } */
+/* { dg-skip-if "" { x86_64-*-mingw* } { "*" } { "" } } */
 /* { dg-options "-O2 -fdump-rtl-expand" } */

 struct shared_ptr_struct
Index: gcc.target/i386/pr20020-3.c
===
--- gcc.target/i386/pr20020-3.c (Revision 196507)
+++ gcc.target/i386/pr20020-3.c (Arbeitskopie)
@@ -1,5 +1,6 @@
 /* Check that 128-bit struct's are represented as TImode values.  */
 /* { dg-do compile { target int128 } } */
+/* { dg-skip-if "" { x86_64-*-mingw* } { "*" } { "" } } */
 /* { dg-options "-O2 -fdump-rtl-expand" } */

 struct shared_ptr_struct
Index: gcc.target/i386/pr53425-1.c
===
--- gcc.target/i386/pr53425-1.c (Revision 196507)
+++ gcc.target/i386/pr53425-1.c (Arbeitskopie)
@@ -1,6 +1,7 @@
 /* PR target/53425 */
 /* { dg-do compile { target { ! { ia32 } } } } */
 /* { dg-options "-O2 -mno-sse" } */
+/* { dg-skip-if "no SSE vector" { x86_64-*-mingw* } { "*" } { "" } } */

 typedef double __v2df __attribute__ ((__vector_size__ (16)));

Index: gcc.target/i386/pr53425-2.c
===
--- gcc.target/i386/pr53425-2.c (Revision 196507)
+++ gcc.target/i386/pr53425-2.c (Arbeitskopie)
@@ -1,6 +1,7 @@
 /* PR target/53425 */
 /* { dg-do compile { target { ! { ia32 } } } } */
 /* { dg-options "-O2 -mno-sse" } */
+/* { dg-skip-if "no SSE vector" { x86_64-*-mingw* } { "*" } { "" } } */

 typedef float __v2sf __attribute__ ((__vector_size__ (8)));

Index: gcc.target/i386/pr53907.c
===
--- gcc.target/i386/pr53907.c   (Revision 196507)
+++ gcc.target/i386/pr53907.c   (Arbeitskopie)
@@ -3,10 +3,12 @@

 #include 

+__extension__ typedef __UINTPTR_TYPE__ uintptr_t;
+
 __m128i x(char *s)
 {
   __m128i sz,z,mvec;
-  s-=((unsigned long) s)%16;
+  s-=((uintptr_t) s)%16;
   sz=_mm_load_si128((__m128i *)s);
   return sz;
 }
Index: gcc.target/i386/pr55093.c
===
--- gcc.target/i386/pr55093.c   (Revision 196507)
+++ gcc.target/i386/pr55093.c   (Arbeitskopie)
@@ -1,5 +1,6 @@
 /* { dg-do compile { target { ! { ia32 } } } } */
 /* { dg-options "-O2 -mx32 -maddress-mode=long" } */
+/* { dg-skip-if "" { x86_64-*-mingw* } { "*" } { "" } } */

 typedef union tree_node *tree;
 typedef const union tree_node *const_tree;


[patch testsuite]: Fixes in gcc.dg for mingw-targets

2013-03-07 Thread Kai Tietz
Hi,

this patch fixes some remaining issue for mingw-targets in gcc.dg's testsuite.

ChangeLog

2013-03-07  Kai Tietz  

* gcc.dg/pr14092-1.c: Mark intptr_t typedef to use extension.
* gcc.dg/pr24683.c: Avoid warning about casting constant string.
* gcc.dg/pr52549.c: Add LLP64 case.
* gcc.dg/pr53701.c: Use for uintptr_t typedef __UINTPTR_TYPE__.
* gcc.dg/pr56510.c: Adjust for LLP64 targets.
* gcc.dg/torture/pr51071-2.c: Likewise.
* gcc.dg/tree-ssa/vrp72.c: Likewise.
* gcc.dg/tree-ssa/vrp73.c: Likewise.
* gcc.dg/tree-ssa/vrp75.c: Likewise.
* gcc.dg/torture/pr53922.c: Skike for mingw-targets.
* gcc.dg/weak/weak-1.c: Likewise.
* gcc.dg/weak/weak-2.c: Likewise.
* gcc.dg/weak/weak-3.c: Likewise.
* gcc.dg/weak/weak-4.c: Likewise.
* gcc.dg/weak/weak-5.c: Likewise.
* gcc.dg/weak/weak-15.c: Likewise.
* gcc.dg/weak/weak-16.c: Likewise.

ok for apply?

Kai

Index: gcc.dg/pr14092-1.c
===
--- gcc.dg/pr14092-1.c  (Revision 196507)
+++ gcc.dg/pr14092-1.c  (Arbeitskopie)
@@ -6,7 +6,7 @@

 /* Define this so that we are more portable.  The testcase in the
PR failed on 64-bit hosts.  */
-typedef __INTPTR_TYPE__ intptr_t;
+__extension__ typedef __INTPTR_TYPE__ intptr_t;

 typedef struct _PLCI {
   unsigned char x;
Index: gcc.dg/pr24683.c
===
--- gcc.dg/pr24683.c(Revision 196507)
+++ gcc.dg/pr24683.c(Arbeitskopie)
@@ -1,11 +1,11 @@
 /* { dg-do compile { target fpic } } */
 /* { dg-options "-O2 -fPIC" } */
-int *block;
+const int *block;
 void final(unsigned int j)
 {
   unsigned int i;
-  unsigned char *data = (unsigned char *)"\0";
+  const unsigned char *data = (const unsigned char *)"\0";
   for (i = 0; i < 8; i++)
 for (; j + 63 < 1; j += 64)
-  block = (int *) &data[j];
+  block = (const int *) &data[j];
 }
Index: gcc.dg/pr52549.c
===
--- gcc.dg/pr52549.c(Revision 196507)
+++ gcc.dg/pr52549.c(Arbeitskopie)
@@ -10,4 +10,9 @@ _mark (int obj, int i, char *a)
 {
   (char *)&(((int *)(obj)) [i]) - a;
 }
+#elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
+__extension__ _mark (long long obj, int i, char *a)
+{
+  (char *)&(((int *)(obj)) [i]) - a;
+}
 #endif
Index: gcc.dg/pr53701.c
===
--- gcc.dg/pr53701.c(Revision 196507)
+++ gcc.dg/pr53701.c(Arbeitskopie)
@@ -1,7 +1,7 @@
 /* { dg-do compile { target powerpc*-*-* ia64-*-* i?86-*-* x86_64-*-* } } */
 /* { dg-options "-O3 -fselective-scheduling2 -fsel-sched-pipelining" } */
 typedef unsigned short int uint16_t;
-typedef unsigned long int uintptr_t;
+__extension__ typedef __UINTPTR_TYPE__ uintptr_t;
 typedef struct GFX_VTABLE
 {
   int color_depth;
Index: gcc.dg/pr56510.c
===
--- gcc.dg/pr56510.c(Revision 196507)
+++ gcc.dg/pr56510.c(Arbeitskopie)
@@ -2,11 +2,12 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -g" } */

+__extension__ typedef __INTPTR_TYPE__ intptr_t;
 struct S { unsigned long s1; void **s2[0]; };
 void **a, **b, **c, **d, **e, **f;

 static void **
-baz (long x, long y)
+baz (intptr_t x, intptr_t y)
 {
   void **s = f;
   *f = (void **) (y << 8 | (x & 0xff));
Index: gcc.dg/torture/pr51071-2.c
===
--- gcc.dg/torture/pr51071-2.c  (Revision 196507)
+++ gcc.dg/torture/pr51071-2.c  (Arbeitskopie)
@@ -1,9 +1,11 @@
 /* { dg-do compile } */
 /* { dg-options "-fno-delete-null-pointer-checks" } */

+__extension__ typedef __UINTPTR_TYPE__ uintptr_t;
+
 extern struct module __this_module;
 static inline void
-trace_module_get  (struct module *mod, unsigned long ip) { }
+trace_module_get  (struct module *mod, uintptr_t ip) { }
 struct module;
 static inline __attribute__((no_instrument_function))
 int try_module_get(struct module *module)
@@ -16,7 +18,7 @@ int try_module_get(struct module *module)
  __label__ __here;
  asm("");
  __here:
- trace_module_get(module, (unsigned long)&&__here);
+ trace_module_get(module, (uintptr_t)&&__here);
}
   else
ret = 0;
Index: gcc.dg/torture/pr53922.c
===
--- gcc.dg/torture/pr53922.c(Revision 196507)
+++ gcc.dg/torture/pr53922.c(Arbeitskopie)
@@ -1,5 +1,6 @@
 /* { dg-do run } */
 /* { dg-require-weak "" } */
+/* { dg-skip-if "No undefined" { *-*-mingw* } { "*" } { "" } } */
 /* { dg-skip-if "No undefined weak" { hppa*-*-hpux* && { ! lp64 } } {
"*" } { "" } } */
 /* { dg-options "-Wl,-undefined,dynamic_lookup" { target *-*-darwin* } } */

Index: gcc.dg/tree-ssa/vrp72.c
===
--- gcc.dg/tree-ss

Re: [patch testsuite]: Skip c-c++-common/pr54486.c test for mingw-targets

2013-03-07 Thread Jeff Law

On 03/07/2013 11:16 AM, Kai Tietz wrote:

Hi,

one small nit for mingw targets without gnu-style printf-formatter.

ChangeLog

2013-03-07  Kai Tietz  

* c-c++-common/pr54486.c: Skip test for mingw-targets.

Ok for apply?
OK.  Only because it's the testsuite and not a change to the compiler 
itself.  As Jakub mentioned, we need to be locking things down pretty 
tight at this stage in the game.


Jeff



Re: [patch testsuite]: Fixes in gcc.dg for mingw-targets

2013-03-07 Thread Jeff Law

On 03/07/2013 11:34 AM, Kai Tietz wrote:

Hi,

this patch fixes some remaining issue for mingw-targets in gcc.dg's testsuite.

ChangeLog

2013-03-07  Kai Tietz  

* gcc.dg/pr14092-1.c: Mark intptr_t typedef to use extension.
* gcc.dg/pr24683.c: Avoid warning about casting constant string.
* gcc.dg/pr52549.c: Add LLP64 case.
* gcc.dg/pr53701.c: Use for uintptr_t typedef __UINTPTR_TYPE__.
* gcc.dg/pr56510.c: Adjust for LLP64 targets.
* gcc.dg/torture/pr51071-2.c: Likewise.
* gcc.dg/tree-ssa/vrp72.c: Likewise.
* gcc.dg/tree-ssa/vrp73.c: Likewise.
* gcc.dg/tree-ssa/vrp75.c: Likewise.
* gcc.dg/torture/pr53922.c: Skike for mingw-targets.
* gcc.dg/weak/weak-1.c: Likewise.
* gcc.dg/weak/weak-2.c: Likewise.
* gcc.dg/weak/weak-3.c: Likewise.
* gcc.dg/weak/weak-4.c: Likewise.
* gcc.dg/weak/weak-5.c: Likewise.
* gcc.dg/weak/weak-15.c: Likewise.
* gcc.dg/weak/weak-16.c: Likewise.

OK.  Same note as previous change, only because it's the testsuite :-)

jeff



[Patch, libfortran] PR51825 - Fortran runtime error: Cannot match namelist object name

2013-03-07 Thread Tilo Schwarz

Hi,

this patch fixes PR 51825.

Built and regtested on Linux 3.2.0-4-686-pae.

(Dear Jerry, this is my patch you wanted to look at, but improved with  
test cases and Changelog. Please consider looking at this version instead  
of the old version. Thank you!)


Regards,

Tilo2013-03-07  Tilo Schwarz  

	PR libfortran/51825
	* io/list_read.c (nml_read_obj): Don't end the component loop on a
	nested derived type, but continue with the next loop iteration.
	(nml_get_obj_data): Don't move the first_nl pointer further in the
	list if a qualifier was found.
	* gcc/testsuite/gfortran.dg/namelist_77.f90: New.
	* gcc/testsuite/gfortran.dg/namelist_78.f90: New.

diff --git a/gcc/testsuite/gfortran.dg/namelist_77.f90 b/gcc/testsuite/gfortran.dg/namelist_77.f90
new file mode 100644
index 000..3ce2ee7
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/namelist_77.f90
@@ -0,0 +1,48 @@
+! { dg-do run }
+! PR 51825 - Fortran runtime error: Cannot match namelist object name
+! Test case derived from PR.
+
+module local_mod
+
+type mytype1
+integer :: int1
+end type
+
+type mytype2
+integer :: n_x   
+integer :: n_px
+end type
+
+type beam_init_struct
+character(16) :: chars(1) = ''  
+type (mytype1) dummy
+type (mytype2) grid(1)  
+end type
+
+end module
+
+program error_namelist
+
+use local_mod
+
+implicit none
+
+type (beam_init_struct) beam_init
+
+namelist / error_params / beam_init
+
+open (10, status='scratch')
+write (10, '(a)') "&error_params"
+write (10, '(a)') "  beam_init%chars(1)='JUNK'"
+write (10, '(a)') "  beam_init%grid(1)%n_x=3"
+write (10, '(a)') "  beam_init%grid(1)%n_px=2"
+write (10, '(a)') "/"
+rewind(10)
+read(10, nml=error_params)
+close (10)
+
+if (beam_init%chars(1) /= 'JUNK') call abort
+if (beam_init%grid(1)%n_x /= 3) call abort
+if (beam_init%grid(1)%n_px /= 2) call abort
+
+end program
diff --git a/gcc/testsuite/gfortran.dg/namelist_78.f90 b/gcc/testsuite/gfortran.dg/namelist_78.f90
new file mode 100644
index 000..2ed41ce
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/namelist_78.f90
@@ -0,0 +1,32 @@
+! { dg-do run }
+! Test case regarding namelist problems with derived types
+
+program namelist
+
+type d1
+integer :: j = 0
+end type d1
+
+type d2
+type(d1) k
+end type d2
+
+type d3
+type(d2) d(2)
+end type d3
+
+type(d3) der
+namelist /nmlst/ der
+
+open (10, status='scratch')
+write (10, '(a)') "&NMLST"
+write (10, '(a)') " DER%D(1)%K%J = 1,"
+write (10, '(a)') " DER%D(2)%K%J = 2,"
+write (10, '(a)') "/"
+rewind(10)
+read(10, nml=nmlst)
+close (10)
+
+if (der%d(1)%k%j /= 1) call abort
+if (der%d(2)%k%j /= 2) call abort
+end program namelist
diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c
index fb8a841..6f2f7b9 100644
--- a/libgfortran/io/list_read.c
+++ b/libgfortran/io/list_read.c
@@ -2578,17 +2578,17 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
 	   since a single object can have multiple reads.  */
 	dtp->u.p.expanded_read = 0;
 
-	/* Now loop over the components. Update the component pointer
-	   with the return value from nml_write_obj.  This loop jumps
-	   past nested derived types by testing if the potential
-	   component name contains '%'.  */
+	/* Now loop over the components.  */
 
 	for (cmp = nl->next;
 		 cmp &&
-		   !strncmp (cmp->var_name, obj_name, obj_name_len) &&
-		   !strchr (cmp->var_name + obj_name_len, '%');
+		   !strncmp (cmp->var_name, obj_name, obj_name_len);
 		 cmp = cmp->next)
 	  {
+		/* Jump over nested derived type by testing if the potential
+		   component name contains '%'.  */
+		if (strchr (cmp->var_name + obj_name_len, '%'))
+		continue;
 
 		if (nml_read_obj (dtp, cmp, (index_type)(pdata - nl->mem_pos),
   pprev_nl, nml_err_msg, nml_err_msg_size,
@@ -2901,7 +2901,8 @@ get_name:
 	  goto nml_err_ret;
 	}
 
-  if (*pprev_nl == NULL || !component_flag)
+  /* Don't move first_nl further in the list if a qualifier was found.  */
+  if ((*pprev_nl == NULL && !qualifier_flag) || !component_flag)
 	first_nl = nl;
 
   root_nl = nl;


Fix vector C++11 allocator bug

2013-03-07 Thread François Dumont

Hi

While working on unordered containers C++11 allocator integration I 
used forward_list tests you have done Jon. It reported some problems 
that should have been seen on forward_list or vector allocator tests too 
if those tests were indeed manipulating memory. But there weren't 
because no element was ever injected in the containers.


So I have started injecting elements and the propagating_allocator 
issue shown up like in my unordered container tests. The problem is that 
there is an assertion in the allocator to check that memory is returned 
to the correct allocator instance thanks to the personality. But when 
forward_list or vector instances with non propagating allocators are 
swapped personnality is not swapped and the issue. So I have introduced 
a bool template parameter to disable all assertions regarding 
personality so that the allocator can still be used to check that 
personality hasn't been exchanged.


Additional, making the vector tests more functional revealed a bug 
in vector implementation.


2013-03-08  François Dumont  

* include/bits/vector.tcc (vector<>operator=(const vector<>&):
Reset pointers after deallocation when memory can't be reused.
* testsuite/util/testsuite_allocator.h (uneq_allocator<>): Add
IgnorePerson template parameter to disable assertions regarding
allocator personality.
* testsuite/23_containers/vector/allocator/minimal.cc: Insert
element to really challenge C++11 allocator integration.
* testsuite/23_containers/vector/allocator/copy.cc: Likewise.
* testsuite/23_containers/vector/allocator/copy_assign.cc:
Likewise.
* testsuite/23_containers/vector/allocator/move_assign.cc:
Likewise.
* testsuite/23_containers/vector/allocator/swap.cc: Disable
assertions regarding allocator personality when swapping vectors
with not propagating allocators.
* testsuite/23_containers/forward_list/allocator/minimal.cc:
Insert element to really challenge C++11 allocator integration.
* testsuite/23_containers/forward_list/allocator/copy.cc:
Likewise.
* testsuite/23_containers/forward_list/allocator/copy_assign.cc:
Likewise.
* testsuite/23_containers/forward_list/allocator/move_assign.cc:
Likewise.
* testsuite/23_containers/forward_list/allocator/swap.cc: Disable
assertions regarding allocator personality when swapping vectors
with not propagating allocators.


Tested under Linux x86_64.

Ok to commit ?

François

Index: include/bits/vector.tcc
===
--- include/bits/vector.tcc	(revision 196526)
+++ include/bits/vector.tcc	(working copy)
@@ -173,6 +173,9 @@
 		  _M_deallocate(this->_M_impl._M_start,
 this->_M_impl._M_end_of_storage
 - this->_M_impl._M_start);
+		  this->_M_impl._M_start = nullptr;
+		  this->_M_impl._M_finish = nullptr;
+		  this->_M_impl._M_end_of_storage = nullptr;
 		}
 	  std::__alloc_on_copy(_M_get_Tp_allocator(),
    __x._M_get_Tp_allocator());
Index: testsuite/23_containers/vector/allocator/minimal.cc
===
--- testsuite/23_containers/vector/allocator/minimal.cc	(revision 196526)
+++ testsuite/23_containers/vector/allocator/minimal.cc	(working copy)
@@ -35,6 +35,7 @@
   typedef std::allocator_traits traits_type;
   typedef std::vector test_type;
   test_type v(alloc_type{});
+  v.push_back(T());
   VERIFY( v.max_size() == traits_type::max_size(v.get_allocator()) );
 }
 
Index: testsuite/23_containers/vector/allocator/copy.cc
===
--- testsuite/23_containers/vector/allocator/copy.cc	(revision 196526)
+++ testsuite/23_containers/vector/allocator/copy.cc	(working copy)
@@ -31,6 +31,7 @@
   typedef propagating_allocator alloc_type;
   typedef std::vector test_type;
   test_type v1(alloc_type(1));
+  v1.push_back(T());
   test_type v2(v1);
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(0 == v2.get_allocator().get_personality());
@@ -42,6 +43,7 @@
   typedef propagating_allocator alloc_type;
   typedef std::vector test_type;
   test_type v1(alloc_type(1));
+  v1.push_back(T());
   test_type v2(v1);
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());
Index: testsuite/23_containers/vector/allocator/move_assign.cc
===
--- testsuite/23_containers/vector/allocator/move_assign.cc	(revision 196526)
+++ testsuite/23_containers/vector/allocator/move_assign.cc	(working copy)
@@ -31,7 +31,9 @@
   typedef propagating_allocator alloc_type;
   typedef std::vector test_type;
   test_type v1(alloc_type(1));
+  v1.push_back(T());
   test_type v2(alloc_type(2));
+  v2.push_back(T());
   v2 = std::move(v1);
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(2 == v2.get_allocator().get_personality());
@@ -43,8 +45,10 @@
  

Re: Fix vector C++11 allocator bug

2013-03-07 Thread Jonathan Wakely
On 7 March 2013 21:28, François Dumont wrote:
> Hi
>
> While working on unordered containers C++11 allocator integration I used
> forward_list tests you have done Jon. It reported some problems that should
> have been seen on forward_list or vector allocator tests too if those tests
> were indeed manipulating memory. But there weren't because no element was
> ever injected in the containers.
>
> So I have started injecting elements and the propagating_allocator issue
> shown up like in my unordered container tests. The problem is that there is
> an assertion in the allocator to check that memory is returned to the
> correct allocator instance thanks to the personality. But when forward_list
> or vector instances with non propagating allocators are swapped personnality
> is not swapped and the issue. So I have introduced a bool template parameter
> to disable all assertions regarding personality so that the allocator can
> still be used to check that personality hasn't been exchanged.
>
> Additional, making the vector tests more functional revealed a bug in
> vector implementation.

Good catch, thanks.

Instead of making uneq_allocator more complicated how about just doing
std::swap(v1, v2) again after the tests comparing get_personality?

So we don't touch uneq_allocator, keep the operator== overloads in the
test, and the diff for forward_list/allocator/swap.cc just becomes

diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc
b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc
index a2e70b7..b5b4480 100644
--- a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc
+++ b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc
@@ -48,10 +48,14 @@ void test01()
   typedef propagating_allocator alloc_type;
   typedef std::forward_list test_type;
   test_type v1(alloc_type(1));
+  v1.push_front(T());
   test_type v2(alloc_type(2));
+  v2.push_front(T());
   std::swap(v1, v2);
   VERIFY(1 == v1.get_allocator().get_personality());
   VERIFY(2 == v2.get_allocator().get_personality());
+  // swap back so assertions in uneq_allocator::deallocate don't fail
+  std::swap(v1, v2);
 }

 void test02()
@@ -60,7 +64,9 @@ void test02()
   typedef propagating_allocator alloc_type;
   typedef std::forward_list test_type;
   test_type v1(alloc_type(1));
+  v1.push_front(T());
   test_type v2(alloc_type(2));
+  v2.push_front(T());
   std::swap(v1, v2);
   VERIFY(2 == v1.get_allocator().get_personality());
   VERIFY(1 == v2.get_allocator().get_personality());


That fixes the forward_list failure.  I'm just testing teh vector parts now ...


Re: [LIBFFI] Re: Re: [PATCH] Add support for PaX enable kernels (MPROTECT)

2013-03-07 Thread Dave Korn
On 21/02/2013 19:35, Anthony Green wrote:

> This patch looks fine, thanks.  I don't plan to merge back into GCC
> for at least a week or two, so I think you should commit it to the GCC
> tree independently.

  Committed to GCC revision 196527.  Thanks!

cheers,
  DaveK



Re: Fix vector C++11 allocator bug

2013-03-07 Thread Jonathan Wakely
On 7 March 2013 22:21, Jonathan Wakely wrote:
> On 7 March 2013 21:28, François Dumont wrote:
>> Hi
>>
>> While working on unordered containers C++11 allocator integration I used
>> forward_list tests you have done Jon. It reported some problems that should
>> have been seen on forward_list or vector allocator tests too if those tests
>> were indeed manipulating memory. But there weren't because no element was
>> ever injected in the containers.
>>
>> So I have started injecting elements and the propagating_allocator issue
>> shown up like in my unordered container tests. The problem is that there is
>> an assertion in the allocator to check that memory is returned to the
>> correct allocator instance thanks to the personality. But when forward_list
>> or vector instances with non propagating allocators are swapped personnality
>> is not swapped and the issue. So I have introduced a bool template parameter
>> to disable all assertions regarding personality so that the allocator can
>> still be used to check that personality hasn't been exchanged.
>>
>> Additional, making the vector tests more functional revealed a bug in
>> vector implementation.
>
> Good catch, thanks.
>
> Instead of making uneq_allocator more complicated how about just doing
> std::swap(v1, v2) again after the tests comparing get_personality?
>
> So we don't touch uneq_allocator, keep the operator== overloads in the
> test, and the diff for forward_list/allocator/swap.cc just becomes
>
> diff --git 
> a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc
> b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc
> index a2e70b7..b5b4480 100644
> --- a/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc
> +++ b/libstdc++-v3/testsuite/23_containers/forward_list/allocator/swap.cc
> @@ -48,10 +48,14 @@ void test01()
>typedef propagating_allocator alloc_type;
>typedef std::forward_list test_type;
>test_type v1(alloc_type(1));
> +  v1.push_front(T());
>test_type v2(alloc_type(2));
> +  v2.push_front(T());
>std::swap(v1, v2);
>VERIFY(1 == v1.get_allocator().get_personality());
>VERIFY(2 == v2.get_allocator().get_personality());
> +  // swap back so assertions in uneq_allocator::deallocate don't fail
> +  std::swap(v1, v2);
>  }
>
>  void test02()
> @@ -60,7 +64,9 @@ void test02()
>typedef propagating_allocator alloc_type;
>typedef std::forward_list test_type;
>test_type v1(alloc_type(1));
> +  v1.push_front(T());
>test_type v2(alloc_type(2));
> +  v2.push_front(T());
>std::swap(v1, v2);
>VERIFY(2 == v1.get_allocator().get_personality());
>VERIFY(1 == v2.get_allocator().get_personality());
>
>
> That fixes the forward_list failure.  I'm just testing teh vector parts now 
> ...

As expected it works for vector/swap.cc too.  So we definitely need
the bug fix to std::vector::operator= and the testsuite changes to add
elements, but I think I'd prefer to just re-swap the containers in the
non-propagating case.


PR 56524: TREE_OPTIMIZATION_OPTABS vs. mips16

2013-03-07 Thread Richard Sandiford
This assert in save_optabs_if_changed triggered for gcc.dg/pr43564.c
on mips64-linux-gnu (-mabi=32/-mips16):

  /* ?? If this fails, we should temporarily restore the default
 target first (set_cfun (NULL) ??), do the rest of this function,
 and then restore it.  */
  gcc_assert (this_target_optabs == &default_target_optabs);

We can't do what the comment says because set_cfun (NULL) might not
choose default_target_optabs.  (On MIPS, default_target_optabs is
always for the standard encoding, in order to reduce the differences
between the -mips16 command-line option and "mips16" function attribute.)

The patch instead records which value of this_target_optabs was used
to generate TREE_OPTIMIZATION_OPTABS.  This has the additional advantage
that we won't recompute the optabs if successive functions use the same
optimisation node and same non-default target (which, given the above,
is relatively likely with -mips16).

Recording the base this_target_optabs also lets us initialise
TREE_OPTIMIZATION_OPTABS lazily, so that the C front end doesn't need
to compute optabs when parsing the "optimize" attribute.  That's probably
only a minor benefit though.

After this change, cfun->optabs is only useful on switchable targets
if we regularly switch between functions that have the same non-default
optimisation node and _different_ subtargets.  This seems like a
relatively unusual case so I removed cfun->optabs for simplicity.
However, Jakub didn't think that was a good idea, and since "simplicity"
is a bit of weak argument (especially as Jakub says for something that's
already implemented), I was going to submit two alternatives, one that
kept cfun->optabs and one that didn't.

However, I think there are two other benefits to removing cfun->optabs:

- It means that the TREE_OPTIMIZATION_OPTABS are unequivocally owned by
  the optimisation node, rather than shared between the node and the
  function structure.  It's therefore safe to clear the old optabs when
  we want to recompute them.

- The current implementation of the cache is:

  struct function *fn = DECL_STRUCT_FUNCTION (fndecl);
  if (fn->optabs == NULL)
{
  if (this_target_optabs == &default_target_optabs)
fn->optabs = TREE_OPTIMIZATION_OPTABS (opts);
  else
{
  fn->optabs = (unsigned char *)
ggc_alloc_atomic (sizeof (struct target_optabs));
  init_all_optabs ((struct target_optabs *) fn->optabs);
}
}
  this_fn_optabs = fn->optabs ? (struct target_optabs *) fn->optabs
  : this_target_optabs;

  The equivalent code under the new scheme would be:

  struct function *fn = DECL_STRUCT_FUNCTION (fndecl);
  if (fn->optabs == NULL)
{
  init_tree_optimization_optabs (opts);
  fn->optabs = TREE_OPTIMIZATION_OPTABS (opts);
}
  this_fn_optabs = fn->optabs ? (struct target_optabs *) fn->optabs
  : this_target_optabs;

  But this wouldn't help if the optimisation node does not need different
  optabs from this_target_optabs.  fn->optabs would remain null and
  we'd still go through init_tree_optimization_optabs each time.

  And I think that's almost always going to be the case with optabs
  on MIPS, the only switchable target.  I think the only optabs that
  depend on flags are the floating-point division patterns, which depend
  on flag_unsafe_math_optimizations when using -mfix-sb1.  But the SB-1
  doesn't have MIPS16 support, so it's unlikely that you'd use the two
  together.  And that's building on top of what already seems an unlikely
  situation.  Assuming I've not missed some patterns (which is a very risky
  assumption), I'm not sure anyone would benefit in practice.

  We could add a flag to say whether cfun->optabs is valid, but that's
  adding even more complexity.

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

Richard


gcc/
PR middle-end/56524
* tree.h (tree_optimization_option): Rename target_optabs to optabs.
Add base_optabs.
(TREE_OPTIMIZATION_OPTABS): Update after previous field change.
(TREE_OPTIMIZATION_BASE_OPTABS): New macro.
(save_optabs_if_changed): Replace with...
(init_tree_optimization_optabs): ...this.
* optabs.c (save_optabs_if_changed): Rename to...
(init_tree_optimization_optabs): ...this.  Take the optimization node
as argument.  Do nothing if the base optabs are already correct.
* function.h (function): Remove optabs field.
* function.c (invoke_set_current_function_hook): Call
init_tree_optimization_optabs.  Use the result to initialize
this_fn_optabs.

gcc/c-family/
PR middle-end/56524
* c-common.c (handle_optimize_attribute): Don't call
save_optabs_if_changed.

gcc/

Re: PR 56524: TREE_OPTIMIZATION_OPTABS vs. mips16

2013-03-07 Thread Jakub Jelinek
On Thu, Mar 07, 2013 at 10:51:14PM +, Richard Sandiford wrote:
>  void
> -save_optabs_if_changed (tree fndecl)
> +init_tree_optimization_optabs (tree optnode)
>  {
> -  /* ?? If this fails, we should temporarily restore the default
> - target first (set_cfun (NULL) ??), do the rest of this function,
> - and then restore it.  */
> -  gcc_assert (this_target_optabs == &default_target_optabs);
> +  /* Quick exit if we have already computed optabs for this target.  */
> +  if (TREE_OPTIMIZATION_BASE_OPTABS (optnode) == this_target_optabs)
> +return;
>  
> +  /* Forget any previous information and set up for the current target.  */
> +  TREE_OPTIMIZATION_BASE_OPTABS (optnode) = this_target_optabs;
>struct target_optabs *tmp_optabs = (struct target_optabs *)
> -ggc_alloc_atomic (sizeof (struct target_optabs));
> -  tree optnode = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl);
> +TREE_OPTIMIZATION_OPTABS (optnode);
> +  if (tmp_optabs)
> +memset (tmp_optabs, 0, sizeof (struct target_optabs));
> +  else
> +tmp_optabs = (struct target_optabs *)
> +  ggc_alloc_atomic (sizeof (struct target_optabs));
>  
>/* Generate a new set of optabs into tmp_optabs.  */
>init_all_optabs (tmp_optabs);

If TARGET_OPTIMIZATION_OPTABS is non-NULL upon entering the function,
then we call memset above, and then

...

  /* If the optabs changed, record it.  */
  if (memcmp (tmp_optabs, this_target_optabs, sizeof (struct target_optabs)))
{
  if (TREE_OPTIMIZATION_OPTABS (optnode))
ggc_free (TREE_OPTIMIZATION_OPTABS (optnode));

  TREE_OPTIMIZATION_OPTABS (optnode) = (unsigned char *) tmp_optabs;

As tmp_optabs == TREE_OPTIMIZATION_OPTABS (optnode); in that case,
the ggc_free is wrong, TREE_OPTIMIZATION_OPTABS (optnode) will then point
to freed memory.

So I think the

  if (TREE_OPTIMIZATION_OPTABS (optnode))
ggc_free (TREE_OPTIMIZATION_OPTABS (optnode));

has to be removed (of course the second ggc_free, if memcmp returned 0, is
desirable).  Otherwise looks good.

Jakub


Re: [PATCH, updated] Vtable pointer verification, C++ front end changes (patch 1 of 3)

2013-03-07 Thread Caroline Tice
Ping?

-- Caroline Tice
cmt...@google.com


On Mon, Feb 25, 2013 at 11:24 AM, Caroline Tice  wrote:
> Here are the latest changes to the vtable pointer verification patches
> (again there are 3 patches: c++ front end, main gcc, and c++ runtime
> library).  I think these address all the review comments I have
> received so far.  This patch is the for C++ front end.  Please review
> these changes and let me know if they will be ok to commit once stage
> 1 opens.
>
> -- Caroline Tice
> cmt...@google.com
>
> 2013-02-25  Caroline Tice  
>
> * class.c (finish_struct_1):  Add call to vtv_save_class_info if 
> vtable
> verification is turned on.
> * config-lang.in: Add vtable-class-hierarchy.c to the list of files
> that use GCC's garbage collector.
> * g++spec.c (VTABLE_LOAD_MODULE_UNIT): New macro for link option 
> needed
> with vtable verification.
> (lang_specific_driver): Added variable to indicate if vtable
> verification option is used, and which flavor. Process -fvtable-verify
> option, update num_args if option is present, and add appropriate
> driver options if fvtable-verify is present.
> * vtable-class-hierarchy.c:  New file, containing the bulk of vtable
> verification's front-end work.
> * mangle.c (get_mangled_vtable_map_var_name): New function.
> * decl2.c (start_objects):  Update function comment.
> (cp_write_global_declarations):  If vtable verification is turned on,
> call vtv_recover_class_info and
> vtv_compute_class_hierarchy_transitive_closure before calling
> finalize_compilation_unit.  Call vtv_generate_init_routine after.
> (vtv_start_verification_constructor_init_function): New externally
> visible wrapper function to call start_objects for vtable 
> verification.
> (vtv_finish_verification_constructor_init_function):  New function.
> * init.c (build_vtbl_address):  Make function not static (externally
> visible).
> * Make-lang.in: (CXX_AND_OBJCXX_OBJS):  Add vtable-class-hierarchy.o 
> to
> list of object files.
> (vtable-class-hierarchy.o):  Add rule for building object file.
> * pt.c (mark_class_instantiated):  Add call to vtv_save_class_info if
> vtable verification is turned on.
> * cp-tree.h: Add extern function declarations for
> vtv_start_verification_constructor_init_function,
> vtv_finish_verification_constructor_init_function, build_vtbl_address,
> vtv_compute_class_hierarchy_transitive_closure,
> vtv_generate_init_routine, vtv_save_class_info,
> vtv_recover_class_info and get_mangled_vtable_map_var_name.


Re: [PATCH, updated] Vtable pointer verification, main gcc changes (patch 2 of 3)

2013-03-07 Thread Caroline Tice
Ping?

-- Caroline
cmt...@google.com


On Mon, Feb 25, 2013 at 11:27 AM, Caroline Tice  wrote:
> Here are the latest changes to the vtable pointer verification patches
> (again there are 3 patches: c++ front end, main gcc, and c++ runtime
> library).  I think these address all the review comments I have
> received so far.  This patch is the for main gcc.  Please review these
> changes and let me know if they will be ok to commit once stage 1
> opens.
>
> -- Caroline Tice
> cmt...@google.com
>
> 2013-02-25  Caroline Tice  
>
> * configure (CXX_FOR_TARGET): Add libstdc++-v3/libsupc++/.libs to the
> library search path.
> * ligbcc/config.host (extra_parts):  Add vtv_start.o and vtv_end.o to
> the list.
> * libgcc/Makefile.in: Add definitin for gcc_srcdir; add rules for
> building vtv_start.o and vtv_end.o.
> * passes.c (init_optimization_pass): Add pass_vtable_verify.
> * vtv_start.c:  New file.
> * tree-pass.h (pass_vtable_verify): Declare new pass.
> * tree-vtable-verify.c:  New file, contains vtable verification tree
> pass.
> * tree-vtable-verify.h: New file.
> * common.opt: (fvtable-verify=): New option. Also define vtv_priority
> values for the option.
> * timevar.def (TV_VTABLE_VERIFICATION):  Declare new time var.
> * config/gnu-user.h: Add vtv_start.o to STARTFILE_SPEC if
> fvtable-verify is present; Add vtv_end.o to ENDFILE_SPEC if
> fvtable-verify is present.
> * tree.h: Add extern function declaration for save_vtable_map_decl.
> * vtv_end.c:  New file.
> * flag-types.h (vtv_priority):  New enum, for values for new
> '-fvtable-verify=' option.
> * Makefile.in (OBJS):  Add tree-vtable-verify.o to list of object
> files.
> (tree-vtable-verify.o):  Add rule for building object file.
> (GTFILES): Add tree-vtable-verify.c to list of files that use GCC's
> garbage collector.
> * varasm.c (assemble_variable): Add code for handling variables that
> go into the ".vtable_map_vars" section.
> (assemble_vtv_perinit_initializer):  New function.
> (default_section_type_flags):  Add SECTION_LINKONCE to
> ".vtable_map_vars" section items.
> * output.h (assemble_vtv_preinit_initializer):  External function 
> decl.


Re: [PATCH, updated] Vtable pointer verification, runtime library changes (patch 3 of 3)

2013-03-07 Thread Jonathan Wakely
On 7 March 2013 23:53, Caroline Tice wrote:
> Hello,
>
> I believe this patch addresses all of your comments; I modified the
> configure.ac files to generate the configures, and I fixed the
> spelling mistakes in the comments.  I still get the warnings when
> generating the Makefile.in files from the Makefile.am files, but the
> resulting files seem to be correct, and I don't know how to make the
> warnings go away.
>
> Please review this patch and let me know if it will be ok to commit
> when GCC opens up again.

I'd like to know if someone with better automake skills than I have
can do anything about that warning, but otherwise that looks OK to me,
thanks.


[PATCH] cpuid check code in libgcc, fix cpuinfo code for sandybridge detection

2013-03-07 Thread Sriraman Tallam
Hi,

   I committed this simple patch to check for sandybridge processors
when cpuid model number is 0x2d. This is the model for SandyBridge-E
processors : 
http://software.intel.com/en-us/articles/intel-architecture-and-processor-identification-with-cpuid-model-and-family-numbers


Index: config/i386/cpuinfo.c
===
--- config/i386/cpuinfo.c (revision 196527)
+++ config/i386/cpuinfo.c (working copy)
@@ -178,6 +178,7 @@ get_intel_cpu (unsigned int family, unsigned int m
   __cpu_model.__cpu_subtype = INTEL_COREI7_WESTMERE;
   break;
 case 0x2a:
+case 0x2d:
   /* Sandy Bridge.  */
   __cpu_model.__cpu_type = INTEL_COREI7;
   __cpu_model.__cpu_subtype = INTEL_COREI7_SANDYBRIDGE;


Thanks
Sri


[GOOGLE] Fix incorrect dependency in Makefile.in

2013-03-07 Thread Dehao Chen
This patch fixes the incorrect dependency in Makefile.in.

Bootstrapped and passed regression test.

Okay for google-4_7 branch?

Thanks,
DehaoIndex:

gcc/Makefile.in
===
--- gcc/Makefile.in (revision 196532)
+++ gcc/Makefile.in (working copy)
@@ -3442,7 +3442,7 @@
$(TREE_PASS_H) $(TREE_FLOW_H) $(TREE_INLINE_H)
 cfglayout.o : cfglayout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(RTL_H) $(TREE_H) insn-config.h $(BASIC_BLOCK_H) hard-reg-set.h output.h \
-   $(FUNCTION_H) $(CFGLAYOUT_H) $(CFGLOOP_H) $(TARGET_H) gt-cfglayout.h \
+   $(FUNCTION_H) $(CFGLAYOUT_H) $(CFGLOOP_H) $(TARGET_H) \
$(GGC_H) alloc-pool.h $(FLAGS_H) $(OBSTACK_H) $(TREE_PASS_H) vecprim.h \
$(DF_H) $(EMIT_RTL_H) $(COMMON_TARGET_H)
 timevar.o : timevar.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \


Re: [PATCH] PowerPC merge TD/TF moves

2013-03-07 Thread David Edelsohn
On Wed, Jan 30, 2013 at 5:50 PM, Michael Meissner
 wrote:
> This patch like the previous 2 pages combines the decimal and binary floating
> point moves, this time for 128-bit floating point.
>
> In doing this patch, I discovered that I left out the code in the previous
> patch to enable the wg constraint to enable -mcpu=power6x to utilize the 
> direct
> move instructions.  So, I added the code in this patch, and also created a 
> test
> to make sure that direct moves are generated in the future.
>
> I also added the reload helper for DDmode to rs6000_vector_reload that was
> missed in the last patch.  This was harmless, since that is only used with an
> undocumented debug switch.  Hopefully sometime in the future, I will scalar
> floating point to be able to be loaded in the upper 32 VSX registers that are
> overlaid over the Altivec registers.
>
> Like the previous 2 patches, I've bootstrapped this, and ran make check with 
> no
> regressions.  Is it ok to apply when GCC 4.9 opens up?
>
> I have one more patch in the insn combination to post, combining movdi on
> systems with normal floating point and with the power6 direct move
> instructions.

Mike,

Which of these sets of patches adjusts and updates
rs6000_register_move_cost for -mfpgpr and for VSRs and FPRs sharing
the same register file?

Thanks, David