[PATCH] Fix PR rtl-optimization/pr60663

2014-03-26 Thread Zhenqiang Chen
Hi,

The patch checks the number of the expected operands in
ASM_OPERANDS_TEMPLATE with the same logic as it in output_asm_insn to
make sure the ASM_OPERANDS are legal.

Bootstrap and no make check regression on X86-64 and ARM chromebook.

OK for trunk?

Thanks!
-Zhenqiang

ChangeLog:
2014-03-26  Zhenqiang Chen  zhenqiang.c...@linaro.org

PR rtl-optimization/pr60663
* recog.c (check_asm_operands): Check the number of expected operands.

testsuite/ChangeLog:
2014-03-26  Zhenqiang Chen  zhenqiang.c...@linaro.org

* gcc.dg/pr60663: New testcase.

diff --git a/gcc/recog.c b/gcc/recog.c
index f9040dc..65078ad 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -135,8 +135,8 @@ check_asm_operands (rtx x)
 {
   int noperands;
   rtx *operands;
-  const char **constraints;
-  int i;
+  const char **constraints, *templ;
+  int i, c;

   if (!asm_labels_ok (x))
 return 0;
@@ -159,7 +159,29 @@ check_asm_operands (rtx x)
   operands = XALLOCAVEC (rtx, noperands);
   constraints = XALLOCAVEC (const char *, noperands);

-  decode_asm_operands (x, operands, NULL, constraints, NULL, NULL);
+  templ = decode_asm_operands (x, operands, NULL, constraints, NULL, NULL);
+  /* The following logic is similar with it in output_asm_insn (final.c).
+ It checks the number of expected operands in ASM_OPERANDS_TEMPLATE.  */
+  if (*templ)
+{
+  const char* p = templ;
+  while ((c = *p++))
+   {
+ if (c == '%')
+   if (ISDIGIT (*p))
+ {
+   int opnum;
+   char *endptr;
+
+   opnum = strtoul (p, endptr, 10);
+   if (opnum = noperands)
+ return 0;
+
+p = endptr;
+c = *p;
+ }
+   }
+}

   for (i = 0; i  noperands; i++)
 {

diff --git a/gcc/testsuite/gcc.dg/pr60663.c b/gcc/testsuite/gcc.dg/pr60663.c
new file mode 100644
index 000..6c01084
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lp.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options  -O2  } */
+
+int g (void)
+{
+  unsigned i, j;
+  asm(// %0 %1 : =r (i), =r(j));
+  return i;
+}


Re: [PATCH] Fix PR rtl-optimization/pr60663

2014-03-26 Thread Jakub Jelinek
On Wed, Mar 26, 2014 at 02:16:16PM +0800, Zhenqiang Chen wrote:
 The patch checks the number of the expected operands in
 ASM_OPERANDS_TEMPLATE with the same logic as it in output_asm_insn to
 make sure the ASM_OPERANDS are legal.
 
 Bootstrap and no make check regression on X86-64 and ARM chromebook.
 
 OK for trunk?

No, this is very wrong.  How many operands you refer to and how many times
to each is completely unrelated to the fact that CSE should never modify
asm insns to drop some of the outputs.
You can refer to no operands at all and still it would be invalid to drop
the outputs, or you can have output template like %0 %0 %0 %0 %0 ... million 
times %0.

Jakub


Re: [patch, Fortran] Fix PR 60522

2014-03-26 Thread Tobias Burnus

Thomas Koenig wrote:

Hello world,


print *, 'Hello Thomas'


the attached patch fixes the regression (after some thought
of what might still be optimized, which isn't much :-)

Regression-tested.  OK for trunk?


Looks good to me. (I wonder whether one should also include Mikael's 
test case, but I am not sure whether it is worth a run-time test.)


Thanks for the patch!

Tobias


2014-04-25  Thomas Koenig  tkoe...@gcc.gnu.org

 PR fortran/60522
 * frontend-passes.c (cfe_code):  Do not walk subtrees
 for WHERE.

2014-04-25  Thomas Koenig  tkoe...@gcc.gnu.org

 PR fortran/60522
 * gfortran.dg/where_4.f90:  New test case.




Re: [PATCH] Fix PR rtl-optimization/pr60663

2014-03-26 Thread Zhenqiang Chen
On 26 March 2014 15:00, Jakub Jelinek ja...@redhat.com wrote:
 On Wed, Mar 26, 2014 at 02:16:16PM +0800, Zhenqiang Chen wrote:
 The patch checks the number of the expected operands in
 ASM_OPERANDS_TEMPLATE with the same logic as it in output_asm_insn to
 make sure the ASM_OPERANDS are legal.

 Bootstrap and no make check regression on X86-64 and ARM chromebook.

 OK for trunk?

 No, this is very wrong.  How many operands you refer to and how many times

This is how the output_asm_insn (final.c) check and output the error
message. The logic in my patch is the same as it in output_asm_insn.

 to each is completely unrelated to the fact that CSE should never modify
 asm insns to drop some of the outputs.

Agree. CSE should never modify asm insns to drop some of the outputs.

But in this case, CSE does not drop any of the outputs. It just takes
the SRC of a set and replace the reference of the set. And the
instruction validation tells CSE that it is legal instruction after
replacement. (The original correct asm insn is optimized away after
this replacement)

I think it is common for most rtl-optimizations to do such kind of
validation. So to avoid such kind of bug, check_asm_operands must tell
the optimizer the asm is illegal.

 You can refer to no operands at all and still it would be invalid to drop
 the outputs, or you can have output template like %0 %0 %0 %0 %0 ... million 
 times %0.

I think it does not check the number of %0, but the max n in %n.

Thanks!
-Zhenqiang

 Jakub


Re: [PATCH] Fix PR rtl-optimization/pr60663

2014-03-26 Thread Jakub Jelinek
On Wed, Mar 26, 2014 at 03:30:44PM +0800, Zhenqiang Chen wrote:
 Agree. CSE should never modify asm insns to drop some of the outputs.

So the right fix is top prevent this from happening, not papering over about
it.
 
 But in this case, CSE does not drop any of the outputs. It just takes
 the SRC of a set and replace the reference of the set. And the
 instruction validation tells CSE that it is legal instruction after
 replacement. (The original correct asm insn is optimized away after
 this replacement)
 
 I think it is common for most rtl-optimizations to do such kind of
 validation. So to avoid such kind of bug, check_asm_operands must tell
 the optimizer the asm is illegal.

As it is wrong if CSE does that even with asm ( : =r (i), =r (j));,
your patch is not the right place to fix this.  CSE just must check where
the ASM_OPERANDS is coming from and if it comes from a PARALLEL with
multiple outputs, either give up or duplicate all outputs (if it makes sense
at all).  Or just don't enter into the hash tables ASM_OPERANDS with
multiple outputs.

Jakub


[PATH, SH] Small builtin_strlen improvement

2014-03-26 Thread Christian Bruel
Hello,

This patches adds a few instructions to the inlined builtin_strlen to
unroll the remaining bytes for word-at-a-time loop. This enables to have
2 distinct execution paths (no fall-thru in the byte-at-a-time loop),
allowing block alignment assignation. This partially improves the
problem reported with by Oleg. in [Bug target/0539] New: [SH] builtin
string functions ignore loop and label alignment

whereas the test now expands (-O2 -m4) as
mov r4,r0
tst #3,r0
mov r4,r2
bf/s.L12
mov r4,r3
mov #0,r2
.L4:
mov.l   @r4+,r1
cmp/str r2,r1
bf  .L4
add #-4,r4
mov.b   @r4,r1
tst r1,r1
bt  .L2
add #1,r4
mov.b   @r4,r1
tst r1,r1
bt  .L2
add #1,r4
mov.b   @r4,r1
tst r1,r1
mov #-1,r1
negcr1,r1
add r1,r4
.L2:
mov r4,r0
rts
sub r3,r0
.align 1
.L12:
mov.b   @r4+,r1
tst r1,r1
bf/s.L12
mov r2,r3
add #1,r3
mov r4,r0
rts
sub r3,r0


Best tuning compared to the compact version I got on is ~1% for c++
regular expression benchmark, but well, code looks best this way.

regtested tested for -m2, -m4

OK for trunk ?


2014-03-20  Christian Bruel  christian.br...@st.com

	* config/sh/sh-mem.cc (sh_expand_strlen): Unroll last word.

Index: gcc/config/sh/sh-mem.cc
===
--- gcc/config/sh/sh-mem.cc	(revision 208745)
+++ gcc/config/sh/sh-mem.cc	(working copy)
@@ -586,9 +586,35 @@ sh_expand_strlen (rtx *operands)
 
   emit_move_insn (current_addr, plus_constant (Pmode, current_addr, -4));
 
-  /* start byte loop.  */
   addr1 = adjust_address (addr1, QImode, 0);
 
+  /* unroll remaining bytes.  */
+  emit_insn (gen_extendqisi2 (tmp1, addr1));
+  emit_insn (gen_cmpeqsi_t (tmp1, const0_rtx));
+  jump = emit_jump_insn (gen_branch_true (L_return));
+  add_int_reg_note (jump, REG_BR_PROB, prob_likely);
+
+  emit_move_insn (current_addr, plus_constant (Pmode, current_addr, 1));
+
+  emit_insn (gen_extendqisi2 (tmp1, addr1));
+  emit_insn (gen_cmpeqsi_t (tmp1, const0_rtx));
+  jump = emit_jump_insn (gen_branch_true (L_return));
+  add_int_reg_note (jump, REG_BR_PROB, prob_likely);
+
+  emit_move_insn (current_addr, plus_constant (Pmode, current_addr, 1));
+
+  emit_insn (gen_extendqisi2 (tmp1, addr1));
+  emit_insn (gen_cmpeqsi_t (tmp1, const0_rtx));
+  jump = emit_jump_insn (gen_branch_true (L_return));
+  add_int_reg_note (jump, REG_BR_PROB, prob_likely);
+
+  emit_move_insn (current_addr, plus_constant (Pmode, current_addr, 1));
+
+  emit_insn (gen_extendqisi2 (tmp1, addr1));
+  jump = emit_jump_insn (gen_jump_compact (L_return));
+  emit_barrier_after (jump);
+
+  /* start byte loop.  */
   emit_label (L_loop_byte);
 
   emit_insn (gen_extendqisi2 (tmp1, addr1));
@@ -600,11 +626,12 @@ sh_expand_strlen (rtx *operands)
 
   /* end loop.  */
 
+  emit_insn (gen_addsi3 (start_addr, start_addr, GEN_INT (1)));
+
   emit_label (L_return);
 
-  emit_insn (gen_addsi3 (start_addr, start_addr, GEN_INT (1)));
-
   emit_insn (gen_subsi3 (operands[0], current_addr, start_addr));
 
   return true;
 }
+


Re: Fix PR ipa/60315 (inliner explosion)

2014-03-26 Thread Bernhard Reutner-Fischer

On 26 March 2014 03:17:11 Jan Hubicka hubi...@ucw.cz wrote:


Hi,


Just 2 nits, cannot comment on the patch itself.
s/clonning/cloning/g as usual :)
And the content of the testcase is duplicated.

Thanks,

this patch fixes compile time issue in the testcase that is caused by fact 
that the inliner
is repeatedly inlining into an call it earlier proved to be unreachable.  
The analysis part
knows that such calls are not accounted into overall function summaries, 
but the transform
part sees them merely as cold calls and thus it attempts to do inlining for 
size.
This patch makes analysis part to practively redirect all known to be 
unreachable

calls to BUILTIN_UNREAHABLE.

Doing so uncovered the bug in ipa-pure-const I fixed earlier and also another
but in set_cond_stmt_execution_predicate where invert_tree_comparison is
called and the condition is used further. The function returns ERROR_MARK 
for FP

comparsions in some cases (though I think it should not since there seems to
be no toher way to invert comparsion without this and we have the unordered 
codes).

This concide with ipa-inline-analysis.c internal use of ERROR_MARK and leads to
inconsistent predicates.

Bootstrapped/regtested x86_64-linux, comitted.

PR ipa/60315
* cif-code.def (UNREACHABLE) New code.
* ipa-inline.c (inline_small_functions): Skip edges to 
__builtlin_unreachable.
(estimate_edge_growth): Allow edges to __builtlin_unreachable.
* ipa-inline-analysis.c (edge_set_predicate): Redirect edges with false
predicate to __bulitin_unreachable.
(set_cond_stmt_execution_predicate): Fix issue when 
invert_tree_comparison
returns ERROR_MARK.
* ipa-pure-const.c (propagate_pure_const, propagate_nothrow): Do not
propagate to inline clones.
* cgraph.c (verify_edge_corresponds_to_fndecl): Allow redirection
to unreachable.
* ipa-cp.c (create_specialized_node): Be ready for new node to appear.
* cgraphclones.c (cgraph_clone_node): If call destination is already
ureachable, do not redirect it back.
* tree-inline.c (fold_marked_statements): Hanlde calls becoming
unreachable.

* testsuite/g++.dg/torture/pr60315.C: New testcase.
Index: cif-code.def
===
--- cif-code.def(revision 208829)
+++ cif-code.def(working copy)
@@ -127,3 +127,7 @@ DEFCIFCODE(USES_COMDAT_LOCAL, CIF_FINAL_
 /* We can't inline because of mismatched caller/callee attributes.  */
 DEFCIFCODE(ATTRIBUTE_MISMATCH, CIF_FINAL_NORMAL,
   N_(function attribute mismatch))
+
+/* We proved that the call is unreachable.  */
+DEFCIFCODE(UNREACHABLE, CIF_FINAL_NORMAL,
+  N_(unreachable))
Index: cgraphclones.c
===
--- cgraphclones.c  (revision 208829)
+++ cgraphclones.c  (working copy)
@@ -238,8 +238,12 @@ cgraph_clone_node (struct cgraph_node *n
   FOR_EACH_VEC_ELT (redirect_callers, i, e)
 {
   /* Redirect calls to the old version node to point to its new
-version.  */
-  cgraph_redirect_edge_callee (e, new_node);
+version.  The only exception is when the edge was proved to
+be unreachable during the clonning procedure.  */
+  if (!e-callee
+ || DECL_BUILT_IN_CLASS (e-callee-decl) != BUILT_IN_NORMAL
+ || DECL_FUNCTION_CODE (e-callee-decl) != BUILT_IN_UNREACHABLE)
+cgraph_redirect_edge_callee (e, new_node);
 }


Index: ipa-inline.c
===
--- ipa-inline.c(revision 208829)
+++ ipa-inline.c(working copy)
@@ -1685,7 +1685,7 @@ inline_small_functions (void)
   edge = (struct cgraph_edge *) fibheap_extract_min (edge_heap);
   gcc_assert (edge-aux);
   edge-aux = NULL;
-  if (!edge-inline_failed)
+  if (!edge-inline_failed || !edge-callee-analyzed)
continue;

   /* Be sure that caches are maintained consistent.
Index: ipa-inline.h
===
--- ipa-inline.h(revision 208829)
+++ ipa-inline.h(working copy)
@@ -285,7 +285,8 @@ static inline int
 estimate_edge_growth (struct cgraph_edge *edge)
 {
 #ifdef ENABLE_CHECKING
-  gcc_checking_assert (inline_edge_summary (edge)-call_stmt_size);
+  gcc_checking_assert (inline_edge_summary (edge)-call_stmt_size
+  || !edge-callee-analyzed);
 #endif
   return (estimate_edge_size (edge)
  - inline_edge_summary (edge)-call_stmt_size);
Index: testsuite/g++.dg/torture/pr60315.C
===
--- testsuite/g++.dg/torture/pr60315.C  (revision 0)
+++ testsuite/g++.dg/torture/pr60315.C  (revision 0)
@@ -0,0 +1,32 @@
+// { dg-do compile }
+struct Base {
+virtual int f() = 0;
+};
+
+struct Derived : public Base {
+virtual int f() final 

Re: RFA: Fix PR rtl-optimization/60651

2014-03-26 Thread Eric Botcazou
 As described in the PR, this patch fixes a wrong-code bug by making the
 order of emitted mode switching instructions more consistet  predictable.

I don't understand this change (but I'm not a specialist of mode switching): 
currently the mode setting sequence is always emitted before the insns that 
need it but, with the change, if an insn right after a NOTE_BASIC_BLOCK note 
needs it, if will be emitted either before it (if insn_ptr is the insn) or 
after it (if insn_ptr is the NOTE_BASIC_BLOCK note).

-- 
Eric Botcazou


Re: [PATCH] Fix --with-build-config=bootstrap-ubsan bootstrap of lto-plugin (PR sanitizer/56781)

2014-03-26 Thread Jakub Jelinek
On Tue, Mar 25, 2014 at 05:24:40PM -0700, H.J. Lu wrote:
 Doesn't work:
 
 libtool: link:
 /export/build/gnu/gcc-asan/build-x86_64-linux/./prev-gcc/xgcc
 -B/export/build/gnu/gcc-asan/build-x86_64-linux/./prev-gcc/
 -B/usr/local/x86_64-unknown-linux-gnu/bin/
 -B/usr/local/x86_64-unknown-linux-gnu/bin/
 -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem
 /usr/local/x86_64-unknown-linux-gnu/include -isystem
 /usr/local/x86_64-unknown-linux-gnu/sys-include-shared
 .libs/lto-plugin.o-static-libgcc -static-libstdc++ -static-libgcc
 -fsanitize=address -static-libasan
 -B/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libsanitizer/
 -B/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libsanitizer/asan/
 -B/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libsanitizer/asan/.libs
 ../libiberty/noasan/libiberty.a   -Wl,-soname -Wl,liblto_plugin.so.0
 -o .libs/liblto_plugin.so.0.0.0
 ...

Then it probably needs to use override on CFLAGS/LDFLAGS in
lto-plugin/Makefile.{am,in} instead, but the rest of the changes should be
the same.

Jakub


Re: Fix PR ipa/60315 (inliner explosion)

2014-03-26 Thread Andreas Schwab
Jan Hubicka hubi...@ucw.cz writes:

 Index: testsuite/g++.dg/torture/pr60315.C
 ===
 --- testsuite/g++.dg/torture/pr60315.C(revision 0)
 +++ testsuite/g++.dg/torture/pr60315.C(revision 0)
 @@ -0,0 +1,32 @@
 +// { dg-do compile }
 +struct Base {
 +virtual int f() = 0;
 +};
 +
 +struct Derived : public Base {
 +virtual int f() final override {
 +return 42;
 +}
 +};
 +
 +extern Base* b;
 +
 +int main() {
 +return (static_castDerived*(b)-*(Derived::f))();
 +}
 +// { dg-do compile }
 +struct Base {
 +virtual int f() = 0;
 +};
 +
 +struct Derived : public Base {
 +virtual int f() final override {
 +return 42;
 +}
 +};
 +
 +extern Base* b;
 +
 +int main() {
 +return (static_castDerived*(b)-*(Derived::f))();
 +}

* g++.dg/torture/pr60315.C: Remove duplication.

diff --git a/gcc/testsuite/g++.dg/torture/pr60315.C 
b/gcc/testsuite/g++.dg/torture/pr60315.C
index 7f12260..72ce507 100644
--- a/gcc/testsuite/g++.dg/torture/pr60315.C
+++ b/gcc/testsuite/g++.dg/torture/pr60315.C
@@ -14,19 +14,3 @@ extern Base* b;
 int main() {
 return (static_castDerived*(b)-*(Derived::f))();
 }
-// { dg-do compile }
-struct Base {
-virtual int f() = 0;
-};
-
-struct Derived : public Base {
-virtual int f() final override {
-return 42;
-}
-};
-
-extern Base* b;
-
-int main() {
-return (static_castDerived*(b)-*(Derived::f))();
-}
-- 
1.9.1


Andreas.

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


Re: [PATCH, PR 60419] Clear thunk flag of zombie nodes

2014-03-26 Thread Richard Biener
On Fri, 21 Mar 2014, Martin Jambor wrote:

 Hi,
 
 On Fri, Mar 21, 2014 at 09:41:24AM +0100, Richard Biener wrote:
  On Thu, 20 Mar 2014, Martin Jambor wrote:
  
   Hi,
   
   in PR 60419 we end up with a call graph node for a thunk that has no
   callee because symtab_remove_unreachable_nodes has determined its body
   is not needed although its declaration is still reachable (more
   details in comment 11 in bugzilla) and removal of callees is a part of
   the zombification process that such nodes undergo.  Later on, the last
   stage of inlining that runs after that connects the thunk to the call
   graph and we segfault because we expect thunks to have a callee.
   
   So we can either keep thunk targets alive or clear the thunk flag.
   Thunks and aliases are quite similar and
   symtab_remove_unreachable_nodes does clear the alias flag and the in
   border nodes are referred to but not output and thus just another
   symbol.  Therefore I believe it is correct and much simpler to remove
   the thunk flag s well.
   
   Bootstrapped and tested on x86_64, I have also build Mozilla Firefox
   witht the patch (without LTO, partly on purpose, partly because again
   I'm having issues with LTO after updating FF).  OK for trunk?
  
  Ok.
 
 Thanks, I have just committed the trunk patch.  A proposed 4.8 variant
 is below, it does the same thing at the same spot, although there is a
 number of minor differences between the branches.  One of them is that
 symtab_remove_unreachable_nodes does not clear any flags there in 4.8
 and therefore I have added also clearing of the alias flag because
 (although I do not have a testcase) just like there should not be any
 thunks without callees, there also should not be any aliases without
 references, cgraph_function_node would choke on them too.
 
 Bootstrapped and tested on the 4.8 branch on x86_64-linux.  OK for the
 branch?

Ok.

Thanks,
Richard.

 Thanks,
 
 Martin
 
 
 2014-03-20  Martin Jambor  mjam...@suse.cz
 
   PR ipa/60419
   * ipa.c (symtab_remove_unreachable_nodes): Clear thunk and
   alias flags of nodes in the border.
 
 testsuite/
   * g++.dg/ipa/pr60419.C: New test.
 
 diff --git a/gcc/ipa.c b/gcc/ipa.c
 index a9b8fb4..d73d105 100644
 --- a/gcc/ipa.c
 +++ b/gcc/ipa.c
 @@ -359,6 +359,8 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, 
 FILE *file)
   {
 if (file)
   fprintf (file,  %s, cgraph_node_name (node));
 +   node-alias = false;
 +   node-thunk.thunk_p = false;
 cgraph_node_remove_callees (node);
 ipa_remove_all_references (node-symbol.ref_list);
 changed = true;
 diff --git a/gcc/testsuite/g++.dg/ipa/pr60419.C 
 b/gcc/testsuite/g++.dg/ipa/pr60419.C
 new file mode 100644
 index 000..84461f3
 --- /dev/null
 +++ b/gcc/testsuite/g++.dg/ipa/pr60419.C
 @@ -0,0 +1,80 @@
 +// PR middle-end/60419
 +// { dg-do compile }
 +// { dg-options -O2 }
 +
 +struct C
 +{
 +};
 +
 +struct I : C
 +{
 +  I ();
 +};
 +
 +struct J
 +{
 +  void foo ();
 +  J ();
 +  virtual void foo (int , int);
 +};
 +
 +template class
 +struct D
 +{
 +  virtual void foo (I ) const;
 +  void bar ()
 +  {
 +I p;
 +foo (p);
 +  }
 +};
 +
 +struct K : J, public Dint
 +{
 +};
 +
 +struct F
 +{
 +  K *operator-();
 +};
 +
 +struct N : public K
 +{
 +  void foo (int , int);
 +  I n;
 +  void foo (I ) const {}
 +};
 +
 +struct L : J
 +{
 +  F l;
 +};
 +
 +struct M : F
 +{
 +  L *operator-();
 +};
 +
 +struct G
 +{
 +  G ();
 +};
 +
 +M h;
 +
 +G::G ()
 +try
 +{
 +  N f;
 +  f.bar ();
 +  throw;
 +}
 +catch (int)
 +{
 +}
 +
 +void
 +baz ()
 +{
 +  h-l-bar ();
 +}
 
 

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


Re: [PATCH] Perform ubsan instrumentation for x = 0 ? x : -x (take 2)

2014-03-26 Thread Richard Biener
On Tue, 25 Mar 2014, Jakub Jelinek wrote:

 On Tue, Mar 25, 2014 at 10:43:02AM +0100, Richard Biener wrote:
  Yes, all transforms in fold-const would be invalid if the result doesn't
  behave in the same way wrt overflow.  Thus you really should instrument
  ABS_EXPR - you can treat it as A  0 ? A : -A if that simplifies it.
  
  I don't like the conditions that disable stuff based on sanitization.
  
  Instrumenting ABS_EXPR shouldn't be too difficult.
 
 Ok, here is a patch that does that.  Tested on x86_64-linux and i686-linux.
 Ok for trunk?

Ok.

Thanks,
Richard.

 2014-03-25  Jakub Jelinek  ja...@redhat.com
 
   PR sanitizer/60636
   * ubsan.c (instrument_si_overflow): Instrument ABS_EXPR.
 
   * c-c++-common/ubsan/pr60636.c: New test.
 
 --- gcc/ubsan.c.jj2014-03-19 14:44:23.0 +0100
 +++ gcc/ubsan.c   2014-03-25 13:00:35.052459078 +0100
 @@ -737,6 +737,21 @@ instrument_si_overflow (gimple_stmt_iter
gimple_call_set_lhs (g, lhs);
gsi_replace (gsi, g, false);
break;
 +case ABS_EXPR:
 +  /* Transform i = ABS_EXPRu;
 +  into
 +  _N = UBSAN_CHECK_SUB (0, u);
 +  i = ABS_EXPR_N;  */
 +  a = build_int_cst (lhstype, 0);
 +  b = gimple_assign_rhs1 (stmt);
 +  g = gimple_build_call_internal (IFN_UBSAN_CHECK_SUB, 2, a, b);
 +  a = make_ssa_name (lhstype, NULL);
 +  gimple_call_set_lhs (g, a);
 +  gimple_set_location (g, gimple_location (stmt));
 +  gsi_insert_before (gsi, g, GSI_SAME_STMT);
 +  gimple_assign_set_rhs1 (stmt, a);
 +  update_stmt (stmt);
 +  break;
  default:
break;
  }
 --- gcc/testsuite/c-c++-common/ubsan/pr60636.c.jj 2014-03-25 
 12:31:29.458629212 +0100
 +++ gcc/testsuite/c-c++-common/ubsan/pr60636.c2014-03-25 
 12:31:29.458629212 +0100
 @@ -0,0 +1,15 @@
 +/* PR sanitizer/60636 */
 +/* { dg-do run } */
 +/* { dg-options -fsanitize=undefined } */
 +
 +volatile long long int a;
 +
 +int
 +main ()
 +{
 +  long long int u = -__LONG_LONG_MAX__ - 1;
 +  a = u  0 ? u : -u;
 +  return 0;
 +}
 +
 +/* { dg-output negation of -9223372036854775808 cannot be represented in 
 type 'long long int' } */
 
 
   Jakub
 
 

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


Re: [PATCH] Fix --with-build-config=bootstrap-ubsan bootstrap of fixincludes (PR sanitizer/56781)

2014-03-26 Thread Paolo Bonzini

Il 25/03/2014 20:24, Jakub Jelinek ha scritto:

Hi!

This patch fixes a problem where build of host fixincludes fails
with --with-build-config=bootstrap-ubsan (and bootstrap-asan).
The problem is that fixincludes is linked against host libiberty
that is bootstrapped, but fixincludes is not bootstrapped.
Thus, libiberty uses post stage1 cflags/ldflags and is compiled
therefore in stage2/stage3 with -fsanitize=undefined, but fixincludes
is compiled/linked with normal cflags/ldflags and thus not linked
against libubsan.

Fixed by making fixincludes another host bootstrapped module
if doing asan/ubsan bootstrap (no need to waste build cycles otherwise).

Bootstrapped/regtested on x86_64-linux (normal bootstrap) and
on i686-linux (--with-build-config=bootstrap-ubsan).  Ok for trunk?

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

PR sanitizer/56781
* Makefile.def: Set bootstrap=true; for host fixincludes.
* configure.ac: Don't bootstrap host fixincludes unless
--with-build-config=bootstrap-{a,ub}san.
* Makefile.in: Regenerated.
* configure: Regenerated.

--- Makefile.def.jj 2013-11-21 09:26:57.0 +0100
+++ Makefile.def2014-03-25 13:55:23.805116854 +0100
@@ -39,7 +39,7 @@ host_modules= { module= cgen; };
 host_modules= { module= dejagnu; };
 host_modules= { module= etc; };
 host_modules= { module= fastjar; no_check_cross= true; };
-host_modules= { module= fixincludes;
+host_modules= { module= fixincludes; bootstrap=true;
missing= TAGS; };
 host_modules= { module= flex; no_check_cross= true; };
 host_modules= { module= gas; bootstrap=true; };
--- configure.ac.jj 2014-03-21 08:15:39.0 +0100
+++ configure.ac2014-03-25 17:11:35.819558369 +0100
@@ -2532,6 +2532,7 @@ AC_MSG_RESULT($enable_vtable_verify)
 # build configuration in Makefile.
 target_configdirs=`echo ${target_configdirs} | sed -e 's/target-//g'`
 build_configdirs=`echo ${build_configdirs} | sed -e 's/build-//g'`
+bootstrap_fixincludes=no

 # If we are building libgomp, bootstrap it.
 if echo  ${target_configdirs}  | grep  libgomp   /dev/null 21 ; then
@@ -2544,6 +2545,7 @@ if echo  ${target_configdirs}  | grep
   case $BUILD_CONFIG in
 *bootstrap-asan* | *bootstrap-ubsan* )
   bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer,
+  bootstrap_fixincludes=yes
   ;;
   esac
 fi
@@ -2626,11 +2628,15 @@ for module in ${configdirs} ; do
   fi
 done
   fi
+  case ${module},${bootstrap_fixincludes} in
+fixincludes,no) host_bootstrap_suffix=no-bootstrap ;;
+*) host_bootstrap_suffix=$bootstrap_suffix ;;
+  esac
   extrasub_host=$extrasub_host
 /^@if $module\$/d
 /^@endif $module\$/d
