Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals

2014-01-22 Thread Dodji Seketeli
Bernd Edlinger  writes:

> Hi,

Hello,

> since there was no progress in the last 2 months on that matter,

Sorry, this is my bad.  I got sidetracked by something else and forgot
that I had the patch working et al, and all its bits that need approval
got approved.  It still can go in right now.  It improves performance
and fixes the issue the way it was discussed.

Here it is, regtested on x86_64-linux-gnu against trunk.

If nobody objects in the next 24 hours, I'll commit it.

libcpp/ChangeLog:

* include/line-map.h (linemap_get_file_highest_location): Declare
new function.
* line-map.c (linemap_get_file_highest_location): Define it.

gcc/ChangeLog:

* input.h (location_get_source_line): Take an additional line_size
parameter.
(void diagnostics_file_cache_fini): Declare new function.
* input.c (struct fcache): New type.
(fcache_tab_size, fcache_buffer_size, fcache_line_record_size):
New static constants.
(diagnostic_file_cache_init, total_lines_num)
(lookup_file_in_cache_tab, evicted_cache_tab_entry)
(add_file_to_cache_tab, lookup_or_add_file_to_cache_tab)
(needs_read, needs_grow, maybe_grow, read_data, maybe_read_data)
(get_next_line, read_next_line, goto_next_line, read_line_num):
New static function definitions.
(diagnostic_file_cache_fini): New function.
(location_get_source_line): Take an additional output line_len
parameter.  Re-write using lookup_or_add_file_to_cache_tab and
read_line_num.
* diagnostic.c (diagnostic_finish): Call
diagnostic_file_cache_fini.
(adjust_line): Take an additional input parameter for the length
of the line, rather than calculating it with strlen.
(diagnostic_show_locus): Adjust the use of
location_get_source_line and adjust_line with respect to their new
signature.  While displaying a line now, do not stop at the first
null byte.  Rather, display the zero byte as a space and keep
going until we reach the size of the line.
* Makefile.in: Add vec.o to OBJS-libcommon

gcc/testsuite/ChangeLog:

* c-c++-common/cpp/warning-zero-in-literals-1.c: New test file.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@204453 
138bc75d-0d04-0410-961f-82ee72b054a4

Signed-off-by: Dodji Seketeli 
---
 gcc/Makefile.in|   3 +-
 gcc/diagnostic.c   |  19 +-
 gcc/diagnostic.h   |   1 +
 gcc/input.c| 633 -
 gcc/input.h|   5 +-
 .../c-c++-common/cpp/warning-zero-in-literals-1.c  | Bin 0 -> 240 bytes
 libcpp/include/line-map.h  |   8 +
 libcpp/line-map.c  |  40 ++
 8 files changed, 670 insertions(+), 39 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/cpp/warning-zero-in-literals-1.c

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 4d683a0..06c617a 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1472,7 +1472,8 @@ OBJS = \
 
 # Objects in libcommon.a, potentially used by all host binaries and with
 # no target dependencies.
-OBJS-libcommon = diagnostic.o diagnostic-color.o pretty-print.o intl.o input.o 
version.o
+OBJS-libcommon = diagnostic.o diagnostic-color.o pretty-print.o intl.o \
+   vec.o  input.o version.o
 
 # Objects in libcommon-target.a, used by drivers and by the core
 # compiler and containing target-dependent code.
diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 36094a1..6c83f03 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -176,6 +176,8 @@ diagnostic_finish (diagnostic_context *context)
 progname);
   pp_newline_and_flush (context->printer);
 }
+
+  diagnostic_file_cache_fini ();
 }
 
 /* Initialize DIAGNOSTIC, where the message MSG has already been
@@ -259,12 +261,13 @@ diagnostic_build_prefix (diagnostic_context *context,
MAX_WIDTH by some margin, then adjust the start of the line such
that the COLUMN is smaller than MAX_WIDTH minus the margin.  The
margin is either 10 characters or the difference between the column
-   and the length of the line, whatever is smaller.  */
+   and the length of the line, whatever is smaller.  The length of
+   LINE is given by LINE_WIDTH.  */
 static const char *
-adjust_line (const char *line, int max_width, int *column_p)
+adjust_line (const char *line, int line_width,
+int max_width, int *column_p)
 {
   int right_margin = 10;
-  int line_width = strlen (line);
   int column = *column_p;
 
   right_margin = MIN (line_width - column, right_margin);
@@ -284,6 +287,7 @@ diagnostic_show_locus (diagnostic_context * context,
   const diagnostic_info *diagnostic)
 {
   const char *line;
+  int line_width;
   char *buffer;
   expanded_location s;
   int m

Re: Resolve pr44194-1.c failure by refining scan-rtl-dump-not pattern

2014-01-22 Thread Richard Sandiford
Eric Botcazou  writes:
>> It looks like the committed version removed the space after "insn".
>> Was that intentional?  It now triggers on MIPS because of the frame-related
>> (insn/f) prologue instruction that stores the link register.  The posted
>> version works for me FWIW.
>
> I found out that it didn't fail with the space on x86 (hence false negative) 
> because of the TI marker added by some RTL pass.  Feel free to adjust back.

Ah, OK.  In that case, how about this?  Tested on mips64-linux-gnu.

Thanks,
Richard


gcc/testsuite/
* gcc.dg/pr44194-1.c: Match "insn " and "insn:", but not "insn/f".

Index: gcc/testsuite/gcc.dg/pr44194-1.c
===
--- gcc/testsuite/gcc.dg/pr44194-1.c2014-01-22 09:14:03.560619722 +
+++ gcc/testsuite/gcc.dg/pr44194-1.c2014-01-22 09:15:32.657347434 +
@@ -15,5 +15,9 @@ void func() {
 /* { dg-final { scan-rtl-dump "global deletions = (2|3)" "dse1" } } */
 /* { dg-final { cleanup-rtl-dump "dse1" } } */
 
-/* { dg-final { scan-rtl-dump-not "insn\[^\n\]*set \\(mem(?!\[^\n\]*scratch)" 
"final" } } */
+/* Here we want to ignore frame-related instructions, marked as insn/f,
+   that do things like store the link register to the stack.  We also want
+   to treat insns the same regardless of whether they have a scheduling
+   :TI marker, so match both "insn " and "insn:".  */
+/* { dg-final { scan-rtl-dump-not "insn\[: \]\[^\n\]*set 
\\(mem(?!\[^\n\]*scratch)" "final" } } */
 /* { dg-final { cleanup-rtl-dump "final" } } */


Re: [C PATCH] Warn about unused RHS of COMPOUND_EXPR (PR c/59871)

2014-01-22 Thread Marek Polacek
On Wed, Jan 22, 2014 at 12:15:00AM +0100, Jakub Jelinek wrote:
> And for
>   (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), (bar (), 7)));
> ?

Argh, for this one we've got COMPOUND_EXPRs even in TREE_OPERAND (r, 1).
Fixed & sorry.
 
> On the other side, there is warn_if_unused_value, which specifically has:
>   /* Let people do `(foo (), 0)' without a warning.  */
>   if (TREE_CONSTANT (TREE_OPERAND (exp, 1)))
> return false;
> so perhaps it is intentional that we don't warn about this?
> That stuff dates all the way back to r759.  Though I wonder why it would
> be desirable to warn about this for C++ and not for C.

This is confusing.  I'll try to sumarize what I see.  Let A, B, C, D
be stmts:

A: bar (), 1;
B: (bar (), 1);
C: bar (), 5 * i;
D: (bar (), 5 * i);

C++ warns on A and C ("right operand..."), those parentheses suppress warnings.
C before patch warns on C and D with "value computed is not used".
C with my patch warns on A, B, C, and D with "right-hand operand...".

I think what my patch does should be desirable.  I added a few more
tests into the testcase.

2014-01-22  Marek Polacek  

PR c/59871
c/
* c-typeck.c (build_compound_expr): Warn even for right-hand operand
of a comma expression.
(emit_side_effect_warnings): Likewise.
libdecnumber/
* decNumberLocal.h (UBFROMUS, UBFROMUI): Remove last argument.
testsuite/
* gcc.dg/20020220-2.c: Adjust dg-warning message.
* gcc.dg/pr59871.c: New test.

--- gcc/libdecnumber/decNumberLocal.h.mp2014-01-21 18:34:32.235540589 
+0100
+++ gcc/libdecnumber/decNumberLocal.h   2014-01-21 22:04:34.331223218 +0100
@@ -153,10 +153,9 @@ see the files COPYING3 and COPYING.RUNTI
   #define UBTOUI(b)  (memcpy((void *)&uiwork, b, 4), uiwork)
 
   /* Store a uInt, etc., into bytes starting at a char* or uByte*.*/
-  /* Returns i, evaluated, for convenience; has to use uiwork because */
-  /* i may be an expression. */
-  #define UBFROMUS(b, i)  (uswork=(i), memcpy(b, (void *)&uswork, 2), uswork)
-  #define UBFROMUI(b, i)  (uiwork=(i), memcpy(b, (void *)&uiwork, 4), uiwork)
+  /* Has to use uiwork because i may be an expression.   */
+  #define UBFROMUS(b, i)  (uswork=(i), memcpy(b, (void *)&uswork, 2))
+  #define UBFROMUI(b, i)  (uiwork=(i), memcpy(b, (void *)&uiwork, 4))
 
   /* X10 and X100 -- multiply integer i by 10 or 100 */
   /* [shifts are usually faster than multiply; could be conditional]  */
--- gcc/gcc/c/c-typeck.c.mp 2014-01-21 11:59:33.221215248 +0100
+++ gcc/gcc/c/c-typeck.c2014-01-22 11:04:51.681894533 +0100
@@ -4776,6 +4776,23 @@ build_compound_expr (location_t loc, tre
"left-hand operand of comma expression has no effect");
}
 }
+  else if (TREE_CODE (expr1) == COMPOUND_EXPR
+  && warn_unused_value)
+{
+  tree r = expr1;
+  location_t cloc = loc;
+  while (TREE_CODE (r) == COMPOUND_EXPR)
+{
+ if (EXPR_HAS_LOCATION (r))
+   cloc = EXPR_LOCATION (r);
+ r = TREE_OPERAND (r, 1);
+   }
+  if (!TREE_SIDE_EFFECTS (r)
+ && !VOID_TYPE_P (TREE_TYPE (r))
+ && !CONVERT_EXPR_P (r))
+   warning_at (cloc, OPT_Wunused_value,
+   "right-hand operand of comma expression has no effect");
+}
 
   /* With -Wunused, we should also warn if the left-hand operand does have
  side-effects, but computes a value which is not used.  For example, in
@@ -9641,6 +9658,23 @@ emit_side_effect_warnings (location_t lo
   if (!VOID_TYPE_P (TREE_TYPE (expr)) && !TREE_NO_WARNING (expr))
warning_at (loc, OPT_Wunused_value, "statement with no effect");
 }
+  else if (TREE_CODE (expr) == COMPOUND_EXPR)
+{
+  tree r = expr;
+  location_t cloc = loc;
+  while (TREE_CODE (r) == COMPOUND_EXPR)
+   {
+ if (EXPR_HAS_LOCATION (r))
+   cloc = EXPR_LOCATION (r);
+ r = TREE_OPERAND (r, 1);
+   }
+  if (!TREE_SIDE_EFFECTS (r)
+ && !VOID_TYPE_P (TREE_TYPE (r))
+ && !CONVERT_EXPR_P (r)
+ && !TREE_NO_WARNING (expr))
+   warning_at (cloc, OPT_Wunused_value,
+   "right-hand operand of comma expression has no effect");
+}
   else
 warn_if_unused_value (expr, loc);
 }
--- gcc/gcc/testsuite/gcc.dg/20020220-2.c.mp2014-01-21 14:47:58.888754509 
+0100
+++ gcc/gcc/testsuite/gcc.dg/20020220-2.c   2014-01-21 23:13:23.758405040 
+0100
@@ -1,5 +1,5 @@
 /* PR c/4697
-   Test whether value computed not used warning is given for compound
+   Test whether operand has no effect warning is given for compound
expression.  */
 /* { dg-do compile } */
 /* { dg-options "-O2 -Wunused" } */
