Re: [PATCH] Fix for PR/62089 (enable missing Asan checks)

2014-08-13 Thread Yury Gribov

On 08/14/2014 09:46 AM, Yury Gribov wrote:

Something like this?


Forgot to mention: full tested the new patch on x64 (bootstrap, regtest, 
Asan-bootstrap).


Re: [PATCH] Fix for PR/62089 (enable missing Asan checks)

2014-08-13 Thread Yury Gribov

On 08/13/2014 02:13 PM, Jakub Jelinek wrote:

I wonder if we just shouldn't handle COMPONENT_REFs with
DECL_BIT_FIELD_REPRESENTATIVE that way unconditionally.
So, do the if (TREE_CODE (t) == COMPONENT_REF ... before the other checks,
and
   else if (bitpos % BITS_PER_UNIT || bitsize != size_in_bytes * BITS_PER_UNIT)
return;


Something like this?

BTW we probably need support for BIT_FIELD_REF as well, I've seen it in 
e.g. GCC code. I'll see if I can cook a patch for this.


-Y
commit 57cb45239f24057e1b309f72795042c5b018d07e
Author: Yury Gribov 
Date:   Mon Aug 11 15:09:45 2014 +0400

2014-08-14  Yury Gribov  

gcc/
	PR sanitizer/62089
	* asan.c (instrument_derefs): Fix bitfield check.

gcc/testsuite/
	PR sanitizer/62089
	* c-c++-common/asan/pr62089.c: New test.
	* c-c++-common/asan/bitfield-1.c: New test.
	* c-c++-common/asan/bitfield-2.c: New test.
	* c-c++-common/asan/bitfield-3.c: New test.
	* c-c++-common/asan/bitfield-4.c: New test.

diff --git a/gcc/asan.c b/gcc/asan.c
index 4e6f438..b1bfa49 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1690,22 +1690,21 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t,
   int volatilep = 0, unsignedp = 0;
   tree inner = get_inner_reference (t, &bitsize, &bitpos, &offset,
 &mode, &unsignedp, &volatilep, false);
-  if (((size_in_bytes & (size_in_bytes - 1)) == 0
-   && (bitpos % (size_in_bytes * BITS_PER_UNIT)))
-  || bitsize != size_in_bytes * BITS_PER_UNIT)
+
+  if (TREE_CODE (t) == COMPONENT_REF)
 {
-  if (TREE_CODE (t) == COMPONENT_REF
-	  && DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1)) != NULL_TREE)
+  if (DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1)) != NULL_TREE)
 	{
 	  tree repr = DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1));
 	  instrument_derefs (iter, build3 (COMPONENT_REF, TREE_TYPE (repr),
 	   TREE_OPERAND (t, 0), repr,
 	   NULL_TREE), location, is_store);
+	  return;
 	}
-  return;
+  else if (bitpos % BITS_PER_UNIT
+	   || bitsize != size_in_bytes * BITS_PER_UNIT)
+	return;
 }
-  if (bitpos % BITS_PER_UNIT)
-return;
 
   if (TREE_CODE (inner) == VAR_DECL
   && offset == NULL_TREE
diff --git a/gcc/testsuite/c-c++-common/asan/bitfield-1.c b/gcc/testsuite/c-c++-common/asan/bitfield-1.c
new file mode 100644
index 000..b3f300c
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/bitfield-1.c
@@ -0,0 +1,25 @@
+/* Check that Asan correctly instruments bitfields with non-round size.  */
+
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+struct A
+{
+  char base;
+  int : 4;
+  long x : 7;
+};
+
+int __attribute__ ((noinline, noclone))
+f (void *p) {
+  return ((struct A *)p)->x;
+}
+
+int
+main ()
+{
+  char a = 0;
+  return f (&a);
+}
+
+/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */
diff --git a/gcc/testsuite/c-c++-common/asan/bitfield-2.c b/gcc/testsuite/c-c++-common/asan/bitfield-2.c
new file mode 100644
index 000..8ab0f80
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/bitfield-2.c
@@ -0,0 +1,25 @@
+/* Check that Asan correctly instruments bitfields with non-round offset.  */
+
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+struct A
+{
+  char base;
+  int : 7;
+  int x : 8;
+};
+
+int __attribute__ ((noinline, noclone))
+f (void *p) {
+  return ((struct A *)p)->x;
+}
+
+int
+main ()
+{
+  char a = 0;
+  return f (&a);
+}
+
+/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */
diff --git a/gcc/testsuite/c-c++-common/asan/bitfield-3.c b/gcc/testsuite/c-c++-common/asan/bitfield-3.c
new file mode 100644
index 000..c590778
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/bitfield-3.c
@@ -0,0 +1,25 @@
+/* Check that Asan correctly instruments bitfields with round offset.  */
+
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+struct A
+{
+  char base;
+  int : 8;
+  int x : 8;
+};
+
+int __attribute__ ((noinline, noclone))
+f (void *p) {
+  return ((struct A *)p)->x;
+}
+
+int
+main ()
+{
+  char a = 0;
+  return f (&a);
+}
+
+/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */
diff --git a/gcc/testsuite/c-c++-common/asan/bitfield-4.c b/gcc/testsuite/c-c++-common/asan/bitfield-4.c
new file mode 100644
index 000..94de9a4
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/bitfield-4.c
@@ -0,0 +1,25 @@
+/* Check that Asan correctly instruments bitfields with round offset.  */
+
+/* { dg-do run } */
+/* { dg-shouldfail "asan" } */
+
+struct A
+{
+  char base;
+  int : 0;
+  int x : 8;
+};
+
+int __attribute__ ((noinline, noclone))
+f (void *p) {
+  return ((struct A *)p)->x;
+}
+
+int
+main ()
+{
+  char a = 0;
+  return f (&a);
+}
+
+/* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */
diff --git a/gcc/testsuite/c-c++-common/asan/pr62089.c b/gcc/testsuite/c-c++-common/asan/pr62089.c
new file mode 100644
index 000..22b877b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/asan/pr62089.c
@@ -0,0 +1,37 @@

Re: [PATCH] Don't set dir prefix twice (PR middle-end/60484)

2014-08-13 Thread Joey Ye
PR60484 is marked as 4.7/4.8 regression and it is reported against 4.8
recently by an user.

OK backporting to 4.7/4.8?

- Joey

On Sat, Mar 15, 2014 at 1:43 AM, Joseph S. Myers
 wrote:
> On Fri, 14 Mar 2014, Marek Polacek wrote:
>
>> This patch makes sure that we set the directory prefix of
>> dump_base_name only once, otherwise we'd end up with invalid path,
>> resulting in error: could not open dump file ...
>> This happened because finish_options is called for every optimize
>> attribute and once more for command line options and every time it
>> added the directory prefix.
>>
>> Regtested/bootstrapped on x86_64-linux, ok for trunk?
>
> OK, though I think it might be better to use separate fields of
> gcc_options for the originally specified name and the prefixed version.
>
> --
> Joseph S. Myers
> jos...@codesourcery.com


[Committed] [PATCH, ARM] Set max_insns_skipped to MAX_INSN_PER_IT_BLOCK when optimize_size for THUMB2

2014-08-13 Thread Zhenqiang Chen
On 13 August 2014 20:29, Richard Earnshaw  wrote:
> On 25/02/14 09:34, Zhenqiang Chen wrote:
>> Hi,
>>
>> Current value for max_insns_skipped is 6. For THUMB2, it needs 2 (IF-THEN)
>> or 3 (IF-THEN-ELSE) IT blocks to hold all the instructions. The overhead of
>> IT is 4 or 6 BYTES.
>>
>> If we do not generate IT blocks, for IF-THEN, the overhead of conditional
>> jump is 2 or 4; for IF-THEN-ELSE, the overhead is 4, 6, or 8.
>>
>> Most THUMB2 jump instructions are 2 BYTES. Tests on CSiBE show no one file
>> has code size regression. So The patch sets max_insns_skipped to
>> MAX_INSN_PER_IT_BLOCK.
>>
>> No make check regression on cortex-m3.
>> For CSiBE, no any file has code size regression. And overall there is >0.01%
>> code size improvement for cortex-a9 and cortex-m4.
>>
>> Is it OK?
>>
>> Thanks!
>> -Zhenqiang
>>
>> 2014-02-25  Zhenqiang Chen  
>>
>>   * config/arm/arm.c (arm_option_override): Set max_insns_skipped
>>   to MAX_INSN_PER_IT_BLOCK when optimize_size for THUMB2.
>>
>> testsuite/ChangeLog:
>> 2014-02-25  Zhenqiang Chen  
>>
>>   * gcc.target/arm/max-insns-skipped.c: New test.
>>
>> diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
>> index b49f43e..99cdbc4 100644
>> --- a/gcc/config/arm/arm.c
>> +++ b/gcc/config/arm/arm.c
>> @@ -2743,6 +2743,15 @@ arm_option_override (void)
>>/* If optimizing for size, bump the number of instructions that we
>>   are prepared to conditionally execute (even on a StrongARM).  */
>>max_insns_skipped = 6;
>> +
>> +  /* For THUMB2, it needs 2 (IF-THEN) or 3 (IF-THEN-ELSE) IT blocks to
>> +  hold all the instructions. The overhead of IT is 4 or 6 BYTES.
>> +  If we do not generate IT blocks, for IF-THEN, the overhead of
>> +  conditional jump is 2 or 4; for IF-THEN-ELSE, the overhead is 4, 6
>> +  or 8.  Most THUMB2 jump instructions are 2 BYTES.
>> +  So set max_insns_skipped to MAX_INSN_PER_IT_BLOCK.  */
>> +  if (TARGET_THUMB2)
>> + max_insns_skipped = MAX_INSN_PER_IT_BLOCK;
>
> Replacing a single 2-byte branch with a 2-byte IT insn doesn't save any
> space in itself.
>
> Pedantically, we save space with IT blocks if either:
> a) we can replace an else clause (saving a branch around that)
> b) we can use non-flag setting versions of insns to replace what would
> otherwise be 4-byte insns with 2-byte versions.
>
> I agree that multiple IT instructions is probably not a win (the
> cond-exec code doesn't know how to reason about the finer points of item
> b) and doesn't even really consider a) either).
>
> So this is OK, but I think the comment should be simplified.  Just say,
> for thumb2 we limit the conditional sequence to one IT block.
>
> OK with that change.

Thanks! Commit the patch with the comment change @r213939.

ChangeLog:
2014-08-14  Zhenqiang Chen  

* config/arm/arm.c (arm_option_override): Set max_insns_skipped
to MAX_INSN_PER_IT_BLOCK when optimize_size for THUMB2.

testsuite/ChangeLog:
2014-08-14  Zhenqiang Chen  

* gcc.target/arm/max-insns-skipped.c: New test.

diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 7f62ca4..2f8d327 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -2989,6 +2989,10 @@ arm_option_override (void)
   /* If optimizing for size, bump the number of instructions that we
  are prepared to conditionally execute (even on a StrongARM).  */
   max_insns_skipped = 6;
+
+  /* For THUMB2, we limit the conditional sequence to one IT block.  */
+  if (TARGET_THUMB2)
+   max_insns_skipped = MAX_INSN_PER_IT_BLOCK;
 }
   else
 max_insns_skipped = current_tune->max_insns_skipped;
diff --git a/gcc/testsuite/gcc.target/arm/max-insns-skipped.c
b/gcc/testsuite/gcc.target/arm/max-insns-skipped.c
new file mode 100644
index 000..0a11554
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/max-insns-skipped.c
@@ -0,0 +1,21 @@
+/* { dg-do assemble { target arm_thumb2 } } */
+/* { dg-options " -Os " } */
+
+int t (int a, int b, int c, int d)
+{
+  int r;
+  if (a > 0) {
+r = a + b;
+r += 0x456;
+r *= 0x1234567;
+}
+  else {
+r = b - a;
+r -= 0x123;
+r *= 0x12387;
+r += d;
+   }
+  return r;
+}
+
+/* { dg-final { object-size text <= 40 } } */

>
>>  }
>>else
>>  max_insns_skipped = current_tune->max_insns_skipped;
>> diff --git a/gcc/testsuite/gcc.target/arm/max-insns-skipped.c
>> b/gcc/testsuite/gcc.target/arm/max-insns-skipped.c
>> new file mode 100644
>> index 000..0a11554
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/arm/max-insns-skipped.c
>> @@ -0,0 +1,21 @@
>> +/* { dg-do assemble { target arm_thumb2 } } */
>> +/* { dg-options " -Os " } */
>> +
>> +int t (int a, int b, int c, int d)
>> +{
>> +  int r;
>> +  if (a > 0) {
>> +r = a + b;
>> +r += 0x456;
>> +r *= 0x1234567;
>> +}
>> +  else {
>> +r = b - a;
>> +r -= 0x123;
>> +r *= 0x12387;
>> +r += d;
>> +   }
>> +  return r;
>> +}
>> +
>> +/* { dg-fi

RE: [PATCH, C/C++] Add -fno-float to forbid floating point data types

2014-08-13 Thread Thomas Preud'homme
> From: Marek Polacek [mailto:pola...@redhat.com]
> Sent: Tuesday, August 12, 2014 5:43 PM
> On Tue, Aug 12, 2014 at 11:34:35AM +0200, Jakub Jelinek wrote:
> >
> > This looks wrong.  c_token_starts_typename is just a function which tells
> > you if certain token can start a typename, issuing diagnostics there doesn't
> > make sense, that routine doesn't actually parse the token.  You should
> > diagnose it where you actually parse it.
> 
> I'd say the proper place would be declspecs_add_type.

Wouldn't that miss casts and sizeof for instance? It's true that
c_token_starts_typename is not the place where the token is parsed but it
seemed a more central place: it catches all these cases in one check. Ok
maybe sizeof (float) should be ignored but I suppose if you use that you
intend to store a float later.

On the other hand I do want to distinguish float declared in prototypes from
float declared elsewhere.

Best regards,

Thomas




[GOOGLE] Fix the bug where implicit section names prevents function splitting

2014-08-13 Thread Yi Yang
This bug is caused by my last patch, which did not differentiate
between explicit section names (via attributes) and implicit section
names (via -ffunction-section).

This patch fixes that.

--

diff --git gcc/bb-reorder.c gcc/bb-reorder.c
index 8f8c420..2115b01 100644
--- gcc/bb-reorder.c
+++ gcc/bb-reorder.c
@@ -2505,7 +2505,7 @@ gate_handle_partition_blocks (void)
 we are going to omit the reordering.  */
  && optimize_function_for_speed_p (cfun)
  && !DECL_ONE_ONLY (current_function_decl)