-/^@if $module-$bootstrap_suffix\$/d
-/^@endif $module-$bootstrap_suffix\$/d
+/^@if $module-$host_bootstrap_suffix\$/d
+/^@endif $module-$host_bootstrap_suffix\$/d
 done
 extrasub_target=
 for module in ${target_configdirs} ; do
--- Makefile.in.jj  2014-03-07 13:58:01.0 +0100
+++ Makefile.in 2014-03-25 13:55:32.0 +0100
@@ -1003,7 +1003,9 @@ all-host: maybe-all-cgen
 all-host: maybe-all-dejagnu
 all-host: maybe-all-etc
 all-host: maybe-all-fastjar
+@if fixincludes-no-bootstrap
 all-host: maybe-all-fixincludes
+@endif fixincludes-no-bootstrap
 all-host: maybe-all-flex
 @if gas-no-bootstrap
 all-host: maybe-all-gas
@@ -7807,7 +7809,6 @@ configure-fixincludes: stage_current
 @if fixincludes
 maybe-configure-fixincludes: configure-fixincludes
 configure-fixincludes:
-   @: $(MAKE); $(unstage)
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
test ! -f $(HOST_SUBDIR)/fixincludes/Makefile || exit 0; \
@@ -7830,6 +7831,204 @@ configure-fixincludes:



+.PHONY: configure-stage1-fixincludes maybe-configure-stage1-fixincludes
+maybe-configure-stage1-fixincludes:
+@if fixincludes-bootstrap
+maybe-configure-stage1-fixincludes: configure-stage1-fixincludes
+configure-stage1-fixincludes:
+   @[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
+   @$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/fixincludes
+   @r=`${PWD_COMMAND}`; export r; \
+   s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+   TFLAGS=$(STAGE1_TFLAGS); \
+   test ! -f $(HOST_SUBDIR)/fixincludes/Makefile || exit 0; \
+   $(HOST_EXPORTS) \
+   CFLAGS=$(STAGE1_CFLAGS); export CFLAGS; \
+   CXXFLAGS=$(STAGE1_CXXFLAGS); export CXXFLAGS; \
+   LIBCFLAGS=$(LIBCFLAGS); export LIBCFLAGS;  \
+   echo Configuring stage 1 in $(HOST_SUBDIR)/fixincludes ; \
+   $(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/fixincludes ; \
+   cd $(HOST_SUBDIR)/fixincludes || exit 1; \
+   case $(srcdir) in \
+ /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+ *) topdir=`echo $(HOST_SUBDIR)/fixincludes/ | \
+   sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+   esac; \
+   srcdiroption=--srcdir=$${topdir}/fixincludes; \
+   

Re: [Build, Driver] Add -lcilkrts for -fcilkplus

2014-03-26 Thread Paolo Bonzini

Il 26/03/2014 00:28, Tobias Burnus ha scritto:

Paolo Bonzini wrote:

Il 11/03/2014 07:42, Tobias Burnus ha scritto:

+XPCFLAGS=
+CFLAGS=$CFLAGS -pthread
+AC_LINK_IFELSE(
...
+ [XPCFLAGS= -Wc,-pthread],

XPCFLAGS is dead, I think?


Yes - contrary to libgomp, from which I have taken that code block. I
have now removed it.


Also, should -pthread be included in the spec too?


Regarding -pthreads: That should already be included via gcc/gcc.c:

+#define CILK_SELF_SPECS %{fcilkplus: -pthread}

 static const char *const driver_self_specs[] = {
...
CILK_SELF_SPECS
 };

Updated patch below (nongenerated libcilkrts only).

Tobias



Ok.

Paolo


Re: [PATCH] Fix folding of UBSAN_CHECK_SUB (x, 0) etc.

2014-03-26 Thread Richard Biener
On Tue, 25 Mar 2014, Jakub Jelinek wrote:

 On Tue, Mar 25, 2014 at 10:15:37AM +0100, Richard Biener wrote:
  On Tue, 25 Mar 2014, Richard Biener wrote:
  
   On Tue, 25 Mar 2014, Jakub Jelinek wrote:
   
Hi!

While working on previous patch, I've noticed a severe omission in the
-fsanitize=signed-integer-overflow support.  Nothing ever
folds addition/subtraction of 0 and multiplication by [0,1], none of 
these
may ever overflow and thus we can fold them to normal operations and let
those be folded as normal operations.

Bootstrapped/regtested on x86_64-linux and i686-linux, tested with
--with-build-config=bootstrap-ubsan bootstrap on i686-linux, ok for 
trunk?
   
   I think you only need to adjust gimple_fold_stmt_to_constant_1.
  
  Actually there only for a * 0 and a - a, as others don't result in
  constants.  Still the other cases should be handled in fold_stmt,
  not only in VRP.
 
 Ok, here is an updated patch that optimizes this in VRP,
 gimple_fold_stmt_to_constant_1 and gimple_fold_call.
 
 Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

 2014-03-25  Jakub Jelinek  ja...@redhat.com
 
   * tree-vrp.c (simplify_internal_call_using_ranges): If only
   one range is range_int_cst_p, but not both, at least optimize
   addition/subtraction of 0 and multiplication by 0 or 1.
   * gimple-fold.c (gimple_fold_call): Fold
   IFN_UBSAN_CHECK_{ADD,SUB,MUL}.
   (gimple_fold_stmt_to_constant_1): If both op0 and op1 aren't
   INTEGER_CSTs, try to fold at least x * 0 and y - y.
 
 --- gcc/tree-vrp.c.jj 2014-03-25 09:22:01.352151925 +0100
 +++ gcc/tree-vrp.c2014-03-25 11:25:44.898562545 +0100
 @@ -9336,31 +9336,58 @@ simplify_internal_call_using_ranges (gim
else if (TREE_CODE (op0) == INTEGER_CST)
  set_value_range_to_value (vr0, op0, NULL);
else
 -return false;
 +set_value_range_to_varying (vr0);
  
if (TREE_CODE (op1) == SSA_NAME)
  vr1 = *get_value_range (op1);
else if (TREE_CODE (op1) == INTEGER_CST)
  set_value_range_to_value (vr1, op1, NULL);
else
 -return false;
 +set_value_range_to_varying (vr1);
  
 -  if (!range_int_cst_p (vr0) || !range_int_cst_p (vr1))
 -return false;
 -
 -  tree r1 = int_const_binop (subcode, vr0.min, vr1.min);
 -  tree r2 = int_const_binop (subcode, vr0.max, vr1.max);
 -  if (r1 == NULL_TREE || TREE_OVERFLOW (r1)
 -  || r2 == NULL_TREE || TREE_OVERFLOW (r2))
 -return false;
 -  if (subcode == MULT_EXPR)
 +  if (!range_int_cst_p (vr0))
 +{
 +  /* If one range is VR_ANTI_RANGE, VR_VARYING etc.,
 +  optimize at least x = y + 0; x = y - 0; x = y * 0;
 +  and x = y * 1; which never overflow.  */
 +  if (!range_int_cst_p (vr1))
 + return false;
 +  if (tree_int_cst_sgn (vr1.min) == -1)
 + return false;
 +  if (compare_tree_int (vr1.max, subcode == MULT_EXPR) == 1)
 + return false;
 +}
 +  else if (!range_int_cst_p (vr1))
 +{
 +  /* If one range is VR_ANTI_RANGE, VR_VARYING etc.,
 +  optimize at least x = 0 + y; x = 0 * y; and x = 1 * y;
 +  which never overflow.  */
 +  if (subcode == MINUS_EXPR)
 + return false;
 +  if (!range_int_cst_p (vr0))
 + return false;
 +  if (tree_int_cst_sgn (vr0.min) == -1)
 + return false;
 +  if (compare_tree_int (vr0.max, subcode == MULT_EXPR) == 1)
 + return false;
 +}
 +  else
  {
 -  tree r3 = int_const_binop (subcode, vr0.min, vr1.max);
 -  tree r4 = int_const_binop (subcode, vr0.max, vr1.min);
 -  if (r3 == NULL_TREE || TREE_OVERFLOW (r3)
 -   || r4 == NULL_TREE || TREE_OVERFLOW (r4))
 +  tree r1 = int_const_binop (subcode, vr0.min, vr1.min);
 +  tree r2 = int_const_binop (subcode, vr0.max, vr1.max);
 +  if (r1 == NULL_TREE || TREE_OVERFLOW (r1)
 +   || r2 == NULL_TREE || TREE_OVERFLOW (r2))
   return false;
 +  if (subcode == MULT_EXPR)
 + {
 +   tree r3 = int_const_binop (subcode, vr0.min, vr1.max);
 +   tree r4 = int_const_binop (subcode, vr0.max, vr1.min);
 +   if (r3 == NULL_TREE || TREE_OVERFLOW (r3)
 +   || r4 == NULL_TREE || TREE_OVERFLOW (r4))
 + return false;
 + }
  }
 +
gimple g = gimple_build_assign_with_ops (subcode, gimple_call_lhs (stmt),
  op0, op1);
gsi_replace (gsi, g, false);
 --- gcc/gimple-fold.c.jj  2014-03-18 17:08:48.0 +0100
 +++ gcc/gimple-fold.c 2014-03-25 12:04:07.277342445 +0100
 @@ -1186,13 +1186,56 @@ gimple_fold_call (gimple_stmt_iterator *
else if (gimple_call_builtin_p (stmt, BUILT_IN_MD))
   changed |= targetm.gimple_fold_builtin (gsi);
  }
 -  else if (gimple_call_internal_p (stmt)
 - gimple_call_internal_fn (stmt) == IFN_BUILTIN_EXPECT)
 +  else if (gimple_call_internal_p (stmt))
  {
 -  tree result = fold_builtin_expect (gimple_location (stmt),
 -  

Re: [PATCH] Fix PR rtl-optimization/pr60663

2014-03-26 Thread Zhenqiang Chen
On 26 March 2014 15:45, Jakub Jelinek ja...@redhat.com wrote:
 On Wed, Mar 26, 2014 at 03:30:44PM +0800, Zhenqiang Chen wrote:
 Agree. CSE should never modify asm insns to drop some of the outputs.

 So the right fix is top prevent this from happening, not papering over about
 it.

 But in this case, CSE does not drop any of the outputs. It just takes
 the SRC of a set and replace the reference of the set. And the
 instruction validation tells CSE that it is legal instruction after
 replacement. (The original correct asm insn is optimized away after
 this replacement)

 I think it is common for most rtl-optimizations to do such kind of
 validation. So to avoid such kind of bug, check_asm_operands must tell
 the optimizer the asm is illegal.

 As it is wrong if CSE does that even with asm ( : =r (i), =r (j));,
 your patch is not the right place to fix this.  CSE just must check where
 the ASM_OPERANDS is coming from and if it comes from a PARALLEL with
 multiple outputs, either give up or duplicate all outputs (if it makes sense
 at all).  Or just don't enter into the hash tables ASM_OPERANDS with
 multiple outputs.

Thanks for the comments. I will rework the patch to check it in CSE.

-Zhenqiang

 Jakub


[PATCH, SH] inline builtin_memset

2014-03-26 Thread Christian Bruel
Hello,

This patch inlines builtin_memset whose size is a constant 128  size 
15. Small sizes are better unrolled with mov_insn sequences. Big size
(or non constants) are better handled with a libc implementation that
does cache line aligned copying and unrolling or prefetching.

No new regressions for sh-none-elf and sh-linux-elf without new errors.

OK for trunk ?

many thanks,








2014-03-20  Christian Bruel  christian.br...@st.com

	* config/sh/sh.md (setmemqi): New expand pattern.
	(CLEAR_RATIO): Define.
	* config/sh/sh-mem.cc (sh_expand_setmem): Define.
	* config/sh/sh-protos.h (sh_expand_setmem): Declare.

2014-01-20  Christian Bruel  christian.br...@st.com

	* gcc.target/sh/memset.c: New test.

Index: gcc/config/sh/sh-mem.cc
===
--- gcc/config/sh/sh-mem.cc	(revision 208745)
+++ gcc/config/sh/sh-mem.cc	(working copy)
@@ -608,3 +608,106 @@ sh_expand_strlen (rtx *operands)
 
   return true;
 }
+
+/* Emit code to perform a memset
+
+   OPERANDS[0] is the destination.
+   OPERANDS[1] is the size;
+   OPERANDS[2] is the char to search.
+   OPERANDS[3] is the alignment.  */
+void
+sh_expand_setmem (rtx *operands)
+{
+  rtx L_loop_byte = gen_label_rtx ();
+  rtx L_loop_word = gen_label_rtx ();
+  rtx L_return = gen_label_rtx ();
+  rtx jump;
+  rtx dest = copy_rtx (operands[0]);
+  rtx dest_addr = copy_addr_to_reg (XEXP (dest, 0));
+  rtx val = force_reg (SImode, operands[2]);
+  int align = INTVAL (operands[3]);
+  int count = 0;
+  rtx len = force_reg (SImode, operands[1]);
+
+  if (! CONST_INT_P (operands[1]))
+return;
+
+  count = INTVAL (operands[1]);
+
+  if (CONST_INT_P (operands[2])
+   (INTVAL (operands[2]) == 0 || INTVAL (operands[2]) == -1)  count  8)
+{
+  rtx lenw = gen_reg_rtx (SImode);
+
+  if (align  4)
+{
+  emit_insn (gen_tstsi_t (GEN_INT (3), dest_addr));
+  jump = emit_jump_insn (gen_branch_false (L_loop_byte));
+  add_int_reg_note (jump, REG_BR_PROB, prob_likely);
+}
+
+  /* word count. Do we have iterations ? */
+  emit_insn (gen_lshrsi3 (lenw, len, GEN_INT (2)));
+
+  dest = adjust_automodify_address (dest, SImode, dest_addr, 0);
+
+  /* start loop.  */
+  emit_label (L_loop_word);
+
+  if (TARGET_SH2)
+emit_insn (gen_dect (lenw, lenw));
+  else
+{
+  emit_insn (gen_addsi3 (lenw, lenw, GEN_INT (-1)));
+  emit_insn (gen_tstsi_t (lenw, lenw));
+}
+
+  emit_move_insn (dest, val);
+  emit_move_insn (dest_addr, plus_constant (Pmode, dest_addr,
+GET_MODE_SIZE (SImode)));
+
+
+  jump = emit_jump_insn (gen_branch_false (L_loop_word));
+  add_int_reg_note (jump, REG_BR_PROB, prob_likely);
+  count = count % 4;
+
+  dest = adjust_address (dest, QImode, 0);
+
+  val = gen_lowpart (QImode, val);
+
+  while (count--)
+{
+  emit_move_insn (dest, val);
+  emit_move_insn (dest_addr, plus_constant (Pmode, dest_addr,
+GET_MODE_SIZE (QImode)));
+}
+
+  jump = emit_jump_insn (gen_jump_compact (L_return));
+  emit_barrier_after (jump);
+}
+
+  dest = adjust_automodify_address (dest, QImode, dest_addr, 0);
+
+  /* start loop.  */
+  emit_label (L_loop_byte);
+
+  if (TARGET_SH2)
+emit_insn (gen_dect (len, len));
+  else
+{
+  emit_insn (gen_addsi3 (len, len, GEN_INT (-1)));
+  emit_insn (gen_tstsi_t (len, len));
+}
+
+  val = gen_lowpart (QImode, val);
+  emit_move_insn (dest, val);
+  emit_move_insn (dest_addr, plus_constant (Pmode, dest_addr,
+GET_MODE_SIZE (QImode)));
+
+  jump = emit_jump_insn (gen_branch_false (L_loop_byte));
+  add_int_reg_note (jump, REG_BR_PROB, prob_likely);
+
+  emit_label (L_return);
+
+  return;
+}
Index: gcc/config/sh/sh-protos.h
===
--- gcc/config/sh/sh-protos.h	(revision 208745)
+++ gcc/config/sh/sh-protos.h	(working copy)
@@ -119,6 +119,7 @@ extern void prepare_move_operands (rtx[], enum mac
 extern bool sh_expand_cmpstr (rtx *);
 extern bool sh_expand_cmpnstr (rtx *);
 extern bool sh_expand_strlen  (rtx *);
+extern void sh_expand_setmem (rtx *);
 extern enum rtx_code prepare_cbranch_operands (rtx *, enum machine_mode mode,
 	   enum rtx_code comparison);
 extern void expand_cbranchsi4 (rtx *operands, enum rtx_code comparison, int);
Index: gcc/config/sh/sh.h
===
--- gcc/config/sh/sh.h	(revision 208745)
+++ gcc/config/sh/sh.h	(working copy)
@@ -1594,6 +1594,11 @@ struct sh_args {
 
 #define SET_BY_PIECES_P(SIZE, ALIGN) STORE_BY_PIECES_P(SIZE, ALIGN)
 
+/* If a memory clear move would take CLEAR_RATIO or more simple
+   move-instruction pairs, we will do a setmem instead.  */
+
+#define CLEAR_RATIO(speed) 

Re: [PATCH, SH] inline builtin_memset

2014-03-26 Thread Christian Bruel

On 03/26/2014 11:22 AM, Christian Bruel wrote:
 Hello,

 This patch inlines builtin_memset whose size is a constant 128  size 
 15. Small sizes are better unrolled with mov_insn sequences. Big size
 (or non constants) are better handled with a libc implementation that
 does cache line aligned copying and unrolling or prefetching.

Correction, it's memcpy that can do that, but nevertheless, a
specialized implementation in the glibc is better for big sizes (and
absorbs the cost of the jump).



 No new regressions for sh-none-elf and sh-linux-elf without new errors.

 OK for trunk ?

 many thanks,











[PATCH] Avoid more casts of switch values

2014-03-26 Thread Richard Biener

This avoids the (int) cast for switches on enums (which are
appearantly using an unsigned type in C++).  It does so by
enhancing the code in simplify_gimple_switch to see if the
case value checks are preserved with a sign-change.

Bootstrap / regtest running on x86_64-unkown-linux-gnu, queued for stage1.

Richard.

2014-03-26  Richard Biener  rguent...@suse.de

* tree-ssa-forwprop.c (simplify_gimple_switch): Enhance
check for which sign-changes we allow when forwarding
a converted value into a switch.

* g++.dg/tree-ssa/forwprop-switch.C: New testcase.

Index: gcc/tree-ssa-forwprop.c
===
*** gcc/tree-ssa-forwprop.c (revision 208812)
--- gcc/tree-ssa-forwprop.c (working copy)
*** simplify_gimple_switch_label_vec (gimple
*** 1356,1398 
  static bool
  simplify_gimple_switch (gimple stmt)
  {
-   tree cond = gimple_switch_index (stmt);
-   tree def, to, ti;
-   gimple def_stmt;
- 
/* The optimization that we really care about is removing unnecessary
   casts.  That will let us do much better in propagating the inferred
   constant at the switch target.  */
if (TREE_CODE (cond) == SSA_NAME)
  {
!   def_stmt = SSA_NAME_DEF_STMT (cond);
!   if (is_gimple_assign (def_stmt))
{
! if (gimple_assign_rhs_code (def_stmt) == NOP_EXPR)
!   {
! int need_precision;
! bool fail;
! 
! def = gimple_assign_rhs1 (def_stmt);
  
! to = TREE_TYPE (cond);
! ti = TREE_TYPE (def);
! 
! /* If we have an extension that preserves value, then we
!can copy the source value into the switch.  */
! 
! need_precision = TYPE_PRECISION (ti);
! fail = false;
! if (! INTEGRAL_TYPE_P (ti))
!   fail = true;
! else if (TYPE_UNSIGNED (to)  !TYPE_UNSIGNED (ti))
!   fail = true;
! else if (!TYPE_UNSIGNED (to)  TYPE_UNSIGNED (ti))
!   need_precision += 1;
! if (TYPE_PRECISION (to)  need_precision)
!   fail = true;
! 
! if (!fail)
{
  gimple_switch_set_index (stmt, def);
  simplify_gimple_switch_label_vec (stmt, ti);
--- 1356,1391 
  static bool
  simplify_gimple_switch (gimple stmt)
  {
/* The optimization that we really care about is removing unnecessary
   casts.  That will let us do much better in propagating the inferred
   constant at the switch target.  */
+   tree cond = gimple_switch_index (stmt);
if (TREE_CODE (cond) == SSA_NAME)
  {
!   gimple def_stmt = SSA_NAME_DEF_STMT (cond);
!   if (gimple_assign_cast_p (def_stmt))
{
! tree def = gimple_assign_rhs1 (def_stmt);
! tree ti = TREE_TYPE (def);
  
! /* If we have an extension or sign-change that preserves the
!values we check against then we can copy the source value into
!the switch.  */
! if (INTEGRAL_TYPE_P (ti)
!  TYPE_PRECISION (ti) = TYPE_PRECISION (TREE_TYPE (cond)))
!   {
! size_t n = gimple_switch_num_labels (stmt);
! tree min = NULL_TREE, max = NULL_TREE;
! if (n  1)
!   {
! min = CASE_LOW (gimple_switch_label (stmt, 1));
! if (CASE_HIGH (gimple_switch_label (stmt, n - 1)))
!   max = CASE_HIGH (gimple_switch_label (stmt, n - 1));
! else
!   max = CASE_LOW (gimple_switch_label (stmt, n - 1));
!   }
! if ((!min || int_fits_type_p (min, ti))
!  (!max || int_fits_type_p (max, ti)))
{
  gimple_switch_set_index (stmt, def);
  simplify_gimple_switch_label_vec (stmt, ti);
Index: gcc/testsuite/g++.dg/tree-ssa/forwprop-switch.C
===
*** gcc/testsuite/g++.dg/tree-ssa/forwprop-switch.C (revision 0)
--- gcc/testsuite/g++.dg/tree-ssa/forwprop-switch.C (working copy)
***
*** 0 
--- 1,24 
+ // { dg-do compile }
+ // { dg-options -O -fdump-tree-cddce1 }
+ 
+ enum Scale  { E1, E2, E3, E4, E5, E6, E7, E8 };
+ 
+ int Test(Scale s)
+ { 
+   switch(s)
+ {
+   case E1: return 12;
+   case E2: return 17;
+   case E3: return 22;
+   case E4: return 42;
+   default:  break;
+ }
+   return 0;
+ }
+ 
+ // tree forwprop should have eliminated the (int) s cast for the
+ // switch value and directly switch on the 's' parameter
+ 
+ // { dg-final { scan-tree-dump-not \\\(int\\\) cddce1 } }
+ // { dg-final { scan-tree-dump switch \\\(s_.\\\(D\\\)\\\) cddce1 } }
+ // { dg-final { cleanup-tree-dump cddce1 } }


Re: Please revert the patches in bug #54040 and #59346 and special case x32

2014-03-26 Thread Svante Signell
On Wed, 2014-03-26 at 00:25 +0100, Eric Botcazou wrote:
  Should I file a bug to get feedback on this issue? I know Ada is not the
  most prioritized language for gcc, but anyway. The current
  implementation is not POSIX-compliant.
 
 Can you post a complete patch doing the reversion?  Breaking POSIX and every 
 Unix for the sake of x32 is definitely too much in my opinion.

The commits are:
http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e3a1f6b50495473f677f413d8740808a3fde5a9a

http://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=d2a4f256f9bc035ef2d6874c4e4c20c83ebf00b4

I think doing special casing for x32 as indicated in the previous mail
could solve the problem also for that architecture.

Add/modify gcc/ada/{s-linux-x32.ads,s-osprim-x32.ads} according to:
   type tv_nsec_t is private;
   type tv_nsec_t is new Long_Long_Integer;
   type timespec is record
  tv_sec  : time_t;
  tv_nsec : tv_nsec_t;
   end record;
   pragma Convention (C, timespec);



Re: [PATH, SH] Small builtin_strlen improvement

2014-03-26 Thread Kaz Kojima
Christian Bruel christian.br...@st.com wrote:
 This patches adds a few instructions to the inlined builtin_strlen to
 unroll the remaining bytes for word-at-a-time loop. This enables to have
 2 distinct execution paths (no fall-thru in the byte-at-a-time loop),
 allowing block alignment assignation. This partially improves the
 problem reported with by Oleg. in [Bug target/0539] New: [SH] builtin
 string functions ignore loop and label alignment
[snip]
 Best tuning compared to the compact version I got on is ~1% for c++
 regular expression benchmark, but well, code looks best this way.
 
 regtested tested for -m2, -m4
 
 OK for trunk ?

OK for trunk when it returns to stage 1 or 2.

Regards,
kaz


Re: [PATCH, SH] inline builtin_memset

2014-03-26 Thread Kaz Kojima
Christian Bruel christian.br...@st.com wrote:
 This patch inlines builtin_memset whose size is a constant 128  size 
 15. Small sizes are better unrolled with mov_insn sequences. Big size
 (or non constants) are better handled with a libc implementation that
 does cache line aligned copying and unrolling or prefetching.
 
 No new regressions for sh-none-elf and sh-linux-elf without new errors.
 
 OK for trunk ?

OK for trunk when it returns to stage 1 or 2.

Regards,
kaz


[PATCH] S/390: Fix FPR restores with shrink wrapping on 31bit zarch

2014-03-26 Thread Andreas Krebbel
Hi,

in the attached testcase the restore of f4 gets dropped when compiled
with -m31 -mzarch.  The problem is that s390_can_use_return_insn lacks
a check for f4 and f6 which are call-saved on 31 bit.

Bootstraps on s390 and s390x are still running.  I'll commit it
afterwards.

This fixes a miscompile of the 433.milc SpecCPU testcase.

Bye,

-Andreas-


2014-03-26  Andreas Krebbel  andreas.kreb...@de.ibm.com

* config/s390/s390.c (s390_can_use_return_insn): Check for
call-saved FPRs on 31 bit.

2014-03-26  Andreas Krebbel  andreas.kreb...@de.ibm.com

* gcc.target/s390/20140326-1.c: New testcase.

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index 7a79286..bdb577c 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -9225,6 +9225,13 @@ s390_can_use_return_insn (void)
 if (cfun_gpr_save_slot (i))
   return false;
 
+  /* For 31 bit this is not covered by the frame_size check below
+ since f4, f6 are saved in the register save area without needing
+ additional stack space.  */
+  if (!TARGET_64BIT
+   (cfun_fpr_save_p (FPR4_REGNUM) || cfun_fpr_save_p (FPR6_REGNUM)))
+return false;
+
   if (cfun-machine-base_reg
!call_really_used_regs[REGNO (cfun-machine-base_reg)])
 return false;
diff --git a/gcc/testsuite/gcc.target/s390/20140326-1.c 
b/gcc/testsuite/gcc.target/s390/20140326-1.c
new file mode 100644
index 000..f71c38f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/20140326-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-options -O3 -m31 -mzarch } */
+
+void
+foo ()
+{
+  asm ( ::: %f4);
+}
+
+/* { dg-final { scan-assembler ld } } */



Re: RFA: Fix PR rtl-optimization/60651

2014-03-26 Thread Joern Rennecke
On 26 March 2014 08:15, Eric Botcazou ebotca...@adacore.com wrote:
 As described in the PR, this patch fixes a wrong-code bug by making the
 order of emitted mode switching instructions more consistet  predictable.

 I don't understand this change (but I'm not a specialist of mode switching):
 currently the mode setting sequence is always emitted before the insns that
 need it but, with the change, if an insn right after a NOTE_BASIC_BLOCK note
 needs it, if will be emitted either before it (if insn_ptr is the insn) or
 after it (if insn_ptr is the NOTE_BASIC_BLOCK note).

When the seginfo is for an initially empty block, appending the mode
switching instruction at the end is fine.
Now that I'm trying to prove that this is always the case when insn_ptr
is set to a a NOTE_INSN_BASIC_BLOCK, I find that is not actually true.
insn_ptr gets set in new_seginfo, and there are three calls to that function.
The second call is for instructions that themselves need a particular mode,
so these are not basic block heads.  The third call is for and BB_END, and
this is a NOTE_INSN_BASIC_BLOCK exactly iff the block is empty.

However, the first call is for blocks with incoming abnormal edges.
If these are empty, the change as I wrote it yesterday is fine, but not
when they are non-empty; in that case, we should indeed insert before the
first instruction in that block.

This can be archived by finding an insert-before position using NEXT_INSN
on the basic block head; this amounts to the very same insertion place
as inserting after the basic block head.  Also, we will continue to set no
location, and use the same bb, because both add_insn_before and
add_insn_after (in contradiction to its block comment) will infer the basic
block from the insn given (in the case for add_insn_before, I assume
that the basic block doesn't start with a BARRIER - that would be invalid -
and that the insn it starts with has a valid BLOCK_FOR_INSN setting the
same way the basic block head has.

bootstrapped on i686-pc-linux-gnu, regtest in progress.


tmp
Description: Binary data


Re: RFA: Fix PR rtl-optimization/60651

2014-03-26 Thread Joern Rennecke
On 26 March 2014 12:35, Joern Rennecke joern.renne...@embecosm.com wrote:

 bootstrapped on i686-pc-linux-gnu, regtest in progress.

Passed now.


[PATCH] Fix GDB PR15559 (inferior calls using thiscall calling convention)

2014-03-26 Thread Julian Brown
Hi,

This is the GCC part of my fix for PR15559, the GDB part of which was
posted here:

https://sourceware.org/ml/gdb-patches/2014-03/msg00610.html

Cross-tested (gcc/g++/libstdc++) from Linux to Mingw32: results are the
same, apart from (what I presume to be) noise in guality.exp/pr55665.C.

According to PR15559, this is technically a regression from pre-4.7.0,
so OK either for now, or for stage 1? For other branches?

Thanks,

Julian

ChangeLog

include/
* dwarf2.h (enum dwarf_calling_convention): Add
DW_CC_GNU_thiscall_i386.

gcc/
* config/i386/i386.c (ix86_dwarf_calling_convention): New.
(TARGET_DWARF_CALLING_CONVENTION): Define, using above.Index: include/dwarf2.h
===
--- include/dwarf2.h	(revision 208642)
+++ include/dwarf2.h	(working copy)
@@ -182,6 +182,7 @@ enum dwarf_calling_convention
 
 DW_CC_GNU_renesas_sh = 0x40,
 DW_CC_GNU_borland_fastcall_i386 = 0x41,
+DW_CC_GNU_thiscall_i386 = 0x42,
 
 /* This DW_CC_ value is not currently generated by any toolchain.  It is
used internally to GDB to indicate OpenCL C functions that have been
Index: gcc/config/i386/i386.c
===
--- gcc/config/i386/i386.c	(revision 208642)
+++ gcc/config/i386/i386.c	(working copy)
@@ -14155,6 +14155,21 @@ output_pic_addr_const (FILE *file, rtx x
 }
 }
 
+/* Return Dwarf2 tag for calling convention to use for FUNCTION.  */
+
+static int
+ix86_dwarf_calling_convention (const_tree function)
+{
+  unsigned int ccvt = ix86_get_callcvt (function);
+
+  /* This is needed so that the debugger can reliably detect when to use the
+ thiscall calling convention to invoke inferior functions/methods.  */
+  if ((ccvt  IX86_CALLCVT_THISCALL) != 0)
+return DW_CC_GNU_thiscall_i386;
+
+  return DW_CC_normal;
+}
+
 /* This is called from dwarf2out.c via TARGET_ASM_OUTPUT_DWARF_DTPREL.
We need to emit DTP-relative relocations.  */
 
@@ -46984,6 +46999,9 @@ ix86_atomic_assign_expand_fenv (tree *ho
 #undef TARGET_C_MODE_FOR_SUFFIX
 #define TARGET_C_MODE_FOR_SUFFIX ix86_c_mode_for_suffix
 
+#undef TARGET_DWARF_CALLING_CONVENTION
+#define TARGET_DWARF_CALLING_CONVENTION ix86_dwarf_calling_convention
+
 #ifdef HAVE_AS_TLS
 #undef TARGET_ASM_OUTPUT_DWARF_DTPREL
 #define TARGET_ASM_OUTPUT_DWARF_DTPREL i386_output_dwarf_dtprel


[AArch64] Fully support rotate on logical operations

2014-03-26 Thread Richard Earnshaw
This patch fixes an issue where only some rotate immediate operations
are merged with logical operations during combine.  The problem is due
to canonicalization.  The architecture only has a rotate-right
operation, so rotate-left has to be converted into rotate-right.  To
avoid fighting the mid-end canonicalization rules, the only way to do
this is during final assembly output.

This patch adds the two necessary patterns to make this happen.  It also
corrects an oversight in the rtx_cost infrastructure in that we didn't
recognize any rotate operations on logical instructions.  We now treat
rotate in the same way as any other shift operation.

I'll apply this to trunk once stage-1 opens.

R.

* aarch64.md (optab_rolmode3): New pattern.
(optab_rolsi3_uxtw): Likewise.
* aarch64.c (aarch64_strip_shift): Handle ROTATE and ROTATERT.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index ebd58c0..4f37c08 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -4458,9 +4458,13 @@ aarch64_strip_shift (rtx x)
 {
   rtx op = x;
 
+  /* We accept both ROTATERT and ROTATE: since the RHS must be a constant
+ we can convert both to ROR during final output.  */
   if ((GET_CODE (op) == ASHIFT
|| GET_CODE (op) == ASHIFTRT
-   || GET_CODE (op) == LSHIFTRT)
+   || GET_CODE (op) == LSHIFTRT
+   || GET_CODE (op) == ROTATERT
+   || GET_CODE (op) == ROTATE)
CONST_INT_P (XEXP (op, 1)))
 return XEXP (op, 0);
 
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index c86a29d..a6d6243 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -2486,7 +2486,18 @@
   [(set_attr type logic_shift_imm)]
 )
 
-;; zero_extend version of above
+(define_insn *optab_rolmode3
+  [(set (match_operand:GPI 0 register_operand =r)
+   (LOGICAL:GPI (rotate:GPI
+ (match_operand:GPI 1 register_operand r)
+ (match_operand:QI 2 aarch64_shift_imm_mode n))
+(match_operand:GPI 3 register_operand r)))]
+  
+  logical\\t%w0, %w3, %w1, ror (sizen - %2)
+  [(set_attr type logic_shift_imm)]
+)
+
+;; zero_extend versions of above
 (define_insn *LOGICAL:optab_SHIFT:optabsi3_uxtw
   [(set (match_operand:DI 0 register_operand =r)
(zero_extend:DI
@@ -2499,6 +2510,18 @@
   [(set_attr type logic_shift_imm)]
 )
 
+(define_insn *optab_rolsi3_uxtw
+  [(set (match_operand:DI 0 register_operand =r)
+   (zero_extend:DI
+(LOGICAL:SI (rotate:SI
+ (match_operand:SI 1 register_operand r)
+ (match_operand:QI 2 aarch64_shift_imm_si n))
+(match_operand:SI 3 register_operand r]
+  
+  logical\\t%w0, %w3, %w1, ror (32 - %2)
+  [(set_attr type logic_shift_imm)]
+)
+
 (define_insn one_cmplmode2
   [(set (match_operand:GPI 0 register_operand =r)
(not:GPI (match_operand:GPI 1 register_operand r)))]

Fix PR60644

2014-03-26 Thread Alexander Ivchenko
Hi,

In gcc/config/linux-android.h we have builtin_define (__ANDROID__);
So ANDROID as in libcilkrts now is not the correct macro to check.

Bootstrapped and passed cilk testsuite on x86_64-unknown-linux-gnu.

diff --git a/libcilkrts/ChangeLog b/libcilkrts/ChangeLog
index eb0d6ec..65efef0 100644
--- a/libcilkrts/ChangeLog
+++ b/libcilkrts/ChangeLog
@@ -1,3 +1,12 @@
+2014-03-26  Alexander Ivchenko  alexander.ivche...@intel.com
+
+ PR bootstrap/60644
+
+ * include/cilk/metaprogramming.h: Change ANDROID to __ANDROID__.
+ * include/cilk/reducer_min_max.h: Ditto.
+ * runtime/bug.h: Ditto.
+ * runtime/os-unix.c: Ditto.
+
 2014-03-20  Tobias Burnus  bur...@net-b.de

  PR other/60589
diff --git a/libcilkrts/include/cilk/metaprogramming.h
b/libcilkrts/include/cilk/metaprogramming.h
index 5f6f29d..29b0839 100644
--- a/libcilkrts/include/cilk/metaprogramming.h
+++ b/libcilkrts/include/cilk/metaprogramming.h
@@ -468,7 +468,7 @@ inline void* allocate_aligned(std::size_t size,
std::size_t alignment)
 #ifdef _WIN32
 return _aligned_malloc(size, alignment);
 #else
-#if defined(ANDROID) || defined(__ANDROID__)
+#if defined(__ANDROID__)
 return memalign(std::max(alignment, sizeof(void*)), size);
 #else
 void* ptr;
diff --git a/libcilkrts/include/cilk/reducer_min_max.h
b/libcilkrts/include/cilk/reducer_min_max.h
index 55f068c..7fe09e8 100644
--- a/libcilkrts/include/cilk/reducer_min_max.h
+++ b/libcilkrts/include/cilk/reducer_min_max.h
@@ -3025,7 +3025,7 @@ struct legacy_reducer_downcast reducer
op_min_indexIndex, Type, Compare, Alig
 #include limits.h

 /* Wchar_t min/max constants */
-#if defined(_MSC_VER) || defined(ANDROID)
+#if defined(_MSC_VER) || defined(__ANDROID__)
 #   include wchar.h
 #else
 #   include stdint.h
diff --git a/libcilkrts/runtime/bug.h b/libcilkrts/runtime/bug.h
index bb18913..1a64bea 100644
--- a/libcilkrts/runtime/bug.h
+++ b/libcilkrts/runtime/bug.h
@@ -90,7 +90,7 @@ COMMON_PORTABLE extern const char *const
__cilkrts_assertion_failed;
  * GPL V3 licensed.
  */
 COMMON_PORTABLE void cilkbug_assert_no_uncaught_exception(void);
-#if defined(_WIN32) || defined(ANDROID)
+#if defined(_WIN32) || defined(__ANDROID__)
 #  define CILKBUG_ASSERT_NO_UNCAUGHT_EXCEPTION()
 #else
 #  define CILKBUG_ASSERT_NO_UNCAUGHT_EXCEPTION() \
diff --git a/libcilkrts/runtime/os-unix.c b/libcilkrts/runtime/os-unix.c
index fafb91d..85bc08d 100644
--- a/libcilkrts/runtime/os-unix.c
+++ b/libcilkrts/runtime/os-unix.c
@@ -282,7 +282,7 @@ void __cilkrts_init_tls_variables(void)
 }
 #endif

-#if defined (__linux__)  ! defined(ANDROID)
+#if defined (__linux__)  ! defined(__ANDROID__)
 /*
  * Get the thread id, rather than the pid. In the case of MIC offload, it's
  * possible that we have multiple threads entering Cilk, and each has a
@@ -354,7 +354,7 @@ static int linux_get_affinity_count (int tid)

 COMMON_SYSDEP int __cilkrts_hardware_cpu_count(void)
 {
-#if defined ANDROID || (defined(__sun__)  defined(__svr4__))
+#if defined __ANDROID__ || (defined(__sun__)  defined(__svr4__))
 return sysconf (_SC_NPROCESSORS_ONLN);
 #elif defined __MIC__
 /// HACK: Usually, the 3rd and 4th hyperthreads are not beneficial
@@ -409,7 +409,7 @@ COMMON_SYSDEP void __cilkrts_yield(void)
 // giving up the processor and latency starting up when work becomes
 // available
 _mm_delay_32(1024);
-#elif defined(ANDROID) || (defined(__sun__)  defined(__svr4__))
+#elif defined(__ANDROID__) || (defined(__sun__)  defined(__svr4__))
 // On Android and Solaris, call sched_yield to yield quantum.  I'm not
 // sure why we don't do this on Linux also.
 sched_yield();




Is it OK?

--Alexander


Re: [PATCH] Fix PR c++/60573

2014-03-26 Thread Jason Merrill

On 03/25/2014 03:48 PM, Adam Butcher wrote:

I don't follow.  Are you suggesting a case like the following?

   struct A
   {
 struct X
 {
   struct B
   {
 void foo(auto);
   };
 };

 void X::B::foo(auto) {}  // { dg-error cannot define }
   };


I meant

  struct A
  {
struct X
{
  struct B
  {
void foo(auto);
  };

  void B::foo(auto) {}  // { dg-error cannot define }
};
  };

Here we push both A and X for the declarator.  When we get to the pushed 
X, we see that the enclosing scope is A, so we break out of the loop and 
don't pop either of the pushed scopes.


Jason



[PATCH] Handle short reads and EINTR in lto-plugin/simple-object

2014-03-26 Thread Richard Biener

The following tries to cure random plugin claim failures I see when
building in KVM (still to be verified that this is the actual problem).
It seems that lto-plugin and simple-object fail to handle short reads
and read returning EINTR which the following fixes by teaching that
to simple_object_internal_read and using that from lto-plugin.c.

(LTO) Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Ok for trunk and branches?

(yes, simple_object_write would have the same issue - I'll fix that
as a followup if it turns out to fix the KVM build issues).

Thanks,
Richard.

2014-03-26  Richard Biener  rguent...@suse.de

libiberty/
* simple-object.c (simple_object_internal_read): Handle
EINTR and short reads.

lto-plugin/
* lto-plugin.c (process_symtab): Use simple_object_internal_read.

Index: libiberty/simple-object.c
===
--- libiberty/simple-object.c   (revision 208812)
+++ libiberty/simple-object.c   (working copy)
@@ -72,15 +72,25 @@ simple_object_internal_read (int descrip
   return 0;
 }
 
-  got = read (descriptor, buffer, size);
-  if (got  0)
+  do
 {
-  *errmsg = read;
-  *err = errno;
-  return 0;
+  got = read (descriptor, buffer, size);
+  if (got  0
+  errno != EINTR)
+   {
+ *errmsg = read;
+ *err = errno;
+ return 0;
+   }
+  else
+   {
+ buffer += got;
+ size -= got;
+   }
 }
+  while (got != 0  size  0);
 
-  if ((size_t) got  size)
+  if (size  0)
 {
   *errmsg = file too short;
   *err = 0;
Index: lto-plugin/lto-plugin.c
===
--- lto-plugin/lto-plugin.c (revision 208812)
+++ lto-plugin/lto-plugin.c (working copy)
@@ -818,6 +818,8 @@ process_symtab (void *data, const char *
   struct plugin_objfile *obj = (struct plugin_objfile *)data;
   char *s;
   char *secdata;
+  char *errmsg;
+  int err;
 
   if (strncmp (name, LTO_SECTION_PREFIX, LTO_SECTION_PREFIX_LEN) != 0)
 return 1;
@@ -827,8 +829,8 @@ process_symtab (void *data, const char *
 sscanf (s, .% PRI_LL x, obj-out-id);
   secdata = xmalloc (length);
   offset += obj-file-offset;
-  if (offset != lseek (obj-file-fd, offset, SEEK_SET)
-   || length != read (obj-file-fd, secdata, length))
+  if (!simple_object_internal_read (obj-file-fd, offset,
+   secdata, length, errmsg, err))
 {
   if (message)
message (LDPL_FATAL, %s: corrupt object file, obj-file-name);


Re: [PATCH] Handle short reads and EINTR in lto-plugin/simple-object

2014-03-26 Thread Ian Lance Taylor
On Wed, Mar 26, 2014 at 8:38 AM, Richard Biener rguent...@suse.de wrote:

 -  got = read (descriptor, buffer, size);
 -  if (got  0)
 +  do
  {
 -  *errmsg = read;
 -  *err = errno;
 -  return 0;
 +  got = read (descriptor, buffer, size);
 +  if (got  0
 +  errno != EINTR)
 +   {
 + *errmsg = read;
 + *err = errno;
 + return 0;
 +   }
 +  else
 +   {
 + buffer += got;
 + size -= got;
 +   }

This appears to do the wrong thing if got  0  errno == EINTR.  In
that case it should not add got to buffer and size.

 -  if (offset != lseek (obj-file-fd, offset, SEEK_SET)
 -   || length != read (obj-file-fd, secdata, length))
 +  if (!simple_object_internal_read (obj-file-fd, offset,
 +   secdata, length, errmsg, err))

Hmmm, internal_read is meant to be, well, internal.  It's not declared
anywhere as far as I can see.

Are you really seeing EINTR reads here?  That seems very odd to me,
since we are always just reading a local file.  But if you are seeing
it, I guess we should handle it.

Ian


[PATCH] Another undef behavior fix

2014-03-26 Thread Jakub Jelinek
Hi!

Doing low = -low; on signed HOST_WIDE_INT results in undefined behavior
if the low HWI is LONG_LONG_MIN.  Fixed thusly, ok for trunk?

2014-03-26  Jakub Jelinek  ja...@redhat.com

PR other/59545
* real.c (real_to_integer2): Change type of low to UHWI.

--- gcc/real.c.jj   2014-01-03 11:40:37.0 +0100
+++ gcc/real.c  2014-03-26 10:11:39.670655366 +0100
@@ -1377,7 +1377,8 @@ real_to_integer2 (HOST_WIDE_INT *plow, H
  const REAL_VALUE_TYPE *r)
 {
   REAL_VALUE_TYPE t;
-  HOST_WIDE_INT low, high;
+  unsigned HOST_WIDE_INT low;
+  HOST_WIDE_INT high;
   int exp;
 
   switch (r-cl)

Jakub


[PATCH] Fix bootstrap-ubsan

2014-03-26 Thread Jakub Jelinek
Hi!

Honza's r208831 change apparently broke bootstrap-ubsan.
The problem is that it now creates __builtin_unreachable with
gimple_location where LOCATION_LOCUS is UNKNOWN_LOCATION (comes from
fnsplit, any ideas what gimple_location to use for the calls if any?)
and with -fsanitize=undefined we fold that into
__ubsan_handle_builtin_unreachable call.
But (already seen several times in the past) instead of emitting unknown
file and 0/0 line/column as location we don't emit anything at all,
which for unreachable data ICEs and in other cases just crashes in libubsan.
The reason for trying to handle UNKNOWN_LOCATION specially is that some data
structures in libubsan don't have sourceLocation (not the ones we emit right
now though), and guess Marek wanted to be prepared to handle that.

This patch robustifies ubsan_create_data, by turning the location into
a pointer to location_t, NULL means location should not be present, pointer
to UNKNOWN_LOCATION means we should emit location as unknown:0:0,
pointer to real locations something else.

Bootstrapped/regtested with bootstrap-ubsan and normal, ok for trunk?

2014-03-26  Jakub Jelinek  ja...@redhat.com

* ubsan.h (ubsan_create_data): Change second argument's type
to const location_t *.
* ubsan.c (ubsan_source_location): If xloc.file is NULL, set it to
_(unknown).
(ubsan_create_data): Change second argument to const location_t *PLOC.
Create Loc field whenever PLOC is non-NULL.
(ubsan_instrument_unreachable, ubsan_expand_null_ifn,
ubsan_build_overflow_builtin, instrument_bool_enum_load): Adjust
callers.
c-family/
* c-ubsan.c (ubsan_instrument_division, ubsan_instrument_shift,
ubsan_instrument_vla, ubsan_instrument_return): Adjust
ubsan_create_data callers.

--- gcc/ubsan.h.jj  2014-01-03 11:40:57.0 +0100
+++ gcc/ubsan.h 2014-03-26 11:14:32.492987318 +0100
@@ -38,7 +38,7 @@ struct ubsan_mismatch_data {
 
 extern void ubsan_expand_null_ifn (gimple_stmt_iterator);
 extern tree ubsan_instrument_unreachable (location_t);
-extern tree ubsan_create_data (const char *, location_t,
+extern tree ubsan_create_data (const char *, const location_t *,
   const struct ubsan_mismatch_data *, ...);
 extern tree ubsan_type_descriptor (tree, bool);
 extern tree ubsan_encode_value (tree, bool = false);
--- gcc/ubsan.c.jj  2014-03-26 10:17:41.0 +0100
+++ gcc/ubsan.c 2014-03-26 11:32:57.053941843 +0100
@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3.
 #include tree-ssanames.h
 #include asan.h
 #include gimplify-me.h
+#include intl.h
 
 /* Map from a tree to a VAR_DECL tree.  */
 
@@ -238,6 +239,8 @@ ubsan_source_location (location_t loc)
   tree type = ubsan_source_location_type ();
 
   xloc = expand_location (loc);
+  if (xloc.file == NULL)
+xloc.file = unknown;
 
   /* Fill in the values from LOC.  */
   size_t len = strlen (xloc.file);
@@ -404,7 +407,7 @@ ubsan_type_descriptor (tree type, bool w
pointer checking.  */
 
 tree
-ubsan_create_data (const char *name, location_t loc,
+ubsan_create_data (const char *name, const location_t *ploc,
   const struct ubsan_mismatch_data *mismatch, ...)
 {
   va_list args;
@@ -412,17 +415,18 @@ ubsan_create_data (const char *name, loc
   tree fields[5];
   vectree, va_gc *saved_args = NULL;
   size_t i = 0;
+  location_t loc = UNKNOWN_LOCATION;
 
   /* Firstly, create a pointer to type descriptor type.  */
   tree td_type = ubsan_type_descriptor_type ();
   TYPE_READONLY (td_type) = 1;
   td_type = build_pointer_type (td_type);
-  loc = LOCATION_LOCUS (loc);
 
   /* Create the structure type.  */
   ret = make_node (RECORD_TYPE);
-  if (loc != UNKNOWN_LOCATION)
+  if (ploc != NULL)
 {
+  loc = LOCATION_LOCUS (*ploc);
   fields[i] = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
  ubsan_source_location_type ());
   DECL_CONTEXT (fields[i]) = ret;
@@ -481,7 +485,7 @@ ubsan_create_data (const char *name, loc
   tree ctor = build_constructor (ret, v);
 
   /* If desirable, set the __ubsan_source_location element.  */
-  if (loc != UNKNOWN_LOCATION)
+  if (ploc != NULL)
 CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, ubsan_source_location (loc));
 
   size_t nelts = vec_safe_length (saved_args);
@@ -513,7 +517,7 @@ tree
 ubsan_instrument_unreachable (location_t loc)
 {
   initialize_sanitizer_builtins ();
-  tree data = ubsan_create_data (__ubsan_unreachable_data, loc, NULL,
+  tree data = ubsan_create_data (__ubsan_unreachable_data, loc, NULL,
 NULL_TREE);
   tree t = builtin_decl_explicit (BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE);
   return build_call_expr_loc (loc, t, 1, build_fold_addr_expr_loc (loc, data));
@@ -583,7 +587,7 @@ ubsan_expand_null_ifn (gimple_stmt_itera
   const struct ubsan_mismatch_data m
 = { build_zero_cst (pointer_sized_int_node), ckind };
   tree data = 

Re: [PATCH] Fix GDB PR15559 (inferior calls using thiscall calling convention)

2014-03-26 Thread Tom Tromey
 Julian == Julian Brown jul...@codesourcery.com writes:

Julian include/
Julian * dwarf2.h (enum dwarf_calling_convention): Add
Julian DW_CC_GNU_thiscall_i386.

We've been trying to ensure that all GNU DWARF extensions are
documented.  In the past we had problems where an extension was added
and then, years later, its use was unclear.

The usual approach is some appropriate text somewhere on the GCC wiki
(though I suppose a note in the mail archives would do in a pinch) along
with a URL in a comment in the appropriate file (dwarf2.h or
dwarf2.def).

Could you please do that?

thanks,
Tom


C++ PATCH for c++/60566 (dtor devirtualization and missing thunks)

2014-03-26 Thread Jason Merrill
My earlier patch for 58678 caused this problem: even if we aren't going 
to refer to the dtor thunks from the vtable, we need to emit them in 
case other translation units use them.


I'm adding xfails to two testcases: devirt-21.C and devirt-23.C.  The 
fails aren't a new bug; we are no longer seeing the devirtualization 
because we remove the path to wrap() through a virtual call to 
~MultiTermDocs that it occurred along.  But it seems odd to me that it 
isn't happening on path through a non-virtual call to ~MultiTermDocs, so 
I'm filing a bug about that.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 38f48ae422064906ffc4acb3db6eaa962c702b39
Author: Jason Merrill ja...@redhat.com
Date:   Wed Mar 26 00:02:35 2014 -0400

	PR c++/60566
	PR c++/58678
	* class.c (build_vtbl_initializer): Handle abstract dtors here.
	* search.c (get_pure_virtuals): Not here.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index b46391b..d277e07 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -9017,6 +9017,16 @@ build_vtbl_initializer (tree binfo,
 	  if (!TARGET_VTABLE_USES_DESCRIPTORS)
 		init = fold_convert (vfunc_ptr_type_node,
  build_fold_addr_expr (fn));
+	  /* Don't refer to a virtual destructor from a constructor
+		 vtable or a vtable for an abstract class, since destroying
+		 an object under construction is undefined behavior and we
+		 don't want it to be considered a candidate for speculative
+		 devirtualization.  But do create the thunk for ABI
+		 compliance.  */
+	  if (DECL_DESTRUCTOR_P (fn_original)
+		   (CLASSTYPE_PURE_VIRTUALS (DECL_CONTEXT (fn_original))
+		  || orig_binfo != binfo))
+		init = size_zero_node;
 	}
 	}
 
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index d99e182..c3eed90 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -2115,22 +2115,6 @@ get_pure_virtuals (tree type)
  which it is a primary base will contain vtable entries for the
  pure virtuals in the base class.  */
   dfs_walk_once (TYPE_BINFO (type), NULL, dfs_get_pure_virtuals, type);
-
-  /* Treat a virtual destructor in an abstract class as pure even if it
- isn't declared as pure; there is no way it would be called through the
- vtable except during construction, which causes undefined behavior.  */
-  if (CLASSTYPE_PURE_VIRTUALS (type)
-   TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type))
-{
-  tree dtor = CLASSTYPE_DESTRUCTORS (type);
-  if (dtor  DECL_VIRTUAL_P (dtor)  !DECL_PURE_VIRTUAL_P (dtor))
-	{
-	  tree clone;
-	  DECL_PURE_VIRTUAL_P (dtor) = true;
-	  FOR_EACH_CLONE (clone, dtor)
-	DECL_PURE_VIRTUAL_P (clone) = true;
-	}
-}
 }
 
 /* Debug info for C++ classes can get very large; try to avoid
diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 2f84f17..6fb1449 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1261,7 +1261,7 @@ get_polymorphic_call_info (tree fndecl,
 	}
 
 	  /* If the function is constructor or destructor, then
-	 the type is possibly in consturction, but we know
+	 the type is possibly in construction, but we know
 	 it is not derived type.  */
 	  if (DECL_CXX_CONSTRUCTOR_P (fndecl)
 	  || DECL_CXX_DESTRUCTOR_P (fndecl))
diff --git a/gcc/testsuite/g++.dg/abi/thunk6.C b/gcc/testsuite/g++.dg/abi/thunk6.C
new file mode 100644
index 000..e3d07f2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/thunk6.C
@@ -0,0 +1,18 @@
+// PR c++/60566
+// We need to emit the construction vtable thunk for ~C even if we aren't
+// going to use it.
+
+struct A
+{
+  virtual void f() = 0;
+  virtual ~A() {}
+};
+
+struct B: virtual A { int i; };
+struct C: virtual A { int i; ~C(); };
+
+C::~C() {}
+
+int main() {}
+
+// { dg-final { scan-assembler _ZTv0_n32_N1CD1Ev } }


Re: C++ PATCH for c++/60566 (dtor devirtualization and missing thunks)

2014-03-26 Thread Jason Merrill

On 03/26/2014 12:49 PM, Jason Merrill wrote:

But it seems odd to me that it
isn't happening on path through a non-virtual call to ~MultiTermDocs, so
I'm filing a bug about that.


60674.

Jason




[RFA][PATCH][pr target/60648] Fix non-canonical RTL from x86 backend -- P1 regression

2014-03-26 Thread Jeff Law


The x86 backend can generate non-canonical RTL when it simplifies 
address expressions.


In particular addresses which have the form
(plus (mult) (A) (B) (label_ref))

If the multiplication can be simplified to a constant, the x86 backend 
will end up generating


(plus (constant) (label_ref))

Which is obviously non-canonical and should be written
(const (plus (label_ref) (constant))

This change merely canonicalizes the RTL, leaving it to other code to 
simplify.  At first I wanted to simplify, but it just gets painful if, 
for example B above is (const_int 0), in which case our example 
collapses into


(label_ref)

The subsequent code in the ix86_legitimize_address assumes it's still 
working with a PLUS.  Fixable, but painful.


It's also the case that simplify_rtx might return NULL.  So the code 
also has to DTRT in that case and the caller's don't DTRT if 
ix86_legitimize_address returns NULL.


Anyway, I did verify that the relevant code in the short example gets 
optimized if we just fix the canonicalization (namely the addition of 
(const_int 0) is eliminated).


Bootstrapped and regression tested on x86_64-unknown-linux-gnu. 
Verified it fixes the original and reduced testcase.


OK for the trunk?

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 53d58b3..80f0ba8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-26  Jeff Law  l...@redhat.com
+
+   * i386/i386.c (ix86_legitimize_address): Canonicalize
+   (plus (const) (label_ref)).
+
 2014-03-26  Richard Biener  rguent...@suse.de
 
* tree-pretty-print.c (percent_K_format): Implement special
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 842be68..79f4aff 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -13939,6 +13939,28 @@ ix86_legitimize_address (rtx x, rtx oldx 
ATTRIBUTE_UNUSED,
   REG_P (XEXP (x, 0)))
return x;
 
+  /* We might have started with something like
+
+(plus (mult (const_int 1) (const_int 4)) (label_ref))
+
+Which we change into:
+
+(plus (const_int 4) (label_ref))
+
+Which is obviously not canonical RTL.  Passing the non
+canonical RTL up to our caller is bad.
+
+Do not simplify, just canonicalize.  Simplification opens up
+a can of worms here as that can change the structure of X which
+this code isn't really prepared to handle.  */
+  if (COMMUTATIVE_ARITH_P (x)
+  swap_commutative_operands_p (XEXP (x, 0), XEXP (x, 1)))
+   {
+ rtx temp = XEXP (x, 0);
+ XEXP (x, 0) = XEXP (x, 1);
+ XEXP (x, 1) = temp;
+   }
+
   if (flag_pic  SYMBOLIC_CONST (XEXP (x, 1)))
{
  changed = 1;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cdc8e9a..789e27d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-27  Jeff Law  l...@redhat.com
+
+   PR target/60648
+   * g++.dg/pr60648.C: New test.
+
 2014-03-26  Jakub Jelinek  ja...@redhat.com
 
PR sanitizer/60636


[PATCH] * MAINTAINERS (Write After Approval): Add myself.

2014-03-26 Thread Dominique Dhumieres
Adding myself as Write After Approval.

Dominique

Index: ChangeLog
===
--- ChangeLog   (revision 208845)
+++ ChangeLog   (working copy)
@@ -1,3 +1,7 @@
+2014-03-26  Dominique d'Humieres domi...@lps.ens.fr
+
+   * MAINTAINERS (Write After Approval): Add myself.
+
 2014-03-26  Jakub Jelinek  ja...@redhat.com
 
PR sanitizer/56781
Index: MAINTAINERS
===
--- MAINTAINERS (revision 208845)
+++ MAINTAINERS (working copy)
@@ -406,6 +406,7 @@
 Cong Hou   co...@google.com
 Falk Hueffner  f...@debian.org
 Andrew John Hughes gnu_and...@member.fsf.org
+Dominique d'Humieres   domi...@lps.ens.fr
 Andy Hutchinsonhutchinsona...@aim.com
 Naveen H.S 
naveen.hurugalaw...@caviumnetworks.com
 Meador Ingemead...@codesourcery.com


Re: [PATCH] * MAINTAINERS (Write After Approval): Add myself.

2014-03-26 Thread Mike Stump
On Mar 26, 2014, at 10:35 AM, Dominique Dhumieres domi...@lps.ens.fr wrote:
 Adding myself as Write After Approval.

Welcome.  :-)


Re: [Patch, fortran] PR34928 - Extension: volatile common blocks

2014-03-26 Thread Dominique Dhumieres
Updated patch. OK to commit?

Dominique

Index: gcc/fortran/ChangeLog
===
--- gcc/fortran/ChangeLog   (revision 208846)
+++ gcc/fortran/ChangeLog   (working copy)
@@ -1,3 +1,9 @@
+2014-03-26 Dominique d'Humieres domi...@lps.ens.fr
+
+   PR fortran/34928
+   * fortran/gfortran.texi: Document Volatile COMMON as not
+   supported.
+
 2014-03-22  Jakub Jelinek  ja...@redhat.com
 
PR debug/60603
Index: gcc/fortran/gfortran.texi
===
--- gcc/fortran/gfortran.texi   (revision 208846)
+++ gcc/fortran/gfortran.texi   (working copy)
@@ -2003,6 +2003,7 @@
 @c * CARRIAGECONTROL, DEFAULTFILE, DISPOSE and RECORDTYPE I/O specifiers::
 @c * Omitted arguments in procedure call::
 * Alternate complex function syntax::
+* Volatile COMMON blocks::
 @end menu
 
 
@@ -2197,7 +2198,19 @@
 common, but not the former.
 
 
+@node Volatile COMMON blocks
+@subsection Volatile @code{COMMON} blocks
+@cindex @code{VOLATILE}
+@cindex @code{COMMON}
 
+Some Fortran compilers, including @command{g77}, let the user declare
+@code{COMMON} with the @code{VOLATILE} attribute. This is
+invalid standard Fortran syntax and is not supported by
+@command{gfortran}.  Note that @command{gfortran} accepts VOLATILE
+variables in COMMON blocks since revision 4.3.
+
+
+
 @c -
 @c Mixed-Language Programming
 @c -


Re: [RFA][PATCH][pr target/60648] Fix non-canonical RTL from x86 backend -- P1 regression

2014-03-26 Thread Jakub Jelinek
On Wed, Mar 26, 2014 at 11:02:48AM -0600, Jeff Law wrote:
 Bootstrapped and regression tested on x86_64-unknown-linux-gnu.
 Verified it fixes the original and reduced testcase.

Note, the testcase is missing from your patch.

But I'd question if this is the right place to canonicalize it.
The non-canonical order seems to be created in the generic code, where
do_tablejump does:
11133 /* ??? The only correct use of CASE_VECTOR_MODE is the one inside the
11134GET_MODE_SIZE, because this indicates how large insns are.  The 
other
11135uses should all be Pmode, because they are addresses.  This code
11136could fail if addresses and insns are not the same size.  */
11137 index = gen_rtx_PLUS
11138   (Pmode,
11139gen_rtx_MULT (Pmode, index,
11140  gen_int_mode (GET_MODE_SIZE (CASE_VECTOR_MODE), 
Pmode)),
11141gen_rtx_LABEL_REF (Pmode, table_label));
and there I don't see why it shouldn't just try to simplify it.
Thus
  index = simplify_gen_binary (MULT, Pmode, index,
   gen_int_mode (GET_MODE_SIZE (CASE_VECTOR_MODE),
 Pmode));
  index = simplify_gen_binary (PLUS, Pmode, index,
   gen_rtx_LABEL_REF (Pmode, table_label));
would be my (untested) preference.  In the usual case where index is
previously a REG (or less frequently a MEM), I guess the simplification
shouldn't make a difference.
Of course it would be better if we optimized this either at the tree level
or during expansion into a normal unconditional jump, but from what I see
we don't have enough info that expand_normal will expand it into a constant
earlier and try_tablejump doesn't get passed labelvec so that it would know
where to jump to.

Jakub


Re: [PATCH] Environment variables forwarding

2014-03-26 Thread Jakub Jelinek
On Wed, Mar 26, 2014 at 10:42:12AM -0700, Mike Stump wrote:
 On Mar 25, 2014, at 7:31 AM, Yury Gribov y.gri...@samsung.com wrote:
  On 03/24/2014 01:46 PM, Maxim Ostapenko wrote:
  
  On 03/24/2014 12:28 PM, Maxim Ostapenko wrote:
  
  When porting Lsan on arm, I ran into problem with testing, because
  almost all lsan tests require environment variables forwarding for
  remote targets. Unfortunately, this feature isn't implemented yet
  neither in Dejagnu nor in GCC. These two small patches seem to resolve
  this issue.
 
 So, I’m interested in what Jakub might say…  but, seems reasonable to enhance 
 it so that this is possible.

I'd personaly think it is not worth bothering, such features could be just
tested on native testing.  But if somebody is willing to maintain it for
cross-testing and review that, I don't object.

Jakub


Re: [RFA][PATCH][pr target/60648] Fix non-canonical RTL from x86 backend -- P1 regression

2014-03-26 Thread Jeff Law

On 03/26/14 12:12, Jakub Jelinek wrote:

On Wed, Mar 26, 2014 at 11:02:48AM -0600, Jeff Law wrote:

Bootstrapped and regression tested on x86_64-unknown-linux-gnu.
Verified it fixes the original and reduced testcase.


Note, the testcase is missing from your patch.

But I'd question if this is the right place to canonicalize it.
The non-canonical order seems to be created in the generic code, where
do_tablejump does:
No, at that point it's still canonical because the x86 backend hasn't 
simpified the (mult ...) subexpression.  Its the simplification of that 
subexpression to a constant that creates the non-canonical RTL.  That's 
why I fixed the x86 bits -- those are the bits that simplify the (mult 
...) into a (const_int) and thus creates the non-canonical RTL.


jeff




Re: [RFA][PATCH][pr target/60648] Fix non-canonical RTL from x86 backend -- P1 regression

2014-03-26 Thread Jeff Law

On 03/26/14 12:28, Jakub Jelinek wrote:

On Wed, Mar 26, 2014 at 12:17:43PM -0600, Jeff Law wrote:

On 03/26/14 12:12, Jakub Jelinek wrote:

On Wed, Mar 26, 2014 at 11:02:48AM -0600, Jeff Law wrote:

Bootstrapped and regression tested on x86_64-unknown-linux-gnu.
Verified it fixes the original and reduced testcase.


Note, the testcase is missing from your patch.

But I'd question if this is the right place to canonicalize it.
The non-canonical order seems to be created in the generic code, where
do_tablejump does:

No, at that point it's still canonical because the x86 backend
hasn't simpified the (mult ...) subexpression.  Its the
simplification of that subexpression to a constant that creates the
non-canonical RTL.  That's why I fixed the x86 bits -- those are the
bits that simplify the (mult ...) into a (const_int) and thus
creates the non-canonical RTL.


(mult:SI (const_int 0) (const_int 4)) is IMHO far from being canonical.
It's debatable.  Our canonicalization rules don't explicitly cover the 
case where both arguments to a commutative expression are constants. 
Thus, I would classify that as legitimate, but unsimplified RTL.


Contrast to
(plus (const_int 0) (label_ref)

Which is clearly non-canonical.

Jeff


Re: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-03-26 Thread Mark Wielaard
On irc Tom Tromey pointed out that the patch generates duplicate base
type DIEs for enums with the same underlying base type. This is because
it was calling base_type_die () and adding the DW_AT_type by hand
instead of calling add_type_attribute () to add it to the enumeration
DIE. The only difference with the original patch is the following:

  {
tree underlying = lang_hooks.types.enum_underlying_base_type (type);
-   dw_die_ref underlying_die = base_type_die (underlying);
-   add_AT_die_ref (type_die, DW_AT_type, underlying_die);
+   add_type_attribute (type_die, underlying, 0, 0, context_die);
  }

This generates the same DWARF except for generating multiple instances
of the same base type DIE in case multiple enums in a CU share the same
underlying base type.
From 964dcd8a1aefb6bc733372aa42868ed3ad8a46d7 Mon Sep 17 00:00:00 2001
From: Mark Wielaard m...@redhat.com
Date: Sun, 23 Mar 2014 12:05:16 +0100
Subject: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
	enum_underlying_base_type defined and DWARF version  3.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
	* c-common.c (c_enum_underlying_base_type): New function.
	* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
---
 gcc/ChangeLog   |   10 ++
 gcc/c-family/ChangeLog  |6 ++
 gcc/c-family/c-common.c |8 
 gcc/c-family/c-common.h |1 +
 gcc/c/ChangeLog |5 +
 gcc/c/c-objc-common.h   |2 ++
 gcc/cp/ChangeLog|6 ++
 gcc/cp/cp-lang.c|   18 ++
 gcc/dwarf2out.c |6 ++
 gcc/langhooks-def.h |4 +++-
 gcc/langhooks.h |2 ++
 11 files changed, 67 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b456eff..7bce951 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,15 @@
 2014-03-21  Mark Wielaard  m...@redhat.com
 
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+	enum_underlying_base_type defined and DWARF version  3.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
+2014-03-21  Mark Wielaard  m...@redhat.com
+
 	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_const_value
 	as unsigned or int depending on type and value used.
 
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 536b4fc..94d779d 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-common.c (c_enum_underlying_base_type): New function.
+	* c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-03-22  Jakub Jelinek  ja...@redhat.com
 
 	PR debug/60603
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index abd96fb..55ebbcc 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3902,6 +3902,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 1099b10..e378b44 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -832,6 +832,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index b39b7d6..9ab6eab 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-21  Mark Wielaard  m...@redhat.com
+
+	PR debug/16063
+	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-03-18  

Re: [PATCH] Fix PR c++/60573

2014-03-26 Thread Adam Butcher

On 2014-03-26 15:17, Jason Merrill wrote:


I meant

  struct A
  {
struct X
{
  struct B
  {
void foo(auto);
  };

  void B::foo(auto) {}  // { dg-error cannot define }
};
  };

Here we push both A and X for the declarator.  When we get to the
pushed X, we see that the enclosing scope is A, so we break out of 
the

loop and don't pop either of the pushed scopes.

Thought I was probably being dense!  :)  Yes, that will be broken with 
the current patch.  Continuing the loop based on TYPE_BEING_DEFINED 
might do the trick.  I'll try to have a look later.


Cheers,
Adam



Re: [RFA][PATCH][pr target/60648] Fix non-canonical RTL from x86 backend -- P1 regression

2014-03-26 Thread Jakub Jelinek
On Wed, Mar 26, 2014 at 12:17:43PM -0600, Jeff Law wrote:
 On 03/26/14 12:12, Jakub Jelinek wrote:
 On Wed, Mar 26, 2014 at 11:02:48AM -0600, Jeff Law wrote:
 Bootstrapped and regression tested on x86_64-unknown-linux-gnu.
 Verified it fixes the original and reduced testcase.
 
 Note, the testcase is missing from your patch.
 
 But I'd question if this is the right place to canonicalize it.
 The non-canonical order seems to be created in the generic code, where
 do_tablejump does:
 No, at that point it's still canonical because the x86 backend
 hasn't simpified the (mult ...) subexpression.  Its the
 simplification of that subexpression to a constant that creates the
 non-canonical RTL.  That's why I fixed the x86 bits -- those are the
 bits that simplify the (mult ...) into a (const_int) and thus
 creates the non-canonical RTL.

(mult:SI (const_int 0) (const_int 4)) is IMHO far from being canonical.
And, I'd say it is likely other target legitimization hooks would also try
to simplify it similarly.
simplify_gen_binary is used in several other places during expansion,
so I don't see why it couldn't be desirable here.

Jakub


Re: [PATCH] Handle short reads and EINTR in lto-plugin/simple-object

2014-03-26 Thread Richard Biener
On March 26, 2014 4:51:58 PM CET, Ian Lance Taylor i...@google.com wrote:
On Wed, Mar 26, 2014 at 8:38 AM, Richard Biener rguent...@suse.de
wrote:

 -  got = read (descriptor, buffer, size);
 -  if (got  0)
 +  do
  {
 -  *errmsg = read;
 -  *err = errno;
 -  return 0;
 +  got = read (descriptor, buffer, size);
 +  if (got  0
 +  errno != EINTR)
 +   {
 + *errmsg = read;
 + *err = errno;
 + return 0;
 +   }
 +  else
 +   {
 + buffer += got;
 + size -= got;
 +   }

This appears to do the wrong thing if got  0  errno == EINTR.  In
that case it should not add got to buffer and size.

Uh, indeed. Will fix.

 -  if (offset != lseek (obj-file-fd, offset, SEEK_SET)
 -   || length != read (obj-file-fd, secdata, length))
 +  if (!simple_object_internal_read (obj-file-fd, offset,
 +   secdata, length, errmsg, err))

Hmmm, internal_read is meant to be, well, internal.  It's not declared
anywhere as far as I can see.

I can duplicate the stuff as well.

Are you really seeing EINTR reads here?  That seems very odd to me,
since we are always just reading a local file.  But if you are seeing
it, I guess we should handle it.

Well, it's a shot in the dark... I definitely know short reads and EINTR 
happens more in virtual machines though. So handling it is an improvement.

I'll see if it fixes my problems and report back.

Thanks,
Richard.

Ian




Re: [PATCH] Another undef behavior fix

2014-03-26 Thread Richard Biener
On March 26, 2014 4:57:28 PM CET, Jakub Jelinek ja...@redhat.com wrote:
Hi!

Doing low = -low; on signed HOST_WIDE_INT results in undefined behavior
if the low HWI is LONG_LONG_MIN.  Fixed thusly, ok for trunk?

OK.
Thanks,
Richard.

2014-03-26  Jakub Jelinek  ja...@redhat.com

   PR other/59545
   * real.c (real_to_integer2): Change type of low to UHWI.

--- gcc/real.c.jj  2014-01-03 11:40:37.0 +0100
+++ gcc/real.c 2014-03-26 10:11:39.670655366 +0100
@@ -1377,7 +1377,8 @@ real_to_integer2 (HOST_WIDE_INT *plow, H
 const REAL_VALUE_TYPE *r)
 {
   REAL_VALUE_TYPE t;
-  HOST_WIDE_INT low, high;
+  unsigned HOST_WIDE_INT low;
+  HOST_WIDE_INT high;
   int exp;
 
   switch (r-cl)

   Jakub




Re: [PATCH] Fix bootstrap-ubsan

2014-03-26 Thread Richard Biener
On March 26, 2014 5:06:20 PM CET, Jakub Jelinek ja...@redhat.com wrote:
Hi!

Honza's r208831 change apparently broke bootstrap-ubsan.
The problem is that it now creates __builtin_unreachable with
gimple_location where LOCATION_LOCUS is UNKNOWN_LOCATION (comes from
fnsplit, any ideas what gimple_location to use for the calls if any?)
and with -fsanitize=undefined we fold that into
__ubsan_handle_builtin_unreachable call.
But (already seen several times in the past) instead of emitting
unknown
file and 0/0 line/column as location we don't emit anything at all,
which for unreachable data ICEs and in other cases just crashes in
libubsan.
The reason for trying to handle UNKNOWN_LOCATION specially is that some
data
structures in libubsan don't have sourceLocation (not the ones we emit
right
now though), and guess Marek wanted to be prepared to handle that.

This patch robustifies ubsan_create_data, by turning the location into
a pointer to location_t, NULL means location should not be present,
pointer
to UNKNOWN_LOCATION means we should emit location as unknown:0:0,
pointer to real locations something else.

Bootstrapped/regtested with bootstrap-ubsan and normal, ok for trunk?

Ok.
Thanks,
Richard.

2014-03-26  Jakub Jelinek  ja...@redhat.com

   * ubsan.h (ubsan_create_data): Change second argument's type
   to const location_t *.
   * ubsan.c (ubsan_source_location): If xloc.file is NULL, set it to
   _(unknown).
   (ubsan_create_data): Change second argument to const location_t *PLOC.
   Create Loc field whenever PLOC is non-NULL.
   (ubsan_instrument_unreachable, ubsan_expand_null_ifn,
   ubsan_build_overflow_builtin, instrument_bool_enum_load): Adjust
   callers.
c-family/
   * c-ubsan.c (ubsan_instrument_division, ubsan_instrument_shift,
   ubsan_instrument_vla, ubsan_instrument_return): Adjust
   ubsan_create_data callers.

--- gcc/ubsan.h.jj 2014-01-03 11:40:57.0 +0100
+++ gcc/ubsan.h2014-03-26 11:14:32.492987318 +0100
@@ -38,7 +38,7 @@ struct ubsan_mismatch_data {
 
 extern void ubsan_expand_null_ifn (gimple_stmt_iterator);
 extern tree ubsan_instrument_unreachable (location_t);
-extern tree ubsan_create_data (const char *, location_t,
+extern tree ubsan_create_data (const char *, const location_t *,
  const struct ubsan_mismatch_data *, ...);
 extern tree ubsan_type_descriptor (tree, bool);
 extern tree ubsan_encode_value (tree, bool = false);
--- gcc/ubsan.c.jj 2014-03-26 10:17:41.0 +0100
+++ gcc/ubsan.c2014-03-26 11:32:57.053941843 +0100
@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3.
 #include tree-ssanames.h
 #include asan.h
 #include gimplify-me.h
+#include intl.h
 
 /* Map from a tree to a VAR_DECL tree.  */
 
@@ -238,6 +239,8 @@ ubsan_source_location (location_t loc)
   tree type = ubsan_source_location_type ();
 
   xloc = expand_location (loc);
+  if (xloc.file == NULL)
+xloc.file = unknown;
 
   /* Fill in the values from LOC.  */
   size_t len = strlen (xloc.file);
@@ -404,7 +407,7 @@ ubsan_type_descriptor (tree type, bool w
pointer checking.  */
 
 tree
-ubsan_create_data (const char *name, location_t loc,
+ubsan_create_data (const char *name, const location_t *ploc,
  const struct ubsan_mismatch_data *mismatch, ...)
 {
   va_list args;
@@ -412,17 +415,18 @@ ubsan_create_data (const char *name, loc
   tree fields[5];
   vectree, va_gc *saved_args = NULL;
   size_t i = 0;
+  location_t loc = UNKNOWN_LOCATION;
 
   /* Firstly, create a pointer to type descriptor type.  */
   tree td_type = ubsan_type_descriptor_type ();
   TYPE_READONLY (td_type) = 1;
   td_type = build_pointer_type (td_type);
-  loc = LOCATION_LOCUS (loc);
 
   /* Create the structure type.  */
   ret = make_node (RECORD_TYPE);
-  if (loc != UNKNOWN_LOCATION)
+  if (ploc != NULL)
 {
+  loc = LOCATION_LOCUS (*ploc);
   fields[i] = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
 ubsan_source_location_type ());
   DECL_CONTEXT (fields[i]) = ret;
@@ -481,7 +485,7 @@ ubsan_create_data (const char *name, loc
   tree ctor = build_constructor (ret, v);
 
   /* If desirable, set the __ubsan_source_location element.  */
-  if (loc != UNKNOWN_LOCATION)
+  if (ploc != NULL)
CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, ubsan_source_location (loc));
 
   size_t nelts = vec_safe_length (saved_args);
@@ -513,7 +517,7 @@ tree
 ubsan_instrument_unreachable (location_t loc)
 {
   initialize_sanitizer_builtins ();
-  tree data = ubsan_create_data (__ubsan_unreachable_data, loc,
NULL,
+  tree data = ubsan_create_data (__ubsan_unreachable_data, loc,
NULL,
NULL_TREE);
tree t = builtin_decl_explicit
(BUILT_IN_UBSAN_HANDLE_BUILTIN_UNREACHABLE);
return build_call_expr_loc (loc, t, 1, build_fold_addr_expr_loc (loc,
data));
@@ -583,7 +587,7 @@ ubsan_expand_null_ifn (gimple_stmt_itera
   const struct ubsan_mismatch_data m
 = 

Re: [Patch, fortran] PR34928 - Extension: volatile common blocks

2014-03-26 Thread Steve Kargl
On Wed, Mar 26, 2014 at 06:56:15PM +0100, Dominique Dhumieres wrote:
 Updated patch. OK to commit?
 
 Dominique
 
 Index: gcc/fortran/ChangeLog
 ===
 --- gcc/fortran/ChangeLog (revision 208846)
 +++ gcc/fortran/ChangeLog (working copy)
 @@ -1,3 +1,9 @@
 +2014-03-26 Dominique d'Humieres domi...@lps.ens.fr

2 spaces after the date and after your name.

 +
 + PR fortran/34928
 + * fortran/gfortran.texi: Document Volatile COMMON as not
 + supported.

Indentation is a tab.

OK.

-- 
Steve


Re: [RFA][PATCH][pr target/60648] Fix non-canonical RTL from x86 backend -- P1 regression

2014-03-26 Thread Jeff Law

On 03/26/14 12:28, Jakub Jelinek wrote:

(mult:SI (const_int 0) (const_int 4)) is IMHO far from being canonical.
And, I'd say it is likely other target legitimization hooks would also try
to simplify it similarly.
simplify_gen_binary is used in several other places during expansion,
so I don't see why it couldn't be desirable here.
No particular reason.  I'll try that since we disagree about the 
validity of the RTL and we can both agree that using simplify_gen_binary 
is reasonable.



jeff


Re: [Patch, fortran] PR34928 - Extension: volatile common blocks

2014-03-26 Thread Tobias Burnus

Steve Kargl wrote:

On Wed, Mar 26, 2014 at 06:56:15PM +0100, Dominique Dhumieres wrote:

Updated patch. OK to commit?
OK. 


I have a minor nit: can you add a @code{} around the second VOLATILE?


+Some Fortran compilers, including @command{g77}, let the user declare
+@code{COMMON} with the @code{VOLATILE} attribute. This is
+invalid standard Fortran syntax and is not supported by
+@command{gfortran}.  Note that @command{gfortran} accepts VOLATILE
+variables in COMMON blocks since revision 4.3.


Thanks for the patch - and welcome to the club of GCC contributors with 
commit access :-)


Tobias


Re: [RFA][PATCH][pr target/60648] Fix non-canonical RTL from x86 backend -- P1 regression

2014-03-26 Thread Jakub Jelinek
On Wed, Mar 26, 2014 at 01:32:44PM -0600, Jeff Law wrote:
 On 03/26/14 12:28, Jakub Jelinek wrote:
 (mult:SI (const_int 0) (const_int 4)) is IMHO far from being canonical.
 And, I'd say it is likely other target legitimization hooks would also try
 to simplify it similarly.
 simplify_gen_binary is used in several other places during expansion,
 so I don't see why it couldn't be desirable here.
 No particular reason.  I'll try that since we disagree about the
 validity of the RTL and we can both agree that using
 simplify_gen_binary is reasonable.

Other possibility if you want to change it in the i386.c legitimize_address
hook would be IMHO using force_reg instead of force_operand, it should be
the same thing in most cases, except for these corner cases, and there would
be no need to canonizalize anything afterwards.
But, if the i?86 maintainers feel otherwise on this and think your patch is
ok, I don't feel that strongly about this.

Jakub


Re: [RFA][PATCH][pr target/60648] Fix non-canonical RTL from x86 backend -- P1 regression

2014-03-26 Thread Mike Stump
On Mar 26, 2014, at 11:33 AM, Jeff Law l...@redhat.com wrote:
 On 03/26/14 12:28, Jakub Jelinek wrote:
 On Wed, Mar 26, 2014 at 12:17:43PM -0600, Jeff Law wrote:
 On 03/26/14 12:12, Jakub Jelinek wrote:
 On Wed, Mar 26, 2014 at 11:02:48AM -0600, Jeff Law wrote:
 Bootstrapped and regression tested on x86_64-unknown-linux-gnu.
 Verified it fixes the original and reduced testcase.
 
 Note, the testcase is missing from your patch.
 
 But I'd question if this is the right place to canonicalize it.
 The non-canonical order seems to be created in the generic code, where
 do_tablejump does:
 No, at that point it's still canonical because the x86 backend
 hasn't simpified the (mult ...) subexpression.  Its the
 simplification of that subexpression to a constant that creates the
 non-canonical RTL.  That's why I fixed the x86 bits -- those are the
 bits that simplify the (mult ...) into a (const_int) and thus
 creates the non-canonical RTL.
 
 (mult:SI (const_int 0) (const_int 4)) is IMHO far from being canonical.
 It's debatable.

  (set (reg) (plus (reg) (mult 2 4)))

should be canonicalized into

  (set (reg) (plus (reg) 8))

remember, the entire point of canonicalization is so that the port doesn’t have 
to match:

  (set (reg) (plus (reg) (mult 2 4)))

and

  (set (reg) (plus (reg) 8)

with two patterns to get good code-gen.  I know, we goof the rules from time to 
time, but when we do, we should just admit there is no value to it, and fix it.

Anyway, the documented rule is:

 There are often cases where multiple RTL expressions could represent an
 operation performed by a single machine instruction.  This situation is
 most commonly encountered with logical, branch, and multiply-accumulate
 instructions.  In such cases, the compiler attempts to convert these
 multiple RTL expressions into a single canonical form to reduce the
 number of insn patterns required.
 
 In addition to algebraic simplifications,

Now, when look up algebraic simplification, I get:

  
http://blog.wolframalpha.com/2011/04/25/algebraic-simplification-simplifying-expressions-in-wolframalpha/

and when I look up:

  http://www.wolframalpha.com/input/?i=2+*+4

it says the answer is 8.  If that isn’t the right answer, please fix google 
and/or wolfram alpha as one of them is seriously misleading.  If the documented 
rule is wrong, please fix the document.

?

 Our canonicalization rules don't explicitly cover the case where both 
 arguments to a commutative expression are constants.

Then why do we document it under:

@section Canonicalization of Instructions   
  
@cindex canonicalization of instructions
@cindex insn canonicalization

?

Re: [patch] fix libstdc++/59548

2014-03-26 Thread Jonathan Wakely

On 24/01/14 20:08 +, Jonathan Wakely wrote:

The debug-mode container base classes need copy constructors that
zero-init their members rather than copy them from the source.

_Safe_unordered_container_base also needs its move constructor to be
non-throwing to fix some FAILs for the PR 55043 tests.

Tested x86_64-linux, normal and debug modes, committed to trunk.
I also want to fix this on the branches once I've finished fixing 4.9
regressions.


Here's a smaller version of the trunk patch which I'm committing to
the 4.8 branch.

Tested x86_64-linux.

(Aside: I wish make check-debug didn't take so long, and why does
that target put conformance.exp in the RUNTESTFLAGS explicitly, so you
can't do RUNTESTFLAGS=conformance.exp=23_containers/unordered_* to
re-run just a subset of the tests?)

commit 39fadff8d22cf549968a2df4117111de4173db2f
Author: Jonathan Wakely jwak...@redhat.com
Date:   Wed Mar 26 19:33:35 2014 +

PR libstdc++/59548
* include/debug/safe_unordered_base.h (_Safe_unordered_container_base):
Define copy and move constructors that handle iterators correctly.
* testsuite/23_containers/unordered_map/59548.cc: New.

diff --git a/libstdc++-v3/include/debug/safe_unordered_base.h 
b/libstdc++-v3/include/debug/safe_unordered_base.h
index 23026cb..35ce08b 100644
--- a/libstdc++-v3/include/debug/safe_unordered_base.h
+++ b/libstdc++-v3/include/debug/safe_unordered_base.h
@@ -133,9 +133,19 @@ namespace __gnu_debug
   protected:
 // Initialize with a version number of 1 and no iterators
 _Safe_unordered_container_base()
-: _M_local_iterators(0), _M_const_local_iterators(0)
+: _M_local_iterators(nullptr), _M_const_local_iterators(nullptr)
 { }
 
+// Initialize with a version number of 1 and no iterators
+_Safe_unordered_container_base(const _Safe_unordered_container_base)
+noexcept
+: _Safe_unordered_container_base() { }
+
+_Safe_unordered_container_base(_Safe_unordered_container_base __x)
+noexcept
+: _Safe_unordered_container_base()
+{ this-_M_swap(__x); }
+
 /** Notify all iterators that reference this container that the
container is being destroyed. */
 ~_Safe_unordered_container_base()
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc 
b/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc
new file mode 100644
index 000..1e81bb7
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_map/59548.cc
@@ -0,0 +1,34 @@
+// { dg-options -std=gnu++11 }
+// { dg-do compile }
+// { dg-require-debug-mode  }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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, or (at your option)
+// any later version.
+
+// This library 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 library; see the file COPYING3.  If not see
+// http://www.gnu.org/licenses/.
+
+// libstdc++/59548
+
+#include unordered_map
+
+int main()
+{
+  std::unordered_mapint,int foo{ {0,1} };
+  auto i = foo.begin();
+  {
+auto bar = foo;
+  }
+  return i-first;
+}


[PATCH] Add support for vbpermq builtin; Improve vec_extract

2014-03-26 Thread Michael Meissner
This patch adds support for adding a builtin to generate the vbpermq
instruction on ISA 2.07.  This instruction takes a vector in the Altivec
register set, and returns a 64-bit value in the upper part of the register, and
0 in the lower part of the register.

The output is explicitly a vector, since the documentation for the instruction
says that to do a permutation of all 8 bits, you need to do 2 vbpermq's, one
with the high bit in each byte within the vector set, and the other with the
high bit cleared.

vbpermq v6,v1,v2# select from high-order half of Q
vxorv0,v1,v4# adjust index values
vbpermq v5,v0,v3# select from low-order half of Q
vor v6,v6,v5# merge the two selections

In writing the tests, I noticed that the vec_extract code did not have
optimizations for getting 64-bit data out, of the vector element happens to be
0 on big endian systems, and 1 on little endian systems.  So I added
optimizations for register/register move, including using the mfvsrd
instruction to transfer the final result to a GPR.  While I was there, I added
vec_extract optimizations to do a 64-bit store and I combined the big endian
and little endian vec_extract load optimizaton.

I built a big endian Spec 2006 suite with this compiler, and compared it to the
trunk compiler without the changes.  Only 3 benchmarks (gamess, dealII, and
povray) generated vec_extracts that became moves instead of permutes.  I ran
the tests on a power7 system, and the differences in run time were in the noise
level.  None of the spec benchmarks generated vec_extract that was a load or a
store.

I did bootstraps on a big endian power7 system, a big endian power8 system, and
a little endian power8 system with no regressions in the test suite.  Are these
patches ok to install on both the trunk?  I would like to apply these patches
there as well, when all of the ISA 2.07 changes are present in the 4.8 branch,
Can I apply these patches?

[gcc]
2014-03-26  Michael Meissner  meiss...@linux.vnet.ibm.com

* config/rs6000/constraints.md (wD constraint): New constraint to
match the constant integer to get the top DImode/DFmode out of a
vector in a VSX register.

* config/rs6000/predicates.md (vsx_scalar_64bit): New predicate to
match the constant integer to get the top DImode/DFmode out of a
vector in a VSX register.

* config/rs6000/rs6000-builtins.def (VBPERMQ): Add vbpermq builtin
for ISA 2.07.

* config/rs6000/rs6000-c.c (altivec_overloaded_builtins): Add
vbpermq builtins.

* config/rs6000/rs6000.c (rs6000_debug_reg_global): If
-mdebug=reg, print value of VECTOR_ELEMENT_SCALAR_64BIT.

* config/rs6000/vsx.md (vsx_extract_mode, V2DI/V2DF modes):
Optimize vec_extract of 64-bit values, where the value being
extracted is in the top word, where we can use scalar
instructions.  Add direct move and store support.  Combine the big
endian/little endian vector select load support into a single
insn.
(vsx_extract_mode_internal1): Likewise.
(vsx_extract_mode_internal2): Likewise.
(vsx_extract_mode_load): Likewise.
(vsx_extract_mode_store): Likewise.
(vsx_extract_mode_zero): Delete, big and little endian insns are
combined into vsx_extract_mode_load.
(vsx_extract_mode_one_le): Likewise.

* config/rs6000/rs6000.h (VECTOR_ELEMENT_SCALAR_64BIT): Macro to
define the top 64-bit vector element.

* doc/md.texi (PowerPC and IBM RS6000 constraints): Document wD
constraint.

[gcc/testsuite]
2014-03-26  Michael Meissner  meiss...@linux.vnet.ibm.com

* gcc.target/powerpc/p8vector-vbpermq.c: New test to test the
vbpermq builtin.

* gcc.target/powerpc/vsx-extract-1.c: New test to test VSX
vec_select optimizations.
* gcc.target/powerpc/vsx-extract-2.c: Likewise.
* gcc.target/powerpc/vsx-extract-3.c: Likewise.



-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797
Index: gcc/config/rs6000/constraints.md
===
--- gcc/config/rs6000/constraints.md(revision 208726)
+++ gcc/config/rs6000/constraints.md(working copy)
@@ -106,6 +106,11 @@ (define_register_constraint wy rs6000
 (define_register_constraint wz rs6000_constraints[RS6000_CONSTRAINT_wz]
   Floating point register if the LFIWZX instruction is enabled or NO_REGS.)
 
+(define_constraint wD
+  Int constant that is the element number of the 64-bit scalar in a vector.
+  (and (match_code const_int)
+   (match_test TARGET_VSX  (ival == VECTOR_ELEMENT_SCALAR_64BIT
+
 ;; Lq/stq validates the address for load/store quad
 (define_memory_constraint wQ
   Memory operand suitable for the load/store quad instructions
Index: 

Re: [RFA][PATCH][pr target/60648] Fix non-canonical RTL from x86 backend -- P1 regression

2014-03-26 Thread Richard Henderson
On 03/26/2014 12:40 PM, Jakub Jelinek wrote:
 On Wed, Mar 26, 2014 at 01:32:44PM -0600, Jeff Law wrote:
 On 03/26/14 12:28, Jakub Jelinek wrote:
 (mult:SI (const_int 0) (const_int 4)) is IMHO far from being canonical.
 And, I'd say it is likely other target legitimization hooks would also try
 to simplify it similarly.
 simplify_gen_binary is used in several other places during expansion,
 so I don't see why it couldn't be desirable here.
 No particular reason.  I'll try that since we disagree about the
 validity of the RTL and we can both agree that using
 simplify_gen_binary is reasonable.
 
 Other possibility if you want to change it in the i386.c legitimize_address
 hook would be IMHO using force_reg instead of force_operand, it should be
 the same thing in most cases, except for these corner cases, and there would
 be no need to canonizalize anything afterwards.
 But, if the i?86 maintainers feel otherwise on this and think your patch is
 ok, I don't feel that strongly about this.

I like this as a solution.  Let the combiner clean things up if it's gotten so 
far.


r~



Re: [Patch, fortran] PR34928 - Extension: volatile common blocks

2014-03-26 Thread Jakub Jelinek
On Wed, Mar 26, 2014 at 12:26:02PM -0700, Steve Kargl wrote:
 On Wed, Mar 26, 2014 at 06:56:15PM +0100, Dominique Dhumieres wrote:
  Updated patch. OK to commit?
  
  Dominique
  
  Index: gcc/fortran/ChangeLog
  ===
  --- gcc/fortran/ChangeLog   (revision 208846)
  +++ gcc/fortran/ChangeLog   (working copy)
  @@ -1,3 +1,9 @@
  +2014-03-26 Dominique d'Humieres domi...@lps.ens.fr
 
 2 spaces after the date and after your name.
 
  +
  +   PR fortran/34928
  +   * fortran/gfortran.texi: Document Volatile COMMON as not
  +   supported.
 
 Indentation is a tab.

And fortran/ prefix doesn't belong to the ChangeLog entry.
The paths are always relative to the ChangeLog file.

Jakub


Re: [Patch, fortran] PR34928 - Extension: volatile common blocks

2014-03-26 Thread Dominique Dhumieres
 I have a minor nit: can you add a @code{} around the second VOLATILE?

What about the COMMON in variables in COMMON blocks since revision 4.3.?

Dominique


Re: [PATCH] Fix PR c++/60573

2014-03-26 Thread Adam Butcher

On 2014-03-25 15:48, Jason Merrill wrote:


I think we need some way to designate a scope that actually
corresponds to a class-specifier.


Agreed.  I'll look into it.

Adam


Re: [Patch: RL78] Add support for 64-bit doubles

2014-03-26 Thread DJ Delorie

Sorry about the delay on this.  As GCC is in pre-release and it would
be bad for 4.9 to pass options that a released binutils doesn't
support, I hesitate to approve this at this time.  It looks OK, it's
just the timing is bad.  Please remind us after GCC is back in stage1.

I would also like to see an explicit initialization for the variable
to guarantee that the default is 32-bit-doubles, or some other
notation that guarantees the default.

Also, please note in the reminder that you've tested both options and
don't see any differences in the testsuite results between them that
reflect bugs in DFmode double support.  Just because you've enabled
the type doesn't mean it will work properly.


Re: [PATCH] Fix --with-build-config=bootstrap-ubsan bootstrap of lto-plugin (PR sanitizer/56781)

2014-03-26 Thread H.J. Lu
On Wed, Mar 26, 2014 at 9:00 AM, Jakub Jelinek ja...@redhat.com wrote:
 On Tue, Mar 25, 2014 at 05:24:40PM -0700, H.J. Lu wrote:
 Doesn't work:

 libtool: link:
 /export/build/gnu/gcc-asan/build-x86_64-linux/./prev-gcc/xgcc
 -B/export/build/gnu/gcc-asan/build-x86_64-linux/./prev-gcc/
 -B/usr/local/x86_64-unknown-linux-gnu/bin/
 -B/usr/local/x86_64-unknown-linux-gnu/bin/
 -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem
 /usr/local/x86_64-unknown-linux-gnu/include -isystem
 /usr/local/x86_64-unknown-linux-gnu/sys-include-shared
 .libs/lto-plugin.o-static-libgcc -static-libstdc++ -static-libgcc
 -fsanitize=address -static-libasan
 -B/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libsanitizer/
 -B/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libsanitizer/asan/
 -B/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libsanitizer/asan/.libs
 ../libiberty/noasan/libiberty.a   -Wl,-soname -Wl,liblto_plugin.so.0
 -o .libs/liblto_plugin.so.0.0.0

 Ok, here is updated patch on top of
 http://gcc.gnu.org/ml/gcc-patches/2014-03/msg01370.html
 that passed bootstrap-ubsan and went well into stage3 of bootstrap-asan
 (--with-build-config=bootstrap-asan --disable-werror due to PR60649).
 Additionally passed normal bootstrap/regtest on x86_64-linux and i686-linux.

 Ok for trunk?

 2014-03-26  Jakub Jelinek  ja...@redhat.com

 PR sanitizer/56781
 lto-plugin/
 * Makefile.am (CFLAGS, LDFLAGS): Filter out -fsanitize=address.
 (liblto_plugin_la_LIBADD, liblto_plugin_la_LDFLAGS,
 liblto_plugin_la_DEPENDENCIES): Prefer ../libiberty/noasan/libiberty.a
 over ../libiberty/pic/libiberty.a if the former exists.
 * Makefile.in: Regenerated.
 libiberty/
 * maint-tool: Also emit rule for noasan/ subdirectory.
 * configure.ac (NOASANFLAG): Set and substitute.
 * Makefile.in: Regenerated.
 (NOASANFLAG): Set.
 (all, $(TARGETLIB), mostlyclean): Handle noasan subdir like pic
 subdir.
 (stamp-noasandir): New goal.
 * configure: Regenerated.


All plug tests failed with

spawn -ignore SIGHUP
/export/build/gnu/gcc-asan/build-x86_64-linux/./prev-gcc/xg++
-B/export/build/gnu/gcc-asan/build-x86_64-linux/./prev-gcc/
-B/usr/local/x86_64-unknown-linux-gnu/bin/ -nostdinc++
-B/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-B/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs
-I/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include/x86_64-unknown-linux-gnu
-I/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include
-I/export/gnu/import/git/gcc/libstdc++-v3/libsupc++
-L/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libstdc++-v3/src/.libs
-L/export/build/gnu/gcc-asan/build-x86_64-linux/prev-x86_64-unknown-linux-gnu/libstdc++-v3/libsupc++/.libs
-g -O2 -fsanitize=address
/export/gnu/import/git/gcc/gcc/testsuite/gcc.dg/plugin/ggcplug.c -I.
-I/export/gnu/import/git/gcc/gcc/testsuite
-I/export/gnu/import/git/gcc/gcc/testsuite/../../gcc
-I/export/build/gnu/gcc-asan/build-x86_64-linux/gcc/testsuite/gcc/../../../gcc
-I/export/gnu/import/git/gcc/gcc/testsuite/../../include
-I/export/gnu/import/git/gcc/gcc/testsuite/../../libcpp/include
-I/export/build/gnu/gcc-asan/build-x86_64-linux/gcc/testsuite/gcc/../../../intl
-O -DIN_GCC -fPIC -shared -fno-rtti -o ggcplug.so^M
/usr/local/x86_64-unknown-linux-gnu/bin/ld: cannot find -lasan^M


-- 
H.J.


Re: [PATCH] Fix --with-build-config=bootstrap-ubsan bootstrap of lto-plugin (PR sanitizer/56781)

2014-03-26 Thread Jakub Jelinek
On Wed, Mar 26, 2014 at 01:50:38PM -0700, H.J. Lu wrote:
 All plug tests failed with

There are some testsuite issues with both both bootstrap-ubsan and
bootstrap-asan, e.g. host libiberty tests fail, and host libbacktrace
btest fails too (in both cases because the host libiberty or libbacktrace
is compiled with -fsanitize={undefined,address}, but when the tests are
linked during make check, this isn't passed any longer, nor the other needed
LDFLAGS), plus this.  That is just a minor detail IMHO, can
be dealt incrementally later on, what is more important is that
--with-build-config=bootstrap-ubsan and
--with-build-config=bootstrap-asan --disable-werror
now both pass bootstrap with these 2 pending patches, and most of the
testing succeeds too.

Jakub


[PATCH] Fix libitm futex handling on non-x86/ppc/sh/alpha targets

2014-03-26 Thread Jakub Jelinek
Hi!

The sys_futex0 caller expects return values as returned by raw syscalls,
i.e. value = 0 success, negative value are errors -errorval.
But, the syscall function returns value = 0 on success, and -1 on error,
with errno set to errorval.  This means if e.g. futex syscall fails with
EAGAIN, and EPERM is 1, we get GTM program terminated because we think
futex returned -EPERM.

Fixed thusly, bootstrapped/regtested on s390x-linux, ok for trunk/4.8?

Testcase that previously succeeded at most 9 times in a row before crashing
now succeeded over 38000 iterations in a row (before I've stopped it).

2014-03-26  Jakub Jelinek  ja...@redhat.com

* config/linux/futex_bits.h: Include errno.h.
(sys_futex0): If syscall returns -1, return -errno rather than
-1.

--- libitm/config/linux/futex_bits.h2014-01-03 11:41:27.495153749 +0100
+++ libitm/config/linux/futex_bits.h2014-03-26 18:03:15.307302524 +0100
@@ -31,9 +31,13 @@
 
 #include unistd.h
 #include sys/syscall.h
+#include errno.h
 
 static inline long
 sys_futex0 (std::atomicint *addr, long op, long val)
 {
-  return syscall (SYS_futex, (int*) addr, op, val, 0);
+  long res = syscall (SYS_futex, (int*) addr, op, val, 0);
+  if (__builtin_expect (res == -1, 0))
+return -errno;
+  return res;
 }

Jakub


Rename libitm.texi Index node for case-insensitive filesystems

2014-03-26 Thread Joseph S. Myers
Various Texinfo manuals have had their indexes given node names other than 
Index to avoid conflicts with index.html when HTML output is generated 
and then used on a case-insensitive filesystem.  I've applied this patch 
to make such a renaming in the libitm manual, using the name Library Index 
as in the libgomp manual.  Bootstrapped with no regressions on 
x86_64-unknown-linux-gnu.

2014-03-26  Joseph Myers  jos...@codesourcery.com

* libitm.texi (Index): Rename to Library Index.

Index: libitm/libitm.texi
===
--- libitm/libitm.texi  (revision 208845)
+++ libitm/libitm.texi  (working copy)
@@ -69,7 +69,7 @@
 * Internals::  Notes on libitm's internal synchronization.
 * GNU Free Documentation License::
How you can copy and share this manual.
-* Index::  Index of this documentation.
+* Library Index::  Index of this documentation.
 @end menu
 
 
@@ -766,8 +766,8 @@
 @c Index
 @c -
 
-@node Index
-@unnumbered Index
+@node Library Index
+@unnumbered Library Index
 
 @printindex cp
 

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


Re: [PATCH] Fix undefined behavior in IRA

2014-03-26 Thread Marc Glisse

On Tue, 25 Mar 2014, Marek Polacek wrote:


This is a temporary fix for UB in IRA, where ubsan complains because
there's signed iteger overflow in the multiplication.  To shut this
error up, we can perform the multiplication in unsigned and only then
cast the result of the multiplication to int.


Naive question: why do you want to shut the error up? If modular 
arithmetic makes sense for costs (sounds doubtful), they should use an 
unsigned type to begin with. Otherwise, this is making it harder to notice 
a bug (doesn't sound like an improvement).


If you want to cast, doesn't something like long long (HOST_WIDEST_INT?) 
make more sense than unsigned?


--
Marc Glisse


Re: Fix PR ipa/60315 (inliner explosion)

2014-03-26 Thread Eric Botcazou
 Bootstrapped/regtested x86_64-linux, comitted.

Not with Ada apparently, resulting in 

=== acats tests ===
FAIL:   c34007d
FAIL:   c34007g
FAIL:   c34007s
FAIL:   c37213j
FAIL:   c37213k
FAIL:   c37213l
FAIL:   ce2201g
FAIL:   cxa5a03
FAIL:   cxa5a04
FAIL:   cxa5a06
FAIL:   cxg2013
FAIL:   cxg2015

=== acats Summary ===
# of expected passes2308
# of unexpected failures12

Reduced testcase attached, compile p.adb at -O2.

-- 
Eric BotcazouWITH Q; use Q;

PROCEDURE P IS

 SUBTYPE COMPONENT IS INTEGER;

 TYPE DESIGNATED IS ARRAY (NATURAL RANGE ) OF COMPONENT;

 SUBTYPE SUBDESIGNATED IS DESIGNATED (IDENT_INT (5) .. IDENT_INT (7));

 TYPE PARENT IS ACCESS DESIGNATED;

 TYPE T IS NEW PARENT (IDENT_INT (5) .. IDENT_INT (7));

 X : T := NEW SUBDESIGNATED'(OTHERS = 2);

 FUNCTION IDENT (X : T) RETURN T IS
 BEGIN
  IF X = NULL OR ELSE
 EQUAL (X'LENGTH, X'LENGTH) THEN
   RETURN X;
  END IF;
  RETURN NEW SUBDESIGNATED;
 END IDENT;

BEGIN
 IF IDENT (NULL) /= NULL THEN
  raise Program_Error;
 END IF;
END;package Q is

   FUNCTION IDENT_INT (X : INTEGER ) RETURN INTEGER; 
   FUNCTION EQUAL (X, Y : INTEGER ) RETURN BOOLEAN;

end Q;

Re: [PATCH] Fix undefined behavior in IRA

2014-03-26 Thread Jakub Jelinek
On Wed, Mar 26, 2014 at 10:27:37PM +0100, Marc Glisse wrote:
 On Tue, 25 Mar 2014, Marek Polacek wrote:
 
 This is a temporary fix for UB in IRA, where ubsan complains because
 there's signed iteger overflow in the multiplication.  To shut this
 error up, we can perform the multiplication in unsigned and only then
 cast the result of the multiplication to int.
 
 Naive question: why do you want to shut the error up? If modular
 arithmetic makes sense for costs (sounds doubtful), they should use
 an unsigned type to begin with. Otherwise, this is making it harder
 to notice a bug (doesn't sound like an improvement).

Because it makes bootstrap-ubsan pretty much useless, e.g. in the testsuite
almost all tests fail because of this.

AFAIK Vlad is aware of this, and if it isn't tracked in some bug, it should
be that it should be investigated.
In PR59545 I've mentioned also other ira issues with ub, if I remember well
it was two other places, but the ira-color.c case has been orders of
magnitude more common.

Jakub


Re: Two build != host fixes

2014-03-26 Thread Maciej W. Rozycki
Alan,

On Tue, 17 Dec 2013, Alan Modra wrote:

 On Tue, Dec 17, 2013 at 01:14:23PM +0100, Bernd Edlinger wrote:
  the reason for this is overwriting GMPINC for the auto-build generation, 
  because
  many test scripts include gmp.h which fails now completely (it is not 
  installed,
  I have it in-tree).
 
 Yes, I understand the reason why your setup is failing.  Please try
 this patch.
 
 Index: gcc/configure.ac
 ===
 --- gcc/configure.ac  (revision 206009)
 +++ gcc/configure.ac  (working copy)
 @@ -1529,8 +1529,13 @@
   /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
   *) realsrcdir=../${srcdir};;
   esac
 + # Clearing GMPINC is necessary to prevent host headers being
 + # used by the build compiler.  Defining GENERATOR_FILE stops
 + # system.h from including gmp.h.
   CC=${CC_FOR_BUILD} CFLAGS=${CFLAGS_FOR_BUILD} \
 - LDFLAGS=${LDFLAGS_FOR_BUILD} GMPINC= \
 + CXX=${CXX_FOR_BUILD} CXXFLAGS=${CXXFLAGS_FOR_BUILD} \
 + LD=${LD_FOR_BUILD} LDFLAGS=${LDFLAGS_FOR_BUILD} \
 + GMPINC= CPPFLAGS=${CPPFLAGS} -DGENERATOR_FILE \
   ${realsrcdir}/configure \
   --enable-languages=${enable_languages-all} \
   --target=$target_alias --host=$build_alias --build=$build_alias

 Can you please backport this change to 4.8 too, to fix the build 
regression discussed here introduced by the previous change that did get 
backported?

 Thanks,

  Maciej


Re: [PATCH] Fix libitm futex handling on non-x86/ppc/sh/alpha targets

2014-03-26 Thread Torvald Riegel
On Wed, 2014-03-26 at 22:19 +0100, Jakub Jelinek wrote:
 Hi!
 
 The sys_futex0 caller expects return values as returned by raw syscalls,
 i.e. value = 0 success, negative value are errors -errorval.
 But, the syscall function returns value = 0 on success, and -1 on error,
 with errno set to errorval.  This means if e.g. futex syscall fails with
 EAGAIN, and EPERM is 1, we get GTM program terminated because we think
 futex returned -EPERM.
 
 Fixed thusly, bootstrapped/regtested on s390x-linux, ok for trunk/4.8?

Looks good to me.  Thanks.




Re: [RFA][PATCH][pr target/60648] Fix non-canonical RTL from x86 backend -- P1 regression

2014-03-26 Thread Richard Sandiford
Richard Henderson r...@redhat.com writes:
 On 03/26/2014 12:40 PM, Jakub Jelinek wrote:
 On Wed, Mar 26, 2014 at 01:32:44PM -0600, Jeff Law wrote:
 On 03/26/14 12:28, Jakub Jelinek wrote:
 (mult:SI (const_int 0) (const_int 4)) is IMHO far from being canonical.
 And, I'd say it is likely other target legitimization hooks would also try
 to simplify it similarly.
 simplify_gen_binary is used in several other places during expansion,
 so I don't see why it couldn't be desirable here.
 No particular reason.  I'll try that since we disagree about the
 validity of the RTL and we can both agree that using
 simplify_gen_binary is reasonable.
 
 Other possibility if you want to change it in the i386.c legitimize_address
 hook would be IMHO using force_reg instead of force_operand, it should be
 the same thing in most cases, except for these corner cases, and there would
 be no need to canonizalize anything afterwards.
 But, if the i?86 maintainers feel otherwise on this and think your patch is
 ok, I don't feel that strongly about this.

 I like this as a solution.  Let the combiner clean things up if it's
 gotten so far.

How about doing both?  Jakub's simplify_gen_binary change looked like a good
idea regardless of whatever else happens.  Seems a shame not to go with it.

Thanks,
Richard


Re: [Build, Driver] Add -lcilkrts for -fcilkplus

2014-03-26 Thread H.J. Lu
On Mon, Mar 10, 2014 at 11:42 PM, Tobias Burnus bur...@net-b.de wrote:
 When using Cilk Plus (-fcilkplus), it makes sense to automatically link the
 run-time library (-lcilkrts).

 This patch mimics libgomp by adding a .spec file; I am not 100% sure whether
 the .spec file is needed, but the pthread tests in libgomp imply that it
 makes sense. (libgomp also checks for -lrt for the high-performance timers,
 a check which is not required for libcilkrts.)

 Bootstrapped on x86-64-gnu-linux.
 OK for the trunk?


All cilk-plus link tests failed with

xgcc: error: libcilkrts.spec: No such file or directory

Don't you need to add -B/libcilkrts for this?


-- 
H.J.


Re: Fix PR ipa/60315 (inliner explosion)

2014-03-26 Thread Jan Hubicka
  Bootstrapped/regtested x86_64-linux, comitted.
 
 Not with Ada apparently, resulting in 
 
 === acats tests ===
 FAIL:   c34007d
 FAIL:   c34007g
 FAIL:   c34007s
 FAIL:   c37213j
 FAIL:   c37213k
 FAIL:   c37213l
 FAIL:   ce2201g
 FAIL:   cxa5a03
 FAIL:   cxa5a04
 FAIL:   cxa5a06
 FAIL:   cxg2013
 FAIL:   cxg2015
 
 === acats Summary ===
 # of expected passes2308
 # of unexpected failures12
 
 Reduced testcase attached, compile p.adb at -O2.

I will check, thanks for the reduced testcase. It seems like another case where
we get predicate wrong that ought to be fixed, of course.

Honza


[Patch] Silence test failures on darwin9

2014-03-26 Thread Dominique Dhumieres
The first patch silences hundreds of harmless warnings from Xcode 3.2.x 
due to r205679 and of the kind

warning: DWARFDebugInfoEntry::AppendDependants() -- check on this item 
TAG_namelist_item: attr =  AT_namelist_item  form = FORM_ref4

The following three patches fix pr54083 for darwin 8 and 9.

The last patch fixes pr54407 and comes from a year ago at

http://gcc.gnu.org/ml/libstdc++/2012-10/msg00111.html

OK for trunk?

Dominique

2014-03-26  Dominique d'Humieres  domi...@lps.ens.fr

PR target/43751
* lib/prune.exp: Modify the regular express to prune
the new warnings introduced by r205679 on darwin9.

2014-03-26  Dominique d'Humieres  domi...@lps.ens.fr
Iain Sandoe i...@codesourcery.com

PR target/54083
* gcc.dg/attr-weakref-1.c: Allow the test on darwin with
the additional options -Wl,-undefined,dynamic_lookup and
-Wl,-flat_namespace
* gcc.dg/torture/pr53922.c: Additional option
-Wl,-flat_namespace for darwin[89].
* gcc.dg/torture/pr60092.c: Additional options
-Wl,-undefined,dynamic_lookup and -Wl,-flat_namespace for 
darwin[89].

libstdc++-v3/testsuite/

2012-10-16  Dominique d'Humieres  domi...@lps.ens.fr
Jack Howarth howa...@bromo.med.uc.edu

PR target/54407
* 30_threads/condition_variable/54185.cc: Skip for darwin  11.


--- ../_gcc_clean/gcc/testsuite/lib/prune.exp   2014-01-08 12:57:20.0 
+0100
+++ gcc/testsuite/lib/prune.exp 2014-01-18 22:53:07.0 +0100
@@ -59,7 +59,7 @@ proc prune_gcc_output { text } {
 
 # Ignore harmless warnings from Xcode 3.2.x.
 regsub -all (^|\n)\[^\n\]*ld: warning: can't add line info to anonymous 
symbol\[^\n\]* $text  text
-regsub -all (^|\n)\[^\n\]*warning: 
DWARFDebugInfoEntry::AppendDependants\[^\n\]*AT_\[^\n\]*_bound\[^\n\]*FORM_ref4\[^\n\]*
 $text  text
+regsub -all (^|\n)\[^\n\]*warning: 
DWARFDebugInfoEntry::AppendDependants\[^\n\]*AT_\[^\n\]*FORM_ref4\[^\n\]* 
$text  text
 regsub -all (^|\n)\[^\n\]*warning:\[^\n\]*TAG_variable:  
AT_location\[^\n\]*didn't have valid function low pc\[^\n\]* $text  text
 
 # Ignore harmless warnings from Xcode 4.0.
--- ../_clean/gcc/testsuite/gcc.dg/attr-weakref-1.c 2013-09-04 
17:48:01.0 +0200
+++ gcc/testsuite/gcc.dg/attr-weakref-1.c   2013-10-07 20:41:33.0 
+0200
@@ -4,12 +4,14 @@
 // This test requires support for undefined weak symbols.  This support
 // is not available on hppa*-*-hpux*.  The test is skipped rather than
 // xfailed to suppress the warning that would otherwise arise.
-// { dg-skip-if  { *-*-darwin* hppa*-*-hpux* *-*-aix* } * {  } }
+// { dg-skip-if  { hppa*-*-hpux* *-*-aix* } * {  } }
 // For kernel modules and static RTPs, the loader treats undefined weak
 // symbols in the same way as undefined strong symbols.  The test
 // therefore fails to load, so skip it.
 // { dg-skip-if  { *-*-vxworks*  nonpic } * { -non-static } }
 // { dg-options -O2 }
+// { dg-additional-options -Wl,-undefined,dynamic_lookup { target 
*-*-darwin* } }
+// { dg-additional-options -Wl,-flat_namespace { target *-*-darwin[89]* } }
 // { dg-additional-sources attr-weakref-1a.c }
 
 // Copyright 2005 Free Software Foundation, Inc.
--- ../_clean/gcc/testsuite/gcc.dg/torture/pr53922.c2013-09-04 
17:48:01.0 +0200
+++ gcc/testsuite/gcc.dg/torture/pr53922.c  2013-10-07 20:43:45.0 
+0200
@@ -4,6 +4,7 @@
 /* { dg-skip-if No undefined weak { *-*-aix* } { * } {  } } */
 /* { dg-skip-if No undefined weak { hppa*-*-hpux*  { ! lp64 } } { * } { 
 } } */
 /* { dg-options -Wl,-undefined,dynamic_lookup { target *-*-darwin* } } */
+/* { dg-additional-options -Wl,-flat_namespace { target *-*-darwin[89]* } } 
*/
 
 int x(int a)
 {
--- ../_clean/gcc/testsuite/gcc.dg/torture/pr60092.c2014-03-24 
08:05:33.0 +0100
+++ gcc/testsuite/gcc.dg/torture/pr60092.c  2014-03-26 22:57:17.0 
+0100
@@ -1,6 +1,8 @@
 /* { dg-do run } */
 /* { dg-require-weak  } */
 /* { dg-skip-if No undefined weak { hppa*-*-hpux*  { ! lp64 } } { * } { 
 } } */
+/* { dg-additional-options -Wl,-undefined,dynamic_lookup { target 
*-*-darwin* } } */
+/* { dg-additional-options -Wl,-flat_namespace { target *-*-darwin[89]* } } 
*/
 /* { dg-xfail-run-if posix_memalign modifies first arg on error { 
*-*-solaris2.11* } { -O0 } } */
 
 typedef __SIZE_TYPE__ size_t;
--- ../_clean/libstdc++-v3/testsuite/30_threads/condition_variable/54185.cc 
2013-06-10 11:06:33.0 +0200
+++ libstdc++-v3/testsuite/30_threads/condition_variable/54185.cc   
2013-06-10 23:12:39.0 +0200
@@ -1,4 +1,4 @@
-// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* 
*-*-solaris* *-*-cygwin *-*-darwin* powerpc-ibm-aix* } }
+// { dg-do run { target *-*-freebsd* *-*-netbsd* *-*-linux* *-*-gnu* 
*-*-solaris* *-*-cygwin *-*-darwin1[1-9]* powerpc-ibm-aix* } }
 // { dg-options  -std=gnu++0x -pthread { target *-*-freebsd* *-*-netbsd* 
*-*-linux* *-*-gnu* 

Re: [Build, Driver] Add -lcilkrts for -fcilkplus

2014-03-26 Thread Tobias Burnus

H.J. Lu wrote:

All cilk-plus link tests failed with
xgcc: error: libcilkrts.spec: No such file or directory
Don't you need to add -B/libcilkrts for this?


Hmm, I really wonder why it fails for you while it works for me:

Running 
/home/tob/projects/gcc/gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp ...

=== gcc Summary ===
# of expected passes1934
Running 
/home/tob/projects/gcc/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp ...

=== g++ Summary ===
# of expected passes1906
# of unsupported tests  37


I cross-checked: I have the installed version not in the $PATH or 
$LD_LIBRARY_PATH. And your version is r208851, which has my spec file, 
which I initially (r208851) missed: 
http://gcc.gnu.org/ml/gcc-testresults/2014-03/msg01965.html


Tobias


Re: [Build, Driver] Add -lcilkrts for -fcilkplus

2014-03-26 Thread H.J. Lu
On Wed, Mar 26, 2014 at 3:35 PM, Tobias Burnus bur...@net-b.de wrote:
 H.J. Lu wrote:

 All cilk-plus link tests failed with
 xgcc: error: libcilkrts.spec: No such file or directory
 Don't you need to add -B/libcilkrts for this?


 Hmm, I really wonder why it fails for you while it works for me:

 Running /home/tob/projects/gcc/gcc/testsuite/gcc.dg/cilk-plus/cilk-plus.exp
 ...
 === gcc Summary ===
 # of expected passes1934
 Running /home/tob/projects/gcc/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp
 ...
 === g++ Summary ===
 # of expected passes1906
 # of unsupported tests  37


 I cross-checked: I have the installed version not in the $PATH or
 $LD_LIBRARY_PATH. And your version is r208851, which has my spec file, which
 I initially (r208851) missed:
 http://gcc.gnu.org/ml/gcc-testresults/2014-03/msg01965.html


I got

spawn -ignore SIGHUP
/export/gnu/import/git/gcc-test-ia32corei7/bld/gcc/xgcc
-B/export/gnu/import/git/gcc-test-ia32corei7/bld/gcc/
/export/gnu/import/git/gcc-test-ia32corei7/src-trunk/gcc/testsuite/c-c++-common/cilk-plus/PS/reduction-1.c
-fno-diagnostics-show-caret -fdiagnostics-color=never -ftree-vectorize
-fcilkplus -std=c99 -O3 -fcilkplus
-L/export/gnu/import/git/gcc-test-ia32corei7/bld/i686-linux/./libcilkrts/.libs
-lm -o ./reduction-1.exe^M
xgcc: error:l libcikrts.spec: No such file or directory^M
compiler exited with status 1

Can you find where your tests get libcilkrts.spec?


-- 
H.J.


Re: [Build, Driver] Add -lcilkrts for -fcilkplus

2014-03-26 Thread Rainer Orth
Tobias Burnus bur...@net-b.de writes:

 H.J. Lu wrote:
 All cilk-plus link tests failed with
 xgcc: error: libcilkrts.spec: No such file or directory
 Don't you need to add -B/libcilkrts for this?

 Hmm, I really wonder why it fails for you while it works for me:
[...]
 I cross-checked: I have the installed version not in the $PATH or
 $LD_LIBRARY_PATH. And your version is r208851, which has my spec file,
 which I initially (r208851) missed:
 http://gcc.gnu.org/ml/gcc-testresults/2014-03/msg01965.html

Do you happen to have the same/a recent version installed at the same
prefix your build under test is configured for?  In that case, it's
likely that libcilkrts.spec is picked up from there.

For reasons like this, I usually configure test builds with a prefix
where no gcc is installed, so I can guarantee I really test the freshly
built version and not a mix.

Rainer

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


Re: [GOOGLE] Refactor the LIPO fixup

2014-03-26 Thread Dehao Chen
Patch updated, passed performance tests.

Dehao

On Tue, Mar 25, 2014 at 4:03 PM, Xinliang David Li davi...@google.com wrote:
 Add comment to the new function. init_node_map is better invoked after
 the link step to avoid creating entries with for dead nodes.

 Ok if large perf testing is fine.

 David

 On Tue, Mar 25, 2014 at 3:38 PM, Dehao Chen de...@google.com wrote:
 This patch refactors LIPO fixup related code to move it into a
 standalone function. This makes sure that
 symtab_remove_unreachable_nodes is called right after the fixup so
 that there is not dangling cgraph nodes any time.

 Bootstrapped and regression test on-going.

 OK for google-4_8?

 Thanks,
 Dehao
Index: gcc/l-ipo.h
===
--- gcc/l-ipo.h (revision 208826)
+++ gcc/l-ipo.h (working copy)
@@ -60,7 +60,7 @@ void add_decl_to_current_module_scope (tree decl,
 int lipo_cmp_type (tree t1, tree t2);
 tree get_type_or_decl_name (tree);
 int equivalent_struct_types_for_tbaa (const_tree t1, const_tree t2);
-void lipo_fixup_cgraph_edge_call_target (gimple);
+void lipo_link_and_fixup (void);
 extern void copy_defined_module_set (tree, tree);
 extern bool is_parsing_done_p (void);
 extern const char* get_module_name (unsigned int);
Index: gcc/auto-profile.c
===
--- gcc/auto-profile.c  (revision 208826)
+++ gcc/auto-profile.c  (working copy)
@@ -1533,16 +1533,10 @@ auto_profile (void)
   if (cgraph_state == CGRAPH_STATE_FINISHED)
 return 0;
 
-  init_node_map ();
   profile_info = autofdo::afdo_profile_info;
+  lipo_link_and_fixup ();
+  init_node_map ();
 
-  cgraph_pre_profiling_inlining_done = true;
-  cgraph_process_module_scope_statics ();
-  /* Now perform link to allow cross module inlining.  */
-  cgraph_do_link ();
-  varpool_do_link ();
-  cgraph_unify_type_alias_sets ();
-
   FOR_EACH_FUNCTION (node)
 {
   if (!gimple_has_body_p (node-symbol.decl))
@@ -1554,35 +1548,6 @@ auto_profile (void)
 
   push_cfun (DECL_STRUCT_FUNCTION (node-symbol.decl));
 
-  if (L_IPO_COMP_MODE)
-   {
- basic_block bb;
- FOR_EACH_BB (bb)
-   {
- gimple_stmt_iterator gsi;
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (gsi))
-   {
- gimple stmt = gsi_stmt (gsi);
- if (is_gimple_call (stmt))
-   lipo_fixup_cgraph_edge_call_target (stmt);
-   }
-   }
-   }
-  rebuild_cgraph_edges ();
-  pop_cfun ();
-}
-
-  FOR_EACH_FUNCTION (node)
-{
-  if (!gimple_has_body_p (node-symbol.decl))
-   continue;
-
-  /* Don't profile functions produced for builtin stuff.  */
-  if (DECL_SOURCE_LOCATION (node-symbol.decl) == BUILTINS_LOCATION)
-   continue;
-
-  push_cfun (DECL_STRUCT_FUNCTION (node-symbol.decl));
-
   /* First do indirect call promotion and early inline to make the
 IR match the profiled binary before actual annotation.
 
Index: gcc/value-prof.c
===
--- gcc/value-prof.c(revision 208826)
+++ gcc/value-prof.c(working copy)
@@ -1286,6 +1286,15 @@ init_gid_map (void)
   entp-node = n;
   entp-gid = ent.gid;
 }
+  else if (cgraph_pre_profiling_inlining_done)
+   {
+ (*slot)-node = cgraph_lipo_get_resolved_node (n-symbol.decl);
+ (*slot)-gid = ent.gid;
+   }
+  else
+   {
+ gcc_assert ((*slot)-gid == ent.gid  (*slot)-node == n);
+   }
 }
 }
 
Index: gcc/cgraphbuild.c
===
--- gcc/cgraphbuild.c   (revision 208826)
+++ gcc/cgraphbuild.c   (working copy)
@@ -244,9 +244,6 @@ add_fake_indirect_call_edges (struct cgraph_node *
   if (!L_IPO_COMP_MODE)
 return;
 
-  if (cgraph_pre_profiling_inlining_done)
-return;
-
   ic_counts
   = get_coverage_counts_no_warn (DECL_STRUCT_FUNCTION (node-symbol.decl),
  GCOV_COUNTER_ICALL_TOPNV, n_counts);
@@ -599,7 +596,7 @@ record_references_in_initializer (tree decl, bool
needs to be set to the resolved node so that ipa-inline
sees the definitions.  */
 #include gimple-pretty-print.h
-void
+static void
 lipo_fixup_cgraph_edge_call_target (gimple stmt)
 {
   tree decl;
@@ -625,6 +622,57 @@ lipo_fixup_cgraph_edge_call_target (gimple stmt)
 }
 }
 
+/* Link the cgraph nodes, varpool nodes and fixup the call target to
+   the correct decl. Remove dead functions.  */
+
+
+void
+lipo_link_and_fixup ()
+{
+  struct cgraph_node *node;
+
+  cgraph_pre_profiling_inlining_done = true;
+  cgraph_process_module_scope_statics ();
+  /* Now perform link to allow cross module inlining.  */
+  cgraph_do_link ();
+  varpool_do_link ();
+  cgraph_unify_type_alias_sets ();
+ 
+  FOR_EACH_DEFINED_FUNCTION (node)
+{
+  if (!gimple_has_body_p 

Re: [GOOGLE] Refactor the LIPO fixup

2014-03-26 Thread Xinliang David Li
is cgraph_init_gid_map called after linking?

David

On Wed, Mar 26, 2014 at 3:54 PM, Dehao Chen de...@google.com wrote:
 Patch updated, passed performance tests.

 Dehao

 On Tue, Mar 25, 2014 at 4:03 PM, Xinliang David Li davi...@google.com wrote:
 Add comment to the new function. init_node_map is better invoked after
 the link step to avoid creating entries with for dead nodes.

 Ok if large perf testing is fine.

 David

 On Tue, Mar 25, 2014 at 3:38 PM, Dehao Chen de...@google.com wrote:
 This patch refactors LIPO fixup related code to move it into a
 standalone function. This makes sure that
 symtab_remove_unreachable_nodes is called right after the fixup so
 that there is not dangling cgraph nodes any time.

 Bootstrapped and regression test on-going.

 OK for google-4_8?

 Thanks,
 Dehao


[Testsuite] Fix Cilk's exp to add -B for libcilkrts (was: Re: [Build, Driver] Add -lcilkrts for -fcilkplus)

2014-03-26 Thread Tobias Burnus


Rainer Orth wrote:

Tobias Burnus bur...@net-b.de writes:

H.J. Lu wrote:

xgcc: error: libcilkrts.spec: No such file or directory

Hmm, I really wonder why it fails for you while it works for me:
Do you happen to have the same/a recent version installed at the same 
prefix your build under test is configured for?


I had - after I removed it, I could reproduce it. Sorry!

Fixed by the attached testsuite patch. HJ: Does it now pass for you? For 
me it now does.


OK for the trunk?

Tobias
2014-03-27  Tobias Burnus  bur...@net-b.de

	* lib/cilk-plus-dg.exp: New.
	* g++.dg/cilk-plus/cilk-plus.exp: Use it.
	* gcc.dg/cilk-plus/cilk-plus.exp: Use it.

diff --git a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp
index 204a754..0cb6539 100644
--- a/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp
+++ b/gcc/testsuite/g++.dg/cilk-plus/cilk-plus.exp
@@ -17,62 +17,55 @@
 # Written by Balaji V. Iyer balaji.v.i...@intel.com
 
 load_lib g++-dg.exp
+load_lib cilk-plus-dg.exp
 
 if { ![check_effective_target_cilkplus] } {
 return;
 }
 
-set library_var [get_multilibs]
-# Pointing the ld_library_path to the Cilk Runtime library binaries.
-append ld_library_path :${library_var}/libcilkrts/.libs
-set_ld_library_path_env_vars
-
-global TEST_EXTRA_LIBS
-set TEST_EXTRA_LIBS -L${library_var}/libcilkrts/.libs
-
 dg-init
-# Run the tests that are shared with C.
-g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/PS/*.c]] 
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] -O3  
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]]
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] -g -O2  
-# Run the C++ only tests.
-g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] 
-dg-finish
+if [cilkplus_init] {
+# Run the tests that are shared with C.
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/PS/*.c]] 
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] -O3  
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]]
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/SE/*.c]] -g -O2  
+# Run the C++ only tests.
+g++-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.C]] 
 
-dg-init
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -O1 -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -O2 -ftree-vectorize -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -O3 -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -g -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -g -O1 -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -g -O2 -ftree-vectorize -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -g -O3 -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -O3 -ftree-vectorize -fcilkplus -g  
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -fcilkplus  
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -O1 -fcilkplus  
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -O2 -ftree-vectorize -fcilkplus  
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -O3 -fcilkplus  
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -g -fcilkplus  
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -g -O1 -fcilkplus  
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -g -O2 -ftree-vectorize -fcilkplus  
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -g -O3 -fcilkplus  
+dg-runtest [lsort [glob -nocomplain $srcdir/c-c++-common/cilk-plus/AN/*.c]]  -O3 -ftree-vectorize -fcilkplus -g  
 
-dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/AN/*.cc]]  -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/AN/*.cc]]  -O0 -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/AN/*.cc]]  -O1 -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/AN/*.cc]]  -O2 -ftree-vectorize -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/AN/*.cc]]  -O3 -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/AN/*.cc]]  -g -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/AN/*.cc]]  -g -O0 -fcilkplus  
-dg-runtest [lsort [glob -nocomplain $srcdir/g++.dg/cilk-plus/AN/*.cc]]  -g -O1 -fcilkplus  
-dg-runtest [lsort [glob 

Re: [Testsuite] Fix Cilk's exp to add -B for libcilkrts (was: Re: [Build, Driver] Add -lcilkrts for -fcilkplus)

2014-03-26 Thread H.J. Lu
On Wed, Mar 26, 2014 at 4:55 PM, Tobias Burnus bur...@net-b.de wrote:

 Rainer Orth wrote:

 Tobias Burnus bur...@net-b.de writes:

 H.J. Lu wrote:

 xgcc: error: libcilkrts.spec: No such file or directory

 Hmm, I really wonder why it fails for you while it works for me:

 Do you happen to have the same/a recent version installed at the same
 prefix your build under test is configured for?


 I had - after I removed it, I could reproduce it. Sorry!

 Fixed by the attached testsuite patch. HJ: Does it now pass for you? For me
 it now does.

It looks OK to me.

Thanks.


-- 
H.J.


Re: [PATCH] Add support for vbpermq builtin; Improve vec_extract

2014-03-26 Thread David Edelsohn
On Wed, Mar 26, 2014 at 3:50 PM, Michael Meissner
meiss...@linux.vnet.ibm.com wrote:
 This patch adds support for adding a builtin to generate the vbpermq
 instruction on ISA 2.07.  This instruction takes a vector in the Altivec
 register set, and returns a 64-bit value in the upper part of the register, 
 and
 0 in the lower part of the register.

 The output is explicitly a vector, since the documentation for the instruction
 says that to do a permutation of all 8 bits, you need to do 2 vbpermq's, one
 with the high bit in each byte within the vector set, and the other with the
 high bit cleared.

 vbpermq v6,v1,v2# select from high-order half of Q
 vxorv0,v1,v4# adjust index values
 vbpermq v5,v0,v3# select from low-order half of Q
 vor v6,v6,v5# merge the two selections

 In writing the tests, I noticed that the vec_extract code did not have
 optimizations for getting 64-bit data out, of the vector element happens to be
 0 on big endian systems, and 1 on little endian systems.  So I added
 optimizations for register/register move, including using the mfvsrd
 instruction to transfer the final result to a GPR.  While I was there, I added
 vec_extract optimizations to do a 64-bit store and I combined the big endian
 and little endian vec_extract load optimizaton.

 I built a big endian Spec 2006 suite with this compiler, and compared it to 
 the
 trunk compiler without the changes.  Only 3 benchmarks (gamess, dealII, and
 povray) generated vec_extracts that became moves instead of permutes.  I ran
 the tests on a power7 system, and the differences in run time were in the 
 noise
 level.  None of the spec benchmarks generated vec_extract that was a load or a
 store.

 I did bootstraps on a big endian power7 system, a big endian power8 system, 
 and
 a little endian power8 system with no regressions in the test suite.  Are 
 these
 patches ok to install on both the trunk?  I would like to apply these patches
 there as well, when all of the ISA 2.07 changes are present in the 4.8 branch,
 Can I apply these patches?

 [gcc]
 2014-03-26  Michael Meissner  meiss...@linux.vnet.ibm.com

 * config/rs6000/constraints.md (wD constraint): New constraint to
 match the constant integer to get the top DImode/DFmode out of a
 vector in a VSX register.

 * config/rs6000/predicates.md (vsx_scalar_64bit): New predicate to
 match the constant integer to get the top DImode/DFmode out of a
 vector in a VSX register.

 * config/rs6000/rs6000-builtins.def (VBPERMQ): Add vbpermq builtin
 for ISA 2.07.

 * config/rs6000/rs6000-c.c (altivec_overloaded_builtins): Add
 vbpermq builtins.

 * config/rs6000/rs6000.c (rs6000_debug_reg_global): If
 -mdebug=reg, print value of VECTOR_ELEMENT_SCALAR_64BIT.

 * config/rs6000/vsx.md (vsx_extract_mode, V2DI/V2DF modes):
 Optimize vec_extract of 64-bit values, where the value being
 extracted is in the top word, where we can use scalar
 instructions.  Add direct move and store support.  Combine the big
 endian/little endian vector select load support into a single
 insn.
 (vsx_extract_mode_internal1): Likewise.
 (vsx_extract_mode_internal2): Likewise.
 (vsx_extract_mode_load): Likewise.
 (vsx_extract_mode_store): Likewise.
 (vsx_extract_mode_zero): Delete, big and little endian insns are
 combined into vsx_extract_mode_load.
 (vsx_extract_mode_one_le): Likewise.

 * config/rs6000/rs6000.h (VECTOR_ELEMENT_SCALAR_64BIT): Macro to
 define the top 64-bit vector element.

 * doc/md.texi (PowerPC and IBM RS6000 constraints): Document wD
 constraint.

 [gcc/testsuite]
 2014-03-26  Michael Meissner  meiss...@linux.vnet.ibm.com

 * gcc.target/powerpc/p8vector-vbpermq.c: New test to test the
 vbpermq builtin.

 * gcc.target/powerpc/vsx-extract-1.c: New test to test VSX
 vec_select optimizations.
 * gcc.target/powerpc/vsx-extract-2.c: Likewise.
 * gcc.target/powerpc/vsx-extract-3.c: Likewise.

Okay.

Good to add the optimizations.

I notice that you emit nop with a comment after a # character. I
notice that you also added that to the POWER8 vector fusion peepholes.

Is it safe to assume that all assemblers for PowerPC will consider all
characters after a # to be a comment?

I would like to make sure there are no other problems with the patch
before backporting to 4.8. It wasn't included in the group of patches
for 4.8 that have been widely tested.

Thanks, David


[PATCH] Fix PR c++/60573

2014-03-26 Thread Adam Butcher
PR c++/60573
* parser.c (synthesize_implicit_template_parm): Use cp_binding_level::
class_shadowed rather than TYPE_BEING_DEFINED as the predicate for
unwinding to class-defining scope to handle the erroneous definition of
a generic function of an arbitrarily nested class within an enclosing
class.

PR c++/60573
* g++.dg/cpp1y/pr60573.C: New testcase.
---
 gcc/cp/parser.c  | 30 --
 gcc/testsuite/g++.dg/cpp1y/pr60573.C | 28 
 2 files changed, 52 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp1y/pr60573.C

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index e729d65..2130bcd 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -32000,7 +32000,7 @@ synthesize_implicit_template_parm  (cp_parser *parser)
{
  /* If not defining a class, then any class scope is a scope level in
 an out-of-line member definition.  In this case simply wind back
-beyond the first such scope to inject the template argument list.
+beyond the first such scope to inject the template parameter list.
 Otherwise wind back to the class being defined.  The latter can
 occur in class member friend declarations such as:
 
@@ -32011,12 +32011,30 @@ synthesize_implicit_template_parm  (cp_parser *parser)
 friend void A::foo (auto);
   };
 
-   The template argument list synthesized for the friend declaration
-   must be injected in the scope of 'B', just beyond the scope of 'A'
-   introduced by 'A::'.  */
+   The template parameter list synthesized for the friend declaration
+   must be injected in the scope of 'B'.  This can also occur in
+   erroneous cases such as:
 
- while (scope-kind == sk_class
- !TYPE_BEING_DEFINED (scope-this_entity))
+  struct A {
+struct B {
+  void foo (auto);
+};
+void B::foo (auto) {}
+  };
+
+Here the attempted definition of 'B::foo' within 'A' is ill-formed
+but, nevertheless, the template parameter list synthesized for the
+declarator should be injected into the scope of 'A' as if the
+ill-formed template was specified explicitly.
+
+Note: cp_binding_level::class_shadowed is used as a predicate to
+indicate whether a class scope is a class-defining scope.  We stop
+at the first such scope as this will be the currently open class
+definition into which the function being declared will be appended;
+and therefore the scope into which the synthesized template
+parameter list for the declarator should be injected.  */
+
+ while (scope-kind == sk_class  !scope-class_shadowed)
{
  parent_scope = scope;
  scope = scope-level_chain;
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr60573.C 
b/gcc/testsuite/g++.dg/cpp1y/pr60573.C
new file mode 100644
index 000..2f60707
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/pr60573.C
@@ -0,0 +1,28 @@
+// PR c++/60573
+// { dg-do compile { target c++1y } }
+// { dg-options  }
+
+struct A
+{
+  struct B
+  {
+void foo(auto);
+  };
+
+  void B::foo(auto) {}  // { dg-error cannot define }
+
+  struct X
+  {
+struct Y
+{
+  struct Z
+  {
+void foo(auto);
+  };
+};
+
+void Y::Z::foo(auto) {}  // { dg-error cannot define }
+  };
+
+  void X::Y::Z::foo(auto) {}  // { dg-error cannot define }
+};
-- 
1.9.0



Re: Two build != host fixes

2014-03-26 Thread Alan Modra
On Wed, Mar 26, 2014 at 09:43:08PM +, Maciej W. Rozycki wrote:
 Alan,
 
 On Tue, 17 Dec 2013, Alan Modra wrote:
 
  On Tue, Dec 17, 2013 at 01:14:23PM +0100, Bernd Edlinger wrote:
   the reason for this is overwriting GMPINC for the auto-build generation, 
   because
   many test scripts include gmp.h which fails now completely (it is not 
   installed,
   I have it in-tree).
  
  Yes, I understand the reason why your setup is failing.  Please try
  this patch.
  
  Index: gcc/configure.ac
  ===
  --- gcc/configure.ac(revision 206009)
  +++ gcc/configure.ac(working copy)
  @@ -1529,8 +1529,13 @@
  /* | [A-Za-z]:[\\/]* ) realsrcdir=${srcdir};;
  *) realsrcdir=../${srcdir};;
  esac
  +   # Clearing GMPINC is necessary to prevent host headers being
  +   # used by the build compiler.  Defining GENERATOR_FILE stops
  +   # system.h from including gmp.h.
  CC=${CC_FOR_BUILD} CFLAGS=${CFLAGS_FOR_BUILD} \
  -   LDFLAGS=${LDFLAGS_FOR_BUILD} GMPINC= \
  +   CXX=${CXX_FOR_BUILD} CXXFLAGS=${CXXFLAGS_FOR_BUILD} \
  +   LD=${LD_FOR_BUILD} LDFLAGS=${LDFLAGS_FOR_BUILD} \
  +   GMPINC= CPPFLAGS=${CPPFLAGS} -DGENERATOR_FILE \
  ${realsrcdir}/configure \
  --enable-languages=${enable_languages-all} \
  --target=$target_alias --host=$build_alias --build=$build_alias
 
  Can you please backport this change to 4.8 too, to fix the build 
 regression discussed here introduced by the previous change that did get 
 backported?

Oops, I'd forgotten that the first patch had gone on the branch..
Backported and regression tested.  OK to apply?

2014-03-27  Alan Modra  amo...@gmail.com

Apply from mainline
2014-01-28  Alan Modra  amo...@gmail.com
* Makefile.in (BUILD_CPPFLAGS): Do not use ALL_CPPFLAGS.
* configure.ac recursive call for build != host: Define
GENERATOR_FILE.  Comment.  Use CXX_FOR_BUILD, CXXFLAGS_FOR_BUILD
and LD_FOR_BUILD too.
* configure: Regenerate.

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

-- 
Alan Modra
Australia Development Lab, IBM


Re: C++ PATCH for c++/60566 (dtor devirtualization and missing thunks)

2014-03-26 Thread Jan Hubicka
 My earlier patch for 58678 caused this problem: even if we aren't
 going to refer to the dtor thunks from the vtable, we need to emit
 them in case other translation units use them.
 
 I'm adding xfails to two testcases: devirt-21.C and devirt-23.C.
 The fails aren't a new bug; we are no longer seeing the
 devirtualization because we remove the path to wrap() through a
 virtual call to ~MultiTermDocs that it occurred along.  But it seems
 odd to me that it isn't happening on path through a non-virtual call
 to ~MultiTermDocs, so I'm filing a bug about that.

MultiTermDocs::~MultiTermDocs() (struct MultiTermDocs * const this, const void 
* * __vtt_parm)
{
  unsigned int i;
  int (*__vtbl_ptr_type) () * iftmp.6_4;
  struct A * _8;
  unsigned int _10;

  bb 2:
  iftmp.6_4 = *__vtt_parm_3(D);
  this_5(D)-_vptr.MultiTermDocs = iftmp.6_4;
  MultiTermDocs::wrap (this_5(D));

I belive the problem here is the _vptr.MultiTermDocs vtable is initialized from
VTT that is not understood by ipa-prop jump functions.
The other path has direct store of VPTR in it.

Honza



Re: [PATCH] Environment variables forwarding

2014-03-26 Thread Yury Gribov

 But if somebody is willing to maintain it for
 cross-testing

Yup, we'll do this.

Now what bothers me is zero feedback from Dejagnu folks...

-Y


Re: [PATCH] Environment variables forwarding

2014-03-26 Thread Ben Elliston
On Thu, Mar 27, 2014 at 09:56:22AM +0400, Yury Gribov wrote:

 Now what bothers me is zero feedback from Dejagnu folks...

Come on, it's only been a couple of days. :-)

Ben


signature.asc
Description: Digital signature