@@ -7,6 +7,6 @@
 int b;
 int foo (int a)
 {
-  a = a + 1, 5 * b;/* { dg-warning "value computed is not used" } */
+  a = a + 1, 5 * b; /* { dg-warning "right-hand oper

Re: [Patch][AArch64] NEON vdup testcases

2014-01-22 Thread Alex Velenko

On 16/01/14 12:12, Alex Velenko wrote:

[AArch64] VDUP testcases

Hi,

This patch implements test cases for following NEON intrinsics:
vdup_lane_f32
vdup_lane_s[8,16]
vdup_lane_s[32,64]
vdup_n_[p,s,u][8,16]
vdup_n_[s,u][32,64]

vdupb_lane_[s,u]8
vduph_lane_[s,u]16
vdupd_lane_[f,s,u]64
vdups_lane_[f,s,u]32

vdupq_lane_[f,s][32,64]
vdupq_lane_s[8,16]
vdup[q]_n_f32
vdupq_n_f64
vdupq_n_[s,p,u][8,16]
vdupq_n_[s,u][32,64]

Tests succeed on both Little-Endian and Big-Eendian.

Ok for trunk?

Thanks,
Alex

gcc/testsuite/

2014-01-16  Alex Velenko  

 * gcc.target/aarch64/vdup_lane_1.c: New testcase.
 * gcc.target/aarch64/vdup_lane_2.c: New testcase.
 * gcc.target/aarch64/vdup_n_1.c: New testcase.


Ping!

Hi,
Can someone, please, review the patch?
Kind regards,
Alex Velenko


Re: [C++ Patch] PR 58980

2014-01-22 Thread Paolo Carlini

On 01/21/2014 04:16 PM, Paolo Carlini wrote:

+  if (TREE_CODE (child) == TYPENAME_TYPE)
+return false;
+

Maybe we want instead to do

if (WILDCARD_TYPE_P (child))
return false;

(which also passes testing, of course).

Thanks,
Paolo.



Re: [Patch, microblaze]: Fix ICE with mhard-float

2014-01-22 Thread David Holsgrove
Hi Michael,

On 22 January 2014 13:43, David Holsgrove  wrote:
>> -Original Message-
>> From: Michael Eager [mailto:ea...@eagerm.com]
>> Sent: Friday, 17 January 2014 4:36 am
>> To: David Holsgrove; gcc-patches@gcc.gnu.org
>> Cc: Edgar Iglesias; John Williams; Vidhumouli Hunsigida; Nagaraju Mekala
>> Subject: Re: [Patch, microblaze]: Fix ICE with mhard-float
>>
>> On 11/25/13 23:50, David Holsgrove wrote:
>> > Hi Michael,
>> >
>> > I've attached the same patch based on latest gcc master.
>> >
>> > Can this be applied to gcc-4_8-branch also.
>> >
>> > thanks,
>> > David
>> >
>> > On 15 July 2013 14:53, David Holsgrove  wrote:
>> >> Add SImode to cstoresf4's comparison operator, prevents ICE during combine
>> >> rtl pass with error message;
>> >>
>> >> internal compiler error: in simplify_subreg, at simplify-rtx.c:5725
>> >>
>> >> Use ordered_comparison_operator predicate to limit operators to
>> >> those fcmp can handle, and letting compiler reorder insns to
>> >> accommodate unordered as necessary.
>> >>
>> >> Changelog entry;
>> >>
>> >> 2013-07-15  David Holsgrove 
>> >>
>> >>   * gcc/config/microblaze/microblaze.md: Fix cstoresf4 and cbranchsf4
>> >>
>> >> Can this be backported to gcc-4_8-branch also?
>>
>>
>> Hi David --
>>
>> You mention that this patch fixes an ICE.  Is there a failing test
>> case in the GCC Test Suite?  Is there a GCC PR for this ICE?
>> If not, please add a test case to the patch.
>
> Hi Michael,
>
> Thanks for the reply. No, unfortunately there isn’t an existing test case 
> which shows this ICE.
>
> I'm in the process of trying to recreate and distil into a small test case if 
> possible, but the error was encountered whilst building a rather large app 
> using microblaze linux.
>

I've attached updated patch which includes a test case to check for
this ICE. Tested on microblaze baremetal and microblazeel linux
toolchains with / without my change.

Updated ChangeLogs would be;

gcc/ChangeLog

2014-01-22  David Holsgrove 

 * config/microblaze/microblaze.md(cstoresf4, cbranchsf4): Replace
   comparison_operator with ordered_comparison_operator.

testsuite/ChangeLog

2014-01-22  David holsgrove 

 * testsuite/gcc.target/microblaze/isa/fcmp4.c: New file.


thanks,
David

>>
>> --
>> Michael Eager  ea...@eagercon.com
>> 1960 Park Blvd., Palo Alto, CA 94306  650-325-8077
>
>
>


0001-Patch-microblaze-cstoresf4-add-mode-and-ordered_comp.patch
Description: Binary data


Re: [RFC][gomp4] Offloading patches (1/3): Add '-fopenmp_target' option

2014-01-22 Thread Andrey Turetskiy
Hi Bernd,

We have some testcases, but they require XeonPhi hardware and a
working libgomp plugin. Our current version of the plugin depends on
some libraries, that are not open-sourced yet, so currently we can’t
share it.

However, you could examine what these patches do, making the following steps:
1) Build GCC with patches:
http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01484.html
http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01485.html
http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01486.html
http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01896.html
2) Set environment variables (e.g. for two ‘targets’):
export OFFLOAD_TARGET_NAMES=mic:hsail  (for now
names don’t really matter)
export OFFLOAD_TARGET_COMPILERS=./gcc:./gcc(use GCC with
patches above as target compiler, because it must support the
-fopenmp_target option)
3) Build any example with #pragma omp target (e.g. see attachment):
./gcc -flto -fopenmp test.c -o test.exe
Options -flto and -fopenmp are necessary for using.

Now you have a binary with target images embedded and tables properly
filled. You can’t run it due to reasons mentioned above, though you
could examine it with objdump/nm/readelf to see new sections and their
content: there will be .offload_image_section with ‘target’ code and
.offload_func_table_section with ‘target’ function table.

On Tue, Jan 21, 2014 at 6:40 PM, Bernd Schmidt  wrote:
> On 12/17/2013 12:35 PM, Michael V. Zolotukhin wrote:
>>
>> Here is a set of patches implementing one more piece of offloading support
>> in
>> GCC.  These three patches allow to build a host binary with target image
>> and all
>> tables embedded.  Along with patches for libgomp and libgomp plugin, which
>> hopefully will be sent soon, that gives a functional and runnable
>> executable (or
>> DSO) with actual offloading to MIC.
>
>
> Do you have a testcase that can be used to see what this does in action?
>
>
> Bernd
>



-- 
Best regards,
Andrey Turetskiy
#define NUM 128

#pragma omp declare target
int cnt = 100;

int calc (int x)
{
  return cnt++ * x;
}
#pragma omp end declare target

int main ()
{
  int a[NUM];
  int i;

  cnt = 0;

  #pragma omp target update to(cnt)

  a[0] = 1;
  for (i = 1; i < NUM; i++)
a[i] = -a[i-1];

  #pragma omp target data map(to: a)
{
  for (i = 0; i < NUM; i++)
a[i] = 2*a[i];

  #pragma omp target
{
  for (i = 0; i < NUM; i++)
a[i] = calc (a[i]);
}

  #pragma omp target update from(a)
}

  return 0;
}


Re: [Patch, microblaze]: Fix bswaphi2 implementation

2014-01-22 Thread David Holsgrove
Hi Michael,

On 26 November 2013 17:48, David Holsgrove  wrote:
> Hi Michael,
>
> Please find attached same patch based against latest from gcc master.
>
> Can this be applied and backported to gcc-4_8-branch when reviewed.
>
> thanks,
> David
>
> On 15 July 2013 14:49, David Holsgrove  wrote:
>> MicroBlaze insn swaph swaps the contents of register rA as two
>> halfwords placing result in rD;
>>
>> (rD)[0:15]  <- (rA)[16:31]
>> (rD)[16:31] <- (rA)[0:15]
>>
>> gcc bswaphi2 is intended to reverse the order of the bytes in the
>> half integer in rA
>>
>> (rD)[8:15]  <- (rA)[0:7]
>> (rD)[7:0]   <- (rA)[8:15]
>> (rD)[24:31] <- (rA)[16:23]
>> (rD)[16:23] <- (rA)[24:31]
>>
>> Correct the microblaze bswaphi2 insn pattern to be a swapb followed
>> by swaph
>>
>> Changelog entry would be:
>>
>> 2013-07-15  David Holsgrove 
>>
>>  * gcc/config/microblaze/microblaze.md: Fix bswaphi2
>>
>>
>> Can this also be backported to the gcc-4_8-branch?
>>

Updated patch attached which includes a testcase to check that
bswaphi2 is using a swapb followed by swaph for MicroBlaze.

Updated Changelogs are;

gcc/Changelog

2014-01-22  David Holsgrove 

 * gcc/config/microblaze/microblaze.md: Correct bswaphi2 / bswapsi2 insn

testsuite/ChangeLog

2014-01-22  David Holsgrove 

 * gcc/testsuite/gcc.target/microblaze/others/bswap16.c: New test.


>> thanks,
>> David


0001-Patch-microblaze-Fix-bswaphi2-implementation.patch
Description: Binary data


Re: Resolve pr44194-1.c failure by refining scan-rtl-dump-not pattern

2014-01-22 Thread Eric Botcazou
> Ah, OK.  In that case, how about this?  Tested on mips64-linux-gnu.

Fine with me, thanks!

-- 
Eric Botcazou


[Ada] Eliminate false positives on "no entities ..." message

2014-01-22 Thread Arnaud Charlet
This change avoids issuing the "no entities .." message for a with'ed
package if serious errors have been found. This eliminates some annoying
false positives, as shown by the following example, compiled with -gnatwa

 1. with System; use System;
 2. package WarnNoEnt is
 3.X : Integer := "ABC";
  |
>>> expected type "Standard.Integer"
>>> found a string type

 4.Y : Integer := 0;
 5. for Y'Address use X'Address;
 6. end WarnNoEnt;

Before this change, line 1 issued a "no entities" warning

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Robert Dewar  

* sem_warn.adb (Check_Use_Clause): Don't give no entities used
msg if errors found.
(Check_One_Unit): Same change.

Index: sem_warn.adb
===
--- sem_warn.adb(revision 206918)
+++ sem_warn.adb(working copy)
@@ -2130,11 +2130,18 @@
   Nam := First (Names (N));
   while Present (Nam) loop
  if Entity (Nam) = Pack then
-Error_Msg_Qual_Level := 1;
-Error_Msg_NE -- CODEFIX
-  ("?u?no entities of package& are referenced!",
- Nam, Pack);
-Error_Msg_Qual_Level := 0;
+
+--  Suppress message if any serious errors detected
+--  that turn off expansion, and thus result in false
+--  positives for this warning.
+
+if Serious_Errors_Detected = 0 then
+   Error_Msg_Qual_Level := 1;
+   Error_Msg_NE -- CODEFIX
+ ("?u?no entities of package& are referenced!",
+Nam, Pack);
+   Error_Msg_Qual_Level := 0;
+end if;
  end if;
 
  Next (Nam);
@@ -2402,8 +2409,13 @@
--  Else give the warning
 
else
-  if not
-Has_Unreferenced (Entity (Name (Item)))
+  --  Warn if we unreferenced flag set and we have
+  --  not had serious errors. The reason we inhibit
+  --  the message if there are errors is to prevent
+  --  false positives from disabling expansion.
+
+  if not Has_Unreferenced (Entity (Name (Item)))
+and then Serious_Errors_Detected = 0
   then
  Error_Msg_N -- CODEFIX
("?u?no entities of & are referenced!",
@@ -2541,6 +2553,8 @@
--  Start of processing for Check_Unused_Withs
 
begin
+  --  Immediate return if no semantics or warning flag not set
+
   if not Opt.Check_Withs or else Operating_Mode = Check_Syntax then
  return;
   end if;


[Ada] Early finalization of temporary variable when using -gnatE

2014-01-22 Thread Arnaud Charlet
This change removes specialized code for insertion of dynamic elaboration
checks (-gnatE) that caused a temporary of a controlled type to be finalized
too early when passed as actual parameter to a subprogram through a
named parameter association.

The following compilation must be accepted and produce the indicated
result:

$ gnatmake -q -gnatE elab_check_ctr
$ ./elab_check_ctr
Inner: X.Ptr.all = 1

with Ada.Finalization;

package Ctrl_Typ is
   type Int_Access is access all Integer;

   type Ctr is new Ada.Finalization.Controlled with record
  Ptr : Int_Access;
   end record;
   procedure Adjust (X : in out Ctr);
   procedure Finalize (X : in out Ctr);
   function Make return Ctr;

end Ctrl_Typ;
with Ada.Unchecked_Deallocation;

package body Ctrl_Typ is

   procedure Free is new Ada.Unchecked_Deallocation (Integer, Int_Access);

   procedure Adjust (X : in out Ctr) is
   begin
  if X.Ptr /= null then
 X.Ptr.all := X.Ptr.all + 1;
  end if;
   end Adjust;

   procedure Finalize (X : in out Ctr) is
   begin
  if X.Ptr /= null then
 if X.Ptr.all < 1 then
raise Program_Error;
 end if;
 X.Ptr.all := X.Ptr.all - 1;
 if X.Ptr.all = 0 then
Free (X.Ptr);
 end if;
  end if;
   end Finalize;

   function Make return Ctr is
   begin
  return Ctr'(Ada.Finalization.Controlled with Ptr => new Integer'(1));
   end Make;

end Ctrl_Typ;
with Ctrl_Typ; use Ctrl_Typ;
with Ada.Text_IO; use Ada.Text_IO;

procedure Elab_Check_Ctr is

   procedure Inner (X : Ctr) is
   begin
  if X.Ptr = null then
 Put_Line ("Inner : X.Ptr = null");
  else
 Put_Line ("Inner: X.Ptr.all =" & X.Ptr.all'Img);
  end if;
   end Inner;

begin
   Inner (X => Make);
end Elab_Check_Ctr;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Thomas Quinot  

* exp_util.adb (Insert_Actions): When inserting actions on a
short circuit operator that has already been analyzed, do not park
actions in node; instead introduce an N_Expression_With_Actions
and insert actions immediately.
Add guard for unexpected case of climbing up through statement
in Actions list of an N_Expression_With_Actions.
* sem_elab.adb (Insert_Elab_Check): Remove complex
specialized circuitry for the case where the context is already
analyzed, as it is not needed and introduces irregularities in
finalization. Instead rely on the above change to Insert_Actions
to ensure that late insertion on short circuit operators works
as expected.

Index: exp_util.adb
===
--- exp_util.adb(revision 206918)
+++ exp_util.adb(working copy)
@@ -3317,7 +3317,21 @@
 
   Kill_Current_Values;
 
-  if Present (Actions (P)) then
+  --  If P has already been expanded, we can't park new actions
+  --  on it, so we need to expand them immediately, introducing
+  --  an Expression_With_Actions. N can't be an expression
+  --  with actions, or else then the actions would have been
+  --  inserted at an inner level.
+
+  if Analyzed (P) then
+ pragma Assert (Nkind (N) /= N_Expression_With_Actions);
+ Rewrite (N,
+   Make_Expression_With_Actions (Sloc (N),
+ Actions=> Ins_Actions,
+ Expression => Relocate_Node (N)));
+ Analyze_And_Resolve (N);
+
+  elsif Present (Actions (P)) then
  Insert_List_After_And_Analyze
(Last (Actions (P)), Ins_Actions);
   else
@@ -3407,8 +3421,12 @@
 --  the new actions come from the expression of the expression with
 --  actions, they must be added to the existing actions. The other
 --  alternative is when the new actions are related to one of the
---  existing actions of the expression with actions. In that case
---  they must be inserted further up the tree.
+--  existing actions of the expression with actions, and should
+--  never reach here: if actions are inserted on a statement within
+--  the Actions of an expression with actions, or on some
+--  sub-expression of such a statement, then the outermost proper
+--  insertion point is right before the statement, and we should
+--  never climb up as far as the N_Expression_With_Actions itself.
 
 when N_Expression_With_Actions =>
if N = Expression (P) then
@@ -3420,6 +3438,9 @@
(Last (Actions (P)), Ins_Actions);
   end if;
   return;
+
+   else
+  raise Program_Error

[Ada] Improved error message for invalid concatenation operands.

2014-01-22 Thread Arnaud Charlet
For practitioners of other languages it is useful to indicate that an access
value is not a legal operand of predefined concatenation.

Compiling foo.adb must yield:

   foo.adb:5:33: invalid operand types for operator "&"
   foo.adb:5:33: left operand is access type
   foo.adb:6:35: invalid operand types for operator "&"
   foo.adb:6:35: right operand is access type


with Ada.Text_IO; use Ada.Text_IO;

procedure Foo is
   Prefix: access String := new String'("Hello ");
   Suffix: String := Prefix & "world!";
   Backwards : String := "world!" & Prefix;
begin
   Put_Line (Suffix);
end Foo;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Ed Schonberg  

* sem_ch4.adb (Operator_Check): Improve error message when an
operand of concatenation is an access type.

Index: sem_ch4.adb
===
--- sem_ch4.adb (revision 206918)
+++ sem_ch4.adb (working copy)
@@ -6151,7 +6151,8 @@
 --  In an instance a generic actual may be a numeric type even if
 --  the formal in the generic unit was not. In that case, the
 --  predefined operator was not a possible interpretation in the
---  generic, and cannot be one in the instance.
+--  generic, and cannot be one in the instance, unless the operator
+--  is an actual of an instance.
 
 if In_Instance
   and then
@@ -6576,6 +6577,17 @@
 if Nkind (N) /= N_Op_Concat then
Error_Msg_NE ("\left operand has}!",  N, Etype (L));
Error_Msg_NE ("\right operand has}!", N, Etype (R));
+
+--  For concatenation operators it is more difficult to
+--  determine which is the wrong operand. It is worth
+--  flagging explicitly an access type, for those who
+--  might think that a dereference happens here.
+
+elsif Is_Access_Type (Etype (L)) then
+   Error_Msg_N ("\left operand is access type", N);
+
+elsif Is_Access_Type (Etype (R)) then
+   Error_Msg_N ("\right operand is access type", N);
 end if;
  end if;
   end if;


[Ada] Visibility issue for expanded name in a proper body

2014-01-22 Thread Arnaud Charlet
This patch fixes a rare visibility issue that arises when an expanded name in
a proper body has a prefix which is a package that appears in a with_clause of
the proper body, when there is a homonym of the package declared in the parent
of the subunit. Previous to this patch a (spurious) error was reported.

The following must compile quietly:

   gnatmake -q -Pacttask

---
with Main;
procedure Acttask is
begin
  Main.Startup;
end Acttask;
---
with Ada.Text_Io; use Ada.Text_Io;
with User;
package body Main is
task type Main_T is new User.Main.T with
  entry Start;
  entry Dispatch (Deliver : User.Buffer_T);
end Main_T;

  T : aliased Main_T;

  package Initiate is
procedure Resources;
  end Initiate;

  package body Initiate is separate;

  procedure Startup is
  begin
T.Start;
  end Startup;

task body Main_T is
  Deliver : User.Buffer_T;
begin
  accept Start;
  Initiate.Resources;
  while True loop
select
  accept Start;
or
  accept Dispatch (Deliver : User.Buffer_T) do
Main_T.Deliver := Deliver;
  end Dispatch;
  User.Dispatch (Deliver);
end select;
delay 1.0;
  end loop;
end Main_T;
end Main;
---
package main is
  procedure Startup;
end Main;
---
with Start;
with Ada.Text_Io;
separate (Main)
package body Initiate is
  procedure Resources is
  begin
User.Start (T'Access);
Ada.Text_Io.Put_Line ("Hej hopp" & Integer'Image (Start.V));
  end Resources;
end Initiate;
--
package start is
  v : constant integer := 17;
end start;
---
generic
  type Deliver_T is private;
package task_if is
  type T is limited interface;
  type Access_T is access all T'Class;

  procedure Dispatch (Synchronized_Interface : in out T; Deliver : Deliver_T)
is abstract;
end;
---
with Ada.Text_Io; use Ada.Text_Io;
package body Task_If.Pump is
  task type Pump_T is
entry Start (Deliver : in Deliver_T; Deliver_To : Access_T);
entry Start2 (Deliver : in Deliver_T; Deliver_To : Access_T);
  end Pump_T;

  P : Pump_T;

  procedure Start (Deliver : in Deliver_T; Deliver_To : Access_T) is
  begin
P.Start (Deliver, Deliver_To);
  end Start;

  task body Pump_T is
Deliver: Deliver_T;
Deliver_To : Access_T;

procedure Working_Hard is
begin
  for I in 1 .. 15 loop
Put (".");
delay 0.1;
  end loop;
  Put_Line ("Eureka!");
end Working_Hard;

  begin
accept Start (Deliver : in Deliver_T; Deliver_To : Access_T) do
  Pump_T.Deliver := Deliver;
  Pump_T.Deliver_To := Deliver_To;
  requeue Start2;
end Start;
accept Start2 (Deliver : in Deliver_T; Deliver_To : Access_T) do
  Put_Line ("All is well:" &
 Boolean'Image
   (Pump_T.Deliver = Deliver and Pump_T.Deliver_To = Deliver_To));
end Start2;
loop
  -- Some possible examples we can do when Dispatch is an entry.
  select
Deliver_To.Dispatch (Deliver);
  else
Put_Line ("Cant deliver");
  end select;
  select
Deliver_To.Dispatch (Deliver);
  or
delay 1.0;
Put_Line ("Timed out");
  end select;
  select
Deliver_To.Dispatch (Deliver);
Put_Line ("");
  then abort
Working_Hard;
  end select;
end loop;
  end Pump_T;
end Task_If.Pump;
---
generic
package Task_If.Pump is
  procedure Start (Deliver : in Deliver_T; Deliver_To : Access_T);
end Task_If.Pump;
---
with Ada.Text_Io; use Ada.Text_Io;
with Task_If.Pump;
package body User is

  package Pump is new Main.Pump;

  procedure Start (Deliver_To : Main.Access_T) is
  begin
Pump.Start ("Hej hopp ditt feta nylle", Deliver_To);
  end Start;

  procedure Dispatch (Buffer : Buffer_T) is
  begin
Put_Line (String (Buffer));
  end Dispatch;
end User;
---
with Task_If;
package user is
  type Buffer_T is new String (1 .. 24);

  package Main is new Task_If (Deliver_T => Buffer_T);

  procedure Start (Deliver_To : Main.Access_T);

  procedure Dispatch (Buffer: Buffer_T);
end User;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Ed Schonberg  

* sem_ch8.adb (Find_Selected_Component): Handle properly the case
of an expanded name in a proper body, whose prefix is a package
in the context of the proper body, when there is a homonym of
the package declared in the parent unit.

Index: sem_ch8.adb
===
--- sem_ch8.adb (revision 206918)
+++ sem_ch8.adb (working copy)
@@ -5963,6 +5963,52 @@
 
   Nam : Node_Id;
 
+  function Is_Reference_In_Subunit return Boolean;
+  --  In a subunit, the scope depth is not a proper measure of hiding,
+  --  because the context of the proper body may itself hide entities in
+  --  parent units. This rare case requires inspecting the tree directly
+  --  because the proper body is inserted in the main unit and its context
+  --  is simply added t

Re: [C++,doc] vector conditional expression

2014-01-22 Thread Marc Glisse
Gerald, are you ok with this version? Jason's approval is conditional to 
your opinion ;-)


On Tue, 31 Dec 2013, Marc Glisse wrote:


On Mon, 2 Dec 2013, Gerald Pfeifer wrote:


On Mon, 2 Dec 2013, Marc Glisse wrote:

Index: doc/extend.texi
===
+In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
+@code{b} and @code{c} are vectors of the same type and @code{a} is an
+integer vector of the same size and number of elements as @code{b} and
+@code{c}

Why "same size and number of elements" in the above?  What is the
difference between these two?

(on x86_64)
A vector of 4 int and a vector of 4 long have the same number of elements 
but

not the same size.
A vector of 8 int and a vector of 4 long have the same size but not the 
same

number of elements.

For semantics, we want the same number of elements. To match the
hardware, we want the same size.


Ah, so it was good I asked. :-)  Thanks for your explanation.

It seems the way this is intended is
 integer vector of the (same size and number of elements) as
whereas I parsed it as
 (integer vector of the same size) and (number of elements) as
hence wondering what the difference between the size of the vector and
the number of elements was.


I think you had parsed it ok. In code terms:
size: sizeof(vec)
number of elements: sizeof(vec)/sizeof(vec[0])

Now when the number of elements is fixed, saying that vectors have the same 
(total) size or that they have elements of the same size is equivalent, so 
any interpretation is fine.



Rephrasing this as "the same number and size of elements as" or better
"the same number of elements of the same size as" may help avoid this.


Ok. Like this then?

+In C++, the ternary operator @code{?:} is available. @code{a?b:c}, where
+@code{b} and @code{c} are vectors of the same type and @code{a} is an
+integer vector with the same number of elements of the same size as @code{b}
+and @code{c}, computes all three arguments and creates a vector
+@code{@{a[0]?b[0]:c[0], a[1]?b[1]:c[1], @dots{}@}}.  Note that unlike in
+OpenCL, @code{a} is thus interpreted as @code{a != 0} and not @code{a < 0}.
+As in the case of binary operations, this syntax is also accepted when
+one of @code{b} or @code{c} is a scalar that is then transformed into a
+vector. If both @code{b} and @code{c} are scalars and the type of
+@code{true?b:c} has the same size as the element type of @code{a}, then
+@code{b} and @code{c} are converted to a vector type whose elements have
+this type and with the same number of elements as @code{a}.

(though arguably one could parse this to mean that the elements of a
have the same size as the whole vector b, but I am fine with ignoring
this)


--
Marc Glisse


RE: Two build != host fixes

2014-01-22 Thread Bernd Edlinger
Hi,


it is quite late in P3 now, so how about the attached patch?

This would return to the status quo before your patch, where $GMPINC must be != 
sysroot.


Bernd.

> Date: Tue, 7 Jan 2014 16:45:15 +0100
>
> Hi Alan,
>
>
> This issue is not yet resolved, in the moment this cross-compiler issue looks 
> like a regression.
>
> But I have tried your follow-up patches, and they make sense for me:
>
> http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01149.html
> http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01544.html
>
> How can we proceed?
>
> Regards
> Bernd.
>
> 

patch-cross-build.diff
Description: Binary data


[v3 patch] move comment to right place

2014-01-22 Thread Jonathan Wakely
Tested x86_64-linux, committed to trunk.
commit ed8eb245c7778ac2ab17a7c29dddc527c3db497e
Author: Jonathan Wakely 
Date:   Wed Jan 22 14:11:12 2014 +

* include/bits/stl_deque.h (_Deque_impl): Move comment.

diff --git a/libstdc++-v3/include/bits/stl_deque.h 
b/libstdc++-v3/include/bits/stl_deque.h
index 10fcb07..996c10f 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -487,13 +487,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   ~_Deque_base() _GLIBCXX_NOEXCEPT;
 
 protected:
-  //This struct encapsulates the implementation of the std::deque
-  //standard container and at the same time makes use of the EBO
-  //for empty allocators.
   typedef typename _Alloc::template rebind<_Tp*>::other _Map_alloc_type;
 
   typedef typename _Alloc::template rebind<_Tp>::other  _Tp_alloc_type;
 
+  //This struct encapsulates the implementation of the std::deque
+  //standard container and at the same time makes use of the EBO
+  //for empty allocators.
   struct _Deque_impl
   : public _Tp_alloc_type
   {


[PATCH] Fix handling of context diff patches in mklog

2014-01-22 Thread Yury Gribov

Hi,

This patch improves support for context diffs in mklog and also fixes 
tiny bug which caused generation of redundant colons in output.


Verified against several real-world patches.

Ok to commit?

-Y
diff --git a/contrib/mklog b/contrib/mklog
index 16ce191..c6d89a9 100755
--- a/contrib/mklog
+++ b/contrib/mklog
@@ -80,18 +80,16 @@ sub remove_suffixes ($) {
 	return $filename;
 }
 
-# Check if line can be a function declaration:
-# First pattern cut extra symbols added by diff
-# second pattern checks that line is not a comment or brace
-sub is_function  {
+# Check if line is a top-level declaration.
+# TODO: ignore preprocessor directives except maybe #define ?
+sub is_top_level {
 	my ($function, $is_context_diff) = (@_);
 	if ($is_context_diff) {
 		$function =~ s/^..//;
 	} else {
 		$function =~ s/^.//;
 	}
-	return $function
-	&& ($function !~ /^[\s{}]/);
+	return $function && $function !~ /^[\s{}]/;
 }
 
 # For every file in the .diff print all the function names in ChangeLog
@@ -105,13 +103,14 @@ chomp (my @diff_lines = );
 close (DFILE);
 $line_idx = 0;
 foreach (@diff_lines) {
-# Stop processing functions if we found a new file
+# Stop processing functions if we found a new file.
 	# Remember both left and right names because one may be /dev/null.
-if (/^[+*][+*][+*] +(\S+)/) {
+# Don't be fooled by line markers in case of context diff.
+if (!/\*\*\*$/ && /^[+*][+*][+*] +(\S+)/) {
 		$left = remove_suffixes ($1);
 		$look_for_funs = 0;
 	}
-if (/^--- +(\S+)?/) {
+if (!/---$/ && /^--- +(\S+)?/) {
 		$right = remove_suffixes ($1);
 		$look_for_funs = 0;
 	}
@@ -120,7 +119,7 @@ foreach (@diff_lines) {
 	# We should now have both left and right name,
 	# so we can decide filename.
 
-if ($left && (/^\*{15}$/ || /^@@ /)) {
+if ($left && (/^\*{15}/ || /^@@ /)) {
 	# If we have not seen any function names in the previous file (ie,
 	# $change_msg is empty), we just write out a ':' before starting the next
 	# file.
@@ -145,9 +144,15 @@ foreach (@diff_lines) {
 	$look_for_funs = $filename =~ '\.(c|cpp|C|cc|h|inc|def)$';
 }
 
-# Remember the last line in a unified diff block that might start
+# Context diffs have extra whitespace after first char;
+# remove it to make matching easier.
+if ($is_context_diff) {
+  s/^([-+! ]) /\1/;
+}
+
+# Remember the last line in a diff block that might start
 # a new function.
-if (/^[-+ ]([a-zA-Z0-9_].*)/) {
+if (/^[-+! ]([a-zA-Z0-9_].*)/) {
 $save_fn = $1;
 }
 
@@ -169,9 +174,9 @@ foreach (@diff_lines) {
 
 # Mark if we met doubtfully changed function.
 $doubtfunc = 0;
-$is_context_diff = 0;
 if ($diff_lines[$line_idx] =~ /^@@ .* @@ ([a-zA-Z0-9_].*)/) {
 	$doubtfunc = 1;
+$is_context_diff = 0;
 }
 elsif ($diff_lines[$line_idx] =~ /^\*\*\*\*\*\** ([a-zA-Z0-9_].*)/) {
 	$doubtfunc = 1;
@@ -184,17 +189,16 @@ foreach (@diff_lines) {
 # Note that we don't try too hard to find good matches.  This should
 # return a superset of the actual set of functions in the .diff file.
 #
-# The first two patterns work with context diff files (diff -c). The
-# third pattern works with unified diff files (diff -u).
+# The first pattern works with context diff files (diff -c). The
+# second pattern works with unified diff files (diff -u).
 #
-# The fourth pattern looks for the starts of functions or classes
-# within a unified diff block.
+# The third pattern looks for the starts of functions or classes
+# within a diff block both for context and unified diff files.
 
 if ($look_for_funs
 && (/^\*\*\*\*\*\** ([a-zA-Z0-9_].*)/
-|| /^[\-\+\!] ([a-zA-Z0-9_]+)[ \t]*\(.*/
 	|| /^@@ .* @@ ([a-zA-Z0-9_].*)/
-	|| /^[-+ ](\{)/))
+	|| /^[-+! ](\{)/))
   {
 	$_ = $1;
 	my $fn;
@@ -219,12 +223,16 @@ foreach (@diff_lines) {
 	$no_real_change = 0;
 	if ($doubtfunc) {
 		$idx = $line_idx;
+	# Skip line info in context diffs.
+		while ($is_context_diff && $diff_lines[$idx + 1] =~ /^[-\*]{3} [0-9]/) {
+			++$idx;
+		}
 	# Check all lines till the first change
 	# for the presence of really changed function
 		do {
 			++$idx;
-			$no_real_change = is_function ($diff_lines[$idx], $is_context_diff);
-		} while (!$no_real_change && ($diff_lines[$idx] !~  /^[\+\-\!]/))
+			$no_real_change = is_top_level ($diff_lines[$idx], $is_context_diff);
+		} while (!$no_real_change && ($diff_lines[$idx] !~ /^[-+!]/))
 	}
 	if ($fn && !$seen_names{$fn} && !$no_real_change) {
 	# If this is the first function in the file, we display it next
@@ -246,7 +254,7 @@ foreach (@diff_lines) {
 # If we have not seen any function names (ie, $change_msg is empty), we just
 # write out a ':'. This happens when there is only one file with no
 # functions.
-$cl_entries{$clname} .= $change_msg ? ": $change_msg\n" : ":\n";
+$cl_entries{$clname} .= $change_msg ? "$change_msg\n" : ":\n";
 
 $temp = `mktemp /tmp/$basename.XX` || 

[Ada] Check that Storage_Pool/Storage_Size not both given for same entity

2014-01-22 Thread Arnaud Charlet
This patch implements fully the rule of 13.11(3) that forbids having both
a Storage_Pool and Storage_Size attribute specified for the same type, as
shown by the following example:

 1. with System.Storage_Elements; use System.Storage_Elements;
 2. with System.Storage_Pools;use System.Storage_Pools;
 3.
 4. package Pool is
 5.type Pool_Element is record
 6.   Element : Storage_Element;
 7.end record;
 8.
 9.type Contents_Array is
10.  array (Storage_Offset range <>) of Pool_Element;
11.
12.type My_Pool (Size : Storage_Offset) is
13.  new Root_Storage_Pool with record
14.   Contents : Contents_Array (1 .. Size);
15.end record;
16.
17.overriding procedure Allocate
18.  (Pool : in out My_Pool;
19.   Storage_Address  : out System.Address;
20.   Size_In_Storage_Elements : Storage_Count;
21.   Alignment: Storage_Count);
22.
23.overriding procedure Deallocate
24.  (Pool : in out My_Pool;
25.   Storage_Address  : System.Address;
26.   Size_In_Storage_Elements : Storage_Count;
27.   Alignment: Storage_Count);
28.
29.overriding function Storage_Size
30.  (Pool: My_Pool) return Storage_Count
31.is (Pool.Size);
32. end Pool;

 1. package body Pool is
 2.procedure Allocate
 3.  (Pool : in out My_Pool;
 4.   Storage_Address  : out System.Address;
 5.   Size_In_Storage_Elements : Storage_Count;
 6.   Alignment: Storage_Count)
 7.is
 8.   pragma Unreferenced
 9. (Pool, Storage_Address,
10.  Size_In_Storage_Elements, Alignment);
11.begin
12.   null;
13.end Allocate;
14.
15.procedure Deallocate
16.  (Pool : in out My_Pool;
17.   Storage_Address  : in System.Address;
18.   Size_In_Storage_Elements : Storage_Count;
19.   Alignment: Storage_Count)
20.is
21.   pragma Unreferenced
22. (Pool, Storage_Address,
23.  Size_In_Storage_Elements, Alignment);
24.begin
25.   null;
26.end Deallocate;
27. end Pool;

 1. with Pool; use Pool;
 2.
 3. package Mix_Of_Attributes is
 4.Pool : My_Pool (16);
 5.
 6.type Rec is record
 7.   Comp : Integer := 123;
 8.end record;
 9.
10.type Ptr_1 is access all Rec;
11.for Ptr_1'Storage_Size use 16;
12.for Ptr_1'Storage_Pool use Pool;
   |
>>> Storage_Size previously given for "Ptr_1" at line 11
>>> cannot have Storage_Size and Storage_Pool (RM 13.11(3))

13.
14.type Ptr_2 is access all Rec;
15.for Ptr_2'Storage_Pool use Pool;
16.for Ptr_2'Storage_Size use 16;
   |
>>> Storage_Pool previously given for "Ptr_2" at line 15
>>> cannot have Storage_Size and Storage_Pool (RM 13.11(3))

17.
18.type Ptr_3 is access all Rec with Storage_Pool => Pool;
19.for Ptr_3'Storage_Size use 16;
   |
>>> Storage_Pool previously given for "Ptr_3" at line 18
>>> cannot have Storage_Size and Storage_Pool (RM 13.11(3))

20.
21.type Ptr_4 is access all Rec with Storage_Size => 16;
22.for Ptr_4'Storage_Pool use Pool;
   |
>>> Storage_Size previously given for "Ptr_4" at line 21
>>> cannot have Storage_Size and Storage_Pool (RM 13.11(3))

23.
24.type Ptr_5 is access all Rec
25.  with Storage_Pool => Pool,
26.   Storage_Size => 16;
  |
>>> Storage_Pool previously given for "Ptr_5" at line 25
>>> cannot have Storage_Size and Storage_Pool (RM 13.11(3))

27.
28.type Ptr_6 is access all Rec
29.  with Storage_Size => 16,
30.   Storage_Pool => Pool;
  |
>>> Storage_Size previously given for "Ptr_6" at line 29
>>> cannot have Storage_Size and Storage_Pool (RM 13.11(3))

31.
32. end Mix_Of_Attributes;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Robert Dewar  

* sem_ch13.adb (Check_Pool_Size_Clash): New procedure
(Analyze_Attribute_Definition_Clause, case Storage_Pool): call
Check_Pool_Size_Clash (Analyze_Attribute_Definition_Clause,
case Storage_Size): call Check_Pool_Size_Clash.

Index: sem_ch13.adb
===
--- sem_ch13.adb(revision 206918)
+++ sem_ch13.adb(working copy)
@@ -112,6 +112,10 @@
--  list is stored in Static_Predicate (Typ), and the Expr is rewritten as
--  a canonicalized membership operation.
 
+   procedure Check_P

Re: [Patch, microblaze]: Fix ICE with mhard-float

2014-01-22 Thread Michael Eager

On 01/22/14 02:50, David Holsgrove wrote:

Hi Michael,

On 22 January 2014 13:43, David Holsgrove  wrote:

-Original Message-
From: Michael Eager [mailto:ea...@eagerm.com]
Sent: Friday, 17 January 2014 4:36 am
To: David Holsgrove; gcc-patches@gcc.gnu.org
Cc: Edgar Iglesias; John Williams; Vidhumouli Hunsigida; Nagaraju Mekala
Subject: Re: [Patch, microblaze]: Fix ICE with mhard-float

On 11/25/13 23:50, David Holsgrove wrote:

Hi Michael,

I've attached the same patch based on latest gcc master.

Can this be applied to gcc-4_8-branch also.

thanks,
David

On 15 July 2013 14:53, David Holsgrove  wrote:

Add SImode to cstoresf4's comparison operator, prevents ICE during combine
rtl pass with error message;

internal compiler error: in simplify_subreg, at simplify-rtx.c:5725

Use ordered_comparison_operator predicate to limit operators to
those fcmp can handle, and letting compiler reorder insns to
accommodate unordered as necessary.

Changelog entry;

2013-07-15  David Holsgrove 

   * gcc/config/microblaze/microblaze.md: Fix cstoresf4 and cbranchsf4

Can this be backported to gcc-4_8-branch also?



Hi David --

You mention that this patch fixes an ICE.  Is there a failing test
case in the GCC Test Suite?  Is there a GCC PR for this ICE?
If not, please add a test case to the patch.


Hi Michael,

Thanks for the reply. No, unfortunately there isn’t an existing test case which 
shows this ICE.

I'm in the process of trying to recreate and distil into a small test case if 
possible, but the error was encountered whilst building a rather large app 
using microblaze linux.



I've attached updated patch which includes a test case to check for
this ICE. Tested on microblaze baremetal and microblazeel linux
toolchains with / without my change.

Updated ChangeLogs would be;

gcc/ChangeLog

2014-01-22  David Holsgrove 

  * config/microblaze/microblaze.md(cstoresf4, cbranchsf4): Replace
comparison_operator with ordered_comparison_operator.

testsuite/ChangeLog

2014-01-22  David holsgrove 

  * testsuite/gcc.target/microblaze/isa/fcmp4.c: New file.


thanks,
David



--
Michael Eager  ea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


Thanks!


--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077



Re: [Patch, microblaze]: Fix bswaphi2 implementation

2014-01-22 Thread Michael Eager

On 01/22/14 02:55, David Holsgrove wrote:

Hi Michael,

On 26 November 2013 17:48, David Holsgrove  wrote:

Hi Michael,

Please find attached same patch based against latest from gcc master.

Can this be applied and backported to gcc-4_8-branch when reviewed.

thanks,
David

On 15 July 2013 14:49, David Holsgrove  wrote:

MicroBlaze insn swaph swaps the contents of register rA as two
halfwords placing result in rD;

(rD)[0:15]  <- (rA)[16:31]
(rD)[16:31] <- (rA)[0:15]

gcc bswaphi2 is intended to reverse the order of the bytes in the
half integer in rA

(rD)[8:15]  <- (rA)[0:7]
(rD)[7:0]   <- (rA)[8:15]
(rD)[24:31] <- (rA)[16:23]
(rD)[16:23] <- (rA)[24:31]

Correct the microblaze bswaphi2 insn pattern to be a swapb followed
by swaph

Changelog entry would be:

2013-07-15  David Holsgrove 

  * gcc/config/microblaze/microblaze.md: Fix bswaphi2


Can this also be backported to the gcc-4_8-branch?



Updated patch attached which includes a testcase to check that
bswaphi2 is using a swapb followed by swaph for MicroBlaze.

Updated Changelogs are;

gcc/Changelog

 2014-01-22  David Holsgrove 

  * gcc/config/microblaze/microblaze.md: Correct bswaphi2 / bswapsi2 insn

testsuite/ChangeLog

 2014-01-22  David Holsgrove 

  * gcc/testsuite/gcc.target/microblaze/others/bswap16.c: New test.


Thanks for the test case.

I had verified that the code was correct by hand, but tests are always
a good addition.


--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


Re: [PATCH][AVX512] Add forgotten intrinsics.

2014-01-22 Thread Uros Bizjak
On Wed, Jan 22, 2014 at 2:55 PM, Ilya Tocar  wrote:

>> > I found out that we forgot to implement some of AVX512 intrinsics.
>> > Here is a patch that adds them. Sorry for huge patch, but changes are
>> > mostly trivial.
>> > Ok for trunk?
>>
>> > +(define_insn "avx512f_2_mask_store"
>> > +  [(set (match_operand:PMOV_DST_MODE 0 "nonimmediate_operand" "=m")
>> > +(vec_merge:PMOV_DST_MODE
>> > +  (any_truncate:PMOV_DST_MODE
>> > +(match_operand: 1 "register_operand" "v"))
>> > +  (match_dup 0)
>> > +  (match_operand: 2 "register_operand" "k")))]
>> > +  "TARGET_AVX512F"
>> > +  "vpmov\t{%1, %0%{%2%}|%0%{%2%}, %1}"
>> > +  [(set_attr "type" "ssemov")
>> > +   (set_attr "memory" "store")
>> > +   (set_attr "prefix" "evex")
>> > +   (set_attr "mode" "")])
>>
>> This is the same as the second alternative of the
>> avx512f_2_mask pattern. Please change the above
>> into an expander to reuse existing pattern.
>>
>> Uros.
>
> Fixed.
>
> Changelog:
>
> 2014-01-21  Ilya Tocar  
>
> * config/i386/avx512fintrin.h (_mm512_mask_cvtepi32_storeu_epi8): New.
> (_mm512_mask_cvtsepi32_storeu_epi8): Ditto.
> (_mm512_mask_cvtusepi32_storeu_epi8): Ditto.
> (_mm512_mask_cvtepi32_storeu_epi16): Ditto.
> (_mm512_mask_cvtsepi32_storeu_epi16): Ditto.
> (_mm512_mask_cvtusepi32_storeu_epi16): Ditto.
> (_mm512_mask_cvtepi64_storeu_epi32): Ditto.
> (_mm512_mask_cvtsepi64_storeu_epi32): Ditto.
> (_mm512_mask_cvtusepi64_storeu_epi32): Ditto.
> (_mm512_mask_cvtepi64_storeu_epi16): Ditto.
> (_mm512_mask_cvtsepi64_storeu_epi16): Ditto.
> (_mm512_mask_cvtusepi64_storeu_epi16): Ditto.
> (_mm512_mask_cvtepi64_storeu_epi8): Ditto.
> (_mm512_mask_cvtsepi64_storeu_epi8): Ditto.
> (_mm512_mask_cvtusepi64_storeu_epi8): Ditto.
> (_mm512_storeu_epi64): Ditto.
> (_mm512_cmpge_epi32_mask): Ditto.
> (_mm512_cmpge_epu32_mask): Ditto.
> (_mm512_cmpge_epi64_mask): Ditto.
> (_mm512_cmpge_epu64_mask): Ditto.
> (_mm512_cmple_epi32_mask): Ditto.
> (_mm512_cmple_epu32_mask): Ditto.
> (_mm512_cmple_epi64_mask): Ditto.
> (_mm512_cmple_epu64_mask): Ditto.
> (_mm512_cmplt_epi32_mask): Ditto.
> (_mm512_cmplt_epu32_mask): Ditto.
> (_mm512_cmplt_epi64_mask): Ditto.
> (_mm512_cmplt_epu64_mask): Ditto.
> (_mm512_cmpneq_epi32_mask): Ditto.
> (_mm512_cmpneq_epu32_mask): Ditto.
> (_mm512_cmpneq_epi64_mask): Ditto.
> (_mm512_cmpneq_epu64_mask): Ditto.
> (_mm512_expand_pd): Ditto.
> (_mm512_expand_ps): Ditto.
> * config/i386/i386-builtin-types.def: Add PV16QI, PV16QI, PV16HI,
> VOID_PV8SI_V8DI_QI, VOID_PV8HI_V8DI_QI, VOID_PV16QI_V8DI_QI,
> VOID_PV16QI_V16SI_HI, VOID_PV16HI_V16SI_HI.
> * config/i386/i386.c (ix86_builtins): Add
> IX86_BUILTIN_EXPANDPD512_NOMASK, IX86_BUILTIN_EXPANDPS512_NOMASK,
> IX86_BUILTIN_PMOVDB512_MEM, IX86_BUILTIN_PMOVDW512_MEM,
> IX86_BUILTIN_PMOVQB512_MEM, IX86_BUILTIN_PMOVQD512_MEM,
> IX86_BUILTIN_PMOVQW512_MEM, IX86_BUILTIN_PMOVSDB512_MEM,
> IX86_BUILTIN_PMOVSDW512_MEM, IX86_BUILTIN_PMOVSQB512_MEM,
> IX86_BUILTIN_PMOVSQD512_MEM, IX86_BUILTIN_PMOVSQW512_MEM,
> IX86_BUILTIN_PMOVUSDB512_MEM, IX86_BUILTIN_PMOVUSDW512_MEM,
> IX86_BUILTIN_PMOVUSQB512_MEM, IX86_BUILTIN_PMOVUSQD512_MEM,
> IX86_BUILTIN_PMOVUSQW512_MEM.
> (bdesc_special_args): Add __builtin_ia32_pmovusqd512mem_mask,
> __builtin_ia32_pmovsqd512mem_mask,
> __builtin_ia32_pmovqd512mem_mask,
> __builtin_ia32_pmovusqw512mem_mask,
> __builtin_ia32_pmovsqw512mem_mask,
> __builtin_ia32_pmovqw512mem_mask,
> __builtin_ia32_pmovusdw512mem_mask,
> __builtin_ia32_pmovsdw512mem_mask,
> __builtin_ia32_pmovdw512mem_mask,
> __builtin_ia32_pmovqb512mem_mask,
> __builtin_ia32_pmovusqb512mem_mask,
> __builtin_ia32_pmovsqb512mem_mask,
> __builtin_ia32_pmovusdb512mem_mask,
> __builtin_ia32_pmovsdb512mem_mask,
> __builtin_ia32_pmovdb512mem_mask.
> (bdesc_args): Add __builtin_ia32_expanddf512,
> __builtin_ia32_expandsf512.
> (ix86_expand_special_args_builtin): Handle VOID_FTYPE_PV8SI_V8DI_QI,
> VOID_FTYPE_PV8HI_V8DI_QI, VOID_FTYPE_PV16HI_V16SI_HI,
> VOID_FTYPE_PV16QI_V8DI_QI, VOID_FTYPE_PV16QI_V16SI_HI.
> * config/i386/sse.md (unspec): Add UNSPEC_EXPAND_NOMASK.
> (avx512f_2_mask_store): New.
> (*avx512f_v8div16qi2_store_mask): Renamed to ...
> (avx512f_v8div16qi2_mask_store): This.
> (avx512f_expand): New.
>
>
> Chagelog for tests:
>
> 2014-01-21 Ilya Tocar  
>
> * gcc.target/i386/avx512f-vexpandpd-1.c: Also test _mm512_expand_pd.
> * gcc.target/i386/avx512f-vexpandpd-2.c: Ditto.
> * gcc.target/i386/avx512f

[Ada] Handle new inequality errors in Ada 2012 more completely

2014-01-22 Thread Arnaud Charlet
This patch does two things with respect to the new illegalities in Ada
2012 regarding late declaration of equality for untagged types. First
these errors can be converted to warnings using the -gnatd.E switch.
Second, in earlier versions of Ada, if the -gnatwy switch is set (warn
on Ada incompatibilities, set by default), then warnings are generated
for these situations.

The following test compiles quietly in Ada 95 mode with -gnatwY

 1. package LateEq is
 2.type R is record
 3.   M : Float;
 4.end record;
 5.MM : R;
 6.function "=" (X, Y : R) return Boolean;
 7. end;

In Ada 2012 mode we get:

 1. package LateEq is
 2.type R is record
 3.   M : Float;
 4.end record;
 5.MM : R;
   |
>>> warning: type "R" is frozen by declaration, an
equality operator cannot be declared after this
point

 6.function "=" (X, Y : R) return Boolean;
|
>>> equality operator must be declared before type
"R" is frozen (RM 4.5.2 (9.8)) (Ada 2012)

 7. end;

That error turns into a warning if we set debug flag -gnatd.E

 1. package LateEq is
 2.type R is record
 3.   M : Float;
 4.end record;
 5.MM : R;
   |
>>> warning: type "R" is frozen by declaration, an
equality operator cannot be declared after this
point

 6.function "=" (X, Y : R) return Boolean;
|
>>> warning: equality operator must be declared
before type "R" is frozen (RM 4.5.2 (9.8)) (Ada
2012), equality operation may not compose

 7. end;

Finally we get warnings if we run in Ada 95 mode with the
warnings -gnatwy.d (-gnatwy is the default):

 1. package LateEq is
 2.type R is record
 3.   M : Float;
 4.end record;
 5.MM : R;
   |
>>> warning: type "R" is frozen by declaration (Ada
2012), an equality operator cannot be declared
after this point (Ada 2012) [-gnatwy]

 6.function "=" (X, Y : R) return Boolean;
|
>>> warning: equality operator must be declared
before type "R" is frozen (RM 4.5.2 (9.8)) (Ada
2012) [-gnatwy]

 7. end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Robert Dewar  

* debug.adb: Document messages affected by -gnatd.E including
the new ones that relate to late definition of equality.
* sem_ch6.adb (Check_Untagged_Equality): In Ada 2012 mode, if
debug flag -gnatd.E is set, then generate warnings rather than
errors.
(Check_Untagged_Equality): In earlier versions of Ada,
generate warnings if Warn_On_Ada_2012_Incompatibility flag is set.

Index: debug.adb
===
--- debug.adb   (revision 206928)
+++ debug.adb   (working copy)
@@ -596,10 +596,16 @@
 
--  d.E  Turn selected errors into warnings. This debug switch causes a
--   specific set of error messages into warnings. Setting this switch
-   --   causes Opt.Error_To_Warning to be set to True. Right now the only
-   --   error affected is the case of overlapping subprogram parameters
-   --   which has become illegal in Ada 2012, but only generates a warning
-   --   in earlier versions of Ada.
+   --   causes Opt.Error_To_Warning to be set to True. The intention is
+   --   that this be used for messages representing upwards incompatible
+   --   changes to Ada 2012 that cause previously correct programs to be
+   --   treated as illegal now. The following cases are affected:
+   --
+   --  Errors relating to overlapping subprogram parameters for cases
+   --  other than IN OUT parameters to functions.
+   --
+   --  Errors relating to the new rules about not defining equality
+   --  too late so that composition of equality can be assured.
 
--  d.F  Sets GNATprove_Mode to True. This allows debugging the frontend in
--   the special mode used by GNATprove.
Index: sem_ch6.adb
===
--- sem_ch6.adb (revision 206918)
+++ sem_ch6.adb (working copy)
@@ -193,7 +193,10 @@
--  must appear before the type is frozen, and have the same visibility as
--  that of the type. This procedure checks that this rule is met, and
--  otherwise emits an error on the subprogram declaration and a warning
-   --  on the earlier freeze point if it is easy to locate.
+   --  on the earlier freeze point if it is easy to locate. In Ada 2012 mode,
+   --  this routine outputs errors (or warnings if -gnatd.E is set). In earlier
+   --  versions of Ada, warnings are output if Warn_On_Ada_2012_Incompatibility
+   --  is set, otherwise the call has no effect.
 
procedure Enter_Overloaded

[Ada] Check SPARK restriction on recursive call

2014-01-22 Thread Arnaud Charlet
In SPARK 2005, a subprogram may not contain a direct call to
itself. This patch checks this if SPARK_05 restriction is set
as shown in the following example:

 1. pragma Restrictions (SPARK_05);
 2. package SPARKRec is
 3.procedure p1 (X : Boolean; Y : Integer);
 4. end SPARKRec;

 1. pragma Restrictions (SPARK_05);
 2. package body SPARKRec is
 3.procedure p1 (X : Boolean; Y : Integer) is
 4.begin
 5.   if X then
 6.  p1 (Y > 10, Y - 1);
 |
>>> violation of restriction "SPARK_05" at sparkrec.ads:1
>>>  subprogram may not contain direct call to itself

 7.   end if;
 8.end p1;
 9. end SPARKRec;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Robert Dewar  

* restrict.ads: Minor reformatting.
* sem_res.adb (Resolve_Call): Check for SPARK_05 restriction that
forbids a call from within a subprogram to the same subprogram.

Index: sem_res.adb
===
--- sem_res.adb (revision 206918)
+++ sem_res.adb (working copy)
@@ -5279,8 +5279,7 @@
   is
  Subp_Alias : constant Entity_Id := Alias (S);
   begin
- return S = E
-   or else (Present (Subp_Alias) and then Subp_Alias = E);
+ return S = E or else (Present (Subp_Alias) and then Subp_Alias = E);
   end Same_Or_Aliased_Subprograms;
 
--  Start of processing for Resolve_Call
@@ -5630,6 +5629,16 @@
   if Comes_From_Source (N) then
  Scop := Current_Scope;
 
+ --  Check violation of SPARK_05 restriction which does not permit
+ --  a subprogram body to contain a call to the subprogram directly.
+
+ if Restriction_Check_Required (SPARK_05)
+   and then Same_Or_Aliased_Subprograms (Nam, Scop)
+ then
+Check_SPARK_Restriction
+  ("subprogram may not contain direct call to itself", N);
+ end if;
+
  --  Issue warning for possible infinite recursion in the absence
  --  of the No_Recursion restriction.
 
Index: restrict.ads
===
--- restrict.ads(revision 206918)
+++ restrict.ads(working copy)
@@ -254,7 +254,7 @@
  (Msg   : String;
   N : Node_Id;
   Force : Boolean := False);
-   --  Node N represents a construct not allowed in formal mode. If this is
+   --  Node N represents a construct not allowed in SPARK_05 mode. If this is
--  a source node, or if the restriction is forced (Force = True), and
--  the SPARK_05 restriction is set, then an error is issued on N. Msg
--  is appended to the restriction failure message.


Re: [PATCH][AArch64] Vector shift by 64 fix

2014-01-22 Thread Alex Velenko

On 06/01/14 11:52, Alex Velenko wrote:

Hi,

This patch fixes vector shift by 64 behavior to meet reference
manual expectations. Testcase included to check that expectations
are now met. No regressions found.

Is patch OK?

Thanks,
Alex

2014-01-06  Alex Velenko  

gcc/

 * config/aarch64/aarch64-simd-builtins.def (ashr): DI mode removed.
 (ashr_simd): New builtin handling DI mode.
 * config/aarch64/aarch64-simd.md (aarch64_ashr_simddi): New pattern.
 (aarch64_sshr_simddi): New match pattern.
 * config/aarch64/arm_neon.h (vshr_n_s32): Builtin call modified.
 (vshrd_n_s64): Likewise.
 * config/aarch64/predicates.md (aarch64_shift_imm64_di): New
predicate.

gcc/testsuite/

 * gcc.target/aarch64/sshr64_1.c: New testcase.


Ping!

Hi,
Can someone, please, review the patch.
Kind regards,
Alex


[RFC] [PATCH, AARCH64] : Using standard patterns for stack protection.

2014-01-22 Thread Venkataramanan Kumar
Hi Marcus,

After we changed the frame growing direction (downwards) in Aarch64,
the back-end now generates stack smashing set and test based on
generic code available in GCC.

But most of the ports (i386, spu, rs6000, s390, sh, sparc, tilepro and
tilegx) define machine descriptions using standard pattern names
‘stack_protect_set’ and ‘stack_protect_test’. This is done for both
TLS model as well as global variable based stack guard model.

Also all these ports in their machine descriptions,  have cleared the
register that loaded the canary value using an additional instruction.

(GCC internals)
‘stack_protect_set’
This pattern, if defined, moves a ptr_mode value from the memory in operand
1 to the memory in operand 0 without leaving the value in a register afterward.
This is to avoid leaking the value some place that an attacker might use to
rewrite the stack guard slot after having clobbered it.
If this pattern is not defined, then a plain move pattern is generated.
(GCC internals)

I believe this is done for extra security.  Also each target can
control the way of clearing the register that loaded the canary value.

In the attached patch, I have written machine descriptions patterns
for stack_protect_set and stack_protect_test for Aarch64.
Also I am clearing the register by moving 0 to the register while
setting the stack and using "eor" instruction while testing the stack.

However this generates un-optimal code when compared to generic GCC code.

While setting up stack canary ,

Generic code

adrpx19, __stack_chk_guard
ldr x1, [x19,#:lo12:__stack_chk_guard]
str x1, [x29,40]


Patch

adrpx19, __stack_chk_guard
add x1, x19, :lo12:__stack_chk_guard
ldr x2, [x1]
   str x1, [x29,40]
   mov x2, 0

while testing stack canary

generic code
ldr x1, [x29,40]
ldr x0, [x19,#:lo12:__stack_chk_guard]
cmp x1, x0
bne .L7

patch
add x19, x19, :lo12:__stack_chk_guard
ldr x1, [x29,40]
ldr x0, [x19]
eor x0, x1, x0
cbnzx0, .L7

Please let me know if this change is fine for Aarch64.

2014-01-22 Venkataramanan Kumar  
* config/aarch64/aarch64.md (stack_protect_set, stack_protect_test)
(stack_protect_set_, stack_protect_test_): Add
machine descriptions for Stack Smashing Protector.

2014-01-22  Venkataramanan Kumar  
* lib/target-supports.exp
  (check_effective_target_stack_protection): New procedure.
* g++.dg/fstack-protector-strong.C: Add target check for
  stack protection.
* gcc.dg/fstack-protector-strong.c: Likewise.


regards,
Venkat.
Index: gcc/config/aarch64/aarch64.md
===
--- gcc/config/aarch64/aarch64.md   (revision 206874)
+++ gcc/config/aarch64/aarch64.md   (working copy)
@@ -99,6 +99,8 @@
 UNSPEC_TLSDESC
 UNSPEC_USHL_2S
 UNSPEC_VSTRUCTDUMMY
+UNSPEC_SP_SET
+UNSPEC_SP_TEST
 ])
 
 (define_c_enum "unspecv" [
@@ -3631,6 +3633,65 @@
   DONE;
 })
 
+;; Named patterns for stack smashing protection.
+(define_expand "stack_protect_set"
+  [(match_operand 0 "memory_operand")
+   (match_operand 1 "memory_operand")]
+  ""
+{
+  enum machine_mode mode = GET_MODE (operands[0]);
+
+  emit_insn ((mode == DImode
+ ? gen_stack_protect_set_di
+ : gen_stack_protect_set_si) (operands[0], operands[1]));
+  DONE;
+})
+
+(define_insn "stack_protect_set_"
+  [(set (match_operand:PTR 0 "memory_operand" "=m")
+   (unspec:PTR [(match_operand:PTR 1 "memory_operand" "m")]
+UNSPEC_SP_SET))
+   (set (match_scratch:PTR 2 "=&r") (const_int 0))]
+  ""
+  "ldr\\t%x2, %1\;str\\t%x2, %0\;mov\t%x2,0"
+  [(set_attr "length" "12")])
+
+(define_expand "stack_protect_test"
+  [(match_operand 0 "memory_operand")
+   (match_operand 1 "memory_operand")
+   (match_operand 2)]
+  ""
+{
+
+  rtx result = gen_reg_rtx (Pmode);
+
+  enum machine_mode mode = GET_MODE (operands[0]);
+
+  emit_insn ((mode == DImode
+ ? gen_stack_protect_test_di
+ : gen_stack_protect_test_si) (result,
+   operands[0],
+   operands[1]));
+
+  if (mode == DImode)
+emit_jump_insn (gen_cbranchdi4 (gen_rtx_EQ (VOIDmode, result, const0_rtx),
+   result, const0_rtx, operands[2]));
+  else
+emit_jump_insn (gen_cbranchsi4 (gen_rtx_EQ (VOIDmode, result, const0_rtx),
+   result, const0_rtx, operands[2]));
+  DONE;
+})
+
+(define_insn "stack_protect_test_"
+  [(set (match_operand:PTR 0 "register_operand")
+   (unspec:PTR [(match_operand:PTR 1 "memory_operand" "m")
+(match_operand:PTR 2 "memory_operand" "m")]
+UNSPEC_SP_TEST))
+   (clobber (match_scratch:PTR 3 "=&r"))]
+  ""
+  "ldr\t%x3, %x1\;ldr\t%x0, %x2\;eor\t

[Ada] Crash on constant declaration with variable size with generics

2014-01-22 Thread Arnaud Charlet
This change fixes a compiler crash occurring in some cases of constant
declarations initialized with a call to an instance of a generic function,
when the returned type is an array of dynamically sized elements.

The following compilation must be accepted quietly:

$ gcc -c p.adb
package Q is
   function F return Integer;
   subtype Comp is String (1 .. F);
   type Element_T is record
  C : Comp;
   end record;
end Q;

with Q;
procedure P is
   type Exist_Element_T (Exist : Boolean := False) is record
  case Exist is
 when True => Value : Q.Element_T;
 when False => null;
  end case;
   end record;

   type Arr is array (Boolean) of Exist_Element_T;

   generic
  type Idx is (<>);
  type Elmt is private;
  type Arr is array (Idx) of Elmt;
   function F_G return Arr;

   function F_G return Arr is
  A : Elmt;
   begin
  return Arr'(others => A);
   end F_G;

   function F is new F_G (Idx => Boolean, Elmt => Exist_Element_T, Arr => Arr);

   Const_Arr : constant Arr := F;

begin
   null;
end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Thomas Quinot  

* sem_ch3.adb (Analyze_Object_Declaration): For a constant
declaration initialized with a function call, whose type
has variable size, need to remove side effects so that the
initialization expression becomes a dereference of a temporary
reference to the function result.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 206923)
+++ sem_ch3.adb (working copy)
@@ -2991,6 +2991,11 @@
   --  or a variant record type is encountered, Check_Restrictions is called
   --  indicating the count is unknown.
 
+  function Has_Unconstrained_Elements (T : Entity_Id) return Boolean;
+  --  True if T has discriminants and is unconstrained, or is an array
+  --  type whose element type Has_Unconstrained_Elements. Shouldn't this
+  --  be in sem_util???
+
   -
   -- Count_Tasks --
   -
@@ -3045,6 +3050,24 @@
  end if;
   end Count_Tasks;
 
+  
+  -- Has_Unconstrained_Elements --
+  
+
+  function Has_Unconstrained_Elements (T : Entity_Id) return Boolean is
+ U_T : constant Entity_Id := Underlying_Type (T);
+  begin
+ if No (U_T) then
+return False;
+ elsif Is_Record_Type (U_T) then
+return Has_Discriminants (U_T) and then not Is_Constrained (U_T);
+ elsif Is_Array_Type (U_T) then
+return Has_Unconstrained_Elements (Component_Type (U_T));
+ else
+return False;
+ end if;
+  end Has_Unconstrained_Elements;
+
--  Start of processing for Analyze_Object_Declaration
 
begin
@@ -3647,16 +3670,15 @@
 
  Rewrite (Object_Definition (N), New_Occurrence_Of (Act_T, Loc));
 
-  elsif Present (Underlying_Type (T))
-and then not Is_Constrained (Underlying_Type (T))
-and then Has_Discriminants (Underlying_Type (T))
-and then Nkind (E) = N_Function_Call
+  elsif Nkind (E) = N_Function_Call
 and then Constant_Present (N)
+and then Has_Unconstrained_Elements (Etype (E))
   then
  --  The back-end has problems with constants of a discriminated type
  --  with defaults, if the initial value is a function call. We
- --  generate an intermediate temporary for the result of the call.
- --  It is unclear why this should make it acceptable to gcc. ???
+ --  generate an intermediate temporary that will receive a reference
+ --  to the result of the call. The initialization expression then
+ --  becomes a dereference of that temporary.
 
  Remove_Side_Effects (E);
 


[Ada] Do not assume that a volatile variable is valid

2014-01-22 Thread Arnaud Charlet
Volatile variables are never considered valid for the purposes
of validity checking, since the assumption is they could change
unexpectedly at any time.

The following program, compiled with -gnatVa -gnatG

 1. procedure ValidVolatile is
 2.type R is new Integer range 1 .. 10;
 3.A : R;
 4.pragma Volatile (A);
 5.B : R;
 6. begin
 7.A := 1;
 8.B := A;
 9. end;

generates:

Source recreated from tree for Validvolatile (body)

with interfaces;

procedure validvolatile is
   [type validvolatile__TrB is new integer]
   freeze validvolatile__TrB []
   type validvolatile__r is new integer range 1 .. 10;
   a : validvolatile__r;
   pragma volatile (a);
   b : validvolatile__r;
begin
   a := 1;
   R1b : constant validvolatile__r := a;
   [constraint_error when
 not (interfaces__unsigned_32!(R1b) in 1 .. 10)
 "invalid data"]
   b := R1b;
   return;
end validvolatile;

Previously the constraint error check was not generated, because
A was assumed to have a value of 1 from the assignment at line 7

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Robert Dewar  

* checks.adb: Do not assume that a volatile variable is valid.

Index: checks.adb
===
--- checks.adb  (revision 206918)
+++ checks.adb  (working copy)
@@ -5257,6 +5257,10 @@
 
   elsif Is_Entity_Name (Expr)
 and then Is_Known_Valid (Entity (Expr))
+
+--  Exclude volatile variables
+
+and then not Treat_As_Volatile (Entity (Expr))
   then
  return True;
 


[Ada] Visiblity of formals of formal packages in an instance

2014-01-22 Thread Arnaud Charlet
This patch fixes a visibility problem in the presence of formal packages that
have themselves formal packages declared with a box.  In a generic unit the
formals of such packages are visible, and this visibility must be properly
reflected when compiling an instance. 

The following must compile quietly:

   gcc -c -gnat05 test_extensions.adb

---
with Ada.Numerics.Generic_Real_Arrays;
with Ada.Numerics.Generic_Complex_Types;
with Ada.Numerics.Generic_Complex_Arrays;
with Whatever;
procedure Test_Extensions is

   package Real_Arrays
   is new Ada.Numerics.Generic_Real_Arrays (Float);
   package Complex_Types
   is new Ada.Numerics.Generic_Complex_Types (Float);
   package Complex_Arrays
   is new Ada.Numerics.Generic_Complex_Arrays (Real_Arrays, Complex_Types);

   package Extensions
   is new Whatever (Complex_Arrays);

begin
   null;
end Test_Extensions;
---
with Ada.Numerics.Generic_Complex_Arrays;
generic
   with package Complex_Arrays is new Ada.Numerics.Generic_Complex_Arrays (<>);
package Whatever is
   pragma Elaborate_Body;
   use Complex_Arrays;
   use Complex_Arrays.Complex_Types;
   use Complex_Arrays.Real_Arrays;
end Whatever;
---
pragma Warnings (Off);
with System.Generic_Array_Operations;
pragma Warnings (On);

package body Whatever is
   procedure Transpose_Which_Doesnt_Instantiate
   is new System.Generic_Array_Operations.Transpose
 (Scalar => Real'Base,
  Matrix => Real_Matrix);

   procedure Transpose_Which_Instantiates
   is new System.Generic_Array_Operations.Transpose
 (Scalar => Real_Arrays.Real'Base,
  Matrix => Real_Matrix);
end Whatever;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Ed Schonberg  

* sem_ch8.adb (From_Actual_Package): Introduce a recursive
sub-procedure Declared_In_Actual to handle properly the visibility
of actuals in actual packages, that are themselves actuals to a
actual package of the current instance. This mimics properly the
visibility of formals of formal packages declared with a box,
within the corresponding generic unit.

Index: sem_ch8.adb
===
--- sem_ch8.adb (revision 206928)
+++ sem_ch8.adb (working copy)
@@ -4168,10 +4168,11 @@
   --  generate the precise error message.
 
   function From_Actual_Package (E : Entity_Id) return Boolean;
-  --  Returns true if the entity is declared in a package that is
+  --  Returns true if the entity is an actual for a package that is itself
   --  an actual for a formal package of the current instance. Such an
-  --  entity requires special handling because it may be use-visible
-  --  but hides directly visible entities defined outside the instance.
+  --  entity requires special handling because it may be use-visible but
+  --  hides directly visible entities defined outside the instance, because
+  --  the corresponding formal did so in the generic.
 
   function Is_Actual_Parameter return Boolean;
   --  This function checks if the node N is an identifier that is an actual
@@ -4214,11 +4215,57 @@
 
   function From_Actual_Package (E : Entity_Id) return Boolean is
  Scop : constant Entity_Id := Scope (E);
- Act  : Entity_Id;
+ --  Declared scope of candidate entity
 
+ Act : Entity_Id;
+
+ function Declared_In_Actual (Pack : Entity_Id) return Boolean;
+ --  Recursive function that does the work and examines actuals of
+ --  actual packages of current instance.
+
+ 
+ -- Declared_In_Actual --
+ 
+
+ function Declared_In_Actual (Pack : Entity_Id) return Boolean is
+Act : Entity_Id;
+
+ begin
+if No (Associated_Formal_Package (Pack)) then
+   return False;
+
+else
+   Act := First_Entity (Pack);
+   while Present (Act) loop
+  if Renamed_Object (Pack) = Scop then
+ return True;
+
+  --  Check for end of list of actuals.
+
+  elsif Ekind (Act) = E_Package
+and then Renamed_Object (Act) = Pack
+  then
+ return False;
+
+  elsif Ekind (Act) = E_Package
+and then Declared_In_Actual (Act)
+  then
+ return True;
+  end if;
+
+  Next_Entity (Act);
+   end loop;
+
+   return False;
+end if;
+ end Declared_In_Actual;
+
+  --  Start of processing for From_Actual_Package
+
   begin
  if not In_Instance then
 return False;
+
  else
 Inst := Current_Scope;
 while Present (Inst)
@@ -4234,27 +4281,13 @@
 
 Act := First_Entity (Inst);
 while Present (Act) loop
-   

Re: [Patch, microblaze]: Fix bswaphi2 implementation

2014-01-22 Thread Michael Eager

On 01/22/14 07:43, Michael Eager wrote:

On 01/22/14 02:55, David Holsgrove wrote:

Hi Michael,

On 26 November 2013 17:48, David Holsgrove  wrote:

Hi Michael,

Please find attached same patch based against latest from gcc master.

Can this be applied and backported to gcc-4_8-branch when reviewed.

thanks,
David

On 15 July 2013 14:49, David Holsgrove  wrote:

MicroBlaze insn swaph swaps the contents of register rA as two
halfwords placing result in rD;

(rD)[0:15]  <- (rA)[16:31]
(rD)[16:31] <- (rA)[0:15]

gcc bswaphi2 is intended to reverse the order of the bytes in the
half integer in rA

(rD)[8:15]  <- (rA)[0:7]
(rD)[7:0]   <- (rA)[8:15]
(rD)[24:31] <- (rA)[16:23]
(rD)[16:23] <- (rA)[24:31]

Correct the microblaze bswaphi2 insn pattern to be a swapb followed
by swaph

Changelog entry would be:

2013-07-15  David Holsgrove 

  * gcc/config/microblaze/microblaze.md: Fix bswaphi2


Can this also be backported to the gcc-4_8-branch?



Updated patch attached which includes a testcase to check that
bswaphi2 is using a swapb followed by swaph for MicroBlaze.

Updated Changelogs are;

gcc/Changelog

 2014-01-22  David Holsgrove 

  * gcc/config/microblaze/microblaze.md: Correct bswaphi2 / bswapsi2 insn

testsuite/ChangeLog

 2014-01-22  David Holsgrove 

  * gcc/testsuite/gcc.target/microblaze/others/bswap16.c: New test.


Thanks for the test case.

I had verified that the code was correct by hand, but tests are always
a good addition.


The test case only verifies that swapb and swaph instructions are
generated.  It doesn't confirm that the computation is correct.

This is a minor fix.  No test case is needed.


--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


[Ada] Expression functions as fully private protected operations

2014-01-22 Thread Arnaud Charlet
An expression function that is not a completion can appear in a protected body
and requires the same renaming declarations as other protected operations.

The following must compile quietly:

---
with Private_Types;
procedure Main is

   package Integer_Buffer is new
 Private_Types (Element => Integer, Size => 10);

   Buffer : Integer_Buffer.Buffer;

begin
   Buffer.Put (0);
end Main;
---
generic
   type Element is private;
   Size: Positive;
package Private_Types is

   subtype Storage_Range is Positive range 1 .. Size;
   type Storage is array (Storage_Range) of Element;

   protected type Buffer is

  entry Put (Item : in Element);
  entry Get (Item : out Element);

   private

  Item_Buffer : Storage := (others => <>);
  Put_Item_Index, Get_Item_Index : Storage_Range := Storage_Range'First;
  Item_Count : Natural range 0 .. Size := 0;
   end Buffer;
end Private_Types;
---
package body Private_Types is

   protected body Buffer is
  function Is_Full return Boolean is (Item_Count = Size);

  function Is_Empty return Boolean is (Item_Count = 0);

  entry Put (Item : in Element) when not Is_Full is
  begin
 Item_Buffer (Put_Item_Index) := Item;
 Put_Item_Index :=
   (if Put_Item_Index = Storage_Range'Last then
  Storage_Range'First
else
  Storage_Range'Succ (Put_Item_Index));
 Item_Count := Item_Count + 1;
  end Put;

  entry Get (Item : out Element) when not Is_Empty is
  begin
 Item := Item_Buffer (Get_Item_Index);
 Get_Item_Index :=
   (if Get_Item_Index = Storage_Range'Last then
  Storage_Range'First
else
  Storage_Range'Succ (Get_Item_Index));
 Item_Count := Item_Count - 1;
  end Get;
   end Buffer;
end Private_Types;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Ed Schonberg  

* sem_ch6.adb (Analyze_Subprogram_Body_Helper): A subprogram
body generated for an expression function within a protected body
needs a set of renaming declarations if the expression function
comes from source.

Index: sem_ch6.adb
===
--- sem_ch6.adb (revision 206929)
+++ sem_ch6.adb (working copy)
@@ -3218,13 +3218,13 @@
   --  family index (if applicable). This form of early expansion is done
   --  when the Expander is active because Install_Private_Data_Declarations
   --  references entities which were created during regular expansion. The
-  --  body may be the rewritting of an expression function, and we need to
-  --  verify that the original node is in the source.
+  --  subprogram entity must come from source, and not be an internally
+  --  generated subprogram.
 
   if Expander_Active
-and then Comes_From_Source (Original_Node (N))
 and then Present (Prot_Typ)
 and then Present (Spec_Id)
+and then Comes_From_Source (Spec_Id)
 and then not Is_Eliminated (Spec_Id)
   then
  Install_Private_Data_Declarations


[Ada] Implement SPARK_05 rule about calls before bodies

2014-01-22 Thread Arnaud Charlet
In SPARK 2005, it is not permitted to have a call to a subprogram
in the same unit as the subprogram if the body occurs later on.
This implements that rule if restriction SPARK_05 is active as
shown by the following example:

 1. pragma Restrictions (SPARK_05);
 2. package SPARKRec2 is
 3.function P1 return Integer;
 4.X : Integer := P1;
  |
>>> violation of restriction "SPARK_05" at line 1
 call to subprogram cannot appear before its
body
>>> violation of restriction "SPARK_05" at line 1
 initialization expression is not appropriate
>>> warning: cannot call "P1" before body seen,
Program_Error will be raised at run time

 5.function P2 return Integer;
 6.pragma Import (C, P2);
 7.Y : Integer := P2;
  |
>>> violation of restriction "SPARK_05" at line 1
 initialization expression is not appropriate

 8.package SPARKRecP is
   |
>>> violation of restriction "SPARK_05" at line 1
 package specification cannot contain a package
declaration

 9.end SPARKRecP;
10. end SPARKRec2;

 1. pragma Restrictions (SPARK_05);
 2. package body SPARKRec2 is
 3.
 4.XXX : Integer;
 5.
 6.function P3 return Integer is
 7.begin
 8.   return P1;
 |
>>> violation of restriction "SPARK_05" at
sparkrec2.ads:1
 call to subprogram cannot appear before its
body

 9.end P3;
10.
11.package body SPARKRecP is separate;
12.
13.function P1 return Integer is
14.begin
15.   return 13;
16.end P1;
17.
18.function P2a return Integer;
19.pragma Import (C, P2a);
20. begin
21.XXX := P1;
22.XXX := P2;
23.XXX := P2a;
24. end SPARKRec2;

 1. pragma Restrictions (SPARK_05);
 2. separate (SPARKRec2)
 3. package body SPARKRecP is
 4.function JJ return Integer is
 5.begin
 6.   return P1;
 |
>>> violation of restriction "SPARK_05" at line 1
 call to subprogram cannot appear before its
body

 7.end JJ;
 8. end SPARKRecP;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-22  Robert Dewar  

* lib.adb (In_Extended_Main_Code_Unit): Return False for
Standard_Location.
(In_Extended_Main_Source_Unit): Return False for Standard_Location.
* lib.ads (In_Extended_Main_Code_Unit): Add documentation on
treatment of Slocs No_Location and Standard_Location.
* restrict.adb (Check_Restriction_No_Dependence): Explicitly
check for entity with Standard_Location Sloc, rather than relying
on Lib routines to do that.
* sem_res.adb (Resolve_Call): Implement SPARK_05 restriction
that a call cannot occur before a later occuring body within
the same unit.

Index: lib.adb
===
--- lib.adb (revision 206918)
+++ lib.adb (working copy)
@@ -718,7 +718,7 @@
is
begin
   if Sloc (N) = Standard_Location then
- return True;
+ return False;
 
   elsif Sloc (N) = No_Location then
  return False;
@@ -750,7 +750,7 @@
function In_Extended_Main_Code_Unit (Loc : Source_Ptr) return Boolean is
begin
   if Loc = Standard_Location then
- return True;
+ return False;
 
   elsif Loc = No_Location then
  return False;
@@ -787,7 +787,7 @@
   --  Special value cases
 
   elsif Nloc = Standard_Location then
- return True;
+ return False;
 
   elsif Nloc = No_Location then
  return False;
@@ -826,7 +826,7 @@
   --  Special value cases
 
   elsif Loc = Standard_Location then
- return True;
+ return False;
 
   elsif Loc = No_Location then
  return False;
Index: lib.ads
===
--- lib.ads (revision 206918)
+++ lib.ads (working copy)
@@ -520,6 +520,14 @@
--  instantiations are included in the extended main unit for this call.
--  If the main unit is itself a subunit, then the extended main code unit
--  includes its parent unit, and the parent unit spec if it is separate.
+   --
+   --  This routine (and the following three routines) all return False if
+   --  Sloc (N) is No_Location or Standard_Location. In an earlier version,
+   --  they returned True for Standard_Location, but this was odd, and some
+   --  archeology indicated that this was done for the sole benefit of the
+   --  call in Restrict.Check_Restriction_No_Dependence, so we have moved
+   --  the special case check to that routine. This avoids some difficulties
+   --  with some other calls that

FYI: remove two stray uses of PARAMS

2014-01-22 Thread Tom Tromey
Jan-Benedict Glaw pointed out to me that my recent ansidecl.h change
caused a build failure for CR16.  I had missed a couple spots where
PARAMS was still used in the gcc tree.

I'm checking in this patch as obvious.

Tom

2014-01-22  Tom Tromey  

* config/i386/i386-interix.h (i386_pe_unique_section): Don't use
PARAMS.
* config/cr16/cr16-protos.h (notice_update_cc): Don't use PARAMS.

Index: config/cr16/cr16-protos.h
===
--- config/cr16/cr16-protos.h   (revision 206930)
+++ config/cr16/cr16-protos.h   (working copy)
@@ -68,7 +68,7 @@
   CR16_ABSOLUTE
 };
 
-extern void notice_update_cc PARAMS ((rtx));
+extern void notice_update_cc (rtx);
 extern int cr16_operand_bit_pos (int val, int bitval);
 extern void cr16_decompose_const (rtx x, int *code,
  enum data_model_type *data,
Index: config/i386/i386-interix.h
===
--- config/i386/i386-interix.h  (revision 206930)
+++ config/i386/i386-interix.h  (working copy)
@@ -195,7 +195,7 @@
  */
 #define MULTIPLE_SYMBOL_SPACES 1
 
-extern void i386_pe_unique_section PARAMS ((tree, int));
+extern void i386_pe_unique_section (tree, int);
 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
 
 /* Switch into a generic section.  */


Re: [C++ Patch] PR 58980

2014-01-22 Thread Jason Merrill

On 01/21/2014 09:55 AM, Jason Merrill wrote:

I think I would prefer to change the "child" assert to be
MAYBE_CLASS_TYPE_P rather than CLASS_TYPE_P.


On second thought, no, I think we do want to specifically handle 
TYPENAME_TYPE.  But I think we want a different error message; getting a 
TYPENAME_TYPE here means that B has not been declared.  The current 
scope is irrelevant.  So we want to check for TYPENAME_TYPE before we 
think about checking prev_scope.


Jason



Re: [C++ patch] PR 59482

2014-01-22 Thread Paolo Carlini

On 01/21/2014 04:24 PM, Jason Merrill wrote:

OK, thanks.
I don't think Ville has Write After Approval, thus I'm going to commit 
this on his behalf.


Thanks,
Paolo.


Re: [patch] Pass -fuse-ld=gold to gccgo on targets supporting -fsplit-stack

2014-01-22 Thread Matthias Klose
Am 18.01.2014 03:03, schrieb Ian Lance Taylor:
> On Fri, Nov 29, 2013 at 5:29 AM, Matthias Klose  wrote:
>> to get full advantage of the -fsplit-stack option, gccgo binaries have to be
>> linked with gold, not the bfd linker.  When the system linker defaults to the
>> bfd linker, then gccgo should explicitly use the gold linker, passing
>> fuse-ld=gold, unless another -fuse-ld option is present.  Tested with and
>> without having ld.gold on the system.
> 
> The change to libgo/configure.ac seems unrelated.

No, it is required.  Without it you would check (with ld.bfd as the default) the
help text of the ld.bfd linker, and not the one used for gccgo ($LD vs. $GOC).
The quoting fix to fix the underquoting is now required because the argument has
a comma now.

> I don't think you can use "which" in a configure script.  You need to
> use something like AC_PATH_PROG.

Ok, but I cannot do this directly.  gcc_cv_ld may already be an absolute path.
So now I'm checking the very same location as gcc_cv_ld first, then fall back to
AC_PATH_PROG.

updated patch attached.

  Matthias


# DP: Pass -fuse-ld=gold to gccgo on targets supporting -fsplit-stack

gcc/go/ 
 
* gospec.c (lang_specific_driver): Pass -fuse-ld=gold on targets
supporting -fsplit-stack, unless overwritten.   
 

 
gcc/
 
* configure.ac: New define HAVE_GOLD_NON_DEFAULT.  
* config.in: Regenerate.
  

 
libgo/  
 
* configure.ac (libgo_cv_c_linker_supports_split_stack): Fix quoting. 
Check the linker used by the gccgo driver.

Index: gcc/configure.ac
===
--- gcc/configure.ac(revision 206924)
+++ gcc/configure.ac(working copy)
@@ -2105,6 +2105,19 @@
 fi
 AC_MSG_RESULT($ld_is_gold)
 
+# Check to see if ld is used, and gold is available
+if test x$ld_is_gold = xno; then
+  if test -x ${gcc_cv_ld}.gold; then
+gcc_cv_ld_gold=${gcc_cv_ld}.gold
+  else
+AC_PATH_PROG(gcc_cv_ld_gold,${gcc_cv_ld}.gold,no)
+  fi
+  if test x$gcc_cv_ld_gold != xno; then
+AC_DEFINE(HAVE_GOLD_NON_DEFAULT, 1,
+ [Define if the gold linker is available as a non-default])
+  fi
+fi
+
 ORIGINAL_LD_FOR_TARGET=$gcc_cv_ld
 AC_SUBST(ORIGINAL_LD_FOR_TARGET)
 case "$ORIGINAL_LD_FOR_TARGET" in
Index: gcc/go/gospec.c
===
--- gcc/go/gospec.c (revision 206924)
+++ gcc/go/gospec.c (working copy)
@@ -117,6 +117,10 @@
   /* Whether the -S option was used.  */
   bool saw_opt_S = false;
 
+  /* "-fuse-ld=" if it appears on the command line.  */
+  bool saw_use_ld ATTRIBUTE_UNUSED = false;
+  int need_gold = 0;
+
   /* The first input file with an extension of .go.  */
   const char *first_go_file = NULL;  
 
@@ -217,6 +221,11 @@
}
 
  break;
+
+   case OPT_fuse_ld_bfd:
+   case OPT_fuse_ld_gold:
+ saw_use_ld = true;
+ break;
}
 }
 
@@ -226,8 +235,14 @@
   shared_libgcc = 0;
 #endif
 
+#if defined(TARGET_CAN_SPLIT_STACK) && defined(HAVE_GOLD_NON_DEFAULT)
+  if (!saw_use_ld)
+need_gold = 1;
+#endif
+
   /* Make sure to have room for the trailing NULL argument.  */
-  num_args = argc + need_math + shared_libgcc + (library > 0) * 5 + 10;
+  num_args = argc + need_math + shared_libgcc + need_gold +
+(library > 0) * 5 + 10;
   new_decoded_options = XNEWVEC (struct cl_decoded_option, num_args);
 
   i = 0;
@@ -244,7 +259,15 @@
   &new_decoded_options[j]);
   j++;
 }