- && !DECL_SECTION_NAME (current_function_decl));
+ && !DECL_HAS_EXPLICIT_SECTION_NAME_P(current_function_decl));
 }

 /* This function is the main 'entrance' for the optimization that
diff --git gcc/tree.h gcc/tree.h
index 817507f..738675a 100644
--- gcc/tree.h
+++ gcc/tree.h
@@ -3201,6 +3201,11 @@ struct GTY(()) tree_parm_decl {
 #define DECL_HAS_IMPLICIT_SECTION_NAME_P(NODE) \
   (DECL_WITH_VIS_CHECK (NODE)->decl_with_vis.implicit_section_name_p)

+/* Speficy whether the section name was explicitly set with decl_attributes. */
+#define DECL_HAS_EXPLICIT_SECTION_NAME_P(NODE) \
+  (DECL_HAS_IMPLICIT_SECTION_NAME_P(NODE)? false: \
+   !!DECL_SECTION_NAME(NODE))
+
 struct GTY(()) tree_decl_with_vis {
  struct tree_decl_with_rtl common;
  tree assembler_name;
--


Re: [PATCH] Fix find_inc in the scheduler (PR target/62025)

2014-08-13 Thread Bernd Schmidt

On 08/12/2014 09:35 PM, Jakub Jelinek wrote:

As detailed in the PR, find_inc ignored any possible clobbers on
inc_insn (typically %cc/flags/etc. register) and thus we could ignore
all register dependencies between mem_insn and inc_insn even when
we could only safely ignore the mem_reg0 register dependency.


I've been trying to remember how I intended to prevent this, and there 
is indeed a mechanism: DEP_MULTIPLE, which ought to be set for any 
dependency between two insns that is found for more than one reason. 
find_inc does not try to break such dependencies, which should make it 
examine only cases where the only reason for a dependency is between the 
incremented register and the memory address. I'm pretty sure this worked 
at some point.


So all the new added code may or may not be safe, but it's not exactly 
pretty and I think the real bug is likely elsewhere.



Bernd



Re: [PATCH 124/236] PHASE 3: Per-config subdir commits

2014-08-13 Thread Jeff Law

On 08/06/14 11:21, David Malcolm wrote:

/
* rtx-classes-status.txt: Update
---
  rtx-classes-status.txt | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/rtx-classes-status.txt b/rtx-classes-status.txt
index e350eaf..b22cb1e 100644
--- a/rtx-classes-status.txt
+++ b/rtx-classes-status.txt
@@ -2,8 +2,8 @@
  exists to be modified by marker commits.

  Phase 1: initial "scaffolding" commits:DONE
-Phase 2: per-file commits in main source dir:  IN PROGRESS
-Phase 3: per-file commits within "config" subdirs: TODO
+Phase 2: per-file commits in main source dir:  DONE
+Phase 3: per-file commits within "config" subdirs: IN PROGRESS
  Phase 4: removal of "scaffolding": TODO
  Phase 5: additional rtx_def subclasses:TODO
  Phase 6: use extra rtx_def subclasses: TODO


OK.  As are patches #125-#129.

Jeff


Re: [PATCH 012/236] Convert DF_REF_INSN to a function for now

2014-08-13 Thread Jeff Law

On 08/13/14 18:11, David Malcolm wrote:

On Wed, 2014-08-13 at 14:34 -0600, Jeff Law wrote:

On 08/13/14 14:28, David Malcolm wrote:

Thanks.  Although this function gets converted back to a macro in patch
191, I just realized that in the meantime that it's not inlined, as is
the case for some of the other macro->function conversions in patches
13-16.

Do I need to convert them to inline functions with the appropriate
headers, and is that regarded as a sufficiently trivial fix to the stuff
you've already reviewed to not need re-review? (I will bootstrap&test).

I'd just make it a follow-up. #237 ;-)


Right, but these would be modifications to stuff that only exists
between phases 1-3 of the kit, before going away in phase 4, so although
it might be #237, it would need to be applied when the individual
changes go in.
If they're around just through phases #1-#3, then I wouldn't worry about 
it.



Transient, yes, but given the amount of time for me to simply bootstrap
each candidate patch, the non-inlined functions could last in trunk for
a couple of weeks (there are only 168 hours in a week, and a bootstrap
+regrtest takes about 3 hours on my box, so for 236 patches we're
talking ~4 weeks of compute time just for that).

Well, I'd suggest a few things.

1. For the config/ changes, a full bootstrap is not necessary.  For 
those targets which are embedded, just build a stage1 cross to the 
target to verify it builds and call it good.


2. For targets where you can bootstrap, go ahead and do so, but just on 
those targets.  Some of these you can probably have going in parallel.


3. Some of the changes are so trivial that I'd squash them together in a 
single build/test cycle.


I would even consider seeing all the scaffolding go in as a single 
chunk.  It's nice to see the individuals during the review process, but 
I wouldn't lose any sleep if bundled those together.





I guess the underlying point here is that this is a big change and I'm
trying to be fastidious here.  Murphy's Law suggests I'm going to break
at least *something* :(
Understood, but we don't want to be so fastidious that the time this 
stuff is in flux is so long that it creates more problems than it would 
if we took some sensible and safe shortcuts.


Jeff


[PATCH, ira] Miss checks in split_live_ranges_for_shrink_wrap

2014-08-13 Thread Zhenqiang Chen
Hi,

Function split_live_ranges_for_shrink_wrap has code

  if (!flag_shrink_wrap)
return false;

But flag_shrink_wrap is TRUE by default when optimize > 0 even if the
port does not support shrink-wrap. To make sure shrink-wrap is
enabled, "HAVE_simple_return" must be defined and "HAVE_simple_return"
must be TRUE.

Please refer function.c and shrink-wrap.c on how shrink-wrap is
enabled in thread_prologue_and_epilogue_insns.

To make the check easy, the patch defines a MICRO:
SUPPORT_SHRINK_WRAP_P and replace the uses in ira.c and ifcvt.c

Bootstrap and no make check regression on X86-64.

OK for trunk?

Thanks!
-Zhenqiang

ChangeLog:
2014-08-14  Zhenqiang Chen  

* shrink-wrap.h: #define SUPPORT_SHRINK_WRAP_P.
* ira.c: #include "shrink-wrap.h"
(split_live_ranges_for_shrink_wrap): Use SUPPORT_SHRINK_WRAP_P.
* ifcvt.c: #include "shrink-wrap.h"
(dead_or_predicable): Use SUPPORT_SHRINK_WRAP_P.

testsuite/ChangeLog:
2014-08-14  Zhenqiang Chen  

* gcc.target/arm/split-live-ranges-for-shrink-wrap.c: New test.

diff --git a/gcc/shrink-wrap.h b/gcc/shrink-wrap.h
index bccfb31..31ce2d4 100644
--- a/gcc/shrink-wrap.h
+++ b/gcc/shrink-wrap.h
@@ -45,6 +45,9 @@ extern edge get_unconverted_simple_return (edge, bitmap_head,
 extern void convert_to_simple_return (edge entry_edge, edge orig_entry_edge,
  bitmap_head bb_flags, rtx returnjump,
  vec unconverted_simple_returns);
+#define SUPPORT_SHRINK_WRAP_P (flag_shrink_wrap && HAVE_simple_return)
+#else
+#define SUPPORT_SHRINK_WRAP_P false
 #endif

 #endif  /* GCC_SHRINK_WRAP_H  */
diff --git a/gcc/ira.c b/gcc/ira.c
index ccc6c79..8d58b60 100644
--- a/gcc/ira.c
+++ b/gcc/ira.c
@@ -392,6 +392,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "lra.h"
 #include "dce.h"
 #include "dbgcnt.h"
+#include "shrink-wrap.h"

 struct target_ira default_target_ira;
 struct target_ira_int default_target_ira_int;
@@ -4775,7 +4776,7 @@ split_live_ranges_for_shrink_wrap (void)
   bitmap_head need_new, reachable;
   vec queue;

-  if (!flag_shrink_wrap)
+  if (!SUPPORT_SHRINK_WRAP_P)
 return false;

   bitmap_initialize (&need_new, 0);
diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index e44c1dc..c44e1c2 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -42,6 +42,7 @@
 #include "df.h"
 #include "vec.h"
 #include "dbgcnt.h"
+#include "shrink-wrap.h"

 #ifndef HAVE_conditional_move
 #define HAVE_conditional_move 0
@@ -4239,14 +4240,13 @@ dead_or_predicable (basic_block test_bb,
basic_block merge_bb,
if (NONDEBUG_INSN_P (insn))
  df_simulate_find_defs (insn, merge_set);

-#ifdef HAVE_simple_return
   /* If shrink-wrapping, disable this optimization when test_bb is
 the first basic block and merge_bb exits.  The idea is to not
 move code setting up a return register as that may clobber a
 register used to pass function parameters, which then must be
 saved in caller-saved regs.  A caller-saved reg requires the
 prologue, killing a shrink-wrap opportunity.  */
-  if ((flag_shrink_wrap && HAVE_simple_return && !epilogue_completed)
+  if ((SUPPORT_SHRINK_WRAP_P && !epilogue_completed)
  && ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb == test_bb
  && single_succ_p (new_dest)
  && single_succ (new_dest) == EXIT_BLOCK_PTR_FOR_FN (cfun)
@@ -4293,7 +4293,6 @@ dead_or_predicable (basic_block test_bb,
basic_block merge_bb,
}
  BITMAP_FREE (return_regs);
}
-#endif
 }

  no_body:


Re: [PATCH 109/236] resource.c: Use rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:21, David Malcolm wrote:

gcc/
* resource.c (next_insn_no_annul): Strengthen local "next" from
rtx to rtx_insn *.
(mark_referenced_resources): Likewise for local "insn".
---
  gcc/resource.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

OK.

As are patches #110-#123.

Jeff



Re: [PATCH 108/236] reload: Use rtx_insn (also touches caller-save.c and config/arc/arc)

2014-08-13 Thread Jeff Law

On 08/06/14 11:21, David Malcolm wrote:

gcc/
* reload.h (struct insn_chain): Strengthen field "insn" from rtx
to rtx_insn *.
(find_reloads): Likewise for param 1.
(subst_reloads): Likewise for sole param.
(find_equiv_reg): Likwise for param 2.
(regno_clobbered_p): Likwise for param 2.
(reload): Likewise for param 1.

* caller-save.c (save_call_clobbered_regs): Strengthen local
"insn" from rtx to rtx_insn *.
(insert_one_insn): Likewise for local "insn".

* reload.c (this_insn): Likewise for this global.
(find_reloads): Likewise for param "insn".
(find_reloads_toplev): Likewise.
(find_reloads_address): Likewise.
(subst_reg_equivs): Likewise.
(update_auto_inc_notes): Likewise.
(find_reloads_address_1): Likewise.
(find_reloads_subreg_address): Likewise.
(subst_reloads): Likewise.
(find_equiv_reg): Likewise, also for local "p".
(regno_clobbered_p): Likewise for param "insn".

* reload1.c (reg_reloaded_insn): Likewise for the elements of this
array.
(spill_reg_store): Likewise for the elements of this array.
(remove_init_insns): Likewise for local "equiv_insn".
(will_delete_init_insn_p): Likewise for param "insn".
(reload): Likewise for param ""first" and local "insn".
(calculate_needs_all_insns): Strengthen local "insn" from rtx to
rtx_insn *.
(calculate_elim_costs_all_insns): Likewise.
(delete_caller_save_insns): Likewise.
(spill_failure): Likewise for param "insn".
(delete_dead_insn): Likewise.
(set_label_offsets): Likewise.
(eliminate_regs_in_insn): Likewise, also for locals "base_insn" and
"prev_insn".
(elimination_costs_in_insn): Likewise for param "insn".
(set_initial_eh_label_offset): Replace use of NULL_RTX with NULL
when referring to an insn.
(set_initial_label_offsets): Likewise.
(set_offsets_for_label): Strengthen param "insn" from rtx to
rtx_insn *.
(init_eliminable_invariants): Likewise for param "first" and local
"insn".
(fixup_eh_region_note): Likewise for param "insn".
(reload_as_needed): Likewise for locals "prev", "insn",
"old_next", "old_prev", "next".
(gen_reload_chain_without_interm_reg_p): Likewise for locals "insn",
"last".
(reload_inheritance_insn): Strengthen elements of this array from
rtx to rtx_insn *.
(failed_reload): Likewise for param "insn".
(choose_reload_regs): Likewise for local "insn".  Replace use of
NULL_RTX with NULL when referring to an insn.
(input_reload_insns): Strengthen elements of this array from rtx
to rtx_insn *.
(other_input_address_reload_insns): Likewise for this global.
(other_input_reload_insns): Likewise for this global.
(input_address_reload_insns): Likwise for the elements of this
array.
(inpaddr_address_reload_insns): Likwise for the elements of this
array.
(output_reload_insns): Likewise for the elements of this array.
(output_address_reload_insns): Likewise for the elements of this
array.
(outaddr_address_reload_insns): Likewise for the elements of this
array.
(operand_reload_insns): Likewise for this global.
(other_operand_reload_insns): Likewise for this global.
(other_output_reload_insns): Likewise for the elements of this
array.
(new_spill_reg_store): Likewise for the elements of this
array.
(emit_input_reload_insns): Likewise for locals "insn", "temp".
Strengthen local "where" from rtx * to rtx_insn **.
(emit_output_reload_insns): Strengthen locals "insn", "p", "next"
from rtx to rtx_insn *.
(do_input_reload): Likewise for local "insn".
(do_output_reload): Likewise for local "insn".
(emit_reload_insns): Likewise for locals "insn" and "store_insn".
(emit_insn_if_valid_for_reload): Likewise for return type and local
"last".  Add checked cast to rtx_insn when returning "insn" since
this has been through emit_insn.
(gen_reload): Strengthen return type and locals "last", "insn", "set"
from rtx to rtx_insn *.  Add checked cast to rtx_insn when
returning "insn" since it's been through
emit_insn_if_valid_for_reload at this point.
(delete_output_reload): Strengthen param "insn" and locals
"output_reload_insn", "i2" from rtx to rtx_insn *.
(delete_address_reloads): Likewise for params "dead_insn",
"current_insn" and locals "prev", "next".
(delete_address_reloads_1): Likewise for params "dead_insn",
"current_insn" and locals "prev", "i2".
(inc_for_reload): Likewise for locals "last", "add_insn".
(add_auto_inc_no

Re: [PATCH] microblaze: microblaze.md: Use 'SI' instead of 'VOID' for operand 1 of 'call_value_intern'

2014-08-13 Thread Chen Gang
On 8/14/14 10:14, Michael Eager wrote:
>> OK, thanks, and I shall analyze it, but excuse me, I have to do other
>> things this week, so hope I can finish it within next week (2014-08-24).
>> If this time point is too long to bare, please let me know.
> 
> Take your time and let me know when you have this resolved.

OK, thanks. I shall try to finish within next week (2014-08-24).


Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed


Re: [PATCH] microblaze: microblaze.md: Use 'SI' instead of 'VOID' for operand 1 of 'call_value_intern'

2014-08-13 Thread Michael Eager

On 08/13/14 18:35, Chen Gang wrote:


Firstly, thank you very much for spending your time resource on the
related 2 patches.


You're welcome.



On 8/13/14 23:10, Michael Eager wrote:

On 07/06/14 03:26, Chen Gang wrote:


* microblaze/mocroblaze.md (call_value_intern): Use 'SI' instead of
'VOID' for operand 1, just like 'call_internal1' has done.

The related warning:

../../gcc/gcc/config/microblaze/microblaze.md:2172: warning: operand 1 
missing mode?


Signed-off-by: Chen Gang 
---
   gcc/config/microblaze/microblaze.md | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/microblaze/microblaze.md 
b/gcc/config/microblaze/microblaze.md
index 2bd5d72..9580221 100644
--- a/gcc/config/microblaze/microblaze.md
+++ b/gcc/config/microblaze/microblaze.md
@@ -2171,7 +2171,7 @@

   (define_insn "call_value_intern"
 [(set (match_operand:VOID 0 "register_operand" "=d")
-(call (mem (match_operand:VOID 1 "call_insn_operand" "ri"))
+(call (mem (match_operand:SI 1 "call_insn_operand" "ri"))
 (match_operand:SI 2 "" "i")))
  (clobber (match_operand:SI 3 "register_operand" "=d"))]
 ""


This patch causes a test suite regression:

Executing on host: mb-gcc  -fno-diagnostics-show-caret 
-fdiagnostics-color=never-O0  -w -c -mno-xl-soft-mul -mxl-barrel-shift 
-mcpu=v6.00.a   -o calls.o testsuite/gcc.c-torture/compile/calls.c(timeout 
= 60)
pid is 24832 -24832
testsuite/gcc.c-torture/compile/calls.c: In function 'f1':
testsuite/gcc.c-torture/compile/calls.c:6:1: error: unrecognizable insn:
(call_insn 5 2 8 2 (parallel [
 (set (reg:SI 3 r3)
 (call (mem:SI (const_int 0 [0]) [0 MEM[(void * (*) 
(void))0B] S4 A32])
 (const_int 24 [0x18])))
 (clobber (reg:SI 15 r15))
 ]) testsuite/gcc.c-torture/compile/calls.c:5 -1
  (nil)
 (nil))
testsuite/gcc.c-torture/compile/calls.c:6:1: internal compiler error: in 
extract_insn, at recog.c:2204
0x983018 _fatal_insn(char const*, rtx_def const*, char const*, int, char const*)
 /store/Xilinx/repo/fsf/gcc/gcc/rtl-error.c:109
0x983041 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
 /store/Xilinx/repo/fsf/gcc/gcc/rtl-error.c:117
0x9539cd extract_insn(rtx_def*)
 /store/Xilinx/repo/fsf/gcc/gcc/recog.c:2204
0x7a5b59 instantiate_virtual_regs_in_insn
 /store/Xilinx/repo/fsf/gcc/gcc/function.c:1561
0x7aaa78 instantiate_virtual_regs
 /store/Xilinx/repo/fsf/gcc/gcc/function.c:1932



OK, thanks, and I shall analyze it, but excuse me, I have to do other
things this week, so hope I can finish it within next week (2014-08-24).
If this time point is too long to bare, please let me know.


Take your time and let me know when you have this resolved.


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


Re: [PATCH mips] Pass -msoft-float/-mhard-float flags to GAS

2014-08-13 Thread Eric Christopher
On Tue, Aug 12, 2014 at 2:07 AM, Matthew Fortune
 wrote:
> Eric Christopher  writes:
>> On Sat, Aug 9, 2014 at 12:00 PM, Matthew Fortune
>>  wrote:
>> > Moore, Catherine  writes:
>> >> > -Original Message-
>> >> > From: Steve Ellcey [mailto:sell...@mips.com]
>> >> > Sent: Friday, August 08, 2014 3:42 PM
>> >> > To: Moore, Catherine; matthew.fort...@imgtec.com; echri...@gmail.com;
>> >> >
>> >> > 2014-08-08  Steve Ellcey  
>> >> >
>> >> > * config/mips/mips.h (ASM_SPEC): Pass float options to assembler.
>> >> >
>> >> > diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index
>> >> > 8d7a09f..9a15287 100644
>> >> > --- a/gcc/config/mips/mips.h
>> >> > +++ b/gcc/config/mips/mips.h
>> >> > @@ -1187,6 +1187,8 @@ struct mips_cpu_info {  %{mshared} %{mno-
>> >> > shared} \  %{msym32} %{mno-sym32} \  %{mtune=*} \
>> >> > +%{mhard-float} %{msoft-float} \
>> >> > +%{msingle-float} %{mdouble-float} \
>> >> >  %(subtarget_asm_spec)"
>> >> >
>> >> >  /* Extra switches sometimes passed to the linker.  */
>> >> >
>> >>
>> >> Hi Steve,
>> >> The patch itself looks okay, but perhaps a question for Matthew.
>> >> Does the fact that the assembler requires -msoft-float even if .set
>> >> softfloat is present in the .s file deliberate behavior?
>> >
>> > The assembler requires -msoft-float if .gnu_attribute 4,3 is given. I.e.
>> the
>> > overall module options must match the ABI which has been specified. .set
>> > directives can still be used to override the 'current' options and be
>> > inconsistent with the overall module and/or .gnu_attribute setting.
>> >
>> >> I don't have a problem with passing along the *float* options to gas,
>> but
>> >> would hope that the .set options were honored as well.
>> >
>> > Yes they should be.
>> >
>> >> My short test indicated that the .set *float* options were being ignored
>> if
>> >> the correct command line option wasn't present.
>> >
>> > I'm not certain what you are describing here. Could you confirm with an
>> example
>> > just in case something is not working as expected?
>> >
>>
>> I don't have one offhand, but in skimming the binutils patch I don't
>> recall seeing anything that tested this combination. May have missed
>> it though.
>>
>> That said, the patch looks ok and if you'd like to add some tests for
>> .set and the command line options to binutils that'd be great as well.
>
> What sort of coverage do you think we need here? I did exhaustive coverage
> of anything which can affect the ABI but don't think we need the same for
> command-line options vs .module vs .set.
>

I probably would, but that's a different review thread the the patch
is already in so I'm not going to push it here :)

> There were two pre-existing tests: mips-hard-float-flag and
> mips-double-float-flag which pretty much test these cases I think. Is that
> OK for now until we identify any other areas which need additional
> coverage?

Sure.

-eric


Re: [c++-concepts] explicit instantiation and specialization

2014-08-13 Thread Andrew Sutton
Ah... sorry. Leftovers. I didn't have time to run a full bootstrap
build before heading out for a few days. I'll try to get those out
tomorrow afternoon-ish.

Andrew


On Wed, Aug 13, 2014 at 9:13 PM, Ed Smith-Rowland <3dw...@verizon.net> wrote:
> I get build fail:
>
> ../../gcc_concepts/gcc/cp/call.c:8793:8: error: unused variable ‘m1’
> [-Werror=unused-variable]
>tree m1 = get_temploid (cand1);
> ^
> ../../gcc_concepts/gcc/cp/call.c:8794:8: error: unused variable ‘m2’
> [-Werror=unused-variable]
>tree m2 = get_temploid (cand2);
> ^
> cc1plus: all warnings being treated as errors
>
> Commenting the lines let the build finish.
>
> Ed
>


Re: [PATCH] microblaze: microblaze.md: Use 'SI' instead of 'VOID' for operand 1 of 'call_value_intern'

2014-08-13 Thread Chen Gang

Firstly, thank you very much for spending your time resource on the
related 2 patches.

On 8/13/14 23:10, Michael Eager wrote:
> On 07/06/14 03:26, Chen Gang wrote:
>>
>>* microblaze/mocroblaze.md (call_value_intern): Use 'SI' instead of
>>'VOID' for operand 1, just like 'call_internal1' has done.
>>
>> The related warning:
>>
>>../../gcc/gcc/config/microblaze/microblaze.md:2172: warning: operand 1 
>> missing mode?
>>
>>
>> Signed-off-by: Chen Gang 
>> ---
>>   gcc/config/microblaze/microblaze.md | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/gcc/config/microblaze/microblaze.md 
>> b/gcc/config/microblaze/microblaze.md
>> index 2bd5d72..9580221 100644
>> --- a/gcc/config/microblaze/microblaze.md
>> +++ b/gcc/config/microblaze/microblaze.md
>> @@ -2171,7 +2171,7 @@
>>
>>   (define_insn "call_value_intern"
>> [(set (match_operand:VOID 0 "register_operand" "=d")
>> -(call (mem (match_operand:VOID 1 "call_insn_operand" "ri"))
>> +(call (mem (match_operand:SI 1 "call_insn_operand" "ri"))
>> (match_operand:SI 2 "" "i")))
>>  (clobber (match_operand:SI 3 "register_operand" "=d"))]
>> ""
> 
> This patch causes a test suite regression:
> 
> Executing on host: mb-gcc  -fno-diagnostics-show-caret 
> -fdiagnostics-color=never-O0  -w -c -mno-xl-soft-mul -mxl-barrel-shift 
> -mcpu=v6.00.a   -o calls.o testsuite/gcc.c-torture/compile/calls.c
> (timeout = 60)
> pid is 24832 -24832
> testsuite/gcc.c-torture/compile/calls.c: In function 'f1':
> testsuite/gcc.c-torture/compile/calls.c:6:1: error: unrecognizable insn:
> (call_insn 5 2 8 2 (parallel [
> (set (reg:SI 3 r3)
> (call (mem:SI (const_int 0 [0]) [0 MEM[(void * (*) 
> (void))0B] S4 A32])
> (const_int 24 [0x18])))
> (clobber (reg:SI 15 r15))
> ]) testsuite/gcc.c-torture/compile/calls.c:5 -1
>  (nil)
> (nil))
> testsuite/gcc.c-torture/compile/calls.c:6:1: internal compiler error: in 
> extract_insn, at recog.c:2204
> 0x983018 _fatal_insn(char const*, rtx_def const*, char const*, int, char 
> const*)
> /store/Xilinx/repo/fsf/gcc/gcc/rtl-error.c:109
> 0x983041 _fatal_insn_not_found(rtx_def const*, char const*, int, char const*)
> /store/Xilinx/repo/fsf/gcc/gcc/rtl-error.c:117
> 0x9539cd extract_insn(rtx_def*)
> /store/Xilinx/repo/fsf/gcc/gcc/recog.c:2204
> 0x7a5b59 instantiate_virtual_regs_in_insn
> /store/Xilinx/repo/fsf/gcc/gcc/function.c:1561
> 0x7aaa78 instantiate_virtual_regs
> /store/Xilinx/repo/fsf/gcc/gcc/function.c:1932
>

OK, thanks, and I shall analyze it, but excuse me, I have to do other
things this week, so hope I can finish it within next week (2014-08-24).
If this time point is too long to bare, please let me know.


Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed


Re: [c++-concepts] explicit instantiation and specialization

2014-08-13 Thread Ed Smith-Rowland

I get build fail:

../../gcc_concepts/gcc/cp/call.c:8793:8: error: unused variable ‘m1’ 
[-Werror=unused-variable]

   tree m1 = get_temploid (cand1);
^
../../gcc_concepts/gcc/cp/call.c:8794:8: error: unused variable ‘m2’ 
[-Werror=unused-variable]

   tree m2 = get_temploid (cand2);
^
cc1plus: all warnings being treated as errors

Commenting the lines let the build finish.

Ed



Re: [C++ PATCH] PR c++/62101

2014-08-13 Thread Ville Voutilainen
On 14 August 2014 03:41, Jason Merrill  wrote:
> On 08/13/2014 07:06 PM, Ville Voutilainen wrote:
>
> Looks good, but
>
>> +  int friendp = 0;
>
>
> Let's declare friendp when it's initialized.
>
> And I still need a ChangeLog entry.

Ok, modified patch attached. The changelog entry was attached to the previous
mail as an evil binary attachment (gmail...), here, for convenience:

/cp
2014-08-14  Ville Voutilainen  

PR c++/62101
* decl.c (grokdeclarator): Move the check for friend initializers..
* decl2.c (grokfield) ..here. Remove bogus comment about pure
specifiers, and postpone the previous early return for friends until
after the initializer check.

/testsuite
2014-08-14  Ville Voutilainen  

PR c++/62101
* g++.dg/cpp0x/pr62101.C: New
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 79e7362..92a6dbc 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9765,8 +9765,6 @@ grokdeclarator (const cp_declarator *declarator,
  }
else if (friendp)
  {
-   if (initialized)
- error ("can%'t initialize friend function %qs", name);
if (virtualp)
  {
/* Cannot be both friend and virtual.  */
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 1740a2e..875daf1 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -870,11 +870,6 @@ grokfield (const cp_declarator *declarator,
   if (value == void_type_node)
 return value;
 
-  /* Pass friend decls back.  */
-  if ((TREE_CODE (value) == FUNCTION_DECL
-   || TREE_CODE (value) == TEMPLATE_DECL)
-  && DECL_CONTEXT (value) != current_class_type)
-return value;
 
   name = DECL_NAME (value);
 
@@ -926,7 +921,9 @@ grokfield (const cp_declarator *declarator,
   return value;
 }
 
-  if (DECL_IN_AGGR_P (value))
+  int friendp = decl_spec_seq_has_spec_p (declspecs, ds_friend);
+
+  if (!friendp && DECL_IN_AGGR_P (value))
 {
   error ("%qD is already defined in %qT", value, DECL_CONTEXT (value));
   return void_type_node;
@@ -939,8 +936,6 @@ grokfield (const cp_declarator *declarator,
 {
   if (TREE_CODE (value) == FUNCTION_DECL)
{
- /* Initializers for functions are rejected early in the parser.
-If we get here, it must be a pure specifier for a method.  */
  if (init == ridpointers[(int)RID_DELETE])
{
  DECL_DELETED_FN (value) = 1;
@@ -971,8 +966,12 @@ grokfield (const cp_declarator *declarator,
  else
{
  gcc_assert (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE);
- error ("initializer specified for static member function %qD",
-value);
+ if (friendp)
+   error ("initializer specified for friend function %qD", 
+  value);
+ else
+   error ("initializer specified for static member function %qD",
+  value);
}
}
   else if (TREE_CODE (value) == FIELD_DECL)
@@ -981,6 +980,12 @@ grokfield (const cp_declarator *declarator,
gcc_unreachable ();
 }
 
+  /* Pass friend decls back.  */
+  if ((TREE_CODE (value) == FUNCTION_DECL
+   || TREE_CODE (value) == TEMPLATE_DECL)
+  && DECL_CONTEXT (value) != current_class_type)
+return value;
+
   if (processing_template_decl && VAR_OR_FUNCTION_DECL_P (value))
 {
   value = push_template_decl (value);
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr62101.C 
b/gcc/testsuite/g++.dg/cpp0x/pr62101.C
new file mode 100644
index 000..abec7f7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr62101.C
@@ -0,0 +1,32 @@
+// PR c++/62101
+// { dg-do compile { target c++11 } }
+
+struct X
+{
+  friend void g(X, int) = 0; // { dg-error "initializer specified for friend 
function" }
+  friend void g(X, int) = default; // { dg-error "cannot be defaulted" }
+  // { dg-prune-output "note" }
+  friend void f(X, int) = delete; 
+  friend void f(X, double) {}
+};
+
+struct Y;
+void g(Y, int);
+void g(Y, double);
+
+struct Y
+{
+  // { dg-prune-output "note" }
+  friend void g(Y, int) = delete;
+  friend void g(Y, double) {}
+};
+
+int main()
+{
+  X x;
+  f(x, 5.0);
+  f(x, 5); // { dg-error "use of deleted function" }
+  Y y;
+  g(y, 5.0);
+  g(y, 5); // { dg-error "use of deleted function" }
+}


Re: [C++ PATCH] PR c++/62101

2014-08-13 Thread Jason Merrill

On 08/13/2014 07:06 PM, Ville Voutilainen wrote:

Looks good, but


+  int friendp = 0;


Let's declare friendp when it's initialized.

And I still need a ChangeLog entry.

Jason



Re: [PATCH 000/236] Introduce rtx subclasses

2014-08-13 Thread David Malcolm
On Wed, 2014-08-06 at 13:19 -0400, David Malcolm wrote:
> This is the patch series I spoke about at Cauldron in the talk
> "A proposal for typesafe RTL"; slides here:
> http://dmalcolm.fedorapeople.org/presentations/cauldron-2014/rtl
> 
> They can also be seen at:
> https://dmalcolm.fedorapeople.org/gcc/patch-backups/rtx-classes/v20/

[...snip...]

> The patches (and my control for testing) has been on top of r211061, which
> being from 2014-05-29 is now two months old, but hopefully is still
> reviewable; naturally I'll perform bootstrap and regression testing for
> each patch in turn before committing.

FWIW I've now rebased the patches against today's trunk (specifically
r213914) and I've backed up the results to:
https://dmalcolm.fedorapeople.org/gcc/patch-backups/rtx-classes/v21/

Still TODO:
  * rename as_a_nullable<> to safe_as_a<>
  * eliminate rtx_real_insn
  * make various scaffolding functions be inline, updating gdbinit.in as
appropriate.

[...snip...]

Dave



Re: [PATCH 012/236] Convert DF_REF_INSN to a function for now

2014-08-13 Thread David Malcolm
On Wed, 2014-08-13 at 14:34 -0600, Jeff Law wrote:
> On 08/13/14 14:28, David Malcolm wrote:
> > Thanks.  Although this function gets converted back to a macro in patch
> > 191, I just realized that in the meantime that it's not inlined, as is
> > the case for some of the other macro->function conversions in patches
> > 13-16.
> >
> > Do I need to convert them to inline functions with the appropriate
> > headers, and is that regarded as a sufficiently trivial fix to the stuff
> > you've already reviewed to not need re-review? (I will bootstrap&test).
> I'd just make it a follow-up. #237 ;-)

Right, but these would be modifications to stuff that only exists
between phases 1-3 of the kit, before going away in phase 4, so although
it might be #237, it would need to be applied when the individual
changes go in.

> > Or is it OK to suffer the performance hit as the patchkit lands, before
> > they all become macros again in phase 4 of the patchkit?
> I think so.  This is a transient state, and my goal is to have this 
> stuff reviewed and get off the critical path before I go on PTO next week.

(FWIW I'm on PTO on Friday)

Transient, yes, but given the amount of time for me to simply bootstrap
each candidate patch, the non-inlined functions could last in trunk for
a couple of weeks (there are only 168 hours in a week, and a bootstrap
+regrtest takes about 3 hours on my box, so for 236 patches we're
talking ~4 weeks of compute time just for that).

I guess the underlying point here is that this is a big change and I'm
trying to be fastidious here.  Murphy's Law suggests I'm going to break
at least *something* :(

> > Note also that Jakub expressed concern about the effect of all these
> > inline functions on the debugging experience, and there's this patch
> > (awaiting review) which I believe addresses that:
> > https://gcc.gnu.org/ml/gcc-patches/2014-08/msg00743.html
> Make it #238.

Right.  I probably should move the link to the docs from the commit
message to a comment in the gdbinit.in itself.

Similar ordering considerations apply: I don't want to make debugging
painful on trunk for a few weeks - so this kind of thing would need to
go in as the inline functions go in.


> > Presumably similar changes to gdbinit.in should occur for the relevant
> > headers (e.g. df.h in this case, though possibly targeted to just the
> > new function - there are already quite a few inline functions in df.h)
> Yea, probably.

I guess I'll try to get you patches for this by end of tomorrow.

Thanks for all your reviewing
Dave



Re: [PATCH] Fix find_inc in the scheduler (take 2, PR target/62025)

2014-08-13 Thread Vladimir Makarov

On 2014-08-13, 6:30 PM, Jakub Jelinek wrote:

On Tue, Aug 12, 2014 at 05:12:41PM -0400, Vladimir Makarov wrote:

On 08/12/2014 03:35 PM, Jakub Jelinek wrote:

Hi!

As detailed in the PR, find_inc ignored any possible clobbers on
inc_insn (typically %cc/flags/etc. register) and thus we could ignore
all register dependencies between mem_insn and inc_insn even when
we could only safely ignore the mem_reg0 register dependency.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
Is slightly modified version (just for different iteration over defs and
uses) ok for 4.9?



Ok.  Thanks for fixing this PR, Jakub.


Unfortunately, after looking at the code some more, there are further issues
(theoretical only, don't have testcases).

Here is an incremental patch that I'm bootstrapping/regtesting with
additional instrumentation.

Apparently find_inc handles both the cases where the increment can initially
dominate the mem insn or vice versa.

My patch from yesterday was trying to fix the case where we have:

mem_insn uses %rX in memory address, uses %flags
...
inc_insn %rX += const, clobbers %flags

where it is wrong to move inc_insn before mem_insn, because if it is moved
in between %flags setter before mem_insn and mem_insn, %flags might have
wrong value.

I think giving up for this if mem_insn is dominated originally by inc_insn
is unnecessary, there should be a dependency between %flags setter and
inc_insn which should prevent the move.

find_inc checks that inc_insn is single_set doing %rX += const or
%rX = %rY + const, so the only defs other than %rX IMHO must be clobbers.

But what I see as a problematic case (in my statistics dumps) is:

inc_insn %rX += const, clobbers %flags
...
mem_insn uses %rX in memory address, sets %flags

In this case, moving inc_insn after mem_insn is wrong, if inc_insn is moved
in between mem_insn and the user of %flags after it.  This (potential)
wrong-code I've seen 9611 times in 32-bit code and so far 766 times in
64-bit code during the two bootstraps/regtests.

The case when both inc_insn and mem_insn both clobber the same reg (seems to
happen fairly often, with %flags) is IMHO not a problem.

Also, we've discussed with Vlad on IRC the (theoretical?) possibility that
inc_insn could have also USE rtxs in the pattern beyond the single set and
possible clobbers.  In that case, we don't want to move it either way if
mem_insn defines the reg used in the USE.  Note, no cases found in
x86_64-linux and i686-linux bootstrap statistics dumps.

So, does this make sense?



What a brain damaged excercise to analyze cases for the patch especially 
at the end of day:)  But I believe the patch is ok.


Only minor thing.  Please, read my comments below.


2014-08-14  Jakub Jelinek  

PR target/62025
* sched-deps.c (find_inc): Limit the test for inc_insn defs
vs. mem_insn uses to !backwards case only.  Give up also if
any mem_insn def is used by inc_insn or if non-clobber
mem_insn def in backwards case is clobbered by inc_insn.

--- gcc/sched-deps.c.jj 2014-08-12 17:06:26.0 +0200
+++ gcc/sched-deps.c2014-08-14 00:09:38.0 +0200
@@ -4751,24 +4751,54 @@ find_inc (struct mem_inc_info *mii, bool
   "inc conflicts with store failure.\n");
goto next;
  }
-
- /* The inc instruction could have clobbers, make sure those
-registers are not used in mem insn.  */
- FOR_EACH_INSN_DEF (def, mii->inc_insn)
-   if (!reg_overlap_mentioned_p (DF_REF_REG (def), mii->mem_reg0))
+   else
  {
-   df_ref use;
-   FOR_EACH_INSN_USE (use, mii->mem_insn)
+   df_ref use, def2;
+   FOR_EACH_INSN_USE (use, mii->inc_insn)
  if (reg_overlap_mentioned_p (DF_REF_REG (def),
   DF_REF_REG (use)))
{
  if (sched_verbose >= 5)
fprintf (sched_dump,
-"inc clobber used in store failure.\n");
+"mem def conflict with inc use failure.\n");
  goto next;
}
+   /* DEFS in inc_insn other than mem_reg0 should be always
+  clobbers.


It can be unused set too (not only clobbers) and single_set will still 
return non-null.


inc_insn: def R, def R2, unused R2
mem_insn: use R, def R2
...
use R2

But the code still works in this case.  So I'd only modify the comment.

  If both inc_insn and mem_insn clobber the same

+  register, it is fine, but avoid the case where mem_insn e.g.
+  sets CC and originally earlier inc_insn clobbers it.  */
+   if ((DF_REF_FLAGS (def) & DF_REF_MUST_CLOBBER) == 0
+   && backwards)
+ FOR_EACH_INSN_DEF (def2, mii->inc_insn)
+   if (reg_overlap_menti

[PATCH,rs6000] Add pass to optimize away xxpermdi's from vector computations

2014-08-13 Thread Bill Schmidt
Hi,

This patch adds a PowerPC-specific pass just prior to the first cse RTL
pass.  The pass runs only when generating little-endian code for Power8
with VSX enabled, and for -O1 and up.  For this particular subtarget,
the use of the big-endian-biased vector load and store instructions
requires permutations to order vector elements for little endian.  To
reduce the overhead of these permutations, this pass looks for
computations for which the exact lanes in which computations are
performed does not matter, so long as the results are returned to
storage in the proper order.  For such computations we can remove the
xxpermdi's associated with the vector loads and stores.

This patch relies on another patch posted today that converts a struct
used by the web pass into a base class that this patch can subclass.  If
it's determined that the other patch isn't appropriate, then this patch
will need modifications to duplicate the union-find logic.

A complete description of the new pass appears in rs6000.c (search for
"Analyze vector computations").  That description also identifies some
remaining opportunities we can follow up with later.

A number of new tests are added to verify that the pass works as
expected for some vectorized code samples.

Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no
regressions.  Is this ok for trunk?

Thanks,
Bill


[gcc]

2014-08-13  Bill Schmidt  

* config/rs6000/rs6000.c (context.h): New include.
(tree-pass.h): Likewise.
(make_pass_analyze_swaps): New decl.
(rs6000_option_override): Register pass_analyze_swaps.
(swap_web_entry): New subsclass of web_entry_base (df.h).
(special_handling_values): New enum.
(union_defs): New function.
(union_uses): Likewise.
(insn_is_load_p): Likewise.
(insn_is_store_p): Likewise.
(insn_is_swap_p): Likewise.
(rtx_is_swappable_p): Likewise.
(insn_is_swappable_p): Likewise.
(chain_purpose): New enum.
(chain_contains_only_swaps): New function.
(mark_swaps_for_removal): Likewise.
(swap_const_vector_halves): Likewise.
(adjust_subreg_index): Likewise.
(permute_load): Likewise.
(permute_store): Likewise.
(handle_special_swappables): Likewise.
(replace_swap_with_copy): Likewise.
(dump_swap_insn_table): Likewise.
(rs6000_analyze_swaps): Likewise.
(pass_data_analyze_swaps): New pass_data.
(pass_analyze_swaps): New rtl_opt_pass.
(make_pass_analyze_swaps): New function.
* config/rs6000/rs6000.opt (moptimize-swaps): New option.

[gcc/testsuite]

2014-08-13  Bill Schmidt  

* gcc.target/powerpc/swaps-p8-1.c: New test.
* gcc.target/powerpc/swaps-p8-2.c: New test.
* gcc.target/powerpc/swaps-p8-3.c: New test.
* gcc.target/powerpc/swaps-p8-4.c: New test.
* gcc.target/powerpc/swaps-p8-5.c: New test.
* gcc.target/powerpc/swaps-p8-6.c: New test.
* gcc.target/powerpc/swaps-p8-7.c: New test.
* gcc.target/powerpc/swaps-p8-8.c: New test.
* gcc.target/powerpc/swaps-p8-9.c: New test.
* gcc.target/powerpc/swaps-p8-10.c: New test.
* gcc.target/powerpc/swaps-p8-11.c: New test.
* gcc.target/powerpc/swaps-p8-12.c: New test.


Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 213923)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -79,6 +79,8 @@
 #include "cgraph.h"
 #include "target-globals.h"
 #include "builtins.h"
+#include "context.h"
+#include "tree-pass.h"
 #if TARGET_XCOFF
 #include "xcoffout.h"  /* get declarations of xcoff_*_section_name */
 #endif
@@ -1170,6 +1172,7 @@ static bool rs6000_secondary_reload_move (enum rs6
  enum machine_mode,
  secondary_reload_info *,
  bool);
+rtl_opt_pass *make_pass_analyze_swaps (gcc::context*);
 
 /* Hash table stuff for keeping track of TOC entries.  */
 
@@ -4085,6 +4088,15 @@ static void
 rs6000_option_override (void)
 {
   (void) rs6000_option_override_internal (true);
+
+  /* Register machine-specific passes.  This needs to be done at start-up.
+ It's convenient to do it here (like i386 does).  */
+  opt_pass *pass_analyze_swaps = make_pass_analyze_swaps (g);
+
+  static struct register_pass_info analyze_swaps_info
+= { pass_analyze_swaps, "cse1", 1, PASS_POS_INSERT_BEFORE };
+
+  register_pass (&analyze_swaps_info);
 }
 
 
@@ -33370,7 +33382,1045 @@ emit_fusion_gpr_load (rtx *operands)
 
   return "";
 }
+
+/* Analyze vector computations and remove unnecessary doubleword
+   swaps (xxswapdi instructions).  This pass is performed only
+   for little-endian VSX code generation for the Power8 target.
 
+   For this specific case, loads and stores of 4x32 and 2x64 vectors
+   are inef

[C++ PATCH] PR c++/62101

2014-08-13 Thread Ville Voutilainen
We didn't allow deleted friend definitions, because that was diagnosed
in grokdeclarator, which doesn't have knowledge of the kind of a function
declaration "initializer". Move the test to grokfield and adjust where
necessary. Tested on Linux x86-64.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 79e7362..92a6dbc 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -9765,8 +9765,6 @@ grokdeclarator (const cp_declarator *declarator,
  }
else if (friendp)
  {
-   if (initialized)
- error ("can%'t initialize friend function %qs", name);
if (virtualp)
  {
/* Cannot be both friend and virtual.  */
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 1740a2e..5fa689a 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -846,6 +846,7 @@ grokfield (const cp_declarator *declarator,
   const char *asmspec = 0;
   int flags;
   tree name;
+  int friendp = 0;
 
   if (init
   && TREE_CODE (init) == TREE_LIST
@@ -870,11 +871,6 @@ grokfield (const cp_declarator *declarator,
   if (value == void_type_node)
 return value;
 
-  /* Pass friend decls back.  */
-  if ((TREE_CODE (value) == FUNCTION_DECL
-   || TREE_CODE (value) == TEMPLATE_DECL)
-  && DECL_CONTEXT (value) != current_class_type)
-return value;
 
   name = DECL_NAME (value);
 
@@ -926,7 +922,9 @@ grokfield (const cp_declarator *declarator,
   return value;
 }
 
-  if (DECL_IN_AGGR_P (value))
+  friendp = decl_spec_seq_has_spec_p (declspecs, ds_friend);
+
+  if (!friendp && DECL_IN_AGGR_P (value))
 {
   error ("%qD is already defined in %qT", value, DECL_CONTEXT (value));
   return void_type_node;
@@ -939,8 +937,6 @@ grokfield (const cp_declarator *declarator,
 {
   if (TREE_CODE (value) == FUNCTION_DECL)
{
- /* Initializers for functions are rejected early in the parser.
-If we get here, it must be a pure specifier for a method.  */
  if (init == ridpointers[(int)RID_DELETE])
{
  DECL_DELETED_FN (value) = 1;
@@ -971,8 +967,12 @@ grokfield (const cp_declarator *declarator,
  else
{
  gcc_assert (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE);
- error ("initializer specified for static member function %qD",
-value);
+ if (friendp)
+   error ("initializer specified for friend function %qD", 
+  value);
+ else
+   error ("initializer specified for static member function %qD",
+  value);
}
}
   else if (TREE_CODE (value) == FIELD_DECL)
@@ -981,6 +981,12 @@ grokfield (const cp_declarator *declarator,
gcc_unreachable ();
 }
 
+  /* Pass friend decls back.  */
+  if ((TREE_CODE (value) == FUNCTION_DECL
+   || TREE_CODE (value) == TEMPLATE_DECL)
+  && DECL_CONTEXT (value) != current_class_type)
+return value;
+
   if (processing_template_decl && VAR_OR_FUNCTION_DECL_P (value))
 {
   value = push_template_decl (value);
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr62101.C 
b/gcc/testsuite/g++.dg/cpp0x/pr62101.C
new file mode 100644
index 000..abec7f7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr62101.C
@@ -0,0 +1,32 @@
+// PR c++/62101
+// { dg-do compile { target c++11 } }
+
+struct X
+{
+  friend void g(X, int) = 0; // { dg-error "initializer specified for friend 
function" }
+  friend void g(X, int) = default; // { dg-error "cannot be defaulted" }
+  // { dg-prune-output "note" }
+  friend void f(X, int) = delete; 
+  friend void f(X, double) {}
+};
+
+struct Y;
+void g(Y, int);
+void g(Y, double);
+
+struct Y
+{
+  // { dg-prune-output "note" }
+  friend void g(Y, int) = delete;
+  friend void g(Y, double) {}
+};
+
+int main()
+{
+  X x;
+  f(x, 5.0);
+  f(x, 5); // { dg-error "use of deleted function" }
+  Y y;
+  g(y, 5.0);
+  g(y, 5); // { dg-error "use of deleted function" }
+}


pr62101.changelog
Description: Binary data


[PATCH] Make web_entry subclassable

2014-08-13 Thread Bill Schmidt
Hi,

I want to reuse some of the infrastructure in web.c (and df.h) for a
target-specific RTL pass, particularly the union-find stuff.  I could
just copy it, I suppose, but it seems better to make the struct
web_entry into a class so that I can inherit what I need.  That's what
this patch does.

When I talked about this with some other folks, they mentioned that
there has been talk of eliminating the web pass altogether, so that
might be an argument in favor of just copying the logic.  I am happy to
do that if that's deemed preferable.

I've taken the original struct and made it a base class that only
retains the pred field from the original class, along with the
union-find code.  The reg field is something I don't need, so I've moved
that into a subclass that the web code now uses.  I've removed the
extra_info field, which is not used and no longer makes sense with
inheritance available.  The rest of the changes are just adjusting to
these modifications.

I didn't overly "C++ify" anything, to keep the changes as non-invasive
as possible.

I'll post the PowerPC patch that makes use of the subclassing shortly.

Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no
regressions.  Is this ok for trunk?

Thanks,
Bill


2014-08-13  Bill Schmidt  

* df.h (web_entry_base): Replace existing struct web_entry with a
new class web_entry_base with only the predecessor member.
(unionfind_root): Remove declaration and move to class member.
(unionfind_union): Remove declaration and move to friend
function.
(union_defs): Remove declaration.
* web.c (web_entry_base::unionfind_root): Modify to be member
function and adjust accessors.
(unionfind_union): Modify to be friend function and adjust
accessors.
(web_entry): New subclass of web_entry_base containing the reg
member.
(union_match_dups): Modify for struct -> class changes.
(union_defs): Likewise.
(entry_register): Likewise.
(pass_web::execute): Likewise.


Index: gcc/df.h
===
--- gcc/df.h(revision 213923)
+++ gcc/df.h(working copy)
@@ -1184,20 +1184,22 @@ df_single_use (const df_insn_info *info)
 
 /* web */
 
-/* This entry is allocated for each reference in the insn stream.  */
-struct web_entry
+class web_entry_base
 {
-  /* Pointer to the parent in the union/find tree.  */
-  struct web_entry *pred;
-  /* Newly assigned register to the entry.  Set only for roots.  */
-  rtx reg;
-  void* extra_info;
+ private:
+  /* Reference to the parent in the union/find tree.  */
+  web_entry_base *pred_pvt;
+
+ public:
+  /* Accessors.  */
+  web_entry_base *pred () { return pred_pvt; }
+  void set_pred (web_entry_base *p) { pred_pvt = p; }
+
+  /* Find representative in union-find tree.  */
+  web_entry_base *unionfind_root ();
+
+  /* Union with another set, returning TRUE if they are already unioned.  */
+  friend bool unionfind_union (web_entry_base *first, web_entry_base *second);
 };
 
-extern struct web_entry *unionfind_root (struct web_entry *);
-extern bool unionfind_union (struct web_entry *, struct web_entry *);
-extern void union_defs (df_ref, struct web_entry *,
-   unsigned int *used, struct web_entry *,
-   bool (*fun) (struct web_entry *, struct web_entry *));
-
 #endif /* GCC_DF_H */
Index: gcc/web.c
===
--- gcc/web.c   (revision 213923)
+++ gcc/web.c   (working copy)
@@ -53,17 +53,17 @@ along with GCC; see the file COPYING3.  If not see
 
 /* Find the root of unionfind tree (the representative of set).  */
 
-struct web_entry *
-unionfind_root (struct web_entry *element)
+web_entry_base *
+web_entry_base::unionfind_root ()
 {
-  struct web_entry *element1 = element, *element2;
+  web_entry_base *element = this, *element1 = this, *element2;
 
-  while (element->pred)
-element = element->pred;
-  while (element1->pred)
+  while (element->pred ())
+element = element->pred ();
+  while (element1->pred ())
 {
-  element2 = element1->pred;
-  element1->pred = element;
+  element2 = element1->pred ();
+  element1->set_pred (element);
   element1 = element2;
 }
   return element;
@@ -74,23 +74,32 @@ along with GCC; see the file COPYING3.  If not see
nothing is done.  Otherwise, return false.  */
 
 bool
-unionfind_union (struct web_entry *first, struct web_entry *second)
+unionfind_union (web_entry_base *first, web_entry_base *second)
 {
-  first = unionfind_root (first);
-  second = unionfind_root (second);
+  first = first->unionfind_root ();
+  second = second->unionfind_root ();
   if (first == second)
 return true;
-  second->pred = first;
+  second->set_pred (first);
   return false;
 }
 
+class web_entry : public web_entry_base
+{
+ private:
+  rtx reg_pvt;
+
+ public:
+  rtx reg () { return reg_pvt; }
+  voi

Re: __intN patch 3/5: main __int128 -> __intN conversion.

2014-08-13 Thread DJ Delorie

> A while ago I've removed a couple of those 'typedef struct' things, as
> they are not required in C++ anymore.  Is there any particular reason
> why this couldn't be simply 'struct int_n_data_t' ?

No particular reason.


Go patch committed: Fix unexpected GC interfering with closure passing

2014-08-13 Thread Ian Lance Taylor
The Go frontend passes closures through to functions using the functions
__go_set_closure and __go_get_closure.  The expectation is that there
are no function calls between set_closure and get_closure.  However, it
turns out that there can be function calls if some of the function
arguments require type conversion to an interface type.  Converting to
an interface type can allocate memory, and that can in turn trigger a
garbage collection, and that can in turn call pool cleanup functions
that may call __go_set_closure.  So the called function can see the
wrong closure value, which is bad.

This patch fixes the problem in two different ways.  First, we move all
type conversions in function arguments into temporary variables so that
they can not appear before the call to __go_set_closure.  (This required
shifting the flatten phase after the simplify_thunk phase, since the
latter expects to work with unconverted argument types.)  Second, we fix
the memory allocation function to preserve the closure value across any
possible garbage collection.

A test case is the libgo database/sql check run with the environment
variable GOGC set to 1.

Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.  I committed just the patch to the memory
allocation function to the 4.9 branch--the 4.9 branch doesn't have the
framework for the frontend patch.

Ian

diff -r f66917501eac go/expressions.cc
--- a/go/expressions.cc	Mon Aug 11 12:25:44 2014 -0700
+++ b/go/expressions.cc	Wed Aug 13 14:50:37 2014 -0700
@@ -9013,8 +9013,51 @@
 // Flatten a call with multiple results into a temporary.
 
 Expression*
-Call_expression::do_flatten(Gogo*, Named_object*, Statement_inserter* inserter)
-{
+Call_expression::do_flatten(Gogo* gogo, Named_object*,
+			Statement_inserter* inserter)
+{
+  if (this->classification() == EXPRESSION_ERROR)
+return this;
+
+  // Add temporary variables for all arguments that require type
+  // conversion.
+  Function_type* fntype = this->get_function_type();
+  go_assert(fntype != NULL);
+  if (this->args_ != NULL && !this->args_->empty()
+  && fntype->parameters() != NULL && !fntype->parameters()->empty())
+{
+  bool is_interface_method =
+	this->fn_->interface_field_reference_expression() != NULL;
+
+  Expression_list *args = new Expression_list();
+  Typed_identifier_list::const_iterator pp = fntype->parameters()->begin();
+  Expression_list::const_iterator pa = this->args_->begin();
+  if (!is_interface_method && fntype->is_method())
+	{
+	  // The receiver argument.
+	  args->push_back(*pa);
+	  ++pa;
+	}
+  for (; pa != this->args_->end(); ++pa, ++pp)
+	{
+	  go_assert(pp != fntype->parameters()->end());
+	  if (Type::are_identical(pp->type(), (*pa)->type(), true, NULL))
+	args->push_back(*pa);
+	  else
+	{
+	  Location loc = (*pa)->location();
+	  Expression* arg =
+		Expression::convert_for_assignment(gogo, pp->type(), *pa, loc);
+	  Temporary_statement* temp =
+		Statement::make_temporary(pp->type(), arg, loc);
+	  inserter->insert(temp);
+	  args->push_back(Expression::make_temporary_reference(temp, loc));
+	}
+	}
+  delete this->args_;
+  this->args_ = args;
+}
+
   size_t rc = this->result_count();
   if (rc > 1 && this->call_temp_ == NULL)
 {
diff -r f66917501eac go/go.cc
--- a/go/go.cc	Mon Aug 11 12:25:44 2014 -0700
+++ b/go/go.cc	Wed Aug 13 14:50:37 2014 -0700
@@ -124,15 +124,15 @@
   // Convert named types to backend representation.
   ::gogo->convert_named_types();
 
-  // Flatten the parse tree.
-  ::gogo->flatten();
-
   // Build thunks for functions which call recover.
   ::gogo->build_recover_thunks();
 
   // Convert complicated go and defer statements into simpler ones.
   ::gogo->simplify_thunk_statements();
 
+  // Flatten the parse tree.
+  ::gogo->flatten();
+
   // Dump ast, use filename[0] as the base name
   ::gogo->dump_ast(filenames[0]);
 }
diff -r f66917501eac libgo/runtime/malloc.goc
--- a/libgo/runtime/malloc.goc	Mon Aug 11 12:25:44 2014 -0700
+++ b/libgo/runtime/malloc.goc	Wed Aug 13 14:50:37 2014 -0700
@@ -84,6 +84,7 @@
 	MLink *v, *next;
 	byte *tiny;
 	bool incallback;
+	void *closure;
 
 	if(size == 0) {
 		// All 0-length allocations use this pointer.
@@ -95,6 +96,10 @@
 	m = runtime_m();
 	g = runtime_g();
 
+	// We should not be called in between __go_set_closure and the
+	// actual function call, but cope with it if we are.
+	closure = g->closure;
+
 	incallback = false;
 	if(m->mcache == nil && g->ncgo > 0) {
 		// For gccgo this case can occur when a cgo or SWIG function
@@ -175,6 +180,7 @@
 	m->locks--;
 	if(incallback)
 		runtime_entersyscall();
+	g->closure = closure;
 	return v;
 }
 			}
@@ -264,6 +270,8 @@
 	if(incallback)
 		runtime_entersyscall();
 
+	g->closure = closure;
+
 	return v;
 }
 


[PATCH] Fix find_inc in the scheduler (take 2, PR target/62025)

2014-08-13 Thread Jakub Jelinek
On Tue, Aug 12, 2014 at 05:12:41PM -0400, Vladimir Makarov wrote:
> On 08/12/2014 03:35 PM, Jakub Jelinek wrote:
> > Hi!
> >
> > As detailed in the PR, find_inc ignored any possible clobbers on
> > inc_insn (typically %cc/flags/etc. register) and thus we could ignore
> > all register dependencies between mem_insn and inc_insn even when
> > we could only safely ignore the mem_reg0 register dependency.
> >
> > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> > Is slightly modified version (just for different iteration over defs and
> > uses) ok for 4.9?
> >
> >
> Ok.  Thanks for fixing this PR, Jakub.

Unfortunately, after looking at the code some more, there are further issues
(theoretical only, don't have testcases).

Here is an incremental patch that I'm bootstrapping/regtesting with
additional instrumentation.

Apparently find_inc handles both the cases where the increment can initially
dominate the mem insn or vice versa.

My patch from yesterday was trying to fix the case where we have:

mem_insn uses %rX in memory address, uses %flags
...
inc_insn %rX += const, clobbers %flags

where it is wrong to move inc_insn before mem_insn, because if it is moved
in between %flags setter before mem_insn and mem_insn, %flags might have
wrong value.

I think giving up for this if mem_insn is dominated originally by inc_insn
is unnecessary, there should be a dependency between %flags setter and
inc_insn which should prevent the move.

find_inc checks that inc_insn is single_set doing %rX += const or
%rX = %rY + const, so the only defs other than %rX IMHO must be clobbers.

But what I see as a problematic case (in my statistics dumps) is:

inc_insn %rX += const, clobbers %flags
...
mem_insn uses %rX in memory address, sets %flags

In this case, moving inc_insn after mem_insn is wrong, if inc_insn is moved
in between mem_insn and the user of %flags after it.  This (potential)
wrong-code I've seen 9611 times in 32-bit code and so far 766 times in
64-bit code during the two bootstraps/regtests.

The case when both inc_insn and mem_insn both clobber the same reg (seems to
happen fairly often, with %flags) is IMHO not a problem.

Also, we've discussed with Vlad on IRC the (theoretical?) possibility that
inc_insn could have also USE rtxs in the pattern beyond the single set and
possible clobbers.  In that case, we don't want to move it either way if
mem_insn defines the reg used in the USE.  Note, no cases found in
x86_64-linux and i686-linux bootstrap statistics dumps.

So, does this make sense?

2014-08-14  Jakub Jelinek  

PR target/62025
* sched-deps.c (find_inc): Limit the test for inc_insn defs
vs. mem_insn uses to !backwards case only.  Give up also if
any mem_insn def is used by inc_insn or if non-clobber
mem_insn def in backwards case is clobbered by inc_insn.

--- gcc/sched-deps.c.jj 2014-08-12 17:06:26.0 +0200
+++ gcc/sched-deps.c2014-08-14 00:09:38.0 +0200
@@ -4751,24 +4751,54 @@ find_inc (struct mem_inc_info *mii, bool
   "inc conflicts with store failure.\n");
goto next;
  }
-
- /* The inc instruction could have clobbers, make sure those
-registers are not used in mem insn.  */
- FOR_EACH_INSN_DEF (def, mii->inc_insn)
-   if (!reg_overlap_mentioned_p (DF_REF_REG (def), mii->mem_reg0))
+   else
  {
-   df_ref use;
-   FOR_EACH_INSN_USE (use, mii->mem_insn)
+   df_ref use, def2;
+   FOR_EACH_INSN_USE (use, mii->inc_insn)
  if (reg_overlap_mentioned_p (DF_REF_REG (def),
   DF_REF_REG (use)))
{
  if (sched_verbose >= 5)
fprintf (sched_dump,
-"inc clobber used in store failure.\n");
+"mem def conflict with inc use failure.\n");
  goto next;
}
+   /* DEFS in inc_insn other than mem_reg0 should be always
+  clobbers.  If both inc_insn and mem_insn clobber the same
+  register, it is fine, but avoid the case where mem_insn e.g.
+  sets CC and originally earlier inc_insn clobbers it.  */
+   if ((DF_REF_FLAGS (def) & DF_REF_MUST_CLOBBER) == 0
+   && backwards)
+ FOR_EACH_INSN_DEF (def2, mii->inc_insn)
+   if (reg_overlap_mentioned_p (DF_REF_REG (def),
+DF_REF_REG (def2)))
+ {
+   if (sched_verbose >= 5)
+ fprintf (sched_dump,
+  "mem def conflict with inc def failure.\n");
+   goto next;
+ }
  }
 
+ /* The inc instruction could have clobbers, 

Re: __intN patch 3/5: main __int128 -> __intN conversion.

2014-08-13 Thread Oleg Endo
On Wed, 2014-08-13 at 18:11 -0400, DJ Delorie wrote:
> This is the main __int128 -> __intN conversion patch.  We support up
> to four __int types per target, which may include __int128.  I
> include the minimal change to the msp430 backend to illustrate how to
> add a target-specific __int type.
> 
> [...]
> Index: gcc/machmode.h
> ===
> --- gcc/machmode.h(revision 213886)
> +++ gcc/machmode.h(working copy)
> @@ -342,7 +342,19 @@ extern void init_adjust_machine_modes (v
>GET_MODE_PRECISION (MODE2))
>  
>  #define HWI_COMPUTABLE_MODE_P(MODE) \
>(SCALAR_INT_MODE_P (MODE) \
> && GET_MODE_PRECISION (MODE) <= HOST_BITS_PER_WIDE_INT)
>  
> +typedef struct {
> +  /* These parts are initailized by genmodes output */
> +  unsigned int bitsize;
> +  enum machine_mode m;
> +  /* RID_* is RID_INTN_BASE + index into this array */
> +} int_n_data_t;
> +

A while ago I've removed a couple of those 'typedef struct' things, as
they are not required in C++ anymore.  Is there any particular reason
why this couldn't be simply 'struct int_n_data_t' ?

Cheers,
Oleg




Re: [Patch] Fix crtstuff.c when compiling with mingw tools.

2014-08-13 Thread Kai Tietz
2014-08-13 22:51 GMT+02:00 Steve Ellcey :
> On Wed, 2014-08-13 at 20:42 +, Joseph S. Myers wrote:
>> On Wed, 13 Aug 2014, Steve Ellcey  wrote:
>>
>> > This is a ping on a patch I sent out a while ago to fix the GCC build
>> > when building with the mingw toolset.
>>
>> This is not a review.
>>
>> When pinging, please give *the gcc.gnu.org URL of the patch being pinged*.
>
> Good point, here is the last patch email I sent:
>
> https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00018.html
>
> For some reason this doesn't reference the original patch at:
>
> https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01577.html
>
> Steve Ellcey
> sell...@mips.com
>

Hi Steve,

patch is ok.  Please apply.

Thanks,
Kai


__intN patch 4/5: testsuite updates

2014-08-13 Thread DJ Delorie

Changes to the testsuite to make tests more portable to targets with
unusual address spaces.

* testsuite/
* lib/target-supports.exp (check_effective_target_size32plus):
Increase size to avoid false positives on 24-bit address spaces.
* gcc.c-torture/compile/limits-stringlit.c: Skip if msp430.
* gcc.dg/lto/pr54709_1.c: Fix memcpy prototype.
* gcc.dg/torture/pta-ptrarith-3.c: Use __SIZE_TYPE__ instead of "int".
* gcc.dg/torture/pr36373-10.c: Use __SIZE_TYPE__ if present.
* gcc.dg/torture/pr57864.c: Use __SIZE_TYPE__.
* gcc.dg/torture/pr26763-2.c: Use __SIZE_TYPE__ instead of "int".
* gcc.dg/tree-ssa/isolate-3.c: Use __SIZE_TYPE__ instead of "long 
unsigned int".
* gcc.dg/tree-ssa/isolate-3.c: Likewise.
* gcc.dg/pr52549.c: Use __SIZE_TYPE__ if present.

Index: gcc/testsuite/lib/target-supports.exp
===
--- gcc/testsuite/lib/target-supports.exp   (revision 213886)
+++ gcc/testsuite/lib/target-supports.exp   (working copy)
@@ -1806,17 +1806,18 @@ proc check_effective_target_ptr32plus { 
 return [check_no_compiler_messages ptr32plus object {
int dummy[sizeof (void *) >= 4 ? 1 : -1];
 }]
 }
 
 # Return 1 if we support 32-bit or larger array and structure sizes
-# using default options, 0 otherwise.
+# using default options, 0 otherwise.  Avoid false positive on
+# targets with 20 or 24 bit address spaces.
 
 proc check_effective_target_size32plus { } {
 return [check_no_compiler_messages size32plus object {
-   char dummy[65537];
+   char dummy[16777217L];
 }]
 }
 
 # Returns 1 if we're generating 16-bit or smaller integers with the
 # default options, 0 otherwise.
 
Index: gcc/testsuite/gcc.c-torture/compile/limits-stringlit.c
===
--- gcc/testsuite/gcc.c-torture/compile/limits-stringlit.c  (revision 
213886)
+++ gcc/testsuite/gcc.c-torture/compile/limits-stringlit.c  (working copy)
@@ -1,7 +1,7 @@
-/* { dg-skip-if "Array too big" { avr-*-* picochip-*-* m32c-*-* pdp11-*-* } { 
"*" } { "" } } */ 
+/* { dg-skip-if "Array too big" { avr-*-* picochip-*-* m32c-*-* pdp11-*-* 
msp430-*-* } { "*" } { "" } } */ 
 
 #define STR2 "012345678901234567890123456789012345678901234567890123456789\
 0123456789012345678901234567890123456789"
 #define STR3 STR2 STR2 STR2 STR2 STR2 STR2 STR2 STR2 STR2 STR2
 #define STR4 STR3 STR3 STR3 STR3 STR3 STR3 STR3 STR3 STR3 STR3
 #define STR5 STR4 STR4 STR4 STR4 STR4 STR4 STR4 STR4 STR4 STR4
Index: gcc/testsuite/gcc.dg/lto/pr54709_1.c
===
--- gcc/testsuite/gcc.dg/lto/pr54709_1.c(revision 213886)
+++ gcc/testsuite/gcc.dg/lto/pr54709_1.c(working copy)
@@ -1,5 +1,5 @@
-void * memcpy (void *, void *, long);
+void * memcpy (void *, void *, __SIZE_TYPE__);
 void bar (void *p, void *q, unsigned s)
 {
   memcpy (p, q, s);
 }
Index: gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c
===
--- gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c   (revision 213886)
+++ gcc/testsuite/gcc.dg/torture/pta-ptrarith-3.c   (working copy)
@@ -6,13 +6,13 @@ extern void abort (void);
 struct X {
   int *p;
   int *q;
   int *r;
 };
 int __attribute__((noinline))
-foo(int i, int j, int k, int off)
+foo(int i, int j, int k, __SIZE_TYPE__ off)
 {
   struct X x;
   int **p, *q;
   x.p = &i;
   x.q = &j;
   x.r = &k;
Index: gcc/testsuite/gcc.dg/torture/pr36373-10.c
===
--- gcc/testsuite/gcc.dg/torture/pr36373-10.c   (revision 213886)
+++ gcc/testsuite/gcc.dg/torture/pr36373-10.c   (working copy)
@@ -1,9 +1,11 @@
 /* { dg-do run } */
 
-#if (__SIZEOF_LONG_LONG__ == __SIZEOF_POINTER__)
+#ifdef __SIZE_TYPE__
+typedef __SIZE_TYPE__ uintptr_t;
+#elif (__SIZEOF_LONG_LONG__ == __SIZEOF_POINTER__)
 typedef unsigned long long uintptr_t;
 #elif (__SIZEOF_LONG__ == __SIZEOF_POINTER__)
 typedef unsigned long uintptr_t;
 #elif (__SIZEOF_INT__ == __SIZEOF_POINTER__)
 typedef unsigned int uintptr_t;
 #else
Index: gcc/testsuite/gcc.dg/torture/pr57864.c
===
--- gcc/testsuite/gcc.dg/torture/pr57864.c  (revision 213886)
+++ gcc/testsuite/gcc.dg/torture/pr57864.c  (working copy)
@@ -12,18 +12,18 @@ int c;
 
 static void fn1(union U *p1, int p2, _Bool p3)
 {
 union U *e;
 
 if (p2 == 0)
-   a = ((union U*)((unsigned long)p1 & ~1))->val;
+   a = ((union U*)((__SIZE_TYPE__)p1 & ~1))->val;
 
 if (b) {
e = p1;
 } else if (c) {
-   e = ((union U*)((unsigned long)p1 & ~1))->ptr;
+   e = ((union U*)((__SIZE_TYPE__)p1 & ~1))->ptr;
d = e;
 } else {
e = 0;
d = ((union U*)0)->ptr;
 }
 
Index: gcc/testsuite/gcc.dg/torture/pr26763-2.c
=

__intN patch 5/5: msp430-specific changes

2014-08-13 Thread DJ Delorie

This is the MSP430-specific use of the new intN framework to enable
true 20-bit pointers.  Since I'm one of the MSP430 maintainers, this
patch is being posted for reference, not for approval.

gcc/config/msp430
* config/msp430/msp430-modes.def (PSI): Add.

* config/msp430/msp430-protos.h (msp430_hard_regno_nregs_has_padding): 
New.
(msp430_hard_regno_nregs_with_padding): New.
* config/msp430/msp430.c (msp430_scalar_mode_supported_p): New.
(msp430_hard_regno_nregs_has_padding): New.
(msp430_hard_regno_nregs_with_padding): New.
(msp430_unwind_word_mode): Use PSImode instead of SImode.
(msp430_addr_space_legitimate_address_p): New.
(msp430_asm_integer): New.
(msp430_init_dwarf_reg_sizes_extra): New.
(msp430_print_operand): Use X suffix for PSImode even in small model.
* config/msp430/msp430.h (POINTER_SIZE): Use 20 bits, not 32.
(PTR_SIZE): ...but 4 bytes for EH.
(SIZE_TYPE): Use __int20.
(PTRDIFF_TYPE): Likewise.
(INCOMING_FRAME_SP_OFFSET): Adjust.
* config/msp430/msp430.md (movqi_topbyte): New.
(movpsi): Use fixed suffixes.
(movsipsi2): Enable for 430X, not large model.
(extendhipsi2): Likewise.
(zero_extendhisi2): Likewise.
(zero_extendhisipsi2): Likewise.
(extend_and_shift1_hipsi2): Likewise.
(extendpsisi2): Likewise.
(*bitbranch4_z): Fix suffix logic.


Index: gcc/config/msp430/msp430-protos.h
===
--- gcc/config/msp430/msp430-protos.h   (revision 213886)
+++ gcc/config/msp430/msp430-protos.h   (working copy)
@@ -27,12 +27,15 @@ voidmsp430_expand_epilogue (int);
 void   msp430_expand_helper (rtx *operands, const char *, bool);
 void   msp430_expand_prologue (void);
 const char * msp430x_extendhisi (rtx *);
 void   msp430_fixup_compare_operands (enum machine_mode, rtx *);
 intmsp430_hard_regno_mode_ok (int, enum machine_mode);
 intmsp430_hard_regno_nregs (int, enum machine_mode);
+intmsp430_hard_regno_nregs_has_padding (int, enum machine_mode);
+intmsp430_hard_regno_nregs_with_padding (int, enum machine_mode);
+boolmsp430_hwmult_enabled (void);
 rtxmsp430_incoming_return_addr_rtx (void);
 void   msp430_init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree, int);
 intmsp430_initial_elimination_offset (int, int);
 boolmsp430_is_interrupt_func (void);
 const char * msp430x_logical_shift_right (rtx);
 const char * msp430_mcu_name (void);
Index: gcc/config/msp430/msp430.md
===
--- gcc/config/msp430/msp430.md (revision 213886)
+++ gcc/config/msp430/msp430.md (working copy)
@@ -176,12 +176,19 @@
   ""
   "@
MOV.B\t%1, %0
MOV%X1.B\t%1, %0"
 )
 
+(define_insn "movqi_topbyte"
+  [(set (match_operand:QI 0 "msp_nonimmediate_operand" "=r")
+   (subreg:QI (match_operand:PSI 1 "msp_general_operand" "r") 2))]
+  "msp430x"
+  "PUSHM.A\t#1,%1 { POPM.W\t#1,%0 { POPM.W\t#1,%0"
+)
+
 (define_insn "movqi"
   [(set (match_operand:QI 0 "msp_nonimmediate_operand" "=rYs,rm")
(match_operand:QI 1 "msp_general_operand" "riYs,rmi"))]
   ""
   "@
   MOV.B\t%1, %0
@@ -220,27 +227,27 @@
 ;; Some MOVX.A cases can be done with MOVA, this is only a few of them.
 (define_insn "movpsi"
   [(set (match_operand:PSI 0 "msp_nonimmediate_operand" "=r,Ya,rm")
(match_operand:PSI 1 "msp_general_operand" "riYa,r,rmi"))]
   ""
   "@
-  MOV%Q0\t%1, %0
-  MOV%Q0\t%1, %0
-  MOV%X0.%Q0\t%1, %0")
+  MOVA\t%1, %0
+  MOVA\t%1, %0
+  MOVX.A\t%1, %0")
 
 ; This pattern is identical to the truncsipsi2 pattern except
 ; that it uses a SUBREG instead of a TRUNC.  It is needed in
 ; order to prevent reload from converting (set:SI (SUBREG:PSI (SI)))
 ; into (SET:PSI (PSI)).
 ;
 ; Note: using POPM.A #1 is two bytes smaller than using POPX.A
 
 (define_insn "movsipsi2"
   [(set (match_operand:PSI0 "register_operand" "=r")
(subreg:PSI (match_operand:SI 1 "register_operand" "r") 0))]
-  "TARGET_LARGE"
+  "msp430x"
   "PUSH.W\t%H1 { PUSH.W\t%L1 { POPM.A #1, %0 ; Move reg-pair %L1:%H1 into 
pointer %0"
 )
 
 ;;
 ;; Math
 
@@ -564,49 +571,49 @@
   { return msp430x_extendhisi (operands); }
 )
 
 (define_insn "extendhipsi2"
   [(set (match_operand:PSI 0 "nonimmediate_operand" "=r")
(subreg:PSI (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" 
"0")) 0))]
-  "TARGET_LARGE"
+  "msp430x"
   "RLAM #4, %0 { RRAM #4, %0"
 )
 
 ;; Look for cases where integer/pointer conversions are suboptimal due
 ;; to missing patterns, despite us not having opcodes for these
 ;; patterns.  Doing these manually allows for alternate optimization
 ;; paths.
 (define_insn "zero_extendhisi2"
   [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
(zero_extend:SI (match_operand:HI 1 "nonimmediate_ope

__intN patch 2/5: Fix assumptions about mode precisions

2014-08-13 Thread DJ Delorie

The purpose of this set of changes is to remove assumptions in GCC
about type sizes.  Previous to this patch, GCC assumed that all types
were powers-of-two in size, and used naive math accordingly.

Old:
POINTER_SIZE / BITS_PER_UNIT
TYPE_SIZE
GET_MODE_BITSIZE

New:
POINTER_SIZE_UNITS  (ceil, not floor)
TYPE_PRECISION
GET_MODE_PRECISION

gcc/
* cppbuiltin.c (define_builtin_macros_for_type_sizes): Round
pointer size up to a power of two.
* defaults.h (DWARF2_ADDR_SIZE): Round up.
(POINTER_SIZE_UNITS): New, rounded up value.
* dwarf2asm.c (size_of_encoded_value): Use it.
(dw2_output_indirect_constant_1): Likewise.
* expmed.c (init_expmed_one_conv): We now know the sizes of
partial int modes.
* loop-iv.c (iv_number_of_iterations): Use precision, not size.
* optabs.c (expand_float): Use precision, not size.
(expand_fix): Likewise.
* simplify-rtx (simplify_unary_operation_1): Likewise.
* tree-dfa.c (get_ref_base_and_extent): Likewise.
* varasm.c (assemble_addr_to_section): Round up pointer sizes.
(default_assemble_integer) Likewise.
(dump_tm_clone_pairs): Likewise.
* dwarf2out.c (mem_loc_descriptor): Allow partial-int modes also.
* var-tracking.c (adjust_mems): Allow partial-int modes also.
(prepare_call_arguments): Likewise.
* stor-layout.c (finalize_type_size): Preserve precision.
(layout_type): Use precision, not size.


Index: gcc/cppbuiltin.c
===
--- gcc/cppbuiltin.c(revision 213886)
+++ gcc/cppbuiltin.c(working copy)
@@ -172,13 +172,13 @@ define_builtin_macros_for_type_sizes (cp
  ? "__ORDER_BIG_ENDIAN__"
  : "__ORDER_LITTLE_ENDIAN__"));
 
   /* ptr_type_node can't be used here since ptr_mode is only set when
  toplev calls backend_init which is not done with -E switch.  */
   cpp_define_formatted (pfile, "__SIZEOF_POINTER__=%d",
-   POINTER_SIZE / BITS_PER_UNIT);
+   1 << ceil_log2 ((POINTER_SIZE + BITS_PER_UNIT - 1) / 
BITS_PER_UNIT));
 }
 
 
 /* Define macros builtins common to all language performing CPP
preprocessing.  */
 void
Index: gcc/defaults.h
===
--- gcc/defaults.h  (revision 213886)
+++ gcc/defaults.h  (working copy)
@@ -448,13 +448,13 @@ see the files COPYING3 and COPYING.RUNTI
 /* The size of addresses as they appear in the Dwarf 2 data.
Some architectures use word addresses to refer to code locations,
but Dwarf 2 info always uses byte addresses.  On such machines,
Dwarf 2 addresses need to be larger than the architecture's
pointers.  */
 #ifndef DWARF2_ADDR_SIZE
-#define DWARF2_ADDR_SIZE (POINTER_SIZE / BITS_PER_UNIT)
+#define DWARF2_ADDR_SIZE ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT)
 #endif
 
 /* The size in bytes of a DWARF field indicating an offset or length
relative to a debug info section, specified to be 4 bytes in the
DWARF-2 specification.  The SGI/MIPS ABI defines it to be the same
as PTR_SIZE.  */
@@ -748,12 +748,16 @@ see the files COPYING3 and COPYING.RUNTI
 #endif
 
 /* Width in bits of a pointer.  Mind the value of the macro `Pmode'.  */
 #ifndef POINTER_SIZE
 #define POINTER_SIZE BITS_PER_WORD
 #endif
+#ifndef POINTER_SIZE_UNITS
+#define POINTER_SIZE_UNITS ((POINTER_SIZE + BITS_PER_UNIT - 1) / BITS_PER_UNIT)
+#endif
+
 
 #ifndef PIC_OFFSET_TABLE_REGNUM
 #define PIC_OFFSET_TABLE_REGNUM INVALID_REGNUM
 #endif
 
 #ifndef PIC_OFFSET_TABLE_REG_CALL_CLOBBERED
Index: gcc/dwarf2asm.c
===
--- gcc/dwarf2asm.c (revision 213886)
+++ gcc/dwarf2asm.c (working copy)
@@ -387,13 +387,13 @@ size_of_encoded_value (int encoding)
   if (encoding == DW_EH_PE_omit)
 return 0;
 
   switch (encoding & 0x07)
 {
 case DW_EH_PE_absptr:
-  return POINTER_SIZE / BITS_PER_UNIT;
+  return POINTER_SIZE_UNITS;
 case DW_EH_PE_udata2:
   return 2;
 case DW_EH_PE_udata4:
   return 4;
 case DW_EH_PE_udata8:
   return 8;
@@ -917,13 +917,13 @@ dw2_output_indirect_constant_1 (splay_tr
   if (USE_LINKONCE_INDIRECT)
DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN;
 }
 
   sym_ref = gen_rtx_SYMBOL_REF (Pmode, sym);
   assemble_variable (decl, 1, 1, 1);
-  assemble_integer (sym_ref, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
+  assemble_integer (sym_ref, POINTER_SIZE_UNITS, POINTER_SIZE, 1);
 
   return 0;
 }
 
 /* Emit the constants queued through dw2_force_const_mem.  */
 
Index: gcc/expmed.c
===
--- gcc/expmed.c(revision 213886)
+++ gcc/expmed.c(working copy)
@@ -115,19 +115,25 @@ static void
 init_expmed_one_conv (struc

__intN patch 1/5: convert-move optimization

2014-08-13 Thread DJ Delorie

This patch is part of the __intN series, but is independent.  It
provides an additional optimization opportunity, since the MSP430 does
a lot of conversions between HImode and PSImode.

* expr.c (convert_move): If the target has an explicit converter,
use it.

Index: gcc/expr.c
===
--- gcc/expr.c  (revision 213886)
+++ gcc/expr.c  (working copy)
@@ -406,12 +406,32 @@ convert_move (rtx to, rtx from, int unsi
   from)
  : gen_rtx_FLOAT_EXTEND (to_mode, from));
   return;
 }
 
   /* Handle pointer conversion.  *//* SPEE 900220.  */
+  /* If the target has a converter from FROM_MODE to TO_MODE, use it.  */
+  {
+convert_optab ctab;
+
+if (GET_MODE_PRECISION (from_mode) > GET_MODE_PRECISION (to_mode))
+  ctab = trunc_optab;
+else if (unsignedp)
+  ctab = zext_optab;
+else
+  ctab = sext_optab;
+
+if (convert_optab_handler (ctab, to_mode, from_mode)
+   != CODE_FOR_nothing)
+  {
+   emit_unop_insn (convert_optab_handler (ctab, to_mode, from_mode),
+   to, from, UNKNOWN);
+   return;
+  }
+  }
+
   /* Targets are expected to provide conversion insns between PxImode and
  xImode for all MODE_PARTIAL_INT modes they use, but no others.  */
   if (GET_MODE_CLASS (to_mode) == MODE_PARTIAL_INT)
 {
   enum machine_mode full_mode
= smallest_mode_for_size (GET_MODE_BITSIZE (to_mode), MODE_INT);


__intN patch 0/5: summary

2014-08-13 Thread DJ Delorie

The following five patches are the latest in my ongoing work to
replace the hard-coded __int128 type with a more flexible __int
system that allows target-specific types that correspond to
partial-int modes.  Specifically, this will allow targets to have
pointers that aren't powers-of-two in size.  Tested on x86-64 with no
regressions and msp430-elf with a few where I couldn't figure out how
to fix the testsuite to properly detect the msp430's 20-bit pointer
size (but the msp430 results had a lot more new passes with my patches ;)

I'm pretty sure I've addressed everyone's concerns, and once again
I've manually split up the ChangeLog and patch into multiple posts for
the convenience of review

__intN patch 1/5: convert-move optimization

A standalone patch that allows targets to provide a converter
(trunc/extend) between *any* two modes.  Needed for the msp430
patch.

__intN patch 2/5: Fix assumptions about mode precisions

Many places in gcc use TYPE_SIZE instead of TYPE_PRECISION.
This patch set fixes many (I doubt I found *all* of them) such
cases.

__intN patch 3/5: main __int128 -> __intN conversion.

This is the main part of the patch.  Doesn't require the other
patches for targets that only have power-of-two pointers.

__intN patch 4/5: testsuite updates

Some of the tests had their own assumption about pointer sizes
:-P

__intN patch 5/5: msp430-specific changes

For completeness, this is the msp430-specific fixes and
optimizations to fully support 20-bit pointers.


Re: RFC: Patch for switch elimination (PR 54742)

2014-08-13 Thread Sebastian Pop
Jeff Law wrote:
> I'm pretty sure jump threading *could* handle it, but after looking
> at the full testcase when it was posted, I'm not sure it's *wise* to
> handle this in jump threading.

Thanks for clearing my doubts.

Sebastian


Re: [PATCH] Fix PR61950

2014-08-13 Thread Tobias Burnus

Hi Richard,

sorry for the belated reply due to spending lazily my time at the sea ...

The patch is okay - and I would even claim that it is obvious.

Regarding the data type, I have no idea why it uses a hard-coded 32bit 
integer instead of a size-type one. I have added it as item to 
https://gcc.gnu.org/wiki/LibgfortranAbiCleanup to change it once we 
break the ABI.


Tobias

PS: I wonder where all the other patch reviewers are, given that quite a 
few patches have accumulated. In particular, I am lacking a patch 
reviewer myself.


Richard Biener wrote:

The following fixes PR61950 by properly initializing the _size field
of the static constructor for the vtable init member.  Previously
gfortran would use a 64bit integer to initialize the 32bit size field
(not sure why larger aggregates are not considered).

This breaks more sophisticated constant-folding and previously
inhibited constant folding (which would have worked in this case
been there no mismatch between initializer and field).

Bootstrap and regtest ongoing on powerpc64-linux-gnu, ok?  I'm not
considering a backport as it is only a missed optimization there.

Thanks,
Richard.

2014-07-31  Richard Biener  

* trans-expr.c (gfc_conv_structure): Initialize _size with
a value of proper type.

Index: gcc/fortran/trans-expr.c
===
--- gcc/fortran/trans-expr.c(revision 213342)
+++ gcc/fortran/trans-expr.c(working copy)
@@ -6260,7 +6260,9 @@ gfc_conv_structure (gfc_se * se, gfc_exp
else if (cm->ts.u.derived && strcmp (cm->name, "_size") == 0)
{
  val = TYPE_SIZE_UNIT (gfc_get_derived_type (cm->ts.u.derived));
- CONSTRUCTOR_APPEND_ELT (v, cm->backend_decl, val);
+ CONSTRUCTOR_APPEND_ELT (v, cm->backend_decl,
+ fold_convert (TREE_TYPE (cm->backend_decl),
+   val));
}
else
{





[patch] make gcov-tool build configurable and fix mingw build issue

2014-08-13 Thread Rong Xu
Hi,

This patch makes gcov-tool build configurable. A new configure option
--disable-gcov-tool is added to disable the build.

It also fixes some build issues for mingw.

Tested with regression and bootstrap. mingw test is ongoing.

OK to check in if mingw build passes?

Thanks,

-Rong


gcov_tool_patch_diff
Description: Binary data


Re: RFC: Patch for switch elimination (PR 54742)

2014-08-13 Thread Jeff Law

On 08/13/14 14:55, Sebastian Pop wrote:

Steve Ellcey wrote:

+/* This file implements an optimization where, when a variable is set
+   to a constant value and there is a path that leads from that definition
+   to a switch statement that uses that variable as its controlling expression
+   we duplicate the blocks on this path and change the jump to the switch
+   statement with a direct jump to the label of the switch block that control
+   would goto based on the value of the variable.  This can come up in
+   loops/switch statements that implement state machines.


Can you explain why the jump-threading pass cannot do this?  Why do we need
another pass to handle a corner case that jump-thread does not catch yet?
I'm pretty sure jump threading *could* handle it, but after looking at 
the full testcase when it was posted, I'm not sure it's *wise* to handle 
this in jump threading.


The core issue is we have to look even deeper into the CFG than was 
originally envisioned and do quite a bit more block duplication than was 
originally envisioned.  That's going to have a notable compile-time cost 
(and to a lesser extent issues around codesize).


It's unfortunate that the testcase when we first looked at this was 
over-simplified and not actually representative of what happens in 
Coremark.  Had I seen the Coremark testcase, I probably wouldn't have 
suggested we tackle the problem in jump threading and the extensions I 
made to jump threading would _not_ have included aggressively following 
backedges in the CFG.


You'll note in a separate thread Steve and I discussed this during 
Cauldron and it was at my recommendation Steve resurrected his proof of 
concept plugin and started beating it into shape.


jeff




Re: RFC: Patch for switch elimination (PR 54742)

2014-08-13 Thread Sebastian Pop
Steve Ellcey wrote:
> +/* This file implements an optimization where, when a variable is set
> +   to a constant value and there is a path that leads from that definition
> +   to a switch statement that uses that variable as its controlling 
> expression
> +   we duplicate the blocks on this path and change the jump to the switch
> +   statement with a direct jump to the label of the switch block that control
> +   would goto based on the value of the variable.  This can come up in
> +   loops/switch statements that implement state machines.

Can you explain why the jump-threading pass cannot do this?  Why do we need
another pass to handle a corner case that jump-thread does not catch yet?

> +
> +   Example (modified from PR 54742):
> +
> +   foo(char *str) {
> + int sum=0;
> + int state=0;
> + char *s=str;
> + for (; *s; s++) {
> +   char c=*s;
> +   

>From what I understand, Jeff has fixed jump-threading to catch exactly the
pattern in this example.  What jump-threading doesn't do yet is duplicate the
path when  is a condition, like in the example in comment 27:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54742#c27
(see the if (c == '*') ):

int sum0, sum1, sum2, sum3;
int foo(char * s, char** ret)
{
  int state=0;
  char c;

  for (; *s && state != 4; s++)
{
  c = *s;
  if (c == '*')
{
  s++;
  break;
}
  switch (state) {
case 0:
  if (c == '+') state = 1;
  else if (c != '-') sum0+=c;
  break;
case 1:
  if (c == '+') state = 2;
  else if (c == '-') state = 0;
  else sum1+=c;
  break;
case 2:
  if (c == '+') state = 3;
  else if (c == '-') state = 1;
  else sum2+=c;
  break;
case 3:
  if (c == '-') state = 2;
  else if (c == 'x') state = 4;
  break;
default:
  break;
  }
}
  *ret = s;
  return state;
}


> +   switch (state) {
> + case 0:
> +   if (c == '+')   { state = 1; sum += 9; }
> +   else if (c != '-')  { state = 2; sum += 3; }
> +   break;
> + case 1:
> +   if (c == '+')   { state = 2; sum += 4; }
> +   else if (c == '-')  { state = 0; sum += 7; }
> +   break;
> + case 2:
> +   if (c == '+')   { state = 0; sum += 8; }
> +   else if (c == '-')  { state = 1; sum += 2; }
> +   break;
> +   }
> +   
> + }
> + return state;
> +   }
> +
> +  This pass will convert the code inside 'case 0' to something like:
> +
> +case 0:
> +  if (c == '+')  { state = 1; sum += 9;
> +   
> +   s++; if (!s) goto loop_exit;
> +   
> +   goto case_1; }
> +  else if (c != '-') { state = 2; sum += 3;
> +   
> +   s++; if (!s) goto loop_exit;
> +   
> +   goto case_2; }
> +  else   { 
> +s++; if (!s) goto exit;
> +   
> +   goto case_0; }
> +
> +Similar transformations would apply to the other parts of the switch
> +statement.  This obviously can lead to a lot of code duplication but
> +it can also result in faster code since we are replacing two jumps
> +(one indirect) with a single direct jump.  */


Re: [Patch] Fix crtstuff.c when compiling with mingw tools.

2014-08-13 Thread Steve Ellcey
On Wed, 2014-08-13 at 20:42 +, Joseph S. Myers wrote:
> On Wed, 13 Aug 2014, Steve Ellcey  wrote:
> 
> > This is a ping on a patch I sent out a while ago to fix the GCC build
> > when building with the mingw toolset.
> 
> This is not a review.
> 
> When pinging, please give *the gcc.gnu.org URL of the patch being pinged*.

Good point, here is the last patch email I sent:

https://gcc.gnu.org/ml/gcc-patches/2014-05/msg00018.html

For some reason this doesn't reference the original patch at:

https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01577.html

Steve Ellcey
sell...@mips.com



Re: [patch, testsuite] Applying non_bionic effective target to particular tests

2014-08-13 Thread Joseph S. Myers
On Thu, 14 Aug 2014, Alexander Ivchenko wrote:

> Hi,
> 
> This patch disables a bunch of tests that fail when using Bionic libc.
> But this is expected; three reasons:
> - Bionic does not support complex functions.
> - Bionic does not have tgmath.h and error.h headers.
> - Bionic does not have mempcpy and stpcpy.

Testing logical features for each of these would seem better than testing 
for Bionic.

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


Re: [Patch] Fix crtstuff.c when compiling with mingw tools.

2014-08-13 Thread Joseph S. Myers
On Wed, 13 Aug 2014, Steve Ellcey  wrote:

> This is a ping on a patch I sent out a while ago to fix the GCC build
> when building with the mingw toolset.

This is not a review.

When pinging, please give *the gcc.gnu.org URL of the patch being pinged*.

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


Re: [patch,gomp4] make fortran loop variables implicitly private in openacc

2014-08-13 Thread Tobias Burnus

Cesar Philippidis wrote:

According to section 2.6.1 in the openacc spec, fortran loop variables
should be implicitly private like in openmp. This patch does just so.


Makes sense. Looking at the patch, I wonder whether the context is 
properly handled when mixing OpenMP and OpenACC. I have the feeling that 
one then might end up using the OpenACC context when one should use the 
OpenMP context. However, I have not fully followed the program flow. For 
instance, would something like


!$oacc parallel
!$omp simd private(i) reduction(+:c)
do i = 1, n
...
end do

be properly handled?


Also, while working on this patch, I noticed that I made the check for
variables appearing in multiple openacc clauses too strict. A private
variable may also appear inside a reduction clause. I've also included a
fix for this in this patch.


In OpenMP, one has (OMP 4.0, 2.14.3): "A list item that specifies a 
given variable may not appear in more than one clause on the same 
directive, except that a variable may be specified in both firstprivate 
and lastprivate clauses."
And in 2.14.3.3, OpenMP has: "List items that appear in a private, 
firstprivate, or reduction clause in a parallel construct may also 
appear in a private clause in an enclosed parallel,task, or worksharing, 
or simd construct.


I tried to find it in something similar in OpenACC - but I failed. I 
found in (OpenACC 2.0a, 2.7.11) a reference to reduction with private, 
which implies that a reduction variable my be private, but I didn't find 
much more. In particular, it is not clear to me whether it would permit 
only those which are private implicitly or in an oacc parallel region or 
also in an explicit private clause in the same directive. Can you point 
me to the spec?


Additionally, I wonder whether you shouldn't also add a test case for 
the reduction with private.


Tobias


Re: [PATCH 012/236] Convert DF_REF_INSN to a function for now

2014-08-13 Thread Jeff Law

On 08/13/14 14:28, David Malcolm wrote:

Thanks.  Although this function gets converted back to a macro in patch
191, I just realized that in the meantime that it's not inlined, as is
the case for some of the other macro->function conversions in patches
13-16.

Do I need to convert them to inline functions with the appropriate
headers, and is that regarded as a sufficiently trivial fix to the stuff
you've already reviewed to not need re-review? (I will bootstrap&test).

I'd just make it a follow-up. #237 ;-)




Or is it OK to suffer the performance hit as the patchkit lands, before
they all become macros again in phase 4 of the patchkit?
I think so.  This is a transient state, and my goal is to have this 
stuff reviewed and get off the critical path before I go on PTO next week.




Note also that Jakub expressed concern about the effect of all these
inline functions on the debugging experience, and there's this patch
(awaiting review) which I believe addresses that:
https://gcc.gnu.org/ml/gcc-patches/2014-08/msg00743.html

Make it #238.



Presumably similar changes to gdbinit.in should occur for the relevant
headers (e.g. df.h in this case, though possibly targeted to just the
new function - there are already quite a few inline functions in df.h)

Yea, probably.

jeff


Re: [PATCH 012/236] Convert DF_REF_INSN to a function for now

2014-08-13 Thread David Malcolm
On Tue, 2014-08-12 at 15:20 -0600, Jeff Law wrote:
> On 08/06/14 11:19, David Malcolm wrote:
> > DF_REF_INSN looks up the "insn" field of the referenced df_insn_info.
> > This will eventually be an rtx_insn *, but for now is just an rtx.
> >
> > As further scaffolding: for now, convert DF_REF_INSN to a function,
> > adding a checked downcast to rtx_insn *.  This can eventually be
> > converted back to macro when the field is an rtx_insn *.
> >
> > gcc/
> > * df-core.c (DF_REF_INSN): New, using a checked cast for now.
> > * df.h (DF_REF_INSN): Convert from a macro to a function, so
> > that we can return an rtx_insn *.
> >
> > /
> > * rtx-classes-status.txt: Add DF_REF_INSN.
> OK.

Thanks.  Although this function gets converted back to a macro in patch
191, I just realized that in the meantime that it's not inlined, as is
the case for some of the other macro->function conversions in patches
13-16.

Do I need to convert them to inline functions with the appropriate
headers, and is that regarded as a sufficiently trivial fix to the stuff
you've already reviewed to not need re-review? (I will bootstrap&test).

Or is it OK to suffer the performance hit as the patchkit lands, before
they all become macros again in phase 4 of the patchkit?

Note also that Jakub expressed concern about the effect of all these
inline functions on the debugging experience, and there's this patch
(awaiting review) which I believe addresses that:
https://gcc.gnu.org/ml/gcc-patches/2014-08/msg00743.html

Presumably similar changes to gdbinit.in should occur for the relevant
headers (e.g. df.h in this case, though possibly targeted to just the
new function - there are already quite a few inline functions in df.h)

Dave




Re: [PATCH] fix hardreg_cprop to honor HARD_REGNO_MODE_OK.

2014-08-13 Thread Jeff Law

On 08/11/14 07:49, Ilya Tocar wrote:

Hi,

I've observed SPEC2006 failure on avx512-vlbwdq branch.
It was caused by  hardreg_cprop. In maybe_mode_change it was
assumed, that all values of the same register class and same mode.
are ok. This is not the case for i386/avx512. We need to honor
HARD_REGNO_MODE_OK.
Patch bellow does it.
Ok for trunk?

2014-08-11  Ilya Tocar  

* regcprop.c (maybe_mode_change): Honor HARD_REGNO_MODE_OK.
One could argue that having a class where some members are OK for being 
used in a particular mode, but other members are not is the core issue 
here.


Can you describe a bit about why you've got a class of that nature? 
Background on that would be useful.


jeff



Re: [PATCH 190/236] Remove insn_addresses_new from 'various scheduling strengthenings'

2014-08-13 Thread Jeff Law

On 08/13/14 13:32, David Malcolm wrote:

On Wed, 2014-08-06 at 13:22 -0400, David Malcolm wrote:

---
  gcc/insn-addr.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/insn-addr.h b/gcc/insn-addr.h
index e255ac4..aec09fd 100644
--- a/gcc/insn-addr.h
+++ b/gcc/insn-addr.h
@@ -38,7 +38,7 @@ extern int insn_current_address;
  #define INSN_ADDRESSES_SIZE() (insn_addresses_.length ())

  static inline void
-insn_addresses_new (rtx_insn *insn, int insn_addr)
+insn_addresses_new (rtx insn, int insn_addr)
  {
unsigned insn_uid = INSN_UID ((insn));


Oops; this one undoes part of patch 189.  I think I meant to squash
these two together, since without 190, 189 breaks the build on s390 in a
few places.
NP.Track that however you want.  No need to repost everything right 
now.  Though I do request that you post final versions for archival 
purposes.


Jeff



Re: [PATCH 092/236] lra: use rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:21, David Malcolm wrote:

gcc/
* lra-int.h (struct lra_insn_recog_data): Strengthen field "insn"
from rtx to rtx_insn *.
(lra_push_insn): Likewise for 1st param.
(lra_push_insn_and_update_insn_regno_info): Likewise.
(lra_pop_insn): Likewise for return type.
(lra_invalidate_insn_data): Likewise for 1st param.
(lra_set_insn_deleted): Likewise.
(lra_delete_dead_insn): Likewise.
(lra_process_new_insns): Likewise for first 3 params.
(lra_set_insn_recog_data): Likewise for 1st param.
(lra_update_insn_recog_data): Likewise.
(lra_set_used_insn_alternative): Likewise.
(lra_invalidate_insn_regno_info): Likewise.
(lra_update_insn_regno_info): Likewise.
(lra_former_scratch_operand_p): Likewise.
(lra_eliminate_regs_1): Likewise.
(lra_get_insn_recog_data): Likewise.

* lra-assigns.c (assign_by_spills): Strengthen local "insn" from
rtx to rtx_insn *.

* lra-coalesce.c (move_freq_compare_func): Likewise for locals
"mv1" and "mv2".
(substitute_within_insn): New.
(lra_coalesce): Strengthen locals "mv", "insn", "next" from rtx to
rtx_insn *.  Strengthen sorted_moves from rtx * to rxt_insn **.
Replace call to "substitute" with call to substitute_within_insn.

* lra-constraints.c (curr_insn): Strengthen from rtx to
rtx_insn *.
(get_equiv_with_elimination): Likewise for param "insn".
(match_reload): Strengthen params "before" and "after" from rtx *
to rtx_insn **.
(emit_spill_move): Likewise for return type.  Add a checked cast
to rtx_insn * on result of gen_move_insn for now.
(check_and_process_move): Likewise for local "before".  Replace
NULL_RTX with NULL when referring to insns.
(process_addr_reg): Strengthen params "before" and "after" from
rtx * to rtx_insn **.
(insert_move_for_subreg): Likewise.
(simplify_operand_subreg): Strengthen locals "before" and "after"
from rtx to rtx_insn *.
(process_address_1): Strengthen params "before" and "after" from
rtx * to rtx_insn **.  Strengthen locals "insns", "last_insn" from
rtx to rtx_insn *.
(process_address): Strengthen params "before" and "after" from
rtx * to rtx_insn **.
(emit_inc): Strengthen local "last" from rtx to rtx_insn *.
(curr_insn_transform): Strengthen locals "before" and "after"
from rtx to rtx_insn *.  Replace NULL_RTX with NULL when referring
to insns.
(loc_equivalence_callback): Update cast of "data", changing
resulting type from rtx to rtx_insn *.
(substitute_pseudo_within_insn): New.
(inherit_reload_reg): Strengthen param "insn" from rtx to
rtx_insn *; likewise for local "new_insns".  Replace NULL_RTX with
NULL when referring to insns.  Add a checked cast to rtx_insn *
when using usage_insn to invoke lra_update_insn_regno_info.
(split_reg): Strengthen param "insn" from rtx to rtx_insn *;
likewise for locals "restore", "save".  Add checked casts to
rtx_insn * when using usage_insn to invoke
lra_update_insn_regno_info and lra_process_new_insns.  Replace
NULL_RTX with NULL when referring to insns.
(split_if_necessary): Strengthen param "insn" from rtx to
rtx_insn *.
(update_ebb_live_info): Likewise for params "head", "tail" and local
"prev_insn".
(get_last_insertion_point): Likewise for return type and local "insn".
(get_live_on_other_edges): Likewise for local "last".
(inherit_in_ebb): Likewise for params "head", "tail" and locals
"prev_insn", "next_insn", "restore".
(remove_inheritance_pseudos): Likewise for local "prev_insn".
(undo_optional_reloads): Likewise for local "insn".

* lra-eliminations.c (lra_eliminate_regs_1): Likewise for param
"insn".
(lra_eliminate_regs): Replace NULL_RTX with NULL when referring to
insns.
(eliminate_regs_in_insn): Strengthen param "insn" from rtx to
rtx_insn *.
(spill_pseudos): Likewise for local "insn".
(init_elimination): Likewise.
(process_insn_for_elimination): Likewise for param "insn".

* lra-lives.c (curr_insn): Likewise.;

* lra-spills.c (assign_spill_hard_regs): Likewise for local "insn".
(remove_pseudos): Likewise for param "insn".
(spill_pseudos): Likewise for local "insn".
(lra_final_code_change): Likewise for locals "insn", "curr".

* lra.c (lra_invalidate_insn_data): Likewise for param "insn".
(lra_set_insn_deleted): Likewise.
(lra_delete_dead_insn): Likewise, and for local "prev".
(new_insn_reg): Likewise for param "insn".
(lra_set_insn_recog_data): Likewise.
(lra_update_insn_recog_data): Li

[patch, testsuite] Applying non_bionic effective target to particular tests

2014-08-13 Thread Alexander Ivchenko
Hi,

This patch disables a bunch of tests that fail when using Bionic libc.
But this is expected; three reasons:
- Bionic does not support complex functions.
- Bionic does not have tgmath.h and error.h headers.
- Bionic does not have mempcpy and stpcpy.


diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 536485a..893f2b3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,16 @@
+2014-08-13  Alexander Ivchenko  
+
+ * gcc.dg/builtins-59.c: Disable test for Bionic.
+ * gcc.dg/builtins-61.c: Likewise.
+ * gcc.dg/builtins-67.c: Likewise.
+ * gcc.dg/c99-tgmath-1.c: Likewise.
+ * gcc.dg/c99-tgmath-2.c: Likewise.
+ * gcc.dg/c99-tgmath-3.c: Likewise.
+ * gcc.dg/c99-tgmath-4.c: Likewise.
+ * gcc.dg/dfp/convert-dfp-round-thread.c: Likewise.
+ * gcc.dg/strlenopt-14g.c: Likewise.
+ * gcc.dg/strlenopt-14gf.c: Likewise.
+
 2014-08-12  Marek Polacek  

  * gcc.dg/concat.c: Add dg-options.
diff --git a/gcc/testsuite/gcc.dg/builtins-59.c
b/gcc/testsuite/gcc.dg/builtins-59.c
index b940d39..23feb78 100644
--- a/gcc/testsuite/gcc.dg/builtins-59.c
+++ b/gcc/testsuite/gcc.dg/builtins-59.c
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
 /* { dg-options "-fdump-tree-gimple" } */
 /* { dg-require-effective-target c99_runtime } */
+/* Complex builtins are not supported in Bionic. */
+/* { dg-require-effective-target non_bionic } */

 double test (double x)
 {
diff --git a/gcc/testsuite/gcc.dg/builtins-61.c
b/gcc/testsuite/gcc.dg/builtins-61.c
index dff163f..bd0b4ce 100644
--- a/gcc/testsuite/gcc.dg/builtins-61.c
+++ b/gcc/testsuite/gcc.dg/builtins-61.c
@@ -1,6 +1,8 @@
 /* { dg-do compile } */
 /* { dg-options "-O -ffast-math -fdump-tree-optimized" } */
 /* { dg-require-effective-target c99_runtime } */
+/* Complex builtins are not supported in Bionic. */
+/* { dg-require-effective-target non_bionic } */

 double test1 (double x)
 {
diff --git a/gcc/testsuite/gcc.dg/builtins-67.c
b/gcc/testsuite/gcc.dg/builtins-67.c
index 22267bd..0f02cbb 100644
--- a/gcc/testsuite/gcc.dg/builtins-67.c
+++ b/gcc/testsuite/gcc.dg/builtins-67.c
@@ -3,6 +3,8 @@
 /* { dg-do link } */
 /* { dg-options "-ffast-math -lm" }  */
 /* { dg-add-options c99_runtime } */
+/* Complex builtins are not supported in Bionic. */
+/* { dg-require-effective-target non_bionic } */

 #include "builtins-config.h"

diff --git a/gcc/testsuite/gcc.dg/c99-tgmath-1.c
b/gcc/testsuite/gcc.dg/c99-tgmath-1.c
index c7d848c..0923560 100644
--- a/gcc/testsuite/gcc.dg/c99-tgmath-1.c
+++ b/gcc/testsuite/gcc.dg/c99-tgmath-1.c
@@ -3,6 +3,8 @@
 /* { dg-do preprocess { target c99_runtime } } */
 /* { dg-options "-std=iso9899:1999" } */
 /* { dg-add-options c99_runtime } */
+/* Bionic doesn't have tgmath.h. */
+/* { dg-require-effective-target non_bionic } */

 /* Test that tgmath defines the macros it's supposed to. */
 #include 
diff --git a/gcc/testsuite/gcc.dg/c99-tgmath-2.c
b/gcc/testsuite/gcc.dg/c99-tgmath-2.c
index d4f1f87..f82ab37 100644
--- a/gcc/testsuite/gcc.dg/c99-tgmath-2.c
+++ b/gcc/testsuite/gcc.dg/c99-tgmath-2.c
@@ -3,6 +3,9 @@
 /* { dg-do compile { target c99_runtime } } */
 /* { dg-options "-std=iso9899:1999" } */
 /* { dg-add-options c99_runtime } */
+/* Bionic doesn't have tgmath.h. */
+/* { dg-require-effective-target non_bionic } */
+

 /* Test that invoking type-generic sin on a float invokes sinf. */
 #include 
diff --git a/gcc/testsuite/gcc.dg/c99-tgmath-3.c
b/gcc/testsuite/gcc.dg/c99-tgmath-3.c
index 3e98304..fba9dfb 100644
--- a/gcc/testsuite/gcc.dg/c99-tgmath-3.c
+++ b/gcc/testsuite/gcc.dg/c99-tgmath-3.c
@@ -3,6 +3,8 @@
 /* { dg-do compile { target c99_runtime } } */
 /* { dg-options "-std=iso9899:1999" } */
 /* { dg-add-options c99_runtime } */
+/* Bionic doesn't have tgmath.h. */
+/* { dg-require-effective-target non_bionic } */

 /* Test that invoking type-generic exp on a complex invokes cexp. */
 #include 
diff --git a/gcc/testsuite/gcc.dg/c99-tgmath-4.c
b/gcc/testsuite/gcc.dg/c99-tgmath-4.c
index d8dc043..68bb59e 100644
--- a/gcc/testsuite/gcc.dg/c99-tgmath-4.c
+++ b/gcc/testsuite/gcc.dg/c99-tgmath-4.c
@@ -3,6 +3,8 @@
 /* { dg-do compile { target c99_runtime } } */
 /* { dg-options "-std=iso9899:1999" } */
 /* { dg-add-options c99_runtime } */
+/* Bionic doesn't have tgmath.h. */
+/* { dg-require-effective-target non_bionic } */

 /* Test that invoking type-generic pow on complex float invokes cpowf. */
 #include 
diff --git a/gcc/testsuite/gcc.dg/dfp/convert-dfp-round-thread.c
b/gcc/testsuite/gcc.dg/dfp/convert-dfp-round-thread.c
index 6727e80..896c21d 100644
--- a/gcc/testsuite/gcc.dg/dfp/convert-dfp-round-thread.c
+++ b/gcc/testsuite/gcc.dg/dfp/convert-dfp-round-thread.c
@@ -1,5 +1,7 @@
 /* { dg-options "-std=gnu99 -D_GNU_SOURCE -pthread" } */
 /* { dg-do run { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } } */
+/* Bionic doesn't have error.h. */
+/* { dg-require-effective-target non_bionic } */

 /* N1150 5.2: Conversions among decimal floating types and between
decimal floating types and generic floating ty

Re: [PATCH 005/236] Introduce as_a_nullable

2014-08-13 Thread David Malcolm
On Wed, 2014-08-13 at 12:07 +0200, Richard Biener wrote:
> On Wed, Aug 13, 2014 at 12:01 PM, Martin Jambor  wrote:
> > Hi,
> >
> > On Wed, Aug 06, 2014 at 01:19:44PM -0400, David Malcolm wrote:
> >> In many circumstances, is_a_helper ::test assumes that the pointer is
> >> non-NULL, but sometimes you have a pointer of type T that can be NULL.
> >>
> >> Earlier versions of this patch kit made numerous uses of the ternary
> >> operator to handle nullable pointers e.g.:
> >>
> >>   return insn ? as_a  (insn) : NULL;
> >>
> >> but this was ugly.  Instead, introduce an as_a_nullable variant that
> >> adds a check for NULL, so the above can be written simply as:
> >>
> >>   return as_a_nullable  (insn);
> >
> > A tiny bikeshedding, disregard it if you don't like it: however, the
> > "nullable" part of the name suggests the pointer can be NULLed in the
> > process.  I think that variants of functions that survive NULL
> > arguments are traditionally called "safe" in gcc, so what about
> > "safe_as" (or safely_as)?
> 
> Ok, I resisted at first starting the bike-shedding but I agree on
> the badness of "nullable" (what does that mean anyway?).
> as_a_safe or safe_as_a both work for me.

I think I took the terminology from:
  http://en.wikipedia.org/wiki/Nullable_type

meaning "something that can be NULL".

"safe" as a prefix seems to be the pattern in the rest of the code, so I
guess I'll use "safe_as_a".

Thanks
Dave


> Richard.
> 
> >
> > Martin
> >
> >
> >>
> >> gcc/
> >>   * is-a.h (template as_a_nullable ) New function.
> >> ---
> >>  gcc/is-a.h | 24 
> >>  1 file changed, 24 insertions(+)
> >>
> >> diff --git a/gcc/is-a.h b/gcc/is-a.h
> >> index a14e344..f50e62c 100644
> >> --- a/gcc/is-a.h
> >> +++ b/gcc/is-a.h
> >> @@ -46,6 +46,14 @@ TYPE as_a  (pointer)
> >>
> >>do_something_with (as_a  *ptr);
> >>
> >> +TYPE as_a_nullable  (pointer)
> >> +
> >> +Like as_a  (pointer), but where pointer could be NULL.  This
> >> +adds a check against NULL where the regular is_a_helper hook for TYPE
> >> +assumes non-NULL.
> >> +
> >> +  do_something_with (as_a_nullable  *ptr);
> >> +
> >>  TYPE dyn_cast  (pointer)
> >>
> >>  Converts pointer to TYPE if and only if "is_a  pointer".  
> >> Otherwise,
> >> @@ -185,6 +193,22 @@ as_a (U *p)
> >>return is_a_helper ::cast (p);
> >>  }
> >>
> >> +/* Similar to as_a<>, but where the pointer can be NULL, even if
> >> +   is_a_helper doesn't check for NULL.  */
> >> +
> >> +template 
> >> +inline T
> >> +as_a_nullable (U *p)
> >> +{
> >> +  if (p)
> >> +{
> >> +  gcc_checking_assert (is_a  (p));
> >> +  return is_a_helper ::cast (p);
> >> +}
> >> +  else
> >> +return NULL;
> >> +}
> >> +
> >>  /* A generic checked conversion from a base type U to a derived type T.  
> >> See
> >> the discussion above for when to use this function.  */
> >>
> >> --
> >> 1.8.5.3
> >>




[c++-concepts] explicit instantiation and specialization

2014-08-13 Thread Andrew Sutton
This patch re-implements explicit instantiation and specialization.
The latter isn't fully tested just yet, but it's close.

Constraints for explicit instantiations and specializations are
deduced from their candidates, not explicitly specified as part of the
declaration.

2014-08-13  Andrew Sutton  

Implement deduction-based explicit instantiation and specialization.
* gcc/cp/call.c (joust): Allow all non-templates to be ordered by
constraints.
* gcc/cp/pt.c (get_class_bindings): Remove superfluous parameter and
move constraint check into most_specialized_class.
(most_constrained_function): Order functions with the same signatures
by their constraints.
(determine_specialization): Candidates must satisfy constraints. Also,
order non-template candidates by constraints. Improve diagnostics
for instances where candidates are rejected.
(more_specialized_inst): New. Compare function templates.
(most_specialized_instantiation): Refactor to use
more_specialized_inst and order by constraints.
(most_specialized_class): Candidates must satisfy constraints.
* gcc/cp/decl.c (various) Cosmetic fixes.
(adjust_fn_constraints): Rewrite so that class template constraints
are not imposed on member function declarations.
* gcc/testsuite/g++.dg/concepts: New tests.

Andrew Sutton
Index: gcc/cp/decl.c
===
--- gcc/cp/decl.c	(revision 213909)
+++ gcc/cp/decl.c	(working copy)
@@ -991,11 +991,6 @@ decls_match (tree newdecl, tree olddecl)
   if (t1 != t2)
 	return 0;
 
-  // Normal functions can be constraind. Two functions with the
-  // same type and different constraints are different functions.
-  tree c1 = get_constraints (newdecl);
-  tree c2 = get_constraints (olddecl);
-
   if (CP_DECL_CONTEXT (newdecl) != CP_DECL_CONTEXT (olddecl)
 	  && ! (DECL_EXTERN_C_P (newdecl)
 		&& DECL_EXTERN_C_P (olddecl)))
@@ -1014,6 +1009,11 @@ decls_match (tree newdecl, tree olddecl)
 	 type for declaration matching.  */
   r2 = fndecl_declared_return_type (olddecl);
 
+  // Normal functions can be constraind. Two functions with the
+  // same type and different constraints are different functions.
+  tree c1 = get_constraints (newdecl);
+  tree c2 = get_constraints (olddecl);
+
   if (same_type_p (TREE_TYPE (f1), r2))
 	{
 	  if (!prototype_p (f2) && DECL_EXTERN_C_P (olddecl)
@@ -1041,7 +1041,7 @@ decls_match (tree newdecl, tree olddecl)
 	  TREE_TYPE (newdecl) = TREE_TYPE (olddecl);
 	}
 #endif
-	  else {
+	  else
 	types_match =
 	  compparms (p1, p2)
 	  && type_memfn_rqual (f1) == type_memfn_rqual (f2)
@@ -1049,7 +1049,6 @@ decls_match (tree newdecl, tree olddecl)
 	  && (TYPE_ATTRIBUTES (TREE_TYPE (newdecl)) == NULL_TREE
 	  || comp_type_attributes (TREE_TYPE (newdecl),
 	   TREE_TYPE (olddecl)) != 0);
-  }
 	}
   else
 	types_match = 0;
@@ -7564,24 +7563,54 @@ get_leading_constraints ()
 // parameter list. The adjustment makes them part of the current
 // template requirements.
 static void
-adjust_out_of_class_fn_requirements (tree ctype)
+adjust_fn_constraints (tree ctype)
 {
+  // When grokking a member function template, we are processing
+  // template decl at a depth greater than that of the member's
+  // enclosing class. That is, this case corresponds to the
+  // following declarations:
+  //
+  //template
+  //struct S {
+  //  template void f(U);
+  //};
+  //
+  //template template  void S::f(U) { }
+  //
+  // In both decls, the constraint D is not the current leading
+  // constraint. Make it so.
+  //
+  // Note that for normal member functions, there are no leading
+  // requirements we need to gather.
   if (ctype && processing_template_decl > template_class_depth (ctype))
 {
   if (tree ci = TEMPLATE_PARMS_CONSTRAINTS (current_template_parms))
 {
+  // TODO: When do I ever have leading requirements for a
+  // member function template?
   tree reqs = CI_LEADING_REQS (ci);
   if (reqs && !get_leading_constraints ())
 current_template_reqs = save_leading_constraints (reqs);
 }
 }
-  else if (current_template_parms)
+
+  // Otherwise, this is just a regular function template. Like so:
+  //
+  //template void f();
+  //
+  // Note that the constraint C is not the current leading requirement
+  // at this point; it was stashed before the declarator was parsed.
+  // Make it the leading constraint.
+  else if (!ctype && current_template_parms)
   {
 if (tree ci = TEMPLATE_PARMS_CONSTRAINTS (current_template_parms))
   {
 tree r1 = CI_LEADING_REQS (ci);
 if (current_template_reqs)
   {
+// TODO: As with above, when do I ever have leading
+// requirements that aren't part of the

Re: [PATCH 075/236] final.c: Use rtx_insn (also touches output.c and config/arc/arc.c)

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

In particular, after this patch, the first param passed to the
FINAL_PRESCAN_INSN macro is strengthened from rtx to rtx_insn *.

gcc/
* output.h (final_scan_insn): Strengthen return type from rtx to
rtx_insn *.
(final_forward_branch_p): Likewise for param.
(current_output_insn): Likewise for this global.

* final.c (rtx debug_insn): Likewise for this variable.
(current_output_insn): Likewise.
(get_attr_length_1): Rename param "insn" to "uncast_insn",
adding "insn" back in as an rtx_insn * with a checked cast, so
that macro ADJUST_INSN_LENGTH can be passed an rtx_insn * as the
first param.
(compute_alignments): Strengthen local "label" from rtx to
rtx_insn *.
(shorten_branches): Rename param from "first" to "uncast_first",
introducing a new local rtx_insn * "first" using a checked cast to
effectively strengthen "first" from rtx to rtx_insn * without
affecting the type signature.  Strengthen locals "insn", "seq",
"next", "label" from rtx to rtx_insn *.
(change_scope): Strengthen param "orig_insn" and local "insn" from
rtx to rtx_insn *.
(final_start_function): Rename param from "first" to "uncast_first",
introducing a new local rtx_insn * "first" using a checked cast to
effectively strengthen "first" from rtx to rtx_insn * without
affecting the type signature.  Strengthen local "insn" from rtx to
rtx_insn *.
(dump_basic_block_info): Strengthen param "insn" from rtx to
rtx_insn *.
(final): Rename param from "first" to "uncast_first",
introducing a new local rtx_insn * "first" using a checked cast to
effectively strengthen "first" from rtx to rtx_insn * without
affecting the type signature.  Strengthen locals "insn", "next"
from rtx to rtx_insn *.
(output_alternate_entry_point): Strengthen param "insn" from rtx to
rtx_insn *.
(call_from_call_insn): Strengthen param "insn" from rtx to
rtx_call_insn *.
(final_scan_insn): Rename param from "insn" to "uncast_insn",
introducing a new local rtx_insn * "insn" using a checked cast to
effectively strengthen "insn" from rtx to rtx_insn * without
affecting the type signature.  Strengthen return type and locals
"next", "note", "prev", "new_rtx" from rtx to rtx_insn *.  Remove
now-redundant checked cast to rtx_insn * from both invocations of
debug_hooks->var_location.  Convert CALL_P into a dyn_cast,
introducing a local "call_insn" for use when invoking
call_from_call_insn.
(notice_source_line): Strengthen param "insn" from rtx to
rtx_insn *.
(leaf_function_p): Likewise for local "insn".
(final_forward_branch_p): Likewise.
(leaf_renumber_regs): Likewise for param "first".
(rest_of_clean_state): Likewise for locals "insn" and "next".
(collect_fn_hard_reg_usage): Likewise for local "insn".
(get_call_fndecl): Likewise for param "insn".
(get_call_cgraph_rtl_info): Likewise.
(get_call_reg_set_usage): Rename param from "insn" to "uncast_insn",
introducing a new local rtx_insn * "insn" using a checked cast to
effectively strengthen "insn" from rtx to rtx_insn * without
affecting the type signature.

* config/arc/arc.c (arc_final_prescan_insn): For now, add checked
cast when assigning from param "insn" to current_output_insn.
(arc_pad_return): Strengthen local "insn" from rtx to rtx_insn *
so that we can assign it back to current_output_insn.
OK.  I didn't check all the uncast_XXX thingies, but at least some of 
them go away in later patches.   Presumably you verified the uncast_XXX 
thingies all go away in the end :-)


Patches #76-#91 are OK as well.

jeff


Re: [PATCH 190/236] Remove insn_addresses_new from 'various scheduling strengthenings'

2014-08-13 Thread David Malcolm
On Wed, 2014-08-06 at 13:22 -0400, David Malcolm wrote:
> ---
>  gcc/insn-addr.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gcc/insn-addr.h b/gcc/insn-addr.h
> index e255ac4..aec09fd 100644
> --- a/gcc/insn-addr.h
> +++ b/gcc/insn-addr.h
> @@ -38,7 +38,7 @@ extern int insn_current_address;
>  #define INSN_ADDRESSES_SIZE() (insn_addresses_.length ())
>  
>  static inline void
> -insn_addresses_new (rtx_insn *insn, int insn_addr)
> +insn_addresses_new (rtx insn, int insn_addr)
>  {
>unsigned insn_uid = INSN_UID ((insn));

Oops; this one undoes part of patch 189.  I think I meant to squash
these two together, since without 190, 189 breaks the build on s390 in a
few places.



Re: [patch] libstdc++/61841 odr-use pthread_create in std::thread constructor

2014-08-13 Thread Jakub Jelinek
On Wed, Aug 13, 2014 at 08:02:22PM +0100, Jonathan Wakely wrote:
> On 13/08/14 20:47 +0200, Jakub Jelinek wrote:
> >On Wed, Aug 13, 2014 at 07:40:57PM +0100, Jonathan Wakely wrote:
> >>This should fix the Hurd bug in PR61841 as well as the problem
> >>described in https://gcc.gnu.org/ml/gcc/2013-09/msg00196.html
> >>
> >>Tested x86_64-linux, committed to trunk.
> >>
> >>This is not suitable for the branches as it requires a new exported
> >>symbol. We could maybe just add some other odr-use of pthread_create,
> >>but it would probably be optimized away anyway.
> >
> >E.g. __asm ("" : : "r" (&pthread_create)); would not be optimized away.
> 
> Good idea - thanks. Do we want to do that instead of adding the new
> exported function I've added on trunk?

Dunno, you're the maintainer ;)  On one side, asm has the disadvantage of
being a scheduling barrier (because it is implicitly volatile), on the other
side, we are talking about pthread_create call, so perhaps a few lost ticks
is nothing compared to that.

Jakub


Re: [PATCH] Fix UB in diagnostic.c

2014-08-13 Thread Manuel López-Ibáñez
> This should fix an undefined behavior in diagnostics.c.
> Under certain circumstances, max_width is (INT_MAX - 1),
> and right_margin is -4 -> the subtraction overflows.
> Changing the types to unsigned would involve changing
> much more code than just one cast.
>
> BTW, the diagnostics we output for the testcase in the PR
> is crap - but I'm not fixing it now.

Hi Marek,

I don't think this is the right fix. The problem is that we are trying
to print the caret in a column that is larger than the line_width. We
do this because the file given by the line directive has nothing to do
with the actual code we are parsing. I think in that case it is ok to
just give up and not print a caret. So something like:

@@ -300,11 +299,11 @@ diagnostic_show_locus (diagnostic_contex
 return;

   context->last_location = diagnostic->location;
   s = expand_location_to_spelling_point (diagnostic->location);
   line = location_get_source_line (s, &line_width);
-  if (line == NULL)
+  if (line == NULL || s.column > line_width)
 return;

   max_width = context->caret_max_width;
   line = adjust_line (line, line_width, max_width, &(s.column));

Nonetheless, perhaps in addition adjust_line should have
gcc_checking_assert(line_width >= column).

Another alternative is for location_get_source_line to check this and
return NULL in that case (since that location cannot belong to that
source line). But perhaps such behavior might be useful in other
situations (wrong column info but the file and line are correct).

Cheers,

Manuel.


Re: [patch] libstdc++/61841 odr-use pthread_create in std::thread constructor

2014-08-13 Thread Jonathan Wakely

On 13/08/14 20:47 +0200, Jakub Jelinek wrote:

On Wed, Aug 13, 2014 at 07:40:57PM +0100, Jonathan Wakely wrote:

This should fix the Hurd bug in PR61841 as well as the problem
described in https://gcc.gnu.org/ml/gcc/2013-09/msg00196.html

Tested x86_64-linux, committed to trunk.

This is not suitable for the branches as it requires a new exported
symbol. We could maybe just add some other odr-use of pthread_create,
but it would probably be optimized away anyway.


E.g. __asm ("" : : "r" (&pthread_create)); would not be optimized away.


Good idea - thanks. Do we want to do that instead of adding the new
exported function I've added on trunk?


Re: [PATCH] Fix wrong refactoring in cgraph_node::function_symbol

2014-08-13 Thread Jan Hubicka
> 2014-08-13  Ilya Enkovich  
> 
>   * cgraph.c (cgraph_node::function_symbol): Fix wrong
>   cgraph_function_node to cgraph_node::function_symbol
>   refactoring.

OK, thanks1
Honza
> 
> diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> index 5a0b903..370a96a 100644
> --- a/gcc/cgraph.c
> +++ b/gcc/cgraph.c
> @@ -3000,11 +3000,11 @@ cgraph_node::verify_cgraph_nodes (void)
>  cgraph_node *
>  cgraph_node::function_symbol (enum availability *availability)
>  {
> -  cgraph_node *node = NULL;
> +  cgraph_node *node = this;
>  
>do
>  {
> -  node = ultimate_alias_target (availability);
> +  node = node->ultimate_alias_target (availability);
>if (node->thunk.thunk_p)
>   {
> node = node->callees->callee;


Re: [PATCH testcase]Add bind_pic_locally to case addrtmp.c

2014-08-13 Thread Jeff Law

On 08/07/14 03:43, Bin Cheng wrote:

Hi,

The case depends on GCC inlining of global function, but the callee won't be
inlined because it's global function and considered over-writable during
run-time.
This patch fixes the failure by binding it to pic locally.  Is it OK?

Thanks,
bin

gcc/testsuite/ChangeLog
2014-08-07  Bin Cheng  

* c-c++-common/addrtmp.c: Bind pic locally.

OK.
jeff



Re: [patch] libstdc++/61841 odr-use pthread_create in std::thread constructor

2014-08-13 Thread Jakub Jelinek
On Wed, Aug 13, 2014 at 07:40:57PM +0100, Jonathan Wakely wrote:
> This should fix the Hurd bug in PR61841 as well as the problem
> described in https://gcc.gnu.org/ml/gcc/2013-09/msg00196.html
> 
> Tested x86_64-linux, committed to trunk.
> 
> This is not suitable for the branches as it requires a new exported
> symbol. We could maybe just add some other odr-use of pthread_create,
> but it would probably be optimized away anyway.

E.g. __asm ("" : : "r" (&pthread_create)); would not be optimized away.

> commit 79c721b72b7f9288256cc4bf388cf6b60b65e838
> Author: Jonathan Wakely 
> Date:   Fri Jul 18 15:35:49 2014 +0100
> 
>   PR libstdc++/61841
>   * include/std/thread (thread::_M_start_thread): Declare new overload.
>   (thread::thread<_Callable, _Args...>): Call new overload with an
>   explicit reference to pthread_create.
>   * src/c++11/thread.cc (thread::_M_start_thread): Add new overload.
>   * config/abi/pre/gnu.ver: Export new function.

Jakub


Re: [PATCH 061/236] combine.c: Use rtx_insn

2014-08-13 Thread Jeff Law

On 08/13/14 12:39, Jeff Law wrote:

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* combine.c (i2mod): Strengthen this variable from rtx to rtx_insn *.
(struct reg_stat_struct): Likewise for fields "last_death",
"last_set".
(subst_insn): Likewise for this variable.
(added_links_insn): Likewise.
(struct insn_link): Likewise for field "insn".
(alloc_insn_link): Likewise for param "insn".
(struct undobuf): Likewise for field "other_insn".
(find_single_use): Likewise for param "insn" and local "next".
(combine_validate_cost): Likewise for params "i0", "i1", "i2", "i3".
(delete_noop_moves): Likewise for locals "insn", "next".
(create_log_links): Likewise for locals "insn", "use_insn".
Strengthen local "next_use" from rtx * to rtx_insn **.
(insn_a_feeds_b): Likewise for params "a", "b".
(combine_instructions): Likewise for param "f" and locals "insn",
"next", "prev", "first", "last_combined_insn", "link", "link1",
"temp".  Replace use of NULL_RTX with NULL when referring to
insns.
(setup_incoming_promotions): Likewise for param "first"
(set_nonzero_bits_and_sign_copies): Likewise for local "insn".
(can_combine_p): Likewise for params "insn", "i3", "pred",
"pred2", "succ", "succ2" and for local "p".
(combinable_i3pat): Likewise for param "i3".
(cant_combine_insn_p): Likewise for param "insn".
(likely_spilled_retval_p): Likewise.
(adjust_for_new_dest): Likewise.
(update_cfg_for_uncondjump): Likewise, also for local "insn".
(try_combine): Likewise for return type and for params "i3", "i2",
"i1", "i0", "last_combined_insn", and for locals "insn",
"cc_use_insn", "p", "first", "last", "i2_insn", "i1_insn",
"i0_insn".  Eliminate local "tem" in favor of new locals
"tem_note" and "tem_insn", the latter being an rtx_insn *.  Add a
checked cast for now to rtx_insn * on the return type of
gen_rtx_INSN.  Replace use of NULL_RTX with NULL when referring to
insns.
(find_split_point): Strengthen param "insn" from rtx to
rtx_insn *.
(simplify_set): Likewise for local "other_insn".
(recog_for_combine): Likewise for param "insn".
(record_value_for_reg): Likewise.
(record_dead_and_set_regs_1): Likewise for local
"record_dead_insn".
(record_dead_and_set_regs): Likewise for param "insn".
(record_promoted_value): Likewise.
(check_promoted_subreg): Likewise.
(get_last_value_validate): Likewise.
(reg_dead_at_p): Likewise.
(move_deaths): Likewise for param "to_insn".
(distribute_notes): Likewise for params "from_insn", "i3", "i2"
and locals "place", "place2", "cc0_setter".  Eliminate local "tem
in favor of new locals "tem_note" and "tem_insn", the latter being
an rtx_insn *.
(distribute_links): Strengthen locals "place", "insn" from rtx to
rtx_insn *.
---

OK.

As are patches #62-

This should have been #62-#74.

Jeff



[patch] libstdc++/61841 odr-use pthread_create in std::thread constructor

2014-08-13 Thread Jonathan Wakely

This patch causes the std::thread constructor that launches a new
thread to odr-use pthread_create on glibc-based targets, so that the
program depends directly on pthread_create (and must be linked to
libpthread) not just on the weak symbol in gthr-posix.h

This should fix the Hurd bug in PR61841 as well as the problem
described in https://gcc.gnu.org/ml/gcc/2013-09/msg00196.html

Tested x86_64-linux, committed to trunk.

This is not suitable for the branches as it requires a new exported
symbol. We could maybe just add some other odr-use of pthread_create,
but it would probably be optimized away anyway.

commit 79c721b72b7f9288256cc4bf388cf6b60b65e838
Author: Jonathan Wakely 
Date:   Fri Jul 18 15:35:49 2014 +0100

	PR libstdc++/61841
	* include/std/thread (thread::_M_start_thread): Declare new overload.
	(thread::thread<_Callable, _Args...>): Call new overload with an
	explicit reference to pthread_create.
	* src/c++11/thread.cc (thread::_M_start_thread): Add new overload.
	* config/abi/pre/gnu.ver: Export new function.

diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver
index ed7a93f..41fac71 100644
--- a/libstdc++-v3/config/abi/pre/gnu.ver
+++ b/libstdc++-v3/config/abi/pre/gnu.ver
@@ -1372,6 +1372,9 @@ GLIBCXX_3.4.21 {
 # std::regex_error::regex_error(std::regex_constants::error_type)
 _ZNSt11regex_errorC2ENSt15regex_constants10error_typeE;
 
+# void std::thread::_M_start_thread(__shared_base_type, void(*)())
+_ZNSt6thread15_M_start_threadESt10shared_ptrINS_10_Impl_baseEEPFvvE;
+
 } GLIBCXX_3.4.20;
 
 
diff --git a/libstdc++-v3/include/std/thread b/libstdc++-v3/include/std/thread
index efcb101..0576347 100644
--- a/libstdc++-v3/include/std/thread
+++ b/libstdc++-v3/include/std/thread
@@ -132,9 +132,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   explicit 
   thread(_Callable&& __f, _Args&&... __args)
   {
+#ifdef GTHR_ACTIVE_PROXY
+	// Create a reference to pthread_create, not just the gthr weak symbol
+_M_start_thread(_M_make_routine(std::__bind_simple(
+std::forward<_Callable>(__f),
+std::forward<_Args>(__args)...)),
+	reinterpret_cast(&pthread_create));
+#else
 _M_start_thread(_M_make_routine(std::__bind_simple(
 std::forward<_Callable>(__f),
 std::forward<_Args>(__args)...)));
+#endif
   }
 
 ~thread()
@@ -183,6 +191,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   private:
 void
+_M_start_thread(__shared_base_type, void (*)());
+
+void
 _M_start_thread(__shared_base_type);
 
 template
diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc
index 49aacb5..bbcc99c 100644
--- a/libstdc++-v3/src/c++11/thread.cc
+++ b/libstdc++-v3/src/c++11/thread.cc
@@ -137,6 +137,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __throw_system_error(int(errc::operation_not_permitted));
 #endif
 
+_M_start_thread(__b, nullptr);
+  }
+
+  void
+  thread::_M_start_thread(__shared_base_type __b, void (*)())
+  {
 __b->_M_this_ptr = __b;
 int __e = __gthread_create(&_M_id._M_thread,
 			   &execute_native_thread_routine, __b.get());


Re: [PATCH 061/236] combine.c: Use rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* combine.c (i2mod): Strengthen this variable from rtx to rtx_insn *.
(struct reg_stat_struct): Likewise for fields "last_death", "last_set".
(subst_insn): Likewise for this variable.
(added_links_insn): Likewise.
(struct insn_link): Likewise for field "insn".
(alloc_insn_link): Likewise for param "insn".
(struct undobuf): Likewise for field "other_insn".
(find_single_use): Likewise for param "insn" and local "next".
(combine_validate_cost): Likewise for params "i0", "i1", "i2", "i3".
(delete_noop_moves): Likewise for locals "insn", "next".
(create_log_links): Likewise for locals "insn", "use_insn".
Strengthen local "next_use" from rtx * to rtx_insn **.
(insn_a_feeds_b): Likewise for params "a", "b".
(combine_instructions): Likewise for param "f" and locals "insn",
"next", "prev", "first", "last_combined_insn", "link", "link1",
"temp".  Replace use of NULL_RTX with NULL when referring to
insns.
(setup_incoming_promotions): Likewise for param "first"
(set_nonzero_bits_and_sign_copies): Likewise for local "insn".
(can_combine_p): Likewise for params "insn", "i3", "pred",
"pred2", "succ", "succ2" and for local "p".
(combinable_i3pat): Likewise for param "i3".
(cant_combine_insn_p): Likewise for param "insn".
(likely_spilled_retval_p): Likewise.
(adjust_for_new_dest): Likewise.
(update_cfg_for_uncondjump): Likewise, also for local "insn".
(try_combine): Likewise for return type and for params "i3", "i2",
"i1", "i0", "last_combined_insn", and for locals "insn",
"cc_use_insn", "p", "first", "last", "i2_insn", "i1_insn",
"i0_insn".  Eliminate local "tem" in favor of new locals
"tem_note" and "tem_insn", the latter being an rtx_insn *.  Add a
checked cast for now to rtx_insn * on the return type of
gen_rtx_INSN.  Replace use of NULL_RTX with NULL when referring to
insns.
(find_split_point): Strengthen param "insn" from rtx to
rtx_insn *.
(simplify_set): Likewise for local "other_insn".
(recog_for_combine): Likewise for param "insn".
(record_value_for_reg): Likewise.
(record_dead_and_set_regs_1): Likewise for local
"record_dead_insn".
(record_dead_and_set_regs): Likewise for param "insn".
(record_promoted_value): Likewise.
(check_promoted_subreg): Likewise.
(get_last_value_validate): Likewise.
(reg_dead_at_p): Likewise.
(move_deaths): Likewise for param "to_insn".
(distribute_notes): Likewise for params "from_insn", "i3", "i2"
and locals "place", "place2", "cc0_setter".  Eliminate local "tem
in favor of new locals "tem_note" and "tem_insn", the latter being
an rtx_insn *.
(distribute_links): Strengthen locals "place", "insn" from rtx to
rtx_insn *.
---

OK.

As are patches #62-

Just to be clear, these are largely mechanical changes.  Changes to 
signatures, variables and the like I'm just scanning without deep 
inspection.   Changes in code get more attention, but they're usually 
NULL_RTX->NULL or checked casts.  The checked casts I'm holding my nose 
in the hope that many are going away.   I think after this kit does in, 
a scan of the remaining checked casts would be advisable :-)


jeff




Re: [PATCH 060/236] cfgrtl.c: Use rtx subclasses

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* cfgrtl.c (can_delete_note_p): Require a const rtx_note * rather
than a const_rtx.
(can_delete_label_p): Require a const rtx_code_label * rather than
a const_rtx.
(delete_insn): Add checked cast to rtx_code_label * when we know
we're dealing with LABEL_P (insn).  Strengthen local "bb_note" from
rtx to rtx_insn *.
(delete_insn_chain): Strengthen locals "prev" and "current" from
rtx to rtx_insn *.  Add a checked cast when assigning from
"finish" (strengthening the params will come later).  Add a
checked cast to rtx_note * in region where we know
NOTE_P (current).
(rtl_delete_block): Strengthen locals "insn" and "end" from rtx to
rtx_insn *.
(compute_bb_for_insn): Likewise.
(free_bb_for_insn): Likewise for local "insn".
(compute_bb_for_insn): Likewise.
(update_bb_for_insn_chain): Strengthen params "begin", "end" and
local "insn" from rtx to rtx_insn *
(flow_active_insn_p): Require a const rtx_insn * rather than a
const_rtx.
(contains_no_active_insn_p): Strengthen local "insn" from rtx to
rtx_insn *.
(can_fallthru): Likewise for locals "insn" and "insn2".
(bb_note): Likewise for local "note".
(first_insn_after_basic_block_note): Likewise for local "note" and
for return type.
(rtl_split_block): Likewise for locals "insn" and "next".
(unique_locus_on_edge_between_p): Likewise for locals "insn" and
"end".
(rtl_merge_blocks): Likewise for locals "b_head", "b_end",
"a_end", "del_first", "del_last", "b_debug_start", "b_debug_end",
"prev", "tmp".
(try_redirect_by_replacing_jump): Likewise for locals "insn" (both of
them), "kill_from", "barrier", "new_insn".
(patch_jump_insn): Likewise for params "insn", "old_label".
(redirect_branch_edge): Likewise for locals "old_label", "insn".
(force_nonfallthru_and_redirect): Likewise for locals "insn",
"old_label", "new_label".
(rtl_tidy_fallthru_edge): Likewise for local "q".
(rtl_split_edge): Likewise for locals "before", "last".
(commit_one_edge_insertion): Likewise for locals "before",
"after", "insns", "tmp", "last", adding a checked cast where
currently necessary.
(commit_edge_insertions): Likewise.
(rtl_dump_bb): Likewise for locals "insn", "last".
(print_rtl_with_bb): Likewise for local "x".
(rtl_verify_bb_insns): Likewise for local "x".
(rtl_verify_bb_pointers): Likewise for local "insn".
(rtl_verify_bb_insn_chain): Likewise for locals "x", "last_head",
"head", "end".
(rtl_verify_fallthru): Likewise for local "insn".
(rtl_verify_bb_layout): Likewise for locals "x" and "rtx_first".
(purge_dead_edges): Likewise for local "insn".
(fixup_abnormal_edges): Likewise for locals "insn", "stop", "next".
(skip_insns_after_block): Likewise for return type and for locals
"insn", "last_insn", "next_head", "prev".
(record_effective_endpoints): Likewise for locals "next_insn",
"insn", "end".
(fixup_reorder_chain): Likewise for locals "bb_end_insn" and "end".
(verify_insn_chain): Likewise for locals "x", "prevx", "nextx".
(cfg_layout_can_duplicate_bb_p): Likewise for local "insn".
(duplicate_insn_chain): For now, add checked cast from rtx to
rtx_insn * when returning insn.
(cfg_layout_duplicate_bb): Likewise for local "insn".
(cfg_layout_delete_block): Likewise for locals "insn", "next",
"prev", "remaints".
(cfg_layout_merge_blocks): Likewise for local "insn", "last".
(rtl_block_empty_p): Likewise.
(rtl_split_block_before_cond_jump): Likewise for locals "insn",
"split_point", "last".
(rtl_block_ends_with_call_p): Likewise for local "insn".
(need_fake_edge_p): Strengthen param "insn" from const_rtx to
const rtx_insn *.
(rtl_flow_call_edges_add): Strengthen locals "insn", "prev_insn",
"split_at_insn" from rtx to rtx_insn *.
(rtl_lv_add_condition_to_bb): Likewise for locals "seq", "jump".
(rtl_can_remove_branch_p): Strengthen local "insn" from const_rtx
to const rtx_insn *.
(rtl_account_profile_record): Likewise.
---


OK.

Jeff



Re: [PATCH 057/236] cfgcleanup.c: Use rtx_insn (also touches basic-block.h and ifcvt.c)

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* basic-block.h (flow_find_cross_jump): Strengthen params 3 and 4
"f1" and "f2" from rtx * to rtx_insn **.
(flow_find_head_matching_sequence): Likewise.

* cfgcleanup.c (try_simplify_condjump): Strengthen local
"cbranch_insn" from rtx to rtx_insn *.
(thread_jump): Likewise for local "insn".
(try_forward_edges): Likewise for local "last".
(merge_blocks_move_predecessor_nojumps): Likewise for local "barrier".
(merge_blocks_move_successor_nojumps): Likewise for locals "barrier",
"real_b_end".
(can_replace_by): Likewise for params "i1", "i2".
(old_insns_match_p): Likewise.
(merge_notes): Likewise.
(walk_to_nondebug_insn): Likewise for param "i1".
(flow_find_cross_jump): Strengthen params "f1" and "f2" from rtx *
to rtx_insn **.  Strengthen locals "i1", "i2", "last1", "last2",
"afterlast1", "afterlast2" from rtx to rtx_insn *.
(flow_find_head_matching_sequence): Strengthen params "f1" and
"f2" from rtx * to rtx_insn **.  Strengthen locals "i1", "i2",
"last1", "last2", "beforelast1", "beforelast2" from rtx to
rtx_insn *.
(outgoing_edges_match): Likewise for locals "last1", "last2".
(try_crossjump_to_edge): Likewise for local "insn".
Replace call to for_each_rtx with for_each_rtx_in_insn.

(try_crossjump_to_edge): Likewise for locals "newpos1", "newpos2".
(try_head_merge_bb): Likewise for locals "e0_last_head_, "jump",
"e0_last", "e_last", "head", "curr", "insn".  Strengthen locals
"headptr", "currptr", "nextptr" from rtx * to rtx_insn **.
(try_optimize_cfg): Strengthen local "last" from rtx to
rtx_insn *.
(delete_dead_jumptables): Likewise for locals "insn", "next",
"label".

* ifcvt.c (cond_exec_process_if_block): Likewise for locals
"rtx then_last_head", "rtx else_last_head", "rtx then_first_tail",
"rtx else_first_tail", to reflect the basic-block.h changes above.
OK.  I noticed a for_each_rtx in here.  That block may need updating due 
to Richard S.'s changes.


Patches #58 & #59 are OK too.

jeff



Re: [PATCH 051/236] bb-reorder.c: Use rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* bb-reorder.c (copy_bb_p): Strengthen local "insn" from rtx to
rtx_insn *.
(get_uncond_jump_length): Likewise for locals "label", "jump".
(fix_up_crossing_landing_pad): Likewise for locals "new_label",
"jump", "insn".
(add_labels_and_missing_jumps): Likewise for local "new_jump".
(fix_up_fall_thru_edges): Likewise for local "old_jump".
(find_jump_block): Likewise for local "insn".
(fix_crossing_conditional_branches): Likewise for locals
"old_jump", "new_jump".
(fix_crossing_unconditional_branches): Likewise for locals
"last_insn", "indirect_jump_sequence", "jump_insn", "cur_insn".
(pass_duplicate_computed_gotos::execute): Likewise for local "insn".
---

OK.

As are patches #52-#56

Jeff



Re: [PATCH 050/236] auto-inc-dec.c: strengthen various rtx to rtx_insn *

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

Note to self: verified the compile on pdp11-aout

gcc/
* auto-inc-dec.c (struct inc_insn): Strengthen field "insn" from
rtx to rtx_insn *.
(struct mem_insn): Likewise for field "insn".
(reg_next_use): Strengthen from rtx * to rtx_insn **.
(reg_next_inc_use): Likewise.
(reg_next_def): Likewise.
(move_dead_notes): Strengthen params "to_insn" and "from_insn"
from rtx to rtx_insn *.
(move_insn_before): Likewise for param "next_insn" and local "insns".
(attempt_change): Likewise for local "mov_insn".
(try_merge): Likewise for param "last_insn".
(get_next_ref): Likewise for return type and local "insn".
Strengthen param "next_array" from rtx * to rtx_insn **.
(parse_add_or_inc): Strengthen param "insn" from rtx to
rtx_insn *.
(find_inc): Likewise for locals "insn" and "other_insn" (three of
the latter).
(merge_in_block): Likewise for locals "insn", "curr",
"other_insn".
(pass_inc_dec::execute): Update allocations of the arrays to
reflect the stronger types.

OK.
Jeff




Re: [PATCH 049/236] asan.c: strengthen some rtx locals

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

This is an example of strengthening rtx.  For example, we
now have strong enough types provided by the existing scaffolding to
turn "insn" and "insns" in this:

   for (insn = insns; insn; insn = NEXT_INSN (insn))

from plain rtx into rtx_insn *.

gcc/
* asan.c (asan_clear_shadow): Strengthen locals "insn", "insns"
and "jump" from rtx to rtx_insn *.  Strengthen local "top_label"
from rtx to rtx_code_label *.

OK.
jeff



Re: [PATCH 048/236] alias.c: Use rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* alias.c (init_alias_analysis): Strengthen local "insn" from rtx
to rtx_insn *.

OK.
jeff



Re: [PATCH 047/236] PHASE 2: Per-file commits in main source directory

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

This commit is a placeholder for me when rebasing, to help organize the
patch kit.

/
* rtx-classes-status.txt: Update

OK.
jeff



Re: [PATCH 046/236] delete_related_insns returns an rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* rtl.h (delete_related_insns): Strengthen return type from rtx to
rtx_insn *.

* jump.c (delete_related_insns): Likewise, also for locals "next"
and "prev".

OK.
Jeff



[Patch] Fix crtstuff.c when compiling with mingw tools.

2014-08-13 Thread Steve Ellcey
This is a ping on a patch I sent out a while ago to fix the GCC build
when building with the mingw toolset.

The problem was that crtstuff.c would not compile because it saw two
different (incompatible) definitions of caddr_t, one coming from
auto-host.h (set by the configure script) and one coming from the
sys/types.h system header file (part of glibc in my case).

Since crtstuff.c doesn't actually need or use caddr_t my patch undef's
it after including auto-host.h in the same way that pid_t, rlim_t, ssize_t,
and vfork are already undef'ed.

OK to checkin?

Steve Ellcey
sell...@mips.com


Re: [PATCH 045/236] define_bypass guard functions take a pair of rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

(define_bypass) clauses in .md files can specify the name of a guard
function as their final operand.  Currently these functions are called
with a pair of rtx.  This patch strengthens insn-automata.c so that such
guard functions are passed a pair of rtx_insn *, allowing these guard
functions to be similarly strengthened in the per-target phase of this
patch kit.

gcc/
* genautomata.c (output_internal_insn_latency_func): When writing
the function "internal_insn_latency" to insn-automata.c,
strengthen params "insn" and "insn2" from rtx to rtx_insn *, thus
allowing the optional guard function of (define_bypass) clauses to
expect a pair of rtx_insn *, rather than a pair of rtx.
(output_insn_latency_func): When writing the function
"insn_latency", add an "uncast_" prefix to params "insn" and
"insn2", reintroducing "insn" and "insn2" as rtx_insn * locals
using checked casts from the params, thus enabling the above
change to the generated "internal_insn_latency" function.

OK.
Jeff



Re: [PATCH 044/236] Pass "insn" as an rtx_insn within generated get_attr_ fns in insn-attrtab.c

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

Strengthen "insn" from rtx to rtx_insn * within the generated get_attr_
functions in insn-attrtab.c, without imposing a strengthening from rtx
to rtx_insn * on the param itself and thus the callers.

gcc/
* genattrtab.c (write_attr_get): Within the generated get_attr_
functions, rename param "insn" to "uncast_insn" and reintroduce
"insn" as an local rtx_insn * using a checked cast, so that "insn"
is an rtx_insn * within insn-attrtab.c

OK.
Jeff



Re: [PATCH 043/236] peephole returns an rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* output.h (peephole): Strengthen return type from rtx to rtx_insn *.
* rtl.h (delete_for_peephole): Likewise for both params.
* genpeep.c (main): In generated "peephole" function, strengthen
return type and local "insn" from rtx to rtx_insn *.  For now,
rename param "ins1" to "uncast_ins1", adding "ins1" back as an
rtx_insn *, with a checked cast.
* jump.c (delete_for_peephole): Strengthen params "from", "to" and
locals "insn", "next", "prev" from rtx to rtx_insn *.

OK
Jeff



Re: [PATCH 042/236] try_split returns an rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* rtl.h (try_split): Strengthen return type from rtx to rtx_insn *.

* emit-rtl.c (try_split): Likewise, also for locals "before" and
"after".  For now, don't strengthen param "trial", which requires
adding checked casts when returning it.

OK.
Jeff



Re: [PATCH 041/236] Debug hooks: use rtx_insn and rtx_code_label

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* debug.h (struct gcc_debug_hooks): Strengthen param 1 of hook
"label" from rtx to rtx_code_label *.  Strengthen param 1 o
"var_location" hook from rtx to rtx_insn *.
(debug_nothing_rtx): Delete in favor of...
(debug_nothing_rtx_code_label): New prototype.
(debug_nothing_rtx_rtx): Delete unused prototype.
(debug_nothing_rtx_insn): New prototype.

* final.c (final_scan_insn): Add checked cast to rtx_insn * when
invoking debug_hooks->var_location (in two places, one in a NOTE
case of a switch statement, the other guarded by a CALL_P
conditional.  Add checked cast to rtx_code_label * when invoking
debug_hooks->label (within CODE_LABEL case of switch statement).

* dbxout.c (dbx_debug_hooks): Update "label" hook from
debug_nothing_rtx to debug_nothing_rtx_code_label.  Update
"var_location" from debug_nothing_rtx to debug_nothing_rtx_insn.
(xcoff_debug_hooks): Likewise.
* debug.c (do_nothing_debug_hooks): Likewise.
(debug_nothing_rtx): Delete in favor of...
(debug_nothing_rtx_insn): New function.
(debug_nothing_rtx_rtx): Delete unused function.
(debug_nothing_rtx_code_label): New function.
* dwarf2out.c (dwarf2_debug_hooks): Update "label" hook from
debug_nothing_rtx to debug_nothing_rtx_code_label.
(dwarf2out_var_location): Strengthen param "loc_note" from rtx
to rtx_insn *.
* sdbout.c (sdb_debug_hooks): Update "var_location" hook from
debug_nothing_rtx to debug_nothing_rtx_insn.
(sdbout_label): Strengthen param "insn" from rtx to
rtx_code_label *.
* vmsdbgout.c (vmsdbg_debug_hooks): Update "label" hook from
debug_nothing_rtx to debug_nothing_rtx_code_label.  Update
"var_location" hook from debug_nothing_rtx to
debug_nothing_rtx_insn.
OK.  Note minor typo in changelog line #2.  "o" at EOL should probably 
be "of"


jeff



Re: [PATCH 040/236] Use rtx_insn internally within generated functions

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

With this patch, "insn" and "curr_insn" as used from C++ fragments in .md
files are strengthened from rtx to rtx_insn *, allowing numerous
target-specific functions to have their params be similiar strengthened.

The top-level interfaces ("recog", "split", "peephole2") continue to take
a plain rtx for "insn", to avoid introducing dependencies on other
patches.

gcc/
* recog.h (insn_output_fn): Update this function typedef to match
the changes below to the generated output functions, strengthening
the 2nd param from rtx to rtx_insn *.

* final.c (get_insn_template): Add a checked cast to rtx_insn * on
insn when invoking an output function, to match the new signature
of insn_output_fn with a stronger second param.

* genconditions.c (write_header): In the generated code for
gencondmd.c, strengthen the global "insn" from rtx to rtx_insn *
to match the other changes in this patch.

* genemit.c (gen_split): Strengthen the 1st param "curr_insn" of
the generated "gen_" functions from rtx to rtx_insn * within their
implementations.

* genrecog.c (write_subroutine): Strengthen the 2nd param "insn" of
the subfunctions within the generated "recog_", "split", "peephole2"
function trees from rtx to rtx_insn *.  For now, the top-level
generated functions ("recog", "split", "peephole2") continue to
take a plain rtx for "insn", to avoid introducing dependencies on
other patches.  Rename this 2nd param from "insn" to
"uncast_insn", and reintroduce "insn" as a local variable of type
rtx_insn *, initialized at the top of the generated function with
a checked cast on "uncast_insn".
(make_insn_sequence): Strengthen the 1st param "curr_insn" of
the generated "gen_" functions from rtx to rtx_insn * within their
prototypes.

* genoutput.c (process_template): Strengthen the 2nd param within
the generated "output_" functions "insn" from rtx to rtx_insn *.

OK.
Jeff



Fwd: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Mike Stump
[ dup sorry ]

On Aug 13, 2014, at 5:12 AM, Felix Yang  wrote:
>   The qsort library function may have different behavior on
> different hosts (say Linux vs MinGW).

> OK for trunk?

I just have one question.  Why if we want to use a stable sort, and we program 
in C++, would we not want to just use C++:

 http://www.cplusplus.com/reference/algorithm/stable_sort/

I’m hoping that performance doesn’t fall off the cliff with it...

Re: [PATCH 039/236] create_insn_rtx_from_pattern and create_copy_of_insn_rtx return rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* sel-sched-ir.h (create_insn_rtx_from_pattern): Strengthen return
type from rtx to rtx_insn *.
* sel-sched-ir.h (create_copy_of_insn_rtx): Likewise.
* sel-sched-ir.c (create_insn_rtx_from_pattern): Likewise.
* sel-sched-ir.c (create_copy_of_insn_rtx): Likewise, also for
local "res".

OK.
jeff



Re: [PATCH 038/236] find_first_parameter_load returns an rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* rtl.h (find_first_parameter_load): Strengthen return type from
rtx to rtx_insn *.
* rtlanal.c (find_first_parameter_load): Strengthen return type
from rtx to rtx_insn *.  Add checked cast for now, to postpone
strengthening the params.

OK.
jeff



Re: [PATCH] Add Berkeley qsort to libiberty to make GCC host-independent

2014-08-13 Thread Mike Stump
On Aug 13, 2014, at 5:12 AM, Felix Yang  wrote:
>The qsort library function may have different behavior on
> different hosts (say Linux vs MinGW).

> OK for trunk?

I just have one question.  Why if we want to use a stable sort, and we program 
in C++, would we not want to just use C++:

  http://www.cplusplus.com/reference/algorithm/stable_sort/

I’m hoping that performance doesn’t fall off the cliff with it...

Re: [PATCH 037/236] sel_bb_{head|end} return rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* sel-sched-ir.h (exit_insn): Strengthen from rtx to rtx_insn *.
(sel_bb_head): Strengthen return type insn_t (currently just an
rtx) to rtx_insn *.
(sel_bb_end): Likewise.

* sel-sched-ir.c (exit_insn): Strengthen from rtx to rtx_insn *.
(sel_bb_head): Strengthen return type and local "head" from
insn_t (currently just an rtx) to rtx_insn *.
(sel_bb_end): Likewise for return type.
(free_nop_and_exit_insns): Replace use of NULL_RTX with NULL when
working with insn.

OK.
Jeff



Re: [PATCH 036/236] get_last_bb_insn returns an rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* basic-block.h (get_last_bb_insn): Strengthen return type from
rtx to rtx_insn *.
* cfgrtl.c (get_last_bb_insn): Likewise, and for locals "tmp" and
end".

OK.
jeff



Re: [PATCH 035/236] Return types of unlink_insn_chain and duplicate_insn_chain

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* rtl.h (unlink_insn_chain): Strengthen return type from rtx to
rtx_insn *.
(duplicate_insn_chain): Likewise.
* cfgrtl.c (unlink_insn_chain): Strengthen return type from rtx to
rtx_insn *, also for locals "prevfirst" and "nextlast".  Add a
checked cast for now (until we can strengthen the params in the
same way).
(duplicate_insn_chain): Likewise.

OK.
jeff



Re: [PATCH 034/236] next_cc0_user and prev_cc0_setter scaffolding

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* rtl.h (next_cc0_user): Strengthen return type from rtx to
rtx_insn *.
(prev_cc0_setter): Likewise.

* emit-rtl.c (next_cc0_user): Strengthen return type from rtx to
rtx_insn *, adding checked casts for now as necessary.
(prev_cc0_setter): Likewise.

OK.
jeff



Re: [PATCH 033/236] emit_move et al return rtx_insn *

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* expr.h (emit_move_insn): Strengthen return type from rtx to
rtx_insn *.
(emit_move_insn_1): Likewise.
(emit_move_complex_push): Likewise.
(emit_move_complex_parts): Likewise.

* expr.c (emit_move_via_integer): Strengthen return type from rtx
to rtx_insn *.  Replace use of NULL_RTX with NULL when working
with insns.
(emit_move_complex_push): Strengthen return type from rtx to
rtx_insn *.
(emit_move_complex): Likewise, also for local "ret".
(emit_move_ccmode): Likewise.
(emit_move_multi_word): Likewise for return type and locals
"last_insn", "seq".
(emit_move_insn_1): Likewise for return type and locals "result",
"ret".
(emit_move_insn): Likewise for return type and local "last_insn".
(compress_float_constant): Likewise.

OK.
jeff



Re: [PATCH 032/236] emit_* functions return rtx_insn

2014-08-13 Thread Jeff Law

On 08/06/14 11:20, David Malcolm wrote:

More scaffolding: strengthen the return types from the various emit_
functions from rtx to rtx_insn * (or to the rtx_barrier * subclass in a
few cases).

These will ultimately have their params strengthened also, but we
postpone that until much later in the patch series.  So for now there
are also various checked casts to ensure we really got an insn when
returning such params back.

Doing so requires a minor tweak to config/sh/sh.c

gcc/
* emit-rtl.h (emit_copy_of_insn_after): Strengthen return type
from rtx to rtx_insn *.

* rtl.h (emit_insn_before): Likewise.
(emit_insn_before_noloc): Likewise.
(emit_insn_before_setloc): Likewise.
(emit_jump_insn_before): Likewise.
(emit_jump_insn_before_noloc): Likewise.
(emit_jump_insn_before_setloc): Likewise.
(emit_call_insn_before): Likewise.
(emit_call_insn_before_noloc): Likewise.
(emit_call_insn_before_setloc): Likewise.
(emit_debug_insn_before): Likewise.
(emit_debug_insn_before_noloc): Likewise.
(emit_debug_insn_before_setloc): Likewise.
(emit_label_before): Likewise.
(emit_insn_after): Likewise.
(emit_insn_after_noloc): Likewise.
(emit_insn_after_setloc): Likewise.
(emit_jump_insn_after): Likewise.
(emit_jump_insn_after_noloc): Likewise.
(emit_jump_insn_after_setloc): Likewise.
(emit_call_insn_after): Likewise.
(emit_call_insn_after_noloc): Likewise.
(emit_call_insn_after_setloc): Likewise.
(emit_debug_insn_after): Likewise.
(emit_debug_insn_after_noloc): Likewise.
(emit_debug_insn_after_setloc): Likewise.
(emit_label_after): Likewise.
(emit_insn): Likewise.
(emit_debug_insn): Likewise.
(emit_jump_insn): Likewise.
(emit_call_insn): Likewise.
(emit_label): Likewise.
(gen_clobber): Likewise.
(emit_clobber): Likewise.
(gen_use): Likewise.
(emit_use): Likewise.
(emit): Likewise.

(emit_barrier_before): Strengthen return type from rtx to
rtx_barrier *.
(emit_barrier_after): Likewise.
(emit_barrier): Likewise.

* emit-rtl.c (emit_pattern_before_noloc):  Strengthen return type
from rtx to rtx_insn *.  Add checked casts for now when converting
"last" from rtx to rtx_insn *.
(emit_insn_before_noloc): Likewise for return type.
(emit_jump_insn_before_noloc): Likewise.
(emit_call_insn_before_noloc): Likewise.
(emit_debug_insn_before_noloc): Likewise.
(emit_barrier_before): Strengthen return type and local "insn"
from rtx to rtx_barrier *.
(emit_label_before): Strengthen return type from rtx to
rtx_insn *.  Add checked cast for now when returning param
(emit_pattern_after_noloc): Strengthen return type from rtx to
rtx_insn *.  Add checked casts for now when converting "last" from
rtx to rtx_insn *.
(emit_insn_after_noloc): Strengthen return type from rtx to
rtx_insn *.
(emit_jump_insn_after_noloc): Likewise.
(emit_call_insn_after_noloc): Likewise.
(emit_debug_insn_after_noloc): Likewise.
(emit_barrier_after): Strengthen return type from rtx to
rtx_barrier *.
(emit_label_after): Strengthen return type from rtx to rtx_insn *.
Add checked cast for now when converting "label" from rtx to
rtx_insn *.
(emit_pattern_after_setloc): Strengthen return type from rtx to
rtx_insn *.  Add checked casts for now when converting "last" from
rtx to rtx_insn *.
(emit_pattern_after): Strengthen return type from rtx to
rtx_insn *.
(emit_insn_after_setloc): Likewise.
(emit_insn_after): Likewise.
(emit_jump_insn_after_setloc): Likewise.
(emit_jump_insn_after): Likewise.
(emit_call_insn_after_setloc): Likewise.
(emit_call_insn_after): Likewise.
(emit_debug_insn_after_setloc): Likewise.
(emit_debug_insn_after): Likewise.
(emit_pattern_before_setloc): Likewise.  Add checked casts for now
when converting "last" from rtx to rtx_insn *.
(emit_pattern_before): Strengthen return type from rtx to
rtx_insn *.
(emit_insn_before_setloc): Likewise.
(emit_insn_before): Likewise.
(emit_jump_insn_before_setloc): Likewise.
(emit_jump_insn_before): Likewise.
(emit_call_insn_before_setloc): Likewise.
(emit_call_insn_before): Likewise.
(emit_debug_insn_before_setloc): Likewise.
(emit_debug_insn_before): Likewise.
(emit_insn): Strengthen return type and locals "last", "insn",
"next" from rtx to rtx_insn *.  Add checked cast to rtx_insn
within cases where we know we have an insn.
(emit_debug_insn): Likewise.
(emit_jump_in

Re: [PATCH] Fix PR62077

2014-08-13 Thread Jason Merrill

On 08/13/2014 10:28 AM, Richard Biener wrote:

Sofar the patch survived building stage2 in a LTO bootstrap on the
4.9 branch, full testing is scheduled for trunk.


The patch breaks a lot of C++ testcases, such as
g++.old-deja/g++.other/cvt1.C; I think you need to share the "set the 
canonical type" code with the template path.



Jason, are you happy with that (esp. ripping out the odd
type completion stuff that also messes with types recorded in
said hashtable)?


I'm nervous about it, since it leads to ARRAY_TYPEs with different 
TYPE_ALIGN than their elements, though I'm not sure this actually breaks 
anything.  Perhaps we could copy TYPE_ALIGN and TYPE_USER_ALIGN at the 
same place we copy TYPE_NEEDS_CONSTRUCTING.


Jason



Re: [PATCH i386 AVX512] [8/n] Extend substs for new patterns.

2014-08-13 Thread Uros Bizjak
On Wed, Aug 13, 2014 at 4:23 PM, Kirill Yukhin  wrote:

>> >> In a couple of places,  checks are changed to GET_MODE_SIZE
>> >> (GET_MODE (operands[0])) and in a similar way, mode checks were
>> >> changed to GET_MODE (operands[0]). The previous checks are more
>> >> efficient and are preferred. Is there a reason you need to check
>> >> operands[0] dynamically?
>> >
>> > I agree, runtime tests are worse. But this subst attributes are used
>> > in patterns which actually do not contain mode iterators at all.
>>
>> IMO, two different subst patterns should be used in this case, one for
>> patterns with and one for patterns w/o mode iterators.
>
> That was my second thought after I hit `send'.
>
> Updated patch in the bottom
>
> Bootstrapped.
>
> (Regtest w/ new tests is in progress).
>
> Is it ok if pass?
>
> gcc/
> * config/i386/sse.md: Allow V64QI, V32QI, V32HI, V4HI modes.
> * config/i386/subst.md
> (define_mode_iterator SUBST_V): Update.
> (define_mode_iterator SUBST_A): Ditto.
> (define_subst_attr "mask_operand7"): New.
> (define_subst_attr "mask_operand10"): New.
> (define_subst_attr "mask_operand_arg34") : New.
> (define_subst_attr "mask_expand_op3"): New.
> (define_subst_attr "mask_mode512bit_condition"): Handle 
> TARGET_AVX512VL.
> (define_subst_attr "sd_mask_mode512bit_condition"): Ditto.
> (define_subst_attr "mask_avx512vl_condition"): New.
> (define_subst_attr "round_mask_operand4"): Ditto.
> (define_subst_attr "round_mask_scalar_op3"): Delete.
> (define_subst_attr "round_mask_op4"): New.
> (define_subst_attr "round_mode512bit_condition"): Allow V8DImode,
> V16SImode.
> (define_subst_attr "round_modev8sf_condition"): New.
> (define_subst_attr "round_modev4sf_condition"): GET_MODE instead of
> mode.
> (define_subst_attr "round_saeonly_mask_operand4"): New.
> (define_subst_attr "round_saeonly_mask_op4"): New.
> (define_subst_attr "round_saeonly_mode512bit_condition"): Allow
> V8DImode, V16SImode.
> (define_subst_attr "round_saeonly_modev8sf_condition"): New.
> (define_subst_attr "mask_expand4_name" "mask_expand4"): New.
> (define_subst_attr "mask_expand4_args"): New.
> (define_subst "mask_expand4"): New.

This is OK.

Thanks,
Uros.


Re: [PATCH 029/236] rtl_data.x_parm_birth_insn is an insn

2014-08-13 Thread Jeff Law

On 08/13/14 11:08, David Malcolm wrote:

On Wed, 2014-08-13 at 07:44 -0600, Jeff Law wrote:

On 08/06/14 11:20, David Malcolm wrote:

gcc/
* function.h (struct rtl_data): Strengthen field
"x_parm_birth_insn" from rtx to rtx_insn *.
* function.c (struct assign_parm_data_all): Strengthen fields
"first_conversion_insn" and "last_conversion_insn" from rtx to
rtx_insn *.

OK.  I think at this point any patch which merely changes the type of
some variable or in a signature from rtx to rtx_insn (or any of the
concrete passes) is considered trivial enough to go forward without

^^
Presumably you meant "subclasses" here, right?

yes.




explicit review.

That applies to patches in this series, additions you may need to make
due to changes in the tree since you last rebased and further
strengthening you or anyone else may want to tackle.


Heh - indeed, patch #30 needs a trivial fixup of the return type of the
helper function
   emit_note_eh_region_end
that was added in r212171, from rtx to rtx_note *.

[yes, I'm working on rebasing it all against today's trunk right now]

:-)
Jeff


Re: [PATCH 029/236] rtl_data.x_parm_birth_insn is an insn

2014-08-13 Thread David Malcolm
On Wed, 2014-08-13 at 07:44 -0600, Jeff Law wrote:
> On 08/06/14 11:20, David Malcolm wrote:
> > gcc/
> > * function.h (struct rtl_data): Strengthen field
> > "x_parm_birth_insn" from rtx to rtx_insn *.
> > * function.c (struct assign_parm_data_all): Strengthen fields
> > "first_conversion_insn" and "last_conversion_insn" from rtx to
> > rtx_insn *.
> OK.  I think at this point any patch which merely changes the type of 
> some variable or in a signature from rtx to rtx_insn (or any of the 
> concrete passes) is considered trivial enough to go forward without 
   ^^
Presumably you meant "subclasses" here, right?

> explicit review.
> 
> That applies to patches in this series, additions you may need to make 
> due to changes in the tree since you last rebased and further 
> strengthening you or anyone else may want to tackle.

Heh - indeed, patch #30 needs a trivial fixup of the return type of the
helper function
  emit_note_eh_region_end
that was added in r212171, from rtx to rtx_note *.

[yes, I'm working on rebasing it all against today's trunk right now]

Thanks
Dave




Re: [C++ Patch] Remove "invalid type in declaration" parser error

2014-08-13 Thread Jason Merrill

OK.

Jason


Re: [PATCH 140/236] config/microblaze/microblaze.c: Use rtx_insn and rtx_code_label

2014-08-13 Thread Michael Eager

On 08/06/14 10:21, David Malcolm wrote:

gcc/
* config/microblaze/microblaze.c (microblaze_call_tls_get_addr):
Strengthen return type and local "insns" from rtx to rtx_insn *.
(microblaze_legitimize_tls_address): Likewise for local "insns".
(microblaze_block_move_loop): Strengthen local "label" from rtx
to rtx_code_label *.
(microblaze_expand_prologue): Strengthen two locals named "insn"
from rtx to rtx_insn *.
(microblaze_asm_output_mi_thunk): Likewise for local "insn".
(microblaze_expand_divide): Likewise for locals "jump", "cjump",
"insn".  Strengthen locals "div_label", "div_end_label" from rtx
to rtx_code_label *.



OK


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


Re: [gomp4] Add tables generation

2014-08-13 Thread Ilya Verbin
Hi,

Here is the updated patch.  offload_funcs/vars are now declared in omp-low.h,
the functions have a comment.  Also it fixes the issue of offload_funcs/vars
corruption by the garbage collector.  OK for gomp-4_0-branch?

  -- Ilya

---
 gcc/Makefile.in|1 +
 gcc/gengtype.c |2 +-
 gcc/lto-cgraph.c   |  110 
 gcc/lto-section-in.c   |3 +-
 gcc/lto-streamer-out.c |2 +
 gcc/lto-streamer.h |3 +
 gcc/lto/lto.c  |2 +
 gcc/omp-low.c  |   68 ++
 gcc/omp-low.h  |3 +
 9 files changed, 137 insertions(+), 57 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index bfa5f32..372f586 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2290,6 +2290,7 @@ GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h 
$(srcdir)/coretypes.h \
   $(srcdir)/tree-profile.c $(srcdir)/tree-nested.c \
   $(srcdir)/tree-parloops.c \
   $(srcdir)/omp-low.c \
+  $(srcdir)/omp-low.h \
   $(srcdir)/targhooks.c $(out_file) $(srcdir)/passes.c $(srcdir)/cgraphunit.c \
   $(srcdir)/cgraphclones.c \
   $(srcdir)/tree-phinodes.c \
diff --git a/gcc/gengtype.c b/gcc/gengtype.c
index ffe3f94..5bcbbe2 100644
--- a/gcc/gengtype.c
+++ b/gcc/gengtype.c
@@ -1800,7 +1800,7 @@ open_base_files (void)
   "tree-ssa.h", "reload.h", "cpp-id-data.h", "tree-chrec.h",
   "except.h", "output.h",  "cfgloop.h",
   "target.h", "ipa-prop.h", "lto-streamer.h", "target-globals.h",
-  "ipa-inline.h", "dwarf2out.h", NULL
+  "ipa-inline.h", "dwarf2out.h", "omp-low.h", NULL
 };
 const char *const *ifp;
 outf_p gtype_desc_c;
diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
index bc05400..64ad599 100644
--- a/gcc/lto-cgraph.c
+++ b/gcc/lto-cgraph.c
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "context.h"
 #include "pass_manager.h"
 #include "ipa-utils.h"
+#include "omp-low.h"
 
 /* True when asm nodes has been output.  */
 bool asm_nodes_output = false;
@@ -1044,6 +1045,66 @@ read_string (struct lto_input_block *ib)
   return str;
 }
 
+/* Output function/variable tables that will allow libgomp to look up offload
+   target code.  OFFLOAD_FUNCS is filled in expand_omp_target, OFFLOAD_VARS is
+   filled here just before streaming.  In WHOPR (partitioned) mode during the
+   WPA stage both OFFLOAD_FUNCS and OFFLOAD_VARS are filled by
+   input_offload_tables.  */
+
+void
+output_offload_tables (void)
+{
+  /* Collect all omp-target global variables to offload_vars, if they have not
+ been gathered earlier by input_offload_tables on the WPA stage.  */
+  if (!flag_wpa && vec_safe_is_empty (offload_vars))
+{
+  struct varpool_node *vnode;
+  FOR_EACH_DEFINED_VARIABLE (vnode)
+   {
+ if (!lookup_attribute ("omp declare target",
+DECL_ATTRIBUTES (vnode->decl))
+ || TREE_CODE (vnode->decl) != VAR_DECL
+ || DECL_SIZE (vnode->decl) == 0)
+   continue;
+ vec_safe_push (offload_vars, vnode->decl);
+   }
+}
+
+  if (vec_safe_is_empty (offload_funcs) && vec_safe_is_empty (offload_vars))
+return;
+
+  struct lto_simple_output_block *ob
+= lto_create_simple_output_block (LTO_section_offload_table);
+
+  for (unsigned i = 0; i < vec_safe_length (offload_funcs); i++)
+{
+  streamer_write_enum (ob->main_stream, LTO_symtab_tags,
+  LTO_symtab_last_tag, LTO_symtab_unavail_node);
+  lto_output_fn_decl_index (ob->decl_state, ob->main_stream,
+   (*offload_funcs)[i]);
+}
+
+  for (unsigned i = 0; i < vec_safe_length (offload_vars); i++)
+{
+  streamer_write_enum (ob->main_stream, LTO_symtab_tags,
+  LTO_symtab_last_tag, LTO_symtab_variable);
+  lto_output_var_decl_index (ob->decl_state, ob->main_stream,
+(*offload_vars)[i]);
+}
+
+  streamer_write_uhwi_stream (ob->main_stream, 0);
+  lto_destroy_simple_output_block (ob);
+
+  /* In WHOPR mode during the WPA stage the joint offload tables need to be
+ streamed to one partition only.  That's why we free offload_funcs and
+ offload_vars after the first call of output_offload_tables.  */
+  if (flag_wpa)
+{
+  vec_free (offload_funcs);
+  vec_free (offload_vars);
+}
+}
+
 /* Overwrite the information in NODE based on FILE_DATA, TAG, FLAGS,
STACK_SIZE, SELF_TIME and SELF_SIZE.  This is called either to initialize
NODE or to replace the values in it, for instance because the first
@@ -1739,6 +1800,55 @@ input_symtab (void)
 }
 }
 
+/* Input function/variable tables that will allow libgomp to look up offload
+   target code, and store them into OFFLOAD_FUNCS and OFFLOAD_VARS.  */
+
+void
+input_offload_tables (void)
+{
+  struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data ();
+  struct lto_file_decl_data *file_data;
+  unsigned int j = 0;
+

Re: [PATCH AArch64 1/3] Don't disparage add/sub in SIMD registers

2014-08-13 Thread Vladimir Makarov

On 2014-08-13, 4:36 AM, James Greenhalgh wrote:

On Tue, Aug 12, 2014 at 04:53:38PM +0100, pins...@gmail.com wrote:




On Aug 12, 2014, at 7:40 AM, Alan Lawrence  wrote:

(It is no more expensive.)


Yes on some processors it could be.


Haven't we been here before [1]?

This disparaging mechanism is still not going to give what we are trying to
achieve (assigning cost at the -mcpu/-mtune level, rather than the
target level).

Recall that '!' gives a static cost of 600 [2] and that this cost is
only applied to the alternative if any operand in that alternative needs
reloading - otherwise, LRA sees a set of matching operands and does not
bother checking costs [3]. IRA, as far as I can see, does not care about
'!', but unconditionally adds 2 to the cost of an alternative for '?' [4].



Yes, correct.  IRA follows the old global RA and the documentation.


Even if LRA did try to do a more complete job of always picking the
alternative with lowest cost (rather than the current first-matching
behaviour) "600" would be far too high a cost for the operation.

If IRA took '!' into account, we would be as well to remove the alternative
entirely.



Yes, that is right.


So, I still can't agree that we want these exclamation marks - and we are
now in a halfway state where some instructions have them and some don't.
We have to pick a consistent policy or we are going to see some very poor
code generation.

In an ideal world, we would have a sensible way of describing a
(per-core granularity) alternative cost, which would be considered by
the register allocators. I've played about with doing this using attributes,
but it ends up as a messy patch and I can't bring myself to add yet another
cost framework to the back end.

Do you have any ideas as to how we can make some progress? Maybe Vladimir
has some suggestions?



Yes, I have some thoughts.  We could provide machine-dependent hooks to 
treat different costs for '!' (which will work only for LRA/reload), and 
'?', and even '*' (to ignore or not the next register constraint for 
register preference).  The hook could get insn for which we calculate 
the costs and of course to have the current default values) for 
compatibility.


It could provide a lot of flexibility for machine-description writers.

Although it would create some conflicts with insn cost attribute 
calculation by alternatives and would create more complication for less 
experienced md writer.   So we need some more consistent solution.  It 
is all about code selection which currently is done in many places 
(combiner, register preferences and finally in reload/LRA).  A lot of 
thinking should be done how to better approach to the solution.


The right approach would be reconsider all the pipeline and probably 
rewriting combiner/register preferencing (which is moved from the old 
regclass.c practically without changes and ignore the fact that the 
alternative should be the same for different operands) / partially LRA. 
 So it is complex task and a big project.  But I am going to work in 
this direction when I start to be less busy.  I am only afraid that the 
quick solutions as mentioned by me above could create a lot of 
complications for the long-term project.



Thanks,
James

[1] https://gcc.gnu.org/ml/gcc-patches/2014-03/msg01627.html
[2] regoc.c::preprocess_constraints
[3] I may have misread this, but that seems to be what the final condition
 of the main loop of lra-constraints::process_alt_operands implies.
[4] ira-costs.c::record_reg_classes





[COMMITTED PATCH] Demangler fuzzer

2014-08-13 Thread Gary Benson
Ian Lance Taylor wrote:
> On Tue, Aug 12, 2014 at 10:11 AM, Gary Benson  wrote:
> > Ian Lance Taylor wrote:
> > > I think that by default the program should stop.  That will make
> > > it possible to eventually run as part of "make check".  Give it
> > > some number of iterations that stops it in a second or so.  You
> > > can still have it run forever by using -m -1.
> >
> > On my machine it usually fails in 3-5 seconds, so a 1 second run
> > seems a little too short.  How does 10 seconds sound?
> 
> OK, we can start with that, I suppose.

I have committed the patch inlined below.  By default it tries
7.5 million symbols, which takes roughly 10 seconds on my box.
A good seed for testing is 1407772345 which manages 30,123,441
symbols before crashing (about 45 seconds).

Cheers,
Gary

--
2014-08-13  Gary Benson  

* testsuite/demangler-fuzzer.c: New file.
* testsuite/Makefile.in (fuzz-demangler): New rule.
(demangler-fuzzer): Likewise.
(mostlyclean): Clean up demangler fuzzer.

Index: libiberty/testsuite/Makefile.in
===
--- libiberty/testsuite/Makefile.in (revision 213911)
+++ libiberty/testsuite/Makefile.in (revision 213912)
@@ -59,6 +59,10 @@
 check-expandargv: test-expandargv
./test-expandargv
 
+# Run the demangler fuzzer
+fuzz-demangler: demangler-fuzzer
+   ./demangler-fuzzer
+
 TEST_COMPILE = $(CC) @DEFS@ $(LIBCFLAGS) -I.. -I$(INCDIR) $(HDEFINES)
 test-demangle: $(srcdir)/test-demangle.c ../libiberty.a
$(TEST_COMPILE) -o test-demangle \
@@ -72,6 +76,10 @@
$(TEST_COMPILE) -DHAVE_CONFIG_H -I.. -o test-expandargv \
$(srcdir)/test-expandargv.c ../libiberty.a
 
+demangler-fuzzer: $(srcdir)/demangler-fuzzer.c ../libiberty.a
+   $(TEST_COMPILE) -o demangler-fuzzer \
+   $(srcdir)/demangler-fuzzer.c ../libiberty.a
+
 # Standard (either GNU or Cygnus) rules we don't use.
 html install-html info install-info clean-info dvi pdf install-pdf \
 install etags tags installcheck:
@@ -81,6 +89,7 @@
rm -f test-demangle
rm -f test-pexecute
rm -f test-expandargv
+   rm -f demangler-fuzzer
rm -f core
 clean: mostlyclean
 distclean: clean
Index: libiberty/testsuite/demangler-fuzzer.c
===
--- libiberty/testsuite/demangler-fuzzer.c  (revision 0)
+++ libiberty/testsuite/demangler-fuzzer.c  (revision 213912)
@@ -0,0 +1,108 @@
+/* Demangler fuzzer.
+
+   Copyright (C) 2014 Free Software Foundation, Inc.
+
+   This file is part of GNU libiberty.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see .  */
+
+#include 
+#include 
+#include 
+#include 
+#include "demangle.h"
+
+#define MAXLEN 253
+#define ALPMIN 33
+#define ALPMAX 127
+
+static char *program_name;
+
+#define DEFAULT_MAXCOUNT 750
+
+static void
+print_usage (FILE *fp, int exit_value)
+{
+  fprintf (fp, "Usage: %s [OPTION]...\n", program_name);
+  fprintf (fp, "Options:\n");
+  fprintf (fp, "  -h   Display this message.\n");
+  fprintf (fp, "  -s SEED  Select the random seed to be used.\n");
+  fprintf (fp, "   The default is to base one on the");
+  fprintf (fp, " current time.\n");
+  fprintf (fp, "  -m MAXCOUNT  Exit after MAXCOUNT symbols.\n");
+  fprintf (fp, "   The default is %d.", DEFAULT_MAXCOUNT);
+  fprintf (fp, " Set to `-1' for no limit.\n");
+
+  exit (exit_value);
+}
+
+int
+main (int argc, char *argv[])
+{
+  char symbol[2 + MAXLEN + 1] = "_Z";
+  int seed = -1, seed_set = 0;
+  int count = 0, maxcount = DEFAULT_MAXCOUNT;
+  int optchr;
+
+  program_name = argv[0];
+
+  do
+{
+  optchr = getopt (argc, argv, "hs:m:t:");
+  switch (optchr)
+   {
+   case '?':  /* Unrecognized option.  */
+ print_usage (stderr, 1);
+ break;
+
+   case 'h':
+ print_usage (stdout, 0);
+ break;
+
+   case 's':
+ seed = atoi (optarg);
+ seed_set = 1;
+ break;
+
+   case 'm':
+ maxcount = atoi (optarg);
+ break;
+   }
+}
+  while (optchr != -1);
+
+  if (!seed_set)
+seed = time (NULL);
+  srand (seed);
+  printf ("%s: seed = %d\n", program_name, seed);
+
+  while (maxcount < 0 || count < maxcount)
+{
+  char *buffer = symbol + 2;
+  int length, i;
+
+

Re: [PATCH] gcc/config/microblaze/microblaze.md: Remove redundant '@' to avoid compiling warning

2014-08-13 Thread Michael Eager

On 07/05/14 20:59, Chen Gang wrote:


   * microblaze/microblaze.md: Remove redundant '@' to avoid compiling
   warning.

The related warning:

   ../../gcc/gcc/config/microblaze/microblaze.md:516: '@' is redundant for 
output template with single alternative


Signed-off-by: Chen Gang 
---
  gcc/config/microblaze/microblaze.md | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/config/microblaze/microblaze.md 
b/gcc/config/microblaze/microblaze.md
index 7945d96..2bd5d72 100644
--- a/gcc/config/microblaze/microblaze.md
+++ b/gcc/config/microblaze/microblaze.md
@@ -518,8 +518,7 @@
(minus:DI (match_operand:DI 1 "register_operand" "d")
  (match_operand:DI 2 "arith_operand32" "d")))]
""
-  "@
-   rsub\t%L0,%L2,%L1\;rsubc\t%M0,%M2,%M1"
+  "rsub\t%L0,%L2,%L1\;rsubc\t%M0,%M2,%M1"
[(set_attr "type" "darith")
(set_attr "mode"  "DI")
(set_attr "length""8")])



Committed revision 213913.


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


Re: [PATCH, AArch64] Use MOVN to generate 64-bit negative immediates where sensible

2014-08-13 Thread Kyrill Tkachov


On 07/08/14 20:32, Richard Henderson wrote:

On 08/07/2014 02:57 AM, Kyrill Tkachov wrote:

+  if (one_match > zero_match)
+{
+  /* Set either first three quarters or all but the third.  */
+  mask = 0xll << (16 - first_not__match);
+  emit_insn (gen_rtx_SET (VOIDmode, dest,
+ GEN_INT (val | mask | 0xull)));
+
+  /* Now insert other two quarters. */
+  for (i = first_not__match + 16, mask <<= (first_not__match << 1);
+  i < 64; i += 16, mask <<= 16)
{
  if ((val & mask) != mask)
+   emit_insn (gen_insv_immdi (dest, GEN_INT (i),
+  GEN_INT ((val >> i) & 0x)));
}
+  return;
  }
  
if (zero_match == 2)

You should not place this three instruction sequence before the two instruction
sequences that follow.  I.e. place this just before simple_sequence.

Hi Richard,

Is the attached patch ok? It just moves the section as you suggested. I 
did a build of the Linux kernel with and without this patch to make sure 
no code-gen was accidentally affected.




I do wonder if we should be memo-izing these computations so that we only have
to do the complex search for a sequence only once for each constant...


We'd need to store a mapping from constant to RTXes and everytime we 
have a "cache hit" we'd have to tweak them to make sure the registers 
involved are correct. I had a quick play with this but ended up with LRA 
ICEs  :(

Might look at it later on, but it's not high on my priorities right now.

Thanks,
Kyrill

2014-08-13  Kyrylo Tkachov  

* config/aarch64/aarch64.c (aarch64_expand_mov_immediate): Move
one_match > zero_match case to just before simple_sequence.diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 20debb9..a4e7158 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -1136,24 +1136,6 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
   return;
 }
 
-  if (one_match > zero_match)
-{
-  /* Set either first three quarters or all but the third.	 */
-  mask = 0xll << (16 - first_not__match);
-  emit_insn (gen_rtx_SET (VOIDmode, dest,
-			  GEN_INT (val | mask | 0xull)));
-
-  /* Now insert other two quarters.	 */
-  for (i = first_not__match + 16, mask <<= (first_not__match << 1);
-	   i < 64; i += 16, mask <<= 16)
-	{
-	  if ((val & mask) != mask)
-	emit_insn (gen_insv_immdi (dest, GEN_INT (i),
-   GEN_INT ((val >> i) & 0x)));
-	}
-  return;
-}
-
   if (zero_match == 2)
 goto simple_sequence;
 
@@ -1270,6 +1252,24 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
 	}
 }
 
+  if (one_match > zero_match)
+{
+  /* Set either first three quarters or all but the third.	 */
+  mask = 0xll << (16 - first_not__match);
+  emit_insn (gen_rtx_SET (VOIDmode, dest,
+			  GEN_INT (val | mask | 0xull)));
+
+  /* Now insert other two quarters.	 */
+  for (i = first_not__match + 16, mask <<= (first_not__match << 1);
+	   i < 64; i += 16, mask <<= 16)
+	{
+	  if ((val & mask) != mask)
+	emit_insn (gen_insv_immdi (dest, GEN_INT (i),
+   GEN_INT ((val >> i) & 0x)));
+	}
+  return;
+}
+
  simple_sequence:
   first = true;
   mask = 0x;

  1   2   >