+#ifdef HAVE_GOLD_NON_DEFAULT
+  if (need_gold)
+{
+  generate_option (OPT_fuse_ld_gold, NULL, 1, CL_DRIVER,
+  &new_decoded_options[j]);
+  j++;
+}
 #endif
+#endif
 
   /* NOTE: We start at 1 now, not 0.  */
   while (i < argc)
Index: libgo/configure.ac
===
--- libgo/configure.ac  (revision 206924)
+++ libgo/configure.ac  (working copy)
@@ -357,10 +357,10 @@
 dnl others.
 AC_CACHE_CHECK([whether linker supports split stack],
 [libgo_cv_c_linker_supports_split_stack],
-libgo_cv_c_linker_supports_split_stack=no
-if $LD --help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; then
+[libgo_cv_c_linker_supports_split_stack=no
+if $GOC -Wl,--help 2>/dev/null | grep split-stack-adjust-size >/dev/null 2>&1; 
then
   libgo_cv_c_linker_supports_split_stack=yes
-fi)
+fi])
 if test "$libgo_cv_c_linker_supports_split_s

[PATCH] PR59909, Fix powerpcle64 power8 bootstrap (quad memory support)

2014-01-22 Thread Michael Meissner
The current trunk will not bootstrap on a powerpcle64 power8 box if
--with-cpu=power8 is selected.  This has been traced down to the fact that we
did not swap the double words when we used the quad memory instructions.

In this patch, I split the ISA 2.07 quad memory support into two parts, one for
the non-atomic quad memory support instructions, and the other for atomic quad
memory support.  In big endian systems, both forms are generated, while in
little endian systems only the atomic instructions are generated, since the
overhead of swapping the words would diminish the appeal of using the
non-atomic quad memory instructions.

At a future date, I would like to optimize the quad memory atomic instructions
not to do the swapping in some cases.  That optimization is not in these
patches.

I'm attaching two versions of the patch.  The first version is against the
current trunk.  The second version is against the 4.8 compiler in the IBM
branch.

This has been tested by doing a full bootstrap on a power8 box in little endian
mode.  There are no regressions in the powerpc tests.  Is this patch ok to
apply?

2014-01-22  Michael Meissner  

PR target/59909
* doc/invoke.texi (RS/6000 and PowerPC Options): Document
-mquad-memory-atomic.  Update -mquad-memory documentation to say
it is only used for non-atomic loads/stores.

* config/rs6000/predicates.md (quad_int_reg_operand): Allow either
-mquad-memory or -mquad-memory-atomic switches.

* config/rs6000/rs6000-cpus.def (ISA_2_7_MASKS_SERVER): Add
-mquad-memory-atomic to ISA 2.07 support.

* config/rs6000/rs6000.opt (-mquad-memory-atomic): Add new switch
to separate support of normal quad word memory operations (ldq,
stq) from the atomic quad word memory operations.

* config/rs6000/rs6000.c (rs6000_option_override_internal): Add
support to separate non-atomic quad word operations from atomic
quad word operations.  Disable non-atomic quad word operations in
little endian mode so that we don't have to swap words after the
load and before the store.
(quad_load_store_p): Add comment about atomic quad word support.
(rs6000_opt_masks): Add -mquad-memory-atomic.

* config/rs6000/rs6000.h (TARGET_SYNC_TI): Add support for
-mquad-memory-atomic.
(TARGET_SYNC_HI_QI): Likewise.

* config/rs6000/sync.md (qswap_pred1): Add support for swapping
double word registers with quad word atomic instructions in little
endian mode.
(qswap_pred2): Likewise.
(qswap_other): Likewise.
(qswap_): Likewise.
(load_lockedti): Likewise.
(load_lockedpti): Likewise.
(store_conditionalti): Likewise.
(store_conditionalpti): Likewise.

* gcc/config/rs6000/rs6000.md (UNSPEC_TI_PTI_SWAP): New UNSPEC for
dealing with quad word atomic instructions in little endian mode.

* gcc/config/rs6000/rs6000-c.c (rs6000_target_modify_macros):
Define __QUAD_MEMORY__ and __QUAD_MEMORY_ATOMIC__ based on what
type of quad memory support is available.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi (revision 206895)
+++ gcc/doc/invoke.texi (working copy)
@@ -919,6 +919,7 @@ See RS/6000 and PowerPC Options.
 -mpower8-fusion -mno-mpower8-fusion -mpower8-vector -mno-power8-vector @gol
 -mcrypto -mno-crypto -mdirect-move -mno-direct-move @gol
 -mquad-memory -mno-quad-memory @gol
+-mquad-memory-atomic -mno-quad-memory-atomic @gol
 -mcompat-align-parm -mno-compat-align-parm}
 
 @emph{RX Options}
@@ -18853,7 +18854,8 @@ following options:
 -mpopcntb -mpopcntd  -mpowerpc64 @gol
 -mpowerpc-gpopt  -mpowerpc-gfxopt  -msingle-float -mdouble-float @gol
 -msimple-fpu -mstring  -mmulhw  -mdlmzb  -mmfpgpr -mvsx @gol
--mcrypto -mdirect-move -mpower8-fusion -mpower8-vector -mquad-memory}
+-mcrypto -mdirect-move -mpower8-fusion -mpower8-vector @gol
+-mquad-memory -mquad-memory-atomic}
 
 The particular options set for any particular CPU varies between
 compiler versions, depending on what setting seems to produce optimal
@@ -19040,10 +19042,18 @@ the vector instructions.
 @itemx -mno-quad-memory
 @opindex mquad-memory
 @opindex mno-quad-memory
-Generate code that uses (does not use) the quad word memory
+Generate code that uses (does not use) the non-atomic quad word memory
 instructions.  The @option{-mquad-memory} option requires use of
 64-bit mode.
 
+@item -mquad-memory-atomic
+@itemx -mno-quad-memory-atomic
+@opindex mquad-memory-atomic
+@opindex mno-quad-memory-atomic
+Generate code that uses (does not use) the atomic quad word memory
+instructions.  The @option{-mquad-memory-atomic} option requires use of
+64-bit mode.
+
 @item -mfl

[PATCH, rs6000] Honor -fno-ira-loop-pressure

2014-01-22 Thread Pat Haugen
Discovered that we blindly set flag_ira_loop_pressure at -O3+, 
regardless of whether command line option was given. Following fixes that.


Bootstrap/regtest with no new regressions, ok for trunk?

-Pat


2014-01-22  Pat Haugen  

* config/rs6000/rs6000.c (rs6000_option_override_internal): Don't
force flag_ira_loop_pressure if set via command line.


Index: config/rs6000/rs6000.c
===
--- config/rs6000/rs6000.c(revision 206861)
+++ config/rs6000/rs6000.c(working copy)
@@ -3039,7 +3039,8 @@ rs6000_option_override_internal (bool gl
  calculation works better for RTL loop invariant motion on targets
  with enough (>= 32) registers.  It is an expensive optimization.
  So it is on only for peak performance.  */
-  if (optimize >= 3 && global_init_p)
+  if (optimize >= 3 && global_init_p
+  && !global_options_set.x_flag_ira_loop_pressure)
 flag_ira_loop_pressure = 1;

   /* Set the pointer size.  */



Re: [patch] Pass -fuse-ld=gold to gccgo on targets supporting -fsplit-stack

2014-01-22 Thread Ian Lance Taylor
On Wed, Jan 22, 2014 at 10:16 AM, Matthias Klose  wrote:
> Am 18.01.2014 03:03, schrieb Ian Lance Taylor:
>> On Fri, Nov 29, 2013 at 5:29 AM, Matthias Klose  wrote:
>>> to get full advantage of the -fsplit-stack option, gccgo binaries have to be
>>> linked with gold, not the bfd linker.  When the system linker defaults to 
>>> the
>>> bfd linker, then gccgo should explicitly use the gold linker, passing
>>> fuse-ld=gold, unless another -fuse-ld option is present.  Tested with and
>>> without having ld.gold on the system.
>>
>> The change to libgo/configure.ac seems unrelated.
>
> No, it is required.  Without it you would check (with ld.bfd as the default) 
> the
> help text of the ld.bfd linker, and not the one used for gccgo ($LD vs. $GOC).
> The quoting fix to fix the underquoting is now required because the argument 
> has
> a comma now.

I see.  OK, I committed that part of the patch to mainline.

Thanks.

Ian


Re: [patch] Pass -fuse-ld=gold to gccgo on targets supporting -fsplit-stack

2014-01-22 Thread Ian Lance Taylor
On Wed, Jan 22, 2014 at 10:16 AM, Matthias Klose  wrote:
>
> Ok, but I cannot do this directly.  gcc_cv_ld may already be an absolute path.
> So now I'm checking the very same location as gcc_cv_ld first, then fall back 
> to
> AC_PATH_PROG.

When I look at gcc/configure.ac and gcc/exec-tool.in, it seems to me
that if you pass -fuse-ld=gold the tool will execute
ORIGINAL_LD_GOLD_FOR_TARGET.  Can we simply change the configure
script to test whether that file exists when deciding whether to set
HAVE_GOLD_NON_DEFAULT?

Also, it seems to me that all we really need to set is HAVE_GOLD.  The
code in gospec.c can pass -fuse-ld=gold when -fuse-ld does not appear
and HAVE_GOLD is true.  It's not necessary to only pass -fuse-ld=gold
when gold is not the default.

Ian


patch to fix PR59477

2014-01-22 Thread Vladimir Makarov

  The following patch fixes

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59477

  The patch was successfully bootstrapped and tested on x86/x86-64.

  Committed as rev. 206938.

2014-01-22  Vladimir Makarov  

PR rtl-optimization/59477
* lra-constraints.c (inherit_in_ebb): Process call for living hard
regs.  Update reloads_num and potential_reload_hard_regs for all
insns.

2014-01-22  Vladimir Makarov  

PR rtl-optimization/59477
* g++.dg/pr59477.C: New.


Re: patch to fix PR59477

2014-01-22 Thread Jakub Jelinek
On Wed, Jan 22, 2014 at 02:40:46PM -0500, Vladimir Makarov wrote:
>   The following patch fixes
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59477
> 
>   The patch was successfully bootstrapped and tested on x86/x86-64.
> 
>   Committed as rev. 206938.
> 
> 2014-01-22  Vladimir Makarov  
> 
> PR rtl-optimization/59477
> * lra-constraints.c (inherit_in_ebb): Process call for living hard
> regs.  Update reloads_num and potential_reload_hard_regs for all
> insns.
> 
> 2014-01-22  Vladimir Makarov  
> 
> PR rtl-optimization/59477
> * g++.dg/pr59477.C: New.

ENOPATCH ;)

Jakub


Re: patch to fix PR59477

2014-01-22 Thread Vladimir Makarov

On 1/22/2014, 2:41 PM, Jakub Jelinek wrote:

On Wed, Jan 22, 2014 at 02:40:46PM -0500, Vladimir Makarov wrote:

   The following patch fixes

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59477

   The patch was successfully bootstrapped and tested on x86/x86-64.

   Committed as rev. 206938.

2014-01-22  Vladimir Makarov  

 PR rtl-optimization/59477
 * lra-constraints.c (inherit_in_ebb): Process call for living hard
 regs.  Update reloads_num and potential_reload_hard_regs for all
 insns.

2014-01-22  Vladimir Makarov  

 PR rtl-optimization/59477
 * g++.dg/pr59477.C: New.


ENOPATCH ;)

Jakub


Ops, sorry.  The patch is in the attachment.

Index: lra-constraints.c
===
--- lra-constraints.c   (revision 206686)
+++ lra-constraints.c   (working copy)
@@ -4992,7 +4992,7 @@
 inherit_in_ebb (rtx head, rtx tail)
 {
   int i, src_regno, dst_regno, nregs;
-  bool change_p, succ_p;
+  bool change_p, succ_p, update_reloads_num_p;
   rtx prev_insn, next_usage_insns, set, last_insn;
   enum reg_class cl;
   struct lra_insn_reg *reg;
@@ -5063,6 +5063,7 @@
  src_regno = REGNO (SET_SRC (set));
  dst_regno = REGNO (SET_DEST (set));
}
+  update_reloads_num_p = true;
   if (src_regno < lra_constraint_new_regno_start
  && src_regno >= FIRST_PSEUDO_REGISTER
  && reg_renumber[src_regno] < 0
@@ -5071,6 +5072,7 @@
{
  /* 'reload_pseudo <- original_pseudo'.  */
  reloads_num++;
+ update_reloads_num_p = false;
  succ_p = false;
  if (usage_insns[src_regno].check == curr_usage_insns_check
  && (next_usage_insns = usage_insns[src_regno].insns) != NULL_RTX)
@@ -5094,6 +5096,7 @@
   = usage_insns[dst_regno].insns) != NULL_RTX)
{
  reloads_num++;
+ update_reloads_num_p = false;
  /* 'original_pseudo <- reload_pseudo'.  */
  if (! JUMP_P (curr_insn)
  && inherit_reload_reg (true, dst_regno, cl,
@@ -5282,6 +5285,14 @@
  add_next_usage_insn (src_regno, use_insn, reloads_num);
}
}
+ /* Process call args.  */
+ if (curr_id->arg_hard_regs != NULL)
+   for (i = 0; (src_regno = curr_id->arg_hard_regs[i]) >= 0; i++)
+ if (src_regno < FIRST_PSEUDO_REGISTER)
+   {
+  SET_HARD_REG_BIT (live_hard_regs, src_regno);
+  add_next_usage_insn (src_regno, curr_insn, reloads_num);
+   }
  for (i = 0; i < to_inherit_num; i++)
{
  src_regno = to_inherit[i].regno;
@@ -5292,6 +5303,26 @@
setup_next_usage_insn (src_regno, curr_insn, reloads_num, 
false);
}
}
+  if (update_reloads_num_p
+ && NONDEBUG_INSN_P (curr_insn)
+  && (set = single_set (curr_insn)) != NULL_RTX)
+   {
+ int regno = -1;
+ if ((REG_P (SET_DEST (set))
+  && (regno = REGNO (SET_DEST (set))) >= 
lra_constraint_new_regno_start
+  && reg_renumber[regno] < 0
+  && (cl = lra_get_allocno_class (regno)) != NO_REGS)
+ || (REG_P (SET_SRC (set))
+ && (regno = REGNO (SET_SRC (set))) >= 
lra_constraint_new_regno_start
+ && reg_renumber[regno] < 0
+ && (cl = lra_get_allocno_class (regno)) != NO_REGS))
+   {
+ reloads_num++;
+ if (hard_reg_set_subset_p (reg_class_contents[cl], 
live_hard_regs))
+   IOR_HARD_REG_SET (potential_reload_hard_regs,
+ reg_class_contents[cl]);
+   }
+   }
   /* We reached the start of the current basic block.  */
   if (prev_insn == NULL_RTX || prev_insn == PREV_INSN (head)
  || BLOCK_FOR_INSN (prev_insn) != curr_bb)
Index: testsuite/g++.dg/pr59477.C
===
--- testsuite/g++.dg/pr59477.C  (revision 0)
+++ testsuite/g++.dg/pr59477.C  (working copy)
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+
+struct A
+{
+  unsigned *a, b;
+  A (unsigned x) : a (), b (x) {}
+};
+
+struct B
+{
+  B (int);
+  B (const B &) {}
+};
+
+B bar (B, B, A);
+int v;
+
+void
+foo ()
+{
+  B c = 0;
+  bar (c, c, A (1ULL << v));
+}


[patch] fix libstdc++/58764

2014-01-22 Thread Jonathan Wakely

This undoes the recent change to make the containers' default
constructors explicit, and makes the Debug Mode and Profile Mode
associative containers consistent with normal mode.

The new C++11 containers (forward_list and unordered_*) still have
explicit default constructors, which is probably wrong, but they
weren't changed recently so that isn't a regression and can wait for
the resolution of LWG issue 2193.

Tested x86_64-linux, committed to trunk.

commit 3bc097d1f765fb323cf9ed61b4096b2a255a4cf8
Author: Jonathan Wakely 
Date:   Wed Jan 22 16:41:27 2014 +

PR libstdc++/58764
* include/bits/stl_deque.h (deque::deque(const allocator_type&):
Split into separate default constructor and constructor taking
allocator.
* include/bits/stl_list.h (list::list(const allocator_type&): Likewise.
* include/bits/stl_vector.h (vector::vector(const allocator_type&):
Likewise.
* include/debug/deque (deque::deque(const allocator_type&)): Likewise.
* include/debug/list (list::list(const _Allocator&)): Likewise.
* include/debug/map.h (map::map(const _Compare&, const _Allocator&)):
Likewise.
* include/debug/multimap.h
(multimap::multimap(const _Compare&, const _Allocator&)): Likewise.
* include/debug/set.h (set::set(const _Compare&, const _Allocator&)):
Likewise.
* include/debug/multiset.h
(multiset::multiset(const _Compare&, const _Allocator&)): Likewise.
* include/debug/vector (vector::vector(const allocator_type&)):
Likewise.
* include/profile/deque (deque::deque(const _Allocator&)): Likewise.
* include/profile/list (list::list(const _Allocator&)): Likewise.
* include/profile/map.h
(map::map(const _Compare&, const _Allocator&)): Likewise.
* include/profile/multimap.h
(multimap::multimap(const _Compare&, const _Allocator&)): Likewise.
* include/profile/set.h
(set::set(const _Compare&, const _Allocator&)): Likewise.
* include/profile/multiset.h
(multiset::multiset(const _Compare&, const _Allocator&)): Likewise.
* include/profile/vector (vector::vector(const _Allocator&)):
Likewise.
* testsuite/23_containers/deque/58764.cc: New.
* testsuite/23_containers/list/58764.cc: New.
* testsuite/23_containers/map/58764.cc: New.
* testsuite/23_containers/multimap/58764.cc: New.
* testsuite/23_containers/set/58764.cc: New.
* testsuite/23_containers/multiset/58764.cc: New.
* testsuite/23_containers/vector/58764.cc: New.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.

diff --git a/libstdc++-v3/include/bits/stl_deque.h 
b/libstdc++-v3/include/bits/stl_deque.h
index 996c10f..0f4d0e9 100644
--- a/libstdc++-v3/include/bits/stl_deque.h
+++ b/libstdc++-v3/include/bits/stl_deque.h
@@ -781,12 +781,18 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 public:
   // [23.2.1.1] construct/copy/destroy
   // (assign() and get_allocator() are also listed in this section)
+
+  /**
+   *  @brief  Creates a %deque with no elements.
+   */
+  deque() : _Base() { }
+
   /**
*  @brief  Creates a %deque with no elements.
*  @param  __a  An allocator object.
*/
   explicit
-  deque(const allocator_type& __a = allocator_type())
+  deque(const allocator_type& __a)
   : _Base(__a) { }
 
 #if __cplusplus >= 201103L
diff --git a/libstdc++-v3/include/bits/stl_list.h 
b/libstdc++-v3/include/bits/stl_list.h
index b5e6cc8..19bb189 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -526,12 +526,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 public:
   // [23.2.2.1] construct/copy/destroy
   // (assign() and get_allocator() are also listed in this section)
+

Re: [C++ Patch] PR 58980

2014-01-22 Thread Paolo Carlini

Hi,

On 01/22/2014 06:13 PM, Jason Merrill wrote:

On 01/21/2014 09:55 AM, Jason Merrill wrote:

I think I would prefer to change the "child" assert to be
MAYBE_CLASS_TYPE_P rather than CLASS_TYPE_P.
On second thought, no, I think we do want to specifically handle 
TYPENAME_TYPE.  But I think we want a different error message; getting 
a TYPENAME_TYPE here means that B has not been declared. The current 
scope is irrelevant.  So we want to check for TYPENAME_TYPE before we 
think about checking prev_scope.
Ok. In fact I entertained myself this kind of reasoning, a couple of 
days ago...


I tested the below, which uses "by hand" %Es instead of %qT for more 
concise error messages (consistent with the non-template case).


Thanks,
Paolo.


/cp
2014-01-22  Paolo Carlini  

PR c++/58980
* parser.c (cp_parser_enum_specifier): Handle TYPENAME_TYPE as
nested_name_specifier.

/testsuite
2014-01-22  Paolo Carlini  

PR c++/58980
* g++.dg/parse/enum11.C: New.
Index: cp/parser.c
===
--- cp/parser.c (revision 206933)
+++ cp/parser.c (working copy)
@@ -15469,9 +15469,17 @@ cp_parser_enum_specifier (cp_parser* parser)
error_at (type_start_token->location, "cannot add an enumerator "
  "list to a template instantiation");
 
+ if (prev_scope && TREE_CODE (nested_name_specifier) == TYPENAME_TYPE)
+   {
+ error_at (type_start_token->location,
+   "%<%E::%E%> has not been declared",
+   prev_scope, nested_name_specifier);
+ type = error_mark_node;
+   }
  /* If that scope does not contain the scope in which the
 class was originally declared, the program is invalid.  */
- if (prev_scope && !is_ancestor (prev_scope, nested_name_specifier))
+ else if (prev_scope && !is_ancestor (prev_scope,
+  nested_name_specifier))
{
  if (at_namespace_scope_p ())
error_at (type_start_token->location,
@@ -15480,7 +15488,8 @@ cp_parser_enum_specifier (cp_parser* parser)
  type, prev_scope, nested_name_specifier);
  else
error_at (type_start_token->location,
- "declaration of %qD in %qD which does not enclose 
%qD",
+ "declaration of %qD in %qD which does not "
+ "enclose %qD",
  type, prev_scope, nested_name_specifier);
  type = error_mark_node;
}
Index: testsuite/g++.dg/parse/enum11.C
===
--- testsuite/g++.dg/parse/enum11.C (revision 0)
+++ testsuite/g++.dg/parse/enum11.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/58980
+
+template struct A
+{ 
+  enum A::B::C {};   // { dg-error "has not been declared" }
+};


[C PATCH] Don't leak C_MAYBE_CONST_EXPRs into GIMPLE (PR c/59891)

2014-01-22 Thread Marek Polacek
As mentioned in the PR, C FE leaked C_MAYBE_CONST_EXPR into GIMPLE.
This happened because remove_c_maybe_const_expr doesn't look for
nested C_MAYBE_CONST_EXPRs.  But c_fully_fold will fold these away,
so use that.

Regtested/bootstrapped on x86_64-linux, ok for trunk and 4.8?

Alternatively, we could in if (int_operands) look at op1/op2, and
call c_fully_fold only if C_MAYBE_CONST_EXPR isn't the top level
expression.

2014-01-22  Marek Polacek  

PR c/59891
c/
* c-typeck.c (build_conditional_expr): Call c_fully_fold instead
of remove_c_maybe_const_expr on op1 and op2.
testsuite/
* gcc.dg/torture/pr59891.c: New test.

--- gcc/c/c-typeck.c.mp32014-01-22 18:47:36.812358319 +0100
+++ gcc/c/c-typeck.c2014-01-22 18:45:10.298692933 +0100
@@ -4708,8 +4708,10 @@ build_conditional_expr (location_t colon
 {
   if (int_operands)
{
- op1 = remove_c_maybe_const_expr (op1);
- op2 = remove_c_maybe_const_expr (op2);
+ /* Use c_fully_fold here, since C_MAYBE_CONST_EXPR might be
+nested inside of the expression.  */
+ op1 = c_fully_fold (op1, false, NULL);
+ op2 = c_fully_fold (op2, false, NULL);
}
   ret = build3 (COND_EXPR, result_type, ifexp, op1, op2);
   if (int_operands)
--- gcc/testsuite/gcc.dg/torture/pr59891.c.mp3  2014-01-22 19:16:34.0 
+0100
+++ gcc/testsuite/gcc.dg/torture/pr59891.c  2014-01-22 19:19:23.996129684 
+0100
@@ -0,0 +1,9 @@
+/* PR c/59891 */
+
+unsigned int a;
+
+int
+main ()
+{
+  return (0 ? a : 0) ? : 0 % 0; /* { dg-warning "division by zero" } */
+}

Marek


Re: [C++ Patch] PR 58980

2014-01-22 Thread Jason Merrill
Yep, that's along the lines I was thinking of. But again, prev_scope is 
irrelevant here, so the new code shouldn't mention it at all.

 Original Message 
 From: Paolo Carlini 
 Sent: Wed, Jan 22, 2014 03:34 PM
 To: Jason Merrill ; gcc-patches@gcc.gnu.org
 CC: 
 Subject: Re: [C++ Patch] PR 58980

Hi,

On 01/22/2014 06:13 PM, Jason Merrill wrote:
> On 01/21/2014 09:55 AM, Jason Merrill wrote:
>> I think I would prefer to change the "child" assert to be
>> MAYBE_CLASS_TYPE_P rather than CLASS_TYPE_P.
> On second thought, no, I think we do want to specifically handle 
> TYPENAME_TYPE.  But I think we want a different error message; getting 
> a TYPENAME_TYPE here means that B has not been declared. The current 
> scope is irrelevant.  So we want to check for TYPENAME_TYPE before we 
> think about checking prev_scope.
Ok. In fact I entertained myself this kind of reasoning, a couple of 
days ago...

I tested the below, which uses "by hand" %Es instead of %qT for more 
concise error messages (consistent with the non-template case).

Thanks,
Paolo.




Re: [C PATCH] Don't leak C_MAYBE_CONST_EXPRs into GIMPLE (PR c/59891)

2014-01-22 Thread Joseph S. Myers
On Wed, 22 Jan 2014, Marek Polacek wrote:

> 2014-01-22  Marek Polacek  
> 
>   PR c/59891
> c/
>   * c-typeck.c (build_conditional_expr): Call c_fully_fold instead
>   of remove_c_maybe_const_expr on op1 and op2.
> testsuite/
>   * gcc.dg/torture/pr59891.c: New test.

OK.

-- 
Joseph S. Myers
jos...@codesourcery.com


[PATCH][tree-optimization/59597] Reinstate code to cancel some jump threads

2014-01-22 Thread Jeff Law


I had taken this code out as the original cases I'd encountered were 
better handled by reorganization the order in which we thread blocks.


However, as seen in 59597, there's still clearly cases where a jump 
threading path with a joiner block can have a threaded subpath. 
Threading the joiner block in this case is just wasteful (compile-time, 
memory consumption, code bloat) and as seen in 59597 can inhibit 
optimizations and result in significant performance degradations.


So this brings that code back with some improvements in the debugging 
dumps so we can see when it happens.  It should restore the performance 
of the sample code in 59597 back to where we were a while ago.


Bootstrapped & regression tested on x86_64-unknown-linux-gnu, confirmed 
the testcase's runtime is dramatically improved as well.  Installed on 
the trunk.


Jeff
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bcbb7dd..ea08f1f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2014-01-22  Jeff Law  
+
+   PR tree-optimization/59597
+   * tree-ssa-threadupdate.c (dump_jump_thread_path): Move to earlier
+   in file.  Accept new argument REGISTERING and use it to modify
+   dump output appropriately.
+   (register_jump_thread): Corresponding changes.
+   (mark_threaded_blocks): Reinstate code to cancel unprofitable
+   thread paths involving joiner blocks.  Add code to dump cancelled
+   jump threading paths.
+
 2014-01-21  Vladimir Makarov  
 
PR rtl-optimization/59896
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 447d3c7..b7d7ce3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-22  Jeff Law  
+
+   PR tree-optimization/59597
+   * gcc.dg/tree-ssa/pr59597.c: New test.
+
 2014-01-22  Bill Schmidt  
 
* gcc.dg/vmx/insert-vsx-be-order.c: New.
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr59597.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr59597.c
new file mode 100644
index 000..814d299
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr59597.c
@@ -0,0 +1,55 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -fdump-tree-vrp1-details" } */
+
+typedef unsigned short u16;
+typedef unsigned char u8;
+typedef unsigned int u32;
+#define NNN 10
+
+u32 f[NNN], t[NNN];
+
+u16 Calc_crc8(u8 data, u16 crc )
+{
+  u8 i=0,x16=0,carry=0;
+  for (i = 0; i < 8; i++)
+{
+  x16 = (u8)((data & 1) ^ ((u8)crc & 1));
+  data >>= 1;
+ 
+  if (x16 == 1)
+   {
+ crc ^= 0x4002;
+ carry = 1;
+   }
+  else
+   carry = 0;
+  crc >>= 1;
+  if (carry)
+   crc |= 0x8000;
+  else
+   crc &= 0x7fff;
+}
+  return crc;
+}
+int main (int argc, char argv[])
+{
+  int i, j; u16 crc;
+  for (j = 0; j < 1000; j++)
+{
+  for (i = 0; i < NNN; i++)
+   {
+ f[i] = random(i);
+ t[i] = random(NNN - i - 1);
+   }
+  for (i=0; i
   static inline int equal (const value_type *, const compare_type *);
 };
 
+/* Dump a jump threading path, including annotations about each
+   edge in the path.  */
+
+static void
+dump_jump_thread_path (FILE *dump_file, vec path,
+  bool registering)
+{
+  fprintf (dump_file,
+  "  %s jump thread: (%d, %d) incoming edge; ",
+  (registering ? "Registering" : "Cancelling"),
+  path[0]->e->src->index, path[0]->e->dest->index);
+
+  for (unsigned int i = 1; i < path.length (); i++)
+{
+  /* We can get paths with a NULL edge when the final destination
+of a jump thread turns out to be a constant address.  We dump
+those paths when debugging, so we have to be prepared for that
+possibility here.  */
+  if (path[i]->e == NULL)
+   continue;
+
+  if (path[i]->type == EDGE_COPY_SRC_JOINER_BLOCK)
+   fprintf (dump_file, " (%d, %d) joiner; ",
+path[i]->e->src->index, path[i]->e->dest->index);
+  if (path[i]->type == EDGE_COPY_SRC_BLOCK)
+   fprintf (dump_file, " (%d, %d) normal;",
+path[i]->e->src->index, path[i]->e->dest->index);
+  if (path[i]->type == EDGE_NO_COPY_SRC_BLOCK)
+   fprintf (dump_file, " (%d, %d) nocopy;",
+path[i]->e->src->index, path[i]->e->dest->index);
+}
+  fputc ('\n', dump_file);
+}
+
 /* Simple hashing function.  For any given incoming edge E, we're going
to be most concerned with the final destination of its jump thread
path.  So hash on the block index of the final edge in the path.  */
@@ -1394,16 +1428,61 @@ mark_threaded_blocks (bitmap threaded_blocks)
   edge e;
   edge_iterator ei;
 
-  /* Move the jump threading requests from PATHS to each edge
- which starts a jump thread path.  */
+  /* It is possible to have jump threads in which one is a subpath
+ of the other.  ie, (A, B), (B, C), (C, D) where B is a joiner
+ block and (B, C), (C, D) where no joiner block exists.
+
+ When this occurs ignore the jump thre

Re: [C++ Patch] PR 58980

2014-01-22 Thread Paolo Carlini

On 01/22/2014 10:10 PM, Jason Merrill wrote:

Yep, that's along the lines I was thinking of. But again, prev_scope is 
irrelevant here, so the new code shouldn't mention it at all.
Well, in practice I have to mention it in the error_at itself. Otherwise 
I'm finishing testing the below.


Paolo.

//
Index: cp/parser.c
===
--- cp/parser.c (revision 206933)
+++ cp/parser.c (working copy)
@@ -15469,9 +15469,17 @@ cp_parser_enum_specifier (cp_parser* parser)
error_at (type_start_token->location, "cannot add an enumerator "
  "list to a template instantiation");
 
+ if (TREE_CODE (nested_name_specifier) == TYPENAME_TYPE)
+   {
+ error_at (type_start_token->location,
+   "%<%E::%E%> has not been declared",
+   prev_scope, nested_name_specifier);
+ type = error_mark_node;
+   }
  /* If that scope does not contain the scope in which the
 class was originally declared, the program is invalid.  */
- if (prev_scope && !is_ancestor (prev_scope, nested_name_specifier))
+ else if (prev_scope && !is_ancestor (prev_scope,
+  nested_name_specifier))
{
  if (at_namespace_scope_p ())
error_at (type_start_token->location,
@@ -15480,7 +15488,8 @@ cp_parser_enum_specifier (cp_parser* parser)
  type, prev_scope, nested_name_specifier);
  else
error_at (type_start_token->location,
- "declaration of %qD in %qD which does not enclose 
%qD",
+ "declaration of %qD in %qD which does not "
+ "enclose %qD",
  type, prev_scope, nested_name_specifier);
  type = error_mark_node;
}
Index: testsuite/g++.dg/parse/enum11.C
===
--- testsuite/g++.dg/parse/enum11.C (revision 0)
+++ testsuite/g++.dg/parse/enum11.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/58980
+
+template struct A
+{ 
+  enum A::B::C {};   // { dg-error "has not been declared" }
+};


Re: [PATCH] Fix up ix86_avoid_lea_for_addr (PR target/59880)

2014-01-22 Thread H.J. Lu
On Mon, Jan 20, 2014 at 1:11 AM, Uros Bizjak  wrote:
> On Mon, Jan 20, 2014 at 9:38 AM, Jakub Jelinek  wrote:
>
>> As mentioned in the PR or even in the comment below, ix86_decompose_address
>> sometimes sets parts.base to some REG and parts.disp to const0_rtx, even
>> when the operands aren't of a lea insn, but normal or zero extending mov.
>>
>> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
>> trunk?
>>
>> 2014-01-20  Jakub Jelinek  
>>
>> PR target/59880
>> * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false
>> if operands[1] is a REG or ZERO_EXTEND of a REG.
>>
>> * gcc.target/i386/pr59880.c: New test.
>
>> --- gcc/config/i386/i386.c.jj   2014-01-19 12:18:49.0 +0100
>> +++ gcc/config/i386/i386.c  2014-01-19 19:02:34.078168289 +0100
>> @@ -18159,8 +18159,19 @@ ix86_avoid_lea_for_addr (rtx insn, rtx o
>>if (!TARGET_AVOID_LEA_FOR_ADDR || optimize_function_for_size_p (cfun))
>>  return false;
>>
>> +  /* The "at least two components" test below might not catch simple
>> + *mov[sd]i_internal or *zero_extendsidi2 insns if parts.base is
>> + non-NULL and parts.disp is const0_rtx as the only components in
>> + the address, e.g. if the register is %rbp or %r13.  As this
>> + test is much cheaper and moves or zero extensions are the common
>> + case, do this check first.  */
>> +  if (REG_P (operands[1])
>> +  || (GET_CODE (operands[1]) == ZERO_EXTEND
>> + && REG_P (XEXP (operands[1], 0
>> +return false;
>> +
>>/* Check it is correct to split here.  */
>> -  if (!ix86_ok_to_clobber_flags(insn))
>> +  if (!ix86_ok_to_clobber_flags (insn))
>>  return false;
>>
>>ok = ix86_decompose_address (operands[1], &parts);
>> --- gcc/testsuite/gcc.target/i386/pr59880.c.jj  2014-01-19 
>> 19:24:44.094382629 +0100
>> +++ gcc/testsuite/gcc.target/i386/pr59880.c 2014-01-19 
>> 19:25:30.0 +0100
>> @@ -0,0 +1,14 @@
>> +/* PR target/59880 */
>> +/* { dg-do compile { target { ! ia32 } } } */
>> +/* { dg-options "-O2 -mtune=silvermont" } */
>> +
>> +register unsigned int r13 __asm ("r13");
>> +unsigned long long
>> +foo (void)
>> +{
>> +  return r13;
>> +}
>> +
>> +/* Ensure we don't emit a useless zero-extension after another
>> +   zero-extension.  */
>> +/* { dg-final { scan-assembler-not "%eax, %eax" } } */
>>
>> Jakub
>
> This is OK for mainline, I will take care for a backport (together
> with 59379) to other release branches.
>

I backported gcc.target/i386/pr59880.c to 4.8 branch by
replacing -mtune=silvermont with -mtune=slm.

Thanks.

-- 
H.J.
--
Index: ChangeLog
===
--- ChangeLog (revision 206941)
+++ ChangeLog (working copy)
@@ -1,3 +1,11 @@
+2014-01-22  H.J. Lu  
+
+ Backport from mainline
+ 2014-01-20  Jakub Jelinek  
+
+ PR target/59880
+ * gcc.target/i386/pr59880.c: New test.
+
 2014-01-21  Jakub Jelinek  

  PR middle-end/59860
Index: gcc.target/i386/pr59880.c
===
--- gcc.target/i386/pr59880.c (revision 0)
+++ gcc.target/i386/pr59880.c (working copy)
@@ -0,0 +1,14 @@
+/* PR target/59880 */
+/* { dg-do compile { target { ! ia32 } } } */
+/* { dg-options "-O2 -mtune=slm" } */
+
+register unsigned int r13 __asm ("r13");
+unsigned long long
+foo (void)
+{
+  return r13;
+}
+
+/* Ensure we don't emit a useless zero-extension after another
+   zero-extension.  */
+/* { dg-final { scan-assembler-not "%eax, %eax" } } */


Re: [Patch, fortran] PR59414 [4.8/4.9 Regression] [OOP] ICE in in gfc_conv_expr_descriptor on ALLOCATE inside SELECT TYPE

2014-01-22 Thread Janus Weil
Hi Paul,

> This is a straightforward patch that is completely described in the
> ChangeLog entry. I am surprised that this could be a 4.8 regression
> since, as far as I am aware, SELECT_TYPE was not capable of handling
> array selectors before... Nonetheless, it flagged it up for me :-)

well, actually the selector in the test case is not an array. And
polymorphic arrays as such have been supported since 4.7.


> Bootstrapped and regtested on FC17/x86_64 - OK for trunk and, after a
> decent delay, 4.8?

Yes, looks good to me. Thanks for the patch!


> PS I know of at least one other place where this manoeuvre had to be
> done.  If I find a third, I will turn it into a function in class.c.
> It might be worth doing anyway?

I tend to agree. Up to you ...

Cheers,
Janus



> 2014-01-20  Paul Thomas  
>
> PR fortran/59414
> * trans-stmt.c (gfc_trans_allocate): Before the pointer
> assignment to transfer the source _vptr to a class allocate
> expression, the final class reference should be exposed. The
> tail that includes the _data and array references is stored.
> This reduced expression is transferred to 'lhs' and the _vptr
> added. Then the tail is restored to the allocate expression.
>
> 2014-01-20  Paul Thomas  
>
> PR fortran/59414
> * gfortran.dg/allocate_class_3.f90 : New test


[GOOGLE] Builtins handling in IVOPT

2014-01-22 Thread Wei Mi
This patch handles the mem access builtins in ivopt. The original
problem described here:
http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02648.html

Bootstrapped and passed regression test. Performance test ok for
plain, fdo and lipo. Ok for google 4.8 branch?

Thanks,
Wei.

--- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/expr.c
2013-12-21 21:16:11.006695060 -0800
+++ gcc/expr.c  2013-12-09 11:16:22.698063077 -0800
@@ -7537,7 +7537,21 @@
  tem = fold_build_pointer_plus (tem, TREE_OPERAND (exp, 1));
return expand_expr (tem, target, tmode, modifier);
   }
+case TARGET_MEM_REF:
+  {
+   struct mem_address addr;
+   int old_cse_not_expected;
+   addr_space_t as
+ = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0;

+   get_address_description (exp, &addr);
+   result = addr_for_mem_ref (&addr, as, true);
+   old_cse_not_expected = cse_not_expected;
+   cse_not_expected = 1;
+   result = memory_address_addr_space (tmode, result, as);
+   cse_not_expected = old_cse_not_expected;
+   return result;
+  }
 case CONST_DECL:
   /* Expand the initializer like constants above.  */
   result = XEXP (expand_expr_constant (DECL_INITIAL (exp),
@@ -9579,10 +9593,14 @@
struct mem_address addr;
enum insn_code icode;
unsigned int align;
+   int old_cse_not_expected;

get_address_description (exp, &addr);
op0 = addr_for_mem_ref (&addr, as, true);
+   old_cse_not_expected = cse_not_expected;
+   cse_not_expected = 1;
op0 = memory_address_addr_space (mode, op0, as);
+   cse_not_expected = old_cse_not_expected;
temp = gen_rtx_MEM (mode, op0);
set_mem_attributes (temp, exp, 0);
set_mem_addr_space (temp, as);
--- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/target.def
2013-12-21 21:16:10.926694446 -0800
+++ gcc/target.def  2013-12-09 10:46:07.794472365 -0800
@@ -1119,6 +1119,14 @@
 #undef HOOK_PREFIX
 #define HOOK_PREFIX "TARGET_"

+DEFHOOK
+(builtin_has_mem_ref_p,
+ "This hook return whether the @var{i}th param of the @var{builtin_function}\n\
+is a memory reference. If @var{i} is -1, return whether the
@var{builtin_function}\n\
+contains any memory reference type param.",
+ bool, (int builtin_function, int i),
+ default_builtin_has_mem_ref_p)
+
 /* Allow target specific overriding of option settings after options have
   been changed by an attribute or pragma or when it is reset at the
   end of the code affected by an attribute or pragma.  */
--- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/gimple.c
  2013-12-21 21:16:11.066695519 -0800
+++ gcc/gimple.c2013-12-09 10:50:09.096289179 -0800
@@ -2574,7 +2574,8 @@
 is_gimple_addressable (tree t)
 {
   return (is_gimple_id (t) || handled_component_p (t)
- || TREE_CODE (t) == MEM_REF);
+ || TREE_CODE (t) == MEM_REF
+ || TREE_CODE (t) == TARGET_MEM_REF);
 }

 /* Return true if T is a valid gimple constant.  */
@@ -2625,7 +2626,8 @@
   op = TREE_OPERAND (op, 0);
 }

-  if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF)
+  if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF
+  || TREE_CODE (op) == TARGET_MEM_REF)
 return true;

   switch (TREE_CODE (op))
--- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/targhooks.c
   2013-12-21 21:16:10.926694446 -0800
+++ gcc/targhooks.c 2013-12-09 10:45:50.154339207 -0800
@@ -543,6 +543,13 @@
 }

 bool
+default_builtin_has_mem_ref_p (int built_in_function ATTRIBUTE_UNUSED,
+  int i ATTRIBUTE_UNUSED)
+{
+  return false;
+}
+
+bool
 hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false (
cumulative_args_t ca ATTRIBUTE_UNUSED,
enum machine_mode mode ATTRIBUTE_UNUSED,
--- 
/usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/tree-ssa-loop-ivopts.c
2014-01-22 11:57:10.420073494 -0800
+++ gcc/tree-ssa-loop-ivopts.c  2014-01-22 14:00:14.177908568 -0800
@@ -96,7 +96,7 @@
 /* The infinite cost.  */
 #define INFTY 1000

-#define AVG_LOOP_NITER(LOOP) 5
+#define AVG_LOOP_NITER(LOOP) 50

 /* Returns the expected number of loop iterations for LOOP.
The average trip count is computed from profile data if it
@@ -1785,7 +1785,8 @@

   /* Check that the base expression is addressable.  This needs
 to be done after substituting bases of IVs into it.  */
-  if (may_be_nonaddressable_p (base))
+  if (may_be_nonaddressable_p (base)
+ && REFERENCE_CLASS_P (base))
goto fail;

   /* Moreover, on strict alignment platforms, check that it is
@@ -1793,7 +1794,11 @@
   if (STRICT_ALIGNMENT && may_be_unaligned_p (base, step))
goto fail;

-  base = build_fold_addr_expr (base);
+  /* If base is of reference class, build its addr expr here. If
+base is already an address, then don't need to build addr
+expr.  */
+  if (REFERENCE_CLA

Re: [C++ patch] PR 59482

2014-01-22 Thread Ville Voutilainen
On 22 January 2014 19:39, Paolo Carlini  wrote:
> On 01/21/2014 04:24 PM, Jason Merrill wrote:
>>
>> OK, thanks.
>
> I don't think Ville has Write After Approval, thus I'm going to commit this
> on his behalf.


Oh, I was expecting Jason would do that. Note that Marek Polacek pointed
out two formatting issues:
- comments should have full stop and two spaces at the end
- also two spaces before  in the ChangeLog


Re: [PATCH, rs6000] Honor -fno-ira-loop-pressure

2014-01-22 Thread David Edelsohn
On Wed, Jan 22, 2014 at 1:51 PM, Pat Haugen  wrote:
> Discovered that we blindly set flag_ira_loop_pressure at -O3+, regardless of
> whether command line option was given. Following fixes that.
>
> Bootstrap/regtest with no new regressions, ok for trunk?
>
> -Pat
>
>
> 2014-01-22  Pat Haugen  
>
> * config/rs6000/rs6000.c (rs6000_option_override_internal): Don't
> force flag_ira_loop_pressure if set via command line.

Okay.

Thanks, David


Re: [GOOGLE] Restrict the count_scale to be no larger than 100%

2014-01-22 Thread Dehao Chen
Unfortunately, copy_cfg_body is actually using basic block count
instead of cgraph edge count. Thus even fixing up the call graph does
not solve the problem. The 2nd chunk of the patch (cgraphclones.c) is
actually not necessary. We only need the first part (tree-inline.c).

Thanks,
Dehao

On Fri, Jan 17, 2014 at 3:12 PM, Xinliang David Li  wrote:
> Can callgraph node count be fixed up properly instead of doing
> individual fixups like this?
>
> David
>
> On Fri, Jan 17, 2014 at 2:38 PM, Dehao Chen  wrote:
>> In AutoFDO, sometime edge count might be propagated to be too large
>> due to bad debug info. In this cases, we need to make sure the count
>> scale is no larger than 100% otherwise it'll make real hot code cold.
>>
>> Bootstrapped and passed regression test. Performance test on-going.
>>
>> OK for google-4_8 if performance test is ok?
>>
>> Thanks,
>> Dehao
>>
>> Index: gcc/tree-inline.c
>> ===
>> --- gcc/tree-inline.c (revision 206721)
>> +++ gcc/tree-inline.c (working copy)
>> @@ -2262,6 +2262,9 @@ copy_cfg_body (copy_body_data * id, gcov_type coun
>>else
>>  count_scale = REG_BR_PROB_BASE;
>>
>> +  if (flag_auto_profile && count_scale > REG_BR_PROB_BASE)
>> +count_scale = REG_BR_PROB_BASE;
>> +
>>/* Register specific tree functions.  */
>>gimple_register_cfg_hooks ();
>>
>> Index: gcc/cgraphclones.c
>> ===
>> --- gcc/cgraphclones.c (revision 206721)
>> +++ gcc/cgraphclones.c (working copy)
>> @@ -216,7 +216,10 @@ cgraph_clone_node (struct cgraph_node *n, tree dec
>>   count, we will not update the original callee because it may
>>   mistakenly mark some hot function as cold.  */
>>if (flag_auto_profile && count >= n->count)
>> -update_original = false;
>> +{
>> +  update_original = false;
>> +  new_node->count = n->count;
>> +}
>>if (update_original)
>>  {
>>n->count -= count;


Re: [GOOGLE] Restrict the count_scale to be no larger than 100%

2014-01-22 Thread Xinliang David Li
ok.

David

On Wed, Jan 22, 2014 at 3:23 PM, Dehao Chen  wrote:
> Unfortunately, copy_cfg_body is actually using basic block count
> instead of cgraph edge count. Thus even fixing up the call graph does
> not solve the problem. The 2nd chunk of the patch (cgraphclones.c) is
> actually not necessary. We only need the first part (tree-inline.c).
>
> Thanks,
> Dehao
>
> On Fri, Jan 17, 2014 at 3:12 PM, Xinliang David Li  wrote:
>> Can callgraph node count be fixed up properly instead of doing
>> individual fixups like this?
>>
>> David
>>
>> On Fri, Jan 17, 2014 at 2:38 PM, Dehao Chen  wrote:
>>> In AutoFDO, sometime edge count might be propagated to be too large
>>> due to bad debug info. In this cases, we need to make sure the count
>>> scale is no larger than 100% otherwise it'll make real hot code cold.
>>>
>>> Bootstrapped and passed regression test. Performance test on-going.
>>>
>>> OK for google-4_8 if performance test is ok?
>>>
>>> Thanks,
>>> Dehao
>>>
>>> Index: gcc/tree-inline.c
>>> ===
>>> --- gcc/tree-inline.c (revision 206721)
>>> +++ gcc/tree-inline.c (working copy)
>>> @@ -2262,6 +2262,9 @@ copy_cfg_body (copy_body_data * id, gcov_type coun
>>>else
>>>  count_scale = REG_BR_PROB_BASE;
>>>
>>> +  if (flag_auto_profile && count_scale > REG_BR_PROB_BASE)
>>> +count_scale = REG_BR_PROB_BASE;
>>> +
>>>/* Register specific tree functions.  */
>>>gimple_register_cfg_hooks ();
>>>
>>> Index: gcc/cgraphclones.c
>>> ===
>>> --- gcc/cgraphclones.c (revision 206721)
>>> +++ gcc/cgraphclones.c (working copy)
>>> @@ -216,7 +216,10 @@ cgraph_clone_node (struct cgraph_node *n, tree dec
>>>   count, we will not update the original callee because it may
>>>   mistakenly mark some hot function as cold.  */
>>>if (flag_auto_profile && count >= n->count)
>>> -update_original = false;
>>> +{
>>> +  update_original = false;
>>> +  new_node->count = n->count;
>>> +}
>>>if (update_original)
>>>  {
>>>n->count -= count;


Re: [patch] fix libstdc++/58764

2014-01-22 Thread Jonathan Wakely
Follow-up patch to make the exception specs on the default constructors 
conditional, depending on the allocator.

Tested x86_64-linux, committed to trunk.



commit 67b0d66cc6a1af5f697543d24ad7578d81c5eb98
Author: Jonathan Wakely 
Date:   Wed Jan 22 23:07:23 2014 +

PR libstdc++/58764 (again)
* include/bits/stl_list.h (list): Make default constructor's exception
specification conditional.
* include/bits/stl_vector.h (vector): Likewise.
* testsuite/util/testsuite_allocator.h (SimpleAllocator): Add noexcept
to default constructor.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.

diff --git a/libstdc++-v3/include/bits/stl_list.h 
b/libstdc++-v3/include/bits/stl_list.h
index 19bb189..e014fbc 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -530,7 +530,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   /**
*  @brief  Creates a %list with no elements.
*/
-  list() _GLIBCXX_NOEXCEPT
+  list()
+#if __cplusplus >= 201103L
+  noexcept(is_nothrow_default_constructible<_Node_alloc_type>::value)
+#endif
   : _Base() { }
 
   /**
diff --git a/libstdc++-v3/include/bits/stl_vector.h 
b/libstdc++-v3/include/bits/stl_vector.h
index 14284aa..f482957 100644
--- a/libstdc++-v3/include/bits/stl_vector.h
+++ b/libstdc++-v3/include/bits/stl_vector.h
@@ -246,7 +246,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   /**
*  @brief  Creates a %vector with no elements.
*/
-  vector() _GLIBCXX_NOEXCEPT : _Base() { }
+  vector()
+#if __cplusplus >= 201103L
+  noexcept(is_nothrow_default_constructible<_Alloc>::value)
+#endif
+  : _Base() { }
 
   /**
*  @brief  Creates a %vector with no elements.
diff --git 
a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc 
b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
index fed7829..7c29a2d 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc
@@ -18,7 +18,7 @@
 // .
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1653 }
+// { dg-error "no matching" "" { target *-*-* } 1656 }
 
 #include 
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
 
b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
index f5eae4f..382d985 100644
--- 
a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc
@@ -18,7 +18,7 @@
 // .
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1605 }
+// { dg-error "no matching" "" { target *-*-* } 1608 }
 
 #include 
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
 
b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
index e0fbe97..14585af 100644
--- 
a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
+++ 
b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc
@@ -18,7 +18,7 @@
 // .
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1605 }
+// { dg-error "no matching" "" { target *-*-* } 1608 }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc 
b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
index 3904624..a9f9f30 100644
--- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc
@@ -18,7 +18,7 @@
 // .
 
 // { dg-do compile }
-// { dg-error "no matching" "" { target *-*-* } 1605 }
+// { dg-error "no matching" "" { target *-*-* } 1608 }
 
 #include 
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc 
b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.c

Re: [GOOGLE] Builtins handling in IVOPT

2014-01-22 Thread Xinliang David Li
On Wed, Jan 22, 2014 at 2:23 PM, Wei Mi  wrote:
> This patch handles the mem access builtins in ivopt. The original
> problem described here:
> http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02648.html
>
> Bootstrapped and passed regression test. Performance test ok for
> plain, fdo and lipo. Ok for google 4.8 branch?
>
> Thanks,
> Wei.
>
> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/expr.c
> 2013-12-21 21:16:11.006695060 -0800
> +++ gcc/expr.c  2013-12-09 11:16:22.698063077 -0800
> @@ -7537,7 +7537,21 @@
>   tem = fold_build_pointer_plus (tem, TREE_OPERAND (exp, 1));
> return expand_expr (tem, target, tmode, modifier);
>}
> +case TARGET_MEM_REF:
> +  {

Add more comments here to describe the new code.

> +   struct mem_address addr;
> +   int old_cse_not_expected;
> +   addr_space_t as
> + = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0;
>
> +   get_address_description (exp, &addr);
> +   result = addr_for_mem_ref (&addr, as, true);
> +   old_cse_not_expected = cse_not_expected;
> +   cse_not_expected = 1;
> +   result = memory_address_addr_space (tmode, result, as);
> +   cse_not_expected = old_cse_not_expected;
> +   return result;
> +  }
>  case CONST_DECL:
>/* Expand the initializer like constants above.  */
>result = XEXP (expand_expr_constant (DECL_INITIAL (exp),
> @@ -9579,10 +9593,14 @@
> struct mem_address addr;
> enum insn_code icode;
> unsigned int align;
> +   int old_cse_not_expected;
>
> get_address_description (exp, &addr);
> op0 = addr_for_mem_ref (&addr, as, true);
> +   old_cse_not_expected = cse_not_expected;

Comments on the change.

> +   cse_not_expected = 1;
> op0 = memory_address_addr_space (mode, op0, as);
> +   cse_not_expected = old_cse_not_expected;
> temp = gen_rtx_MEM (mode, op0);
> set_mem_attributes (temp, exp, 0);
> set_mem_addr_space (temp, as);
> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/target.def
> 2013-12-21 21:16:10.926694446 -0800
> +++ gcc/target.def  2013-12-09 10:46:07.794472365 -0800
> @@ -1119,6 +1119,14 @@
>  #undef HOOK_PREFIX
>  #define HOOK_PREFIX "TARGET_"
>
> +DEFHOOK
> +(builtin_has_mem_ref_p,
> + "This hook return whether the @var{i}th param of the 
> @var{builtin_function}\n\
> +is a memory reference. If @var{i} is -1, return whether the
> @var{builtin_function}\n\
> +contains any memory reference type param.",
> + bool, (int builtin_function, int i),
> + default_builtin_has_mem_ref_p)
> +
>  /* Allow target specific overriding of option settings after options have
>been changed by an attribute or pragma or when it is reset at the
>end of the code affected by an attribute or pragma.  */
> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/gimple.c
>   2013-12-21 21:16:11.066695519 -0800
> +++ gcc/gimple.c2013-12-09 10:50:09.096289179 -0800
> @@ -2574,7 +2574,8 @@
>  is_gimple_addressable (tree t)
>  {
>return (is_gimple_id (t) || handled_component_p (t)
> - || TREE_CODE (t) == MEM_REF);
> + || TREE_CODE (t) == MEM_REF
> + || TREE_CODE (t) == TARGET_MEM_REF);
>  }
>
>  /* Return true if T is a valid gimple constant.  */
> @@ -2625,7 +2626,8 @@
>op = TREE_OPERAND (op, 0);
>  }
>
> -  if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF)
> +  if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF
> +  || TREE_CODE (op) == TARGET_MEM_REF)
>  return true;
>
>switch (TREE_CODE (op))
> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/targhooks.c
>2013-12-21 21:16:10.926694446 -0800
> +++ gcc/targhooks.c 2013-12-09 10:45:50.154339207 -0800
> @@ -543,6 +543,13 @@
>  }
>
>  bool
> +default_builtin_has_mem_ref_p (int built_in_function ATTRIBUTE_UNUSED,
> +  int i ATTRIBUTE_UNUSED)
> +{
> +  return false;
> +}
> +
> +bool
>  hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false (
> cumulative_args_t ca ATTRIBUTE_UNUSED,
> enum machine_mode mode ATTRIBUTE_UNUSED,
> --- 
> /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/tree-ssa-loop-ivopts.c
> 2014-01-22 11:57:10.420073494 -0800
> +++ gcc/tree-ssa-loop-ivopts.c  2014-01-22 14:00:14.177908568 -0800
> @@ -96,7 +96,7 @@
>  /* The infinite cost.  */
>  #define INFTY 1000
>
> -#define AVG_LOOP_NITER(LOOP) 5
> +#define AVG_LOOP_NITER(LOOP) 50

Need a parameter to control. This should also go in as an independent patch.


David

>
>  /* Returns the expected number of loop iterations for LOOP.
> The average trip count is computed from profile data if it
> @@ -1785,7 +1785,8 @@
>
>/* Check that the base expression is addressable.  This needs
>  to be done after substituting bases of IVs into it.  */
> -  if (may_be_nonaddressable_p (base))
> +  if (may_be_nonaddressable_p (base)

Re: [PATCH] Fix up ix86_avoid_lea_for_addr (PR target/59880)

2014-01-22 Thread H.J. Lu
On Wed, Jan 22, 2014 at 2:02 PM, H.J. Lu  wrote:
> On Mon, Jan 20, 2014 at 1:11 AM, Uros Bizjak  wrote:
>> On Mon, Jan 20, 2014 at 9:38 AM, Jakub Jelinek  wrote:
>>
>>> As mentioned in the PR or even in the comment below, ix86_decompose_address
>>> sometimes sets parts.base to some REG and parts.disp to const0_rtx, even
>>> when the operands aren't of a lea insn, but normal or zero extending mov.
>>>
>>> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
>>> trunk?
>>>
>>> 2014-01-20  Jakub Jelinek  
>>>
>>> PR target/59880
>>> * config/i386/i386.c (ix86_avoid_lea_for_addr): Return false
>>> if operands[1] is a REG or ZERO_EXTEND of a REG.
>>>
>>> * gcc.target/i386/pr59880.c: New test.
>>
>>> --- gcc/config/i386/i386.c.jj   2014-01-19 12:18:49.0 +0100
>>> +++ gcc/config/i386/i386.c  2014-01-19 19:02:34.078168289 +0100
>>> @@ -18159,8 +18159,19 @@ ix86_avoid_lea_for_addr (rtx insn, rtx o
>>>if (!TARGET_AVOID_LEA_FOR_ADDR || optimize_function_for_size_p (cfun))
>>>  return false;
>>>
>>> +  /* The "at least two components" test below might not catch simple
>>> + *mov[sd]i_internal or *zero_extendsidi2 insns if parts.base is
>>> + non-NULL and parts.disp is const0_rtx as the only components in
>>> + the address, e.g. if the register is %rbp or %r13.  As this
>>> + test is much cheaper and moves or zero extensions are the common
>>> + case, do this check first.  */
>>> +  if (REG_P (operands[1])
>>> +  || (GET_CODE (operands[1]) == ZERO_EXTEND
>>> + && REG_P (XEXP (operands[1], 0
>>> +return false;
>>> +
>>>/* Check it is correct to split here.  */
>>> -  if (!ix86_ok_to_clobber_flags(insn))
>>> +  if (!ix86_ok_to_clobber_flags (insn))
>>>  return false;
>>>
>>>ok = ix86_decompose_address (operands[1], &parts);
>>> --- gcc/testsuite/gcc.target/i386/pr59880.c.jj  2014-01-19 
>>> 19:24:44.094382629 +0100
>>> +++ gcc/testsuite/gcc.target/i386/pr59880.c 2014-01-19 
>>> 19:25:30.0 +0100
>>> @@ -0,0 +1,14 @@
>>> +/* PR target/59880 */
>>> +/* { dg-do compile { target { ! ia32 } } } */
>>> +/* { dg-options "-O2 -mtune=silvermont" } */
>>> +
>>> +register unsigned int r13 __asm ("r13");
>>> +unsigned long long
>>> +foo (void)
>>> +{
>>> +  return r13;
>>> +}
>>> +
>>> +/* Ensure we don't emit a useless zero-extension after another
>>> +   zero-extension.  */
>>> +/* { dg-final { scan-assembler-not "%eax, %eax" } } */
>>>
>>> Jakub
>>
>> This is OK for mainline, I will take care for a backport (together
>> with 59379) to other release branches.
>>
>
> I backported gcc.target/i386/pr59880.c to 4.8 branch by
> replacing -mtune=silvermont with -mtune=slm.
>
> Thanks.
>
> --
> H.J.
> --
> Index: ChangeLog
> ===
> --- ChangeLog (revision 206941)
> +++ ChangeLog (working copy)
> @@ -1,3 +1,11 @@
> +2014-01-22  H.J. Lu  
> +
> + Backport from mainline
> + 2014-01-20  Jakub Jelinek  
> +
> + PR target/59880
> + * gcc.target/i386/pr59880.c: New test.
> +
>  2014-01-21  Jakub Jelinek  
>
>   PR middle-end/59860
> Index: gcc.target/i386/pr59880.c
> ===
> --- gcc.target/i386/pr59880.c (revision 0)
> +++ gcc.target/i386/pr59880.c (working copy)
> @@ -0,0 +1,14 @@
> +/* PR target/59880 */
> +/* { dg-do compile { target { ! ia32 } } } */
> +/* { dg-options "-O2 -mtune=slm" } */
> +
> +register unsigned int r13 __asm ("r13");
> +unsigned long long
> +foo (void)
> +{
> +  return r13;
> +}
> +
> +/* Ensure we don't emit a useless zero-extension after another
> +   zero-extension.  */
> +/* { dg-final { scan-assembler-not "%eax, %eax" } } */

I tested it on the wrong branch.  -mtune=slm doesn't exist
on 4.8 branch.   I reverted.  Sorry for it.

-- 
H.J.


[PATCH] Set correct probability for ORDER/UNORDER jumps

2014-01-22 Thread Dehao Chen
During floating point comparison, compiler inserts conditional jumps
to check if the operand is NAN. These type of checks are normally
false. However, compiler sets the probability the same as the original
float-compare conditional jump. This patch sets the probability of
these conditional jumps as 1%.

Bootstrapped and passed regression test.

OK for trunk?

Thanks,
Dehao

gcc/ChangeLog:
2014-01-22  Dehao Chen  

* dojump.c (do_compare_rtx_and_jump): Sets correct probability for
compiler inserted conditional jumps for NAN float check.

Index: gcc/dojump.c
===
--- gcc/dojump.c (revision 206945)
+++ gcc/dojump.c (working copy)
@@ -1103,6 +1103,11 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rt

   else
 {
+  int first_prob = prob;
+  if (first_code == UNORDERED)
+ first_prob = REG_BR_PROB_BASE / 100;
+  else if (first_code == ORDERED)
+ first_prob = REG_BR_PROB_BASE - REG_BR_PROB_BASE / 100;
   if (and_them)
  {
   rtx dest_label;
@@ -1116,11 +1121,13 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rt
   else
 dest_label = if_false_label;
   do_compare_rtx_and_jump (op0, op1, first_code,
unsignedp, mode,
-   size, dest_label, NULL_RTX, prob);
+   size, dest_label, NULL_RTX,
+   first_prob);
  }
   else
 do_compare_rtx_and_jump (op0, op1, first_code, unsignedp, mode,
- size, NULL_RTX, if_true_label, prob);
+ size, NULL_RTX, if_true_label,
+ first_prob);
 }
  }


Re: Fix compute_reloc_for_constant

2014-01-22 Thread Jan Hubicka
> On 19 January 2014 03:12:56 Jan Hubicka  wrote:
> 
> >Hi,
> >while comparing LTO and non-LTO builds I noticed that with LTO we produce a 
> >lot
> >more vtables in datal.rel.ro rather than data.rel.ro.local
> >This is because of partitioning promoting more symbols global. For RTL we 
> >make
> >section decisions based on SYMBOL_REF_LOCAL_FLAG that is set based on
> >decl_binds_local_p.  For variables we use TREE_PUBLIC check that is overly
> >conservative.
> 
> Honza,
> 
> Would you (or anybody else for that matter) mind looking into
> PR32219 while there?
> See http://gcc.gnu.org/ml/gcc-patches/2010-03/msg00665.html and
> other discussion of that bug on the ML last year.

This patch is IMO wrong for the reasons Jakub describe (the hidden symbol
must bind local).  Optimizer miss the fact that the symbol is weak and thus
it may bind to NULL.  
I was looking into the folder and the logic there is indeed sloppy (have 
somewhere
WIP patch to rewrite it), see DECL_WEAK tests in fold-const.c

Honza
> 
> TIA,
> Bernhard
> >
> >Bootstrapped/regtested x86_64-linux, OK?
> > * varasm.c (compute_reloc_for_constant): Use targetm.binds_local_p
> > instead of TREE_PUBLIC to determine if reference will be local
> > within given DSO or not.
> >Index: varasm.c
> >===
> >--- varasm.c (revision 206684)
> >+++ varasm.c (working copy)
> >@@ -4060,7 +4060,7 @@
> >   break;
> > }
> >
> >-  if (TREE_PUBLIC (tem))
> >+  if (!targetm.binds_local_p (tem))
> > reloc |= 2;
> >   else
> > reloc |= 1;
> 
> 
> 
> Sent with AquaMail for Android
> http://www.aqua-mail.com
> 


Re: Two build != host fixes

2014-01-22 Thread Alan Modra
I was hoping for a reply from someone who could OK the previous patches
submitted.  Admittedly, I didn't tick all the boxes (no changelog entry),
so here they are again.

The Makefile.in BUILD_CPPFLAGS change is for exactly the same reason
as my 2013-12-05 change.  When GMPINC points at an installed host gmp,
it results in picking up other host headers, which might be wrong for
the build machine.  We found this to be true even for very similar
build and host machines, in our case a powerpc64-linux build,
powerpc64le-linux host and target configuration, where differences in
glibc version between the build and host were enough to cause errors.

The configure.ac change is to fix a bug Bernd found when gmp is
in-tree but not installed.  In that case the recursive configure fails
due to system.h wanting to include gmp.h and not finding it:

/* Do not introduce a gmp.h dependency on the build system.  */
#ifndef GENERATOR_FILE
#include 
#endif

So, define GENERATOR_FILE for configure as we do when actually running
the build compiler.  The other changes are for consistency, but are
not strictly necessary.  I left them in this patch because they make
sense to me, and that's the way both Bernd and I tested this patch.

OK for mainline?

Bernd, if this isn't approved then I'll revert my previous change.
I believe I can do that without approval.

* Makefile.in (BUILD_CPPFLAGS): Do not use ALL_CPPFLAGS.
* configure.ac : Define
GENERATOR_FILE.  Comment.  Use CXX_FOR_BUILD, CXXFLAGS_FOR_BUILD
and LD_FOR_BUILD too.
* configure: Regenerate.

Index: gcc/Makefile.in
===
--- gcc/Makefile.in (revision 206915)
+++ gcc/Makefile.in (working copy)
@@ -761,7 +761,8 @@
 
 # Native linker and preprocessor flags.  For x-fragment overrides.
 BUILD_LDFLAGS=@BUILD_LDFLAGS@
-BUILD_CPPFLAGS=$(ALL_CPPFLAGS)
+BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
+   -I$(srcdir)/../include $(CPPINC)
 
 # Actual name to use when installing a native compiler.
 GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
Index: gcc/configure.ac
===
--- gcc/configure.ac(revision 206915)
+++ gcc/configure.ac(working copy)
@@ -1529,8 +1529,13 @@
/* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
*) realsrcdir=../${srcdir};;
esac
+   # Clearing GMPINC is necessary to prevent host headers being
+   # used by the build compiler.  Defining GENERATOR_FILE stops
+   # system.h from including gmp.h.
CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
-   LDFLAGS="${LDFLAGS_FOR_BUILD}" GMPINC="" \
+   CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
+   LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
+   GMPINC="" CPPFLAGS="${CPPFLAGS} -DGENERATOR_FILE" \
${realsrcdir}/configure \
--enable-languages=${enable_languages-all} \
--target=$target_alias --host=$build_alias --build=$build_alias


-- 
Alan Modra
Australia Development Lab, IBM


Re: PR 52125: Detecting which operands are used in an asm

2014-01-22 Thread Jeff Law

On 01/19/14 10:33, Richard Sandiford wrote:

The MIPS %hi and %lo relocation operators act as a pair on REL targets;
you need to see the partnering %lo in order to calculate the addend for
a %hi and detect carries properly.  The assembler therefore complains if
%hi is used without a corresponding %lo.

The MIPS backend tries to remove unmatched %his in mips_reorg.
The problem is that it can wrongly keep a %hi(foo) in cases like:

asm ("" : "=m" (foo));

where a LO_SUM MEM appears as an operand at the rtl level but where
%lo(foo) doesn't appear in the assembly code.

It's very hard without fully parsing an asm to know whether it will need
the LO_SUM or not.  E.g. the operand could appear in the asm string
but could be protected by an .if or only be used in a comment.  But it
should be safe to assume that the LO_SUM in operand N isn't needed if
%N or %N doesn't appear in the string, since AFAIK there's
no other way for the asm to know which register contains the high part.
Specifically, things like:

asm ("sw $0,foo" : "=m" (foo));

work fine either way, since the %hi is implicit in the SW macro.

I split out the routine to detect which operands are used since it
seemed like it might be more generally useful.

Tested on mips64-linux-gnu, where it fixes the gcc.dg/guality/pr36728-2.c
failures for -mabi=32.  OK for the target-independent bits?

Thanks,
Richard


gcc/
PR target/52125
* rtl.h (get_referenced_operands): Declare.
* recog.c (get_referenced_operands): New function.
* config/mips/mips.c (mips_reorg_process_insns): Check which asm
operands have been referenced when recording LO_SUM references.

gcc/testsuite/
PR target/52125
* gcc.dg/pr48774.c: Remove skip for mips_rel.
* gcc.target/mips/pr52125.c: New test.

Machine independent bits are fine with me.

Jeff



Re: Two build != host fixes

2014-01-22 Thread Jeff Law

On 01/22/14 20:46, Alan Modra wrote:

I was hoping for a reply from someone who could OK the previous patches
submitted.  Admittedly, I didn't tick all the boxes (no changelog entry),
so here they are again.
It's been in my stack of patches, others may be shying away from the 
insanity that is our build system.





The Makefile.in BUILD_CPPFLAGS change is for exactly the same reason
as my 2013-12-05 change.  When GMPINC points at an installed host gmp,
it results in picking up other host headers, which might be wrong for
the build machine.  We found this to be true even for very similar
build and host machines, in our case a powerpc64-linux build,
powerpc64le-linux host and target configuration, where differences in
glibc version between the build and host were enough to cause errors.

The configure.ac change is to fix a bug Bernd found when gmp is
in-tree but not installed.  In that case the recursive configure fails
due to system.h wanting to include gmp.h and not finding it:

/* Do not introduce a gmp.h dependency on the build system.  */
#ifndef GENERATOR_FILE
#include 
#endif

So, define GENERATOR_FILE for configure as we do when actually running
the build compiler.  The other changes are for consistency, but are
not strictly necessary.  I left them in this patch because they make
sense to me, and that's the way both Bernd and I tested this patch.

OK for mainline?

Bernd, if this isn't approved then I'll revert my previous change.
I believe I can do that without approval.

* Makefile.in (BUILD_CPPFLAGS): Do not use ALL_CPPFLAGS.
* configure.ac : Define
GENERATOR_FILE.  Comment.  Use CXX_FOR_BUILD, CXXFLAGS_FOR_BUILD
and LD_FOR_BUILD too.
* configure: Regenerate.

The configure.ac changes look fine to me.

Not sure about the Makefile.in changes, probably because I simply don't 
understand this mess anymore.  Is it the $INCLUDES or $CPPFLAGS from 
ALL_CPPFLAGS that causes the problem?  I'm guessing the latter since 
it's substituted via @CPPFLAGS@.


If so, shouldn't we use BUILD_CPPFLAGS=$INCLUDES $(CPPINC)?

Jeff


Re: Fix bootstrap with -mno-accumulate-outgoing-args

2014-01-22 Thread H.J. Lu
On Tue, Jan 21, 2014 at 3:55 PM, Jan Hubicka  wrote:
>> On 01/17/14 14:32, Jan Hubicka wrote:
>> >>* combine-stack-adj.c (combine_stack_adjustments_for_block): Remove
>> >>ARG_SIZE note when adjustment was eliminated.
>> >
>> >Ping...  This patch prevents me from switching the accumulate-args default
>> >for generic and I am waiting for that witht he inliner tunning, so there is
>> >quite a dependency chain.
>> This is fine.
>>
>> Can you add a testcase for this?
>
> It occurs during bootstrap compiling go, so I think we should have this 
> covered.
> I will try to construct some artificial testcase in C, but it seems a bit
> tricky.
>

Enable X86_TUNE_ACCUMULATE_OUTGOING_ARGS for generic
caused:

FAIL: gcc.dg/guality/pr54519-1.c  -O2  line 20 y == 25
FAIL: gcc.dg/guality/pr54519-1.c  -O2  line 20 z == 6
FAIL: gcc.dg/guality/pr54519-1.c  -O2  line 23 y == 117
FAIL: gcc.dg/guality/pr54519-1.c  -O2  line 23 z == 8
FAIL: gcc.dg/guality/pr54519-1.c  -O3 -fomit-frame-pointer  line 20 x == 36
FAIL: gcc.dg/guality/pr54519-1.c  -O3 -fomit-frame-pointer  line 20 y == 25
FAIL: gcc.dg/guality/pr54519-1.c  -O3 -fomit-frame-pointer  line 20 z == 6
FAIL: gcc.dg/guality/pr54519-1.c  -O3 -g  line 20 x == 36
FAIL: gcc.dg/guality/pr54519-1.c  -O3 -g  line 20 y == 25
FAIL: gcc.dg/guality/pr54519-1.c  -O3 -g  line 20 z == 6
FAIL: gcc.dg/guality/pr54519-3.c  -O2 -flto -fno-use-linker-plugin
-flto-partition=none  line 20 x == 36
FAIL: gcc.dg/guality/pr54519-3.c  -O2 -flto -fno-use-linker-plugin
-flto-partition=none  line 23 x == 98
FAIL: gcc.dg/guality/pr54519-3.c  -O2  line 20 x == 36
FAIL: gcc.dg/guality/pr54519-3.c  -O2  line 20 y == 25
FAIL: gcc.dg/guality/pr54519-3.c  -O2  line 20 z == 6
FAIL: gcc.dg/guality/pr54519-3.c  -O2  line 23 x == 98
FAIL: gcc.dg/guality/pr54519-3.c  -O2  line 23 y == 117
FAIL: gcc.dg/guality/pr54519-3.c  -O2  line 23 z == 8
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -fomit-frame-pointer  line 20 x == 36
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -fomit-frame-pointer  line 20 y == 25
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -fomit-frame-pointer  line 20 z == 6
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -fomit-frame-pointer  line 23 x == 98
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -fomit-frame-pointer  line 23 y == 117
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -fomit-frame-pointer  line 23 z == 8
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -g  line 20 x == 36
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -g  line 20 y == 25
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -g  line 20 z == 6
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -g  line 23 x == 98
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -g  line 23 y == 117
FAIL: gcc.dg/guality/pr54519-3.c  -O3 -g  line 23 z == 8
FAIL: gcc.dg/guality/pr54693-2.c  -O3 -fomit-frame-pointer
-funroll-all-loops -finline-functions  line 21 i == v + 1
FAIL: gcc.dg/guality/pr54693-2.c  -O3 -fomit-frame-pointer
-funroll-loops  line 21 i == v + 1
FAIL: gcc.target/i386/pr35767-5.c scan-assembler-not movups

Should we fix

FAIL: gcc.target/i386/pr35767-5.c scan-assembler-not movups


-- 
H.J.


FW: [GOMP4][PATCH] SIMD-enabled functions (formerly Elemental functions) for C++

2014-01-22 Thread Iyer, Balaji V
Hi Jakub,
Did you get a chance to look at this? Is it OK to install to trunk?

Thanks,

Balaji V. Iyer.

> -Original Message-
> From: gcc-patches-ow...@gcc.gnu.org [mailto:gcc-patches-
> ow...@gcc.gnu.org] On Behalf Of Iyer, Balaji V
> Sent: Sunday, January 19, 2014 10:37 PM
> To: Jakub Jelinek
> Cc: 'Aldy Hernandez (al...@redhat.com)'; 'gcc-patches@gcc.gnu.org'
> Subject: RE: [GOMP4][PATCH] SIMD-enabled functions (formerly Elemental
> functions) for C++
> 
> Hi Jakub,
>   I have fixed all the issues you have mentioned below. I am also
> attaching a fixed patch along with ChangeLog entries.  I have also rebased the
> patch to the trunk revision r206786.
> 
>   Is this Ok to install?
> 
> Thanks,
> 
> Balaji V. Iyer.
> 
> > -Original Message-
> > From: Jakub Jelinek [mailto:ja...@redhat.com]
> > Sent: Friday, January 17, 2014 12:46 PM
> > To: Iyer, Balaji V
> > Cc: 'Aldy Hernandez (al...@redhat.com)'; 'gcc-patches@gcc.gnu.org'
> > Subject: Re: [GOMP4][PATCH] SIMD-enabled functions (formerly
> Elemental
> > functions) for C++
> >
> > On Thu, Dec 19, 2013 at 06:12:29PM +, Iyer, Balaji V wrote:
> > > 2013-12-19  Balaji V. Iyer  
> > >
> > > * parser.c (cp_parser_direct_declarator): When Cilk Plus is 
> > > enabled
> > > see if there is an attribute after function decl.  If so, then
> > > parse them now.
> > > (cp_parser_late_return_type_opt): Handle parsing of Cilk Plus SIMD
> > > enabled function late parsing.
> > > (cp_parser_gnu_attribute_list): Parse all the tokens for the 
> > > vector
> > > attribute for a SIMD-enabled function.
> > > (cp_parser_omp_all_clauses): Skip parsing to the end of pragma
> when
> > > the function is used by SIMD-enabled function (indicated by NULL
> > > pragma token).   Added 3 new clauses:
> PRAGMA_CILK_CLAUSE_MASK,
> > > PRAGMA_CILK_CLAUSE_NOMASK and
> > PRAGMA_CILK_CLAUSE_VECTORLENGTH
> > > (cp_parser_cilk_simd_vectorlength): Modified this function to 
> > > handle
> > > vectorlength clause in SIMD-enabled function and #pragma SIMD's
> > > vectorlength clause.  Added a new bool parameter to differentiate
> > > between the two.
> > > (cp_parser_cilk_simd_fn_vector_attrs): New function.
> > > (is_cilkplus_vector_p): Likewise.
> > > (cp_parser_late_parsing_elem_fn_info): Likewise.
> > > (cp_parser_omp_clause_name): Added a check for "mask,"
> "nomask"
> >
> > The comma should have been after " .
> >
> 
> Fixed.
> 
> > > +   /* In here, we handle cases where attribute is used after
> > > +  the function declaration.  For example:
> > > +  void func (int x) __attribute__((vector(..)));  */
> > > +   if (flag_enable_cilkplus
> > > +   && cp_next_tokens_can_be_attribute_p (parser))
> >
> > As you are just calling cp_parser_gnu_attributes_opt here and not
> > ..._std_..., I'd say the above should be
> > cp_next_tokens_can_be_gnu_attribute_p
> > rather than cp_next_tokens_can_be_attribute_p.  I think [[...]]
> > attributes at this position are ignored, so no need to handle them,
> > not sure about whether we allow e.g. combination of GNU and std
> attributes or vice versa.
> >
> 
> Fixed.
> 
> > > + {
> > > +   cp_parser_parse_tentatively (parser);
> > > +   tree attr = cp_parser_gnu_attributes_opt (parser);
> > > +   if (cp_lexer_next_token_is_not (parser->lexer,
> > > +   CPP_SEMICOLON)
> > > +   && cp_lexer_next_token_is_not (parser->lexer,
> > > +  CPP_OPEN_BRACE))
> > > + cp_parser_abort_tentative_parse (parser);
> > > +   else if (!cp_parser_parse_definitely (parser))
> > > + ;
> > > +   else
> > > + attrs = chainon (attr, attrs);
> > > + }
> > > late_return = (cp_parser_late_return_type_opt
> > >(parser, declarator,
> > > memfn ? cv_quals : -1));
> >
> > > @@ -17842,6 +17868,10 @@ cp_parser_late_return_type_opt
> (cp_parser*
> > parser, cp_declarator *declarator,
> > >type = cp_parser_trailing_type_id (parser);
> > >  }
> > >
> > > +  if (cilk_simd_fn_vector_p)
> > > +declarator->std_attributes
> > > +  = cp_parser_late_parsing_cilk_simd_fn_info (parser,
> > > +  declarator->std_attributes);
> >
> > Please make sure declarator is aligned below parser.
> >
> 
> Fixed.
> 
> > > +  token->type = CPP_PRAGMA_EOL;
> > > +  parser->lexer->next_token = token;  cp_lexer_consume_token
> > > + (parser->lexer);
> > > +
> > > +  struct cp_token_cache *cp =
> > > +cp_token_cache_new (v_token, cp_lexer_peek_token
> > > + (parser->lexer));
> >
> > The = should already go on the next line.
> >
> 
>

Re: [GOOGLE] Builtins handling in IVOPT

2014-01-22 Thread Wei Mi
Comments added. I create another patch to add the parameter for AVG_LOOP_ITER.
Both patches are attached.

Thanks,
Wei.

On Wed, Jan 22, 2014 at 4:42 PM, Xinliang David Li  wrote:
> On Wed, Jan 22, 2014 at 2:23 PM, Wei Mi  wrote:
>> This patch handles the mem access builtins in ivopt. The original
>> problem described here:
>> http://gcc.gnu.org/ml/gcc-patches/2013-11/msg02648.html
>>
>> Bootstrapped and passed regression test. Performance test ok for
>> plain, fdo and lipo. Ok for google 4.8 branch?
>>
>> Thanks,
>> Wei.
>>
>> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/expr.c
>> 2013-12-21 21:16:11.006695060 -0800
>> +++ gcc/expr.c  2013-12-09 11:16:22.698063077 -0800
>> @@ -7537,7 +7537,21 @@
>>   tem = fold_build_pointer_plus (tem, TREE_OPERAND (exp, 1));
>> return expand_expr (tem, target, tmode, modifier);
>>}
>> +case TARGET_MEM_REF:
>> +  {
>
> Add more comments here to describe the new code.
>
>> +   struct mem_address addr;
>> +   int old_cse_not_expected;
>> +   addr_space_t as
>> + = TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (TREE_OPERAND (exp, 0;
>>
>> +   get_address_description (exp, &addr);
>> +   result = addr_for_mem_ref (&addr, as, true);
>> +   old_cse_not_expected = cse_not_expected;
>> +   cse_not_expected = 1;
>> +   result = memory_address_addr_space (tmode, result, as);
>> +   cse_not_expected = old_cse_not_expected;
>> +   return result;
>> +  }
>>  case CONST_DECL:
>>/* Expand the initializer like constants above.  */
>>result = XEXP (expand_expr_constant (DECL_INITIAL (exp),
>> @@ -9579,10 +9593,14 @@
>> struct mem_address addr;
>> enum insn_code icode;
>> unsigned int align;
>> +   int old_cse_not_expected;
>>
>> get_address_description (exp, &addr);
>> op0 = addr_for_mem_ref (&addr, as, true);
>> +   old_cse_not_expected = cse_not_expected;
>
> Comments on the change.
>
>> +   cse_not_expected = 1;
>> op0 = memory_address_addr_space (mode, op0, as);
>> +   cse_not_expected = old_cse_not_expected;
>> temp = gen_rtx_MEM (mode, op0);
>> set_mem_attributes (temp, exp, 0);
>> set_mem_addr_space (temp, as);
>> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/target.def
>> 2013-12-21 21:16:10.926694446 -0800
>> +++ gcc/target.def  2013-12-09 10:46:07.794472365 -0800
>> @@ -1119,6 +1119,14 @@
>>  #undef HOOK_PREFIX
>>  #define HOOK_PREFIX "TARGET_"
>>
>> +DEFHOOK
>> +(builtin_has_mem_ref_p,
>> + "This hook return whether the @var{i}th param of the 
>> @var{builtin_function}\n\
>> +is a memory reference. If @var{i} is -1, return whether the
>> @var{builtin_function}\n\
>> +contains any memory reference type param.",
>> + bool, (int builtin_function, int i),
>> + default_builtin_has_mem_ref_p)
>> +
>>  /* Allow target specific overriding of option settings after options have
>>been changed by an attribute or pragma or when it is reset at the
>>end of the code affected by an attribute or pragma.  */
>> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/gimple.c
>>   2013-12-21 21:16:11.066695519 -0800
>> +++ gcc/gimple.c2013-12-09 10:50:09.096289179 -0800
>> @@ -2574,7 +2574,8 @@
>>  is_gimple_addressable (tree t)
>>  {
>>return (is_gimple_id (t) || handled_component_p (t)
>> - || TREE_CODE (t) == MEM_REF);
>> + || TREE_CODE (t) == MEM_REF
>> + || TREE_CODE (t) == TARGET_MEM_REF);
>>  }
>>
>>  /* Return true if T is a valid gimple constant.  */
>> @@ -2625,7 +2626,8 @@
>>op = TREE_OPERAND (op, 0);
>>  }
>>
>> -  if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF)
>> +  if (CONSTANT_CLASS_P (op) || TREE_CODE (op) == MEM_REF
>> +  || TREE_CODE (op) == TARGET_MEM_REF)
>>  return true;
>>
>>switch (TREE_CODE (op))
>> --- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/targhooks.c
>>2013-12-21 21:16:10.926694446 -0800
>> +++ gcc/targhooks.c 2013-12-09 10:45:50.154339207 -0800
>> @@ -543,6 +543,13 @@
>>  }
>>
>>  bool
>> +default_builtin_has_mem_ref_p (int built_in_function ATTRIBUTE_UNUSED,
>> +  int i ATTRIBUTE_UNUSED)
>> +{
>> +  return false;
>> +}
>> +
>> +bool
>>  hook_bool_CUMULATIVE_ARGS_mode_tree_bool_false (
>> cumulative_args_t ca ATTRIBUTE_UNUSED,
>> enum machine_mode mode ATTRIBUTE_UNUSED,
>> --- 
>> /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc/tree-ssa-loop-ivopts.c
>> 2014-01-22 11:57:10.420073494 -0800
>> +++ gcc/tree-ssa-loop-ivopts.c  2014-01-22 14:00:14.177908568 -0800
>> @@ -96,7 +96,7 @@
>>  /* The infinite cost.  */
>>  #define INFTY 1000
>>
>> -#define AVG_LOOP_NITER(LOOP) 5
>> +#define AVG_LOOP_NITER(LOOP) 50
>
> Need a parameter to control. This should also go in as an independent patch.
>
>
> David
>
--- /usr/local/google/home/wmi/workarea/google_r205653_2/src/gcc

Re: [Patch] PR55189 enable -Wreturn-type by default

2014-01-22 Thread Sylvestre Ledru
On 16/01/2014 11:44, Jason Merrill wrote:
> My preference would be to turn -Wreturn-type on by default, but not
> create the separate -Wmissing-return flag.  As I argued in 2002, there
> should only be one flag.
I don't have any opinion on the subject. The separate option or not is
fine with me. I am just following an advice received :)

Sylvestre



Re: [Patch, microblaze]: Fix bswaphi2 implementation

2014-01-22 Thread Michael Eager

On 01/22/14 09:02, Michael Eager wrote:

On 01/22/14 07:43, Michael Eager wrote:

On 01/22/14 02:55, David Holsgrove wrote:

Hi Michael,

On 26 November 2013 17:48, David Holsgrove  wrote:

Hi Michael,

Please find attached same patch based against latest from gcc master.

Can this be applied and backported to gcc-4_8-branch when reviewed.

thanks,
David

On 15 July 2013 14:49, David Holsgrove  wrote:

MicroBlaze insn swaph swaps the contents of register rA as two
halfwords placing result in rD;

(rD)[0:15]  <- (rA)[16:31]
(rD)[16:31] <- (rA)[0:15]

gcc bswaphi2 is intended to reverse the order of the bytes in the
half integer in rA

(rD)[8:15]  <- (rA)[0:7]
(rD)[7:0]   <- (rA)[8:15]
(rD)[24:31] <- (rA)[16:23]
(rD)[16:23] <- (rA)[24:31]

Correct the microblaze bswaphi2 insn pattern to be a swapb followed
by swaph

Changelog entry would be:

2013-07-15  David Holsgrove 

  * gcc/config/microblaze/microblaze.md: Fix bswaphi2


Can this also be backported to the gcc-4_8-branch?



Updated patch attached which includes a testcase to check that
bswaphi2 is using a swapb followed by swaph for MicroBlaze.

Updated Changelogs are;

gcc/Changelog

 2014-01-22  David Holsgrove 

  * gcc/config/microblaze/microblaze.md: Correct bswaphi2 / bswapsi2 insn

testsuite/ChangeLog

 2014-01-22  David Holsgrove 

  * gcc/testsuite/gcc.target/microblaze/others/bswap16.c: New test.


Thanks for the test case.

I had verified that the code was correct by hand, but tests are always
a good addition.


The test case only verifies that swapb and swaph instructions are
generated.  It doesn't confirm that the computation is correct.

This is a minor fix.  No test case is needed.


Head: Committed revision 206952.
gcc-4_8-branch: Committed revision 206954.

--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077