Re: [wwwdocs,Java] Use https for redhat.com.

2012-11-02 Thread Andreas Schwab
Gerald Pfeifer  writes:

> Like some other domains, redhat.com now defaults to http, so this
> adjusts the link.

Are you sure it's not something on your side?

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


[committed] Fix bswapdi2 -m32 miscompilation (PR target/55147)

2012-11-02 Thread Jakub Jelinek
Hi!

As discussed in the PR, *bswapdi2_doubleword splitter would generate wrong
code if there is overlap in between the destination register and the memory
address.  Without bswapdi2 pattern for !TARGET_64BIT, we generate sometimes
better, usually same quality and sometimes slightly worse code, so the fix
is to remove the pattern for 32-bit.  Even with movbe it does the right
thing.  Preapproved in the PR by Uros, bootstrapped/regtested on
x86_64-linux and i686-linux, committed to trunk.

2012-11-02  Jakub Jelinek  

PR target/55147
* config/i386/i386.md (bswapdi2): Limit to TARGET_64BIT.
(*bswapdi2_doubleword): Removed.

* gcc.target/i386/pr55147.c: New test.

--- gcc/config/i386/i386.md.jj  2012-11-01 09:33:06.632302393 +0100
+++ gcc/config/i386/i386.md 2012-11-01 10:37:16.947243914 +0100
@@ -12669,55 +12669,10 @@ (define_insn "*popcountsi2_cmp_zext"
 (define_expand "bswapdi2"
   [(set (match_operand:DI 0 "register_operand")
(bswap:DI (match_operand:DI 1 "nonimmediate_operand")))]
-  ""
+  "TARGET_64BIT"
 {
-  if (TARGET_64BIT && !TARGET_MOVBE)
-operands[1] = force_reg (DImode, operands[1]);
-})
-
-(define_insn_and_split "*bswapdi2_doubleword"
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m")
-   (bswap:DI
- (match_operand:DI 1 "nonimmediate_operand" "0,m,r")))]
-  "!TARGET_64BIT
-   && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
-  "#"
-  "&& reload_completed"
-  [(set (match_dup 2)
-   (bswap:SI (match_dup 1)))
-   (set (match_dup 0)
-   (bswap:SI (match_dup 3)))]
-{
-  split_double_mode (DImode, &operands[0], 2, &operands[0], &operands[2]);
-
-  if (REG_P (operands[0]) && REG_P (operands[1]))
-{
-  emit_insn (gen_swapsi (operands[0], operands[2]));
-  emit_insn (gen_bswapsi2 (operands[0], operands[0]));
-  emit_insn (gen_bswapsi2 (operands[2], operands[2]));
-  DONE;
-}
-
   if (!TARGET_MOVBE)
-{
-  if (MEM_P (operands[0]))
-   {
- emit_insn (gen_bswapsi2 (operands[3], operands[3]));
- emit_insn (gen_bswapsi2 (operands[1], operands[1]));
-
- emit_move_insn (operands[0], operands[3]);
- emit_move_insn (operands[2], operands[1]);
-   }
-  if (MEM_P (operands[1]))
-   {
- emit_move_insn (operands[2], operands[1]);
- emit_move_insn (operands[0], operands[3]);
-
- emit_insn (gen_bswapsi2 (operands[2], operands[2]));
- emit_insn (gen_bswapsi2 (operands[0], operands[0]));
-   }
-  DONE;
-}
+operands[1] = force_reg (DImode, operands[1]);
 })
 
 (define_expand "bswapsi2"
--- gcc/testsuite/gcc.target/i386/pr55147.c.jj  2012-11-01 10:36:33.304496388 
+0100
+++ gcc/testsuite/gcc.target/i386/pr55147.c 2012-11-01 10:35:52.0 
+0100
@@ -0,0 +1,25 @@
+/* PR target/55147 */
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+/* { dg-additional-options "-march=i486" { target ia32 } } */
+
+extern void abort (void);
+
+__attribute__((noclone, noinline)) unsigned int
+foo (unsigned long long *p, int i)
+{
+  return __builtin_bswap64 (p[i]);
+}
+
+int
+main ()
+{
+  unsigned long long p[64];
+  int i;
+  for (i = 0; i < 64; i++)
+p[i] = 0x123456789abcdef0ULL ^ (1ULL << i) ^ (1ULL << (63 - i));
+  for (i = 0; i < 64; i++)
+if (foo (p, i) != __builtin_bswap32 (p[i] >> 32))
+  abort ();
+  return 0;
+}

Jakub


Re: [PR54693] loss of debug info in jump threading and loop ivopts

2012-11-02 Thread Jakub Jelinek
On Thu, Nov 01, 2012 at 10:27:57AM +0100, Jakub Jelinek wrote:
> The patch unfortunately doesn't speed test-tgmath2.i compilation
> significantly, but decreases number of debug stmts from ~ 36000 to ~ 16000,
> the 2+ were clearly redundant.

Testing found a buglet in the patch (doing is_gimple_debug (gsi_stmt (gsi))
even when there might be no stmts after labels in the successor at all),
fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2012-11-02  Jakub Jelinek  

PR debug/54402
* tree-ssa-threadedge.c (thread_around_empty_block): Don't copy over
debug stmts if the successor bb already starts with a debug stmt for
the same var.

--- gcc/tree-ssa-threadedge.c.jj2012-10-30 09:01:15.0 +0100
+++ gcc/tree-ssa-threadedge.c   2012-11-01 10:07:29.114499218 +0100
@@ -1,5 +1,5 @@
 /* SSA Jump Threading
-   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Contributed by Jeff Law  
 
@@ -641,18 +641,62 @@ thread_around_empty_block (edge taken_ed
  we don't lose the bindings as we redirect the edges.  */
   if (MAY_HAVE_DEBUG_STMTS)
 {
+  struct pointer_set_t *vars = NULL;
+
   gsi = gsi_after_labels (bb);
   for (gimple_stmt_iterator si = gsi_last_bb (taken_edge->src);
   !gsi_end_p (si); gsi_prev (&si))
{
+ tree var;
+
  stmt = gsi_stmt (si);
  if (!is_gimple_debug (stmt))
continue;
 
+ var = NULL_TREE;
+ if (gimple_debug_bind_p (stmt))
+   var = gimple_debug_bind_get_var (stmt);
+ else if (gimple_debug_source_bind_p (stmt))
+   var = gimple_debug_source_bind_get_var (stmt);
+
+ /* Don't insert debug stmts for vars which will be immediately
+overridden by debug stmts at the start of bb (either preexisting
+or from earlier thread_around_empty_block attempt), without
+any intervening real stmts.  */
+ if (var != NULL_TREE
+ && !gsi_end_p (gsi)
+ && is_gimple_debug (gsi_stmt (gsi)))
+   {
+ if (vars == NULL)
+   {
+ gimple_stmt_iterator gsi2;
+ vars = pointer_set_create ();
+ for (gsi2 = gsi; !gsi_end_p (gsi2); gsi_next (&gsi2))
+   {
+ gimple stmt2 = gsi_stmt (gsi2);
+ tree var2;
+ if (!is_gimple_debug (stmt2))
+   break;
+ if (gimple_debug_bind_p (stmt2))
+   var2 = gimple_debug_bind_get_var (stmt2);
+ else if (gimple_debug_source_bind_p (stmt2))
+   var2 = gimple_debug_source_bind_get_var (stmt2);
+ else
+   continue;
+ pointer_set_insert (vars, var2);
+   }
+   }
+ if (pointer_set_insert (vars, var))
+   continue;
+   }
+
  stmt = gimple_copy (stmt);
  /* ??? Should we drop the location of the copy?  */
  gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
}
+
+  if (vars != NULL)
+   pointer_set_destroy (vars);
 }
 
   /* This block must have more than one successor.  */

Jakub


Re: [patch] Apply conditional down cast to cgraph.h et.al.

2012-11-02 Thread Eric Botcazou
> Index: gcc/ChangeLog
> 
> 2012-10-31  Lawrence Crowl  
> 
>   * is-a.h: New.
>   (is_a  (U*)): New.  Test for is-a relationship.
>   (as_a  (U*)): New.  Treat as a derived type.
>   (dyn_cast  (U*)): New.  Conditionally cast based on is_a.
>   * cgraph.h (varpool_node): Rename to varpool_node_for_decl.
>   Adjust callers to match.
>   (is_a_helper ::test (symtab_node_def *)): New.
>   (is_a_helper ::test (symtab_node_def *)): New.
>   (symtab_node_def::try_function): New.  Change most calls to
>   symtab_function_p with calls to dyn_cast  (p).
>   (symtab_node_def::try_variable): New.  Change most calls to
>   symtab_variable_p with calls to dyn_cast  (p).
>   (symtab_function_p): Remove.  Change callers to use
> is_a  (p) instead.
>   (symtab_variable_p): Remove.  Change callers to use
> is_a  (p) instead.
>   * cgraph.c (cgraph_node_for_asm): Remove redundant call to
>   symtab_node_for_asm.
>   * cgraphunit.c (symbol_finalized_and_needed): New.
>   (symbol_finalized): New.
>   (cgraph_analyze_functions): Split complicated conditionals out into
>   above new functions.
>   * Makefile.in (CGRAPH_H): Add is-a.h as used by cgraph.h.

The installed patch touches the ada/, cp/ and lto/ subdirectories without 
modifying their ChangeLog files.  Please add the missing entries.

[Some people, like me, do use these ChangeLogs to synchronize trees]

-- 
Eric Botcazou


[PATCH Version 2][RFA]Improving register pressure directed hoist

2012-11-02 Thread Bin Cheng
Hi,
I posted a patch improving register pressure directed hoist at
http://gcc.gnu.org/ml/gcc-patches/2012-10/msg02552.html
Turns out it has a mistake in update_bb_reg_pressure resulting in changing
register pressure incorrectly. Here comes the 2nd version patch for review.
Unfortunately and strangely, this correct patch isn't as good as the bogus
one. The improvement is as below:

improvement
Thumb1  0.17% (0.13% before)
ARM 0.15% (0.12% before)
AARCH64 0.33%
MIPS0.24%
PowerPC 0.62%
Thumb2  X
x86 X
x86_64  X
X means no obvious effect on the corresponding target.

Though the effect is not as good as expected, I still think it worth to be
reviewed, because:
  a) it does improve code size a little bit on ARM target and introduces
fewer regression.
  b) it makes further optimization possible (for example, computing VBE
optimistically in compute_code_hoist_vbeinout). 

Also I don't understand why the bogus patch can catch more hoist
opportunities and improve code size, so please help if you have any idea
about this.

It is re-tested on x86. OK?

Thanks very much.


2012-11-02  Bin Cheng  

* gcse.c: (struct bb_data): Add new fields, old_pressure, live_in
and backup.
(calculate_bb_reg_pressure): Initialize live_in and backup.
(update_bb_reg_pressure): New.
(should_hoist_expr_to_dom): Add new parameter from.
Monitor the change of reg pressure and use it to drive hoisting.
(hoist_code): Update LIVE and reg pressure information.

gcc/testsuite/ChangeLog
2012-11-02  Bin Cheng  

* gcc.dg/hoist-register-pressure-3.c: New test.Index: gcc/testsuite/gcc.dg/hoist-register-pressure-3.c
===
--- gcc/testsuite/gcc.dg/hoist-register-pressure-3.c(revision 0)
+++ gcc/testsuite/gcc.dg/hoist-register-pressure-3.c(revision 0)
@@ -0,0 +1,32 @@
+/* { dg-options "-Os -fdump-rtl-hoist" }  */
+/* { dg-final { scan-rtl-dump "PRE/HOIST: end of bb .* copying expression" 
"hoist" } } */
+
+#define BUF 100
+int a[BUF];
+
+void com (int);
+void bar (int);
+
+int foo (int x, int y, int z)
+{
+  /* "x+y" won't be hoisted if "-fira-hoist-pressure" is disabled,
+ because its rtx_cost is too small.  */
+  if (z)
+{
+  a[1] = a[0] + a[2] + a[3] + a[4] + a[5] + a[6];
+  a[2] = a[1] + a[3] + a[5] + a[5] + a[6] + a[7];
+  a[3] = a[2] + a[5] + a[7] + a[6] + a[7] + a[8];
+  a[4] = a[3] + a[7] + a[11] + a[7] + a[8] + a[9];
+  a[5] = a[5] + a[11] + a[13] + a[8] + a[9] + a[10];
+  a[6] = a[7] + a[13] + a[17] + a[9] + a[10] + a[11];
+  a[7] = a[11] + a[17] + a[19] + a[10] + a[11] + a[12];
+  com (x+y);
+}
+  else
+{
+  bar (x+y);
+}
+
+  return 0;
+}
+
Index: gcc/gcse.c
===
--- gcc/gcse.c  (revision 193013)
+++ gcc/gcse.c  (working copy)
@@ -20,9 +20,6 @@ along with GCC; see the file COPYING3.  If not see
 
 /* TODO
- reordering of memory allocation and freeing to be more space efficient
-   - simulate register pressure change of each basic block accurately during
- hoist process.  But I doubt the benefit since most expressions hoisted
- are constant or address, which usually won't reduce register pressure.
- calc rough register pressure information and use the info to drive all
  kinds of code motion (including code hoisting) in a unified way.
 */
@@ -421,6 +418,15 @@ struct bb_data
   /* Maximal register pressure inside basic block for given register class
  (defined only for the pressure classes).  */
   int max_reg_pressure[N_REG_CLASSES];
+  /* Recorded register pressure of basic block before trying to hoist
+ an expression.  Will be used to restore the register pressure
+ if the expression should not be hoisted.  */
+  int old_pressure;
+  /* Recorded register live_in info of basic block during code hoisting
+ process.  BACKUP is used to record live_in info before trying to
+ hoist an expression, and will be used to restore LIVE_IN if the
+ expression should not be hoisted.  */
+  bitmap live_in, backup;
 };
 
 #define BB_DATA(bb) ((struct bb_data *) (bb)->aux)
@@ -481,7 +487,7 @@ static void compute_code_hoist_vbeinout (void);
 static void compute_code_hoist_data (void);
 static int should_hoist_expr_to_dom (basic_block, struct expr *, basic_block,
 sbitmap, int, int *, enum reg_class,
-int *, bitmap);
+int *, bitmap, rtx);
 static int hoist_code (void);
 static enum reg_class get_pressure_class_and_nregs (rtx insn, int *nregs);
 static int one_code_hoisting_pass (void);
@@ -2847,6 +2853,69 @@ compute_code_hoist_data (void)
 fprintf (dump_file, "\n");
 }
 
+/* Update register pressure for BB when hoisting an expression from
+   instruction FROM, if live ranges of inputs 

[doc,libstdc++] Update Hoard references in libstdc++/doc

2012-11-02 Thread Gerald Pfeifer
Applied.

2012-11-02  Gerald Pfeifer  

* doc/xml/manual/allocator.xml: Update reference to Hoard.
Update reference to Berger's OOPSLA 2002 paper.

Index: doc/xml/manual/allocator.xml
===
--- doc/xml/manual/allocator.xml(revision 193090)
+++ doc/xml/manual/allocator.xml(working copy)
@@ -524,7 +524,7 @@
   
   
http://www.w3.org/1999/xlink";
- xlink:href="http://www.cs.umass.edu/~emery/hoard";>
+ xlink:href="http://www.hoard.org/";>
   The Hoard Memory Allocator

   
@@ -535,7 +535,7 @@
   
   
http://www.w3.org/1999/xlink";
- 
xlink:href="http://www.cs.umass.edu/~emery/pubs/berger-oopsla2002.pdf";>
+ 
xlink:href="http://people.cs.umass.edu/~emery/pubs/berger-oopsla2002.pdf";>
   Reconsidering Custom Memory Allocation

   


Re: [patch, lra, pr55103, committed] Save lra_int struct.

2012-11-02 Thread Richard Sandiford
"Steve Ellcey "  writes:
> I checked in this patch as obvious.  It fixes PR 55103 which is a compiler
> abort on MIPS with the -mips16 flag.  After committing I realized I forgot
> to put the bug number in the ChangeLog, I will update PR 55103 by hand.

Thanks


[SH] PR 51244 - catch more unnecessary T bit stores

2012-11-02 Thread Oleg Endo
Hello,

With this patch a few more cases are handled where the T bit is stored
and then re-tested again before conditional branches.
Tested on rev 193061 with
make -k check RUNTESTFLAGS="--target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"

and no new failures.
OK?

Cheers,
Oleg


gcc/ChangeLog:

PR target/51244
* config/sh/sh.md (*cbranch_t): Allow splitting after reload.
Allow going beyond current basic block before reload when 
looking for the reg set insn.
* config/sh/sh.c (sh_find_set_of_reg): Don't stop at labels.

testsuite/ChangeLog:

PR target/51244
* gcc.target/sh/pr51244-18.c: New.
* gcc.target/sh/pr51244-19.c: New.

Index: gcc/config/sh/sh.md
===
--- gcc/config/sh/sh.md	(revision 192482)
+++ gcc/config/sh/sh.md	(working copy)
@@ -8168,13 +8168,15 @@
 {
   return output_branch (sh_eval_treg_value (operands[1]), insn, operands);
 }
-  "&& can_create_pseudo_p ()"
+  "&& 1"
   [(set (pc) (if_then_else (eq (reg:SI T_REG) (match_dup 2))
 			   (label_ref (match_dup 0))
 			   (pc)))]
 {
   /* Try to find missed test and branch combine opportunities which result
  in redundant T bit tests before conditional branches.
+ This is done not only after combine (and before reload) but in every
+ split pass, because some opportunities are formed also after combine.
  FIXME: Probably this would not be needed if CCmode was used
  together with TARGET_FIXED_CONDITION_CODE_REGS.  */
 
@@ -8213,8 +8215,11 @@
 
   while (true)
 {
+  /* It's not safe to go beyond the current basic block after reload.  */
   set_of_reg s1 = sh_find_set_of_reg (tested_reg, s0.insn,
-	  prev_nonnote_insn_bb);
+	  reload_completed
+	  ? prev_nonnote_insn_bb
+	  : prev_nonnote_insn);
   if (s1.set_src == NULL_RTX)
 	break;
 
Index: gcc/config/sh/sh.c
===
--- gcc/config/sh/sh.c	(revision 192482)
+++ gcc/config/sh/sh.c	(working copy)
@@ -13488,7 +13488,7 @@
   for (result.insn = stepfunc (insn); result.insn != NULL_RTX;
result.insn = stepfunc (result.insn))
 {
-  if (LABEL_P (result.insn) || BARRIER_P (result.insn))
+  if (BARRIER_P (result.insn))
 	return result;
   if (!NONJUMP_INSN_P (result.insn))
 	continue;
Index: gcc/testsuite/gcc.target/sh/pr51244-19.c
===
--- gcc/testsuite/gcc.target/sh/pr51244-19.c	(revision 0)
+++ gcc/testsuite/gcc.target/sh/pr51244-19.c	(revision 0)
@@ -0,0 +1,75 @@
+/* Check that no unnecessary T bit stores are done before conditional
+   branches.
+   This case was extracted from the CSiBE set and contained the following
+   sequence:
+	mov.l	@(8,r4),r2
+	mov.l	@(4,r4),r3
+	cmp/gt	r2,r3
+	movt	r2
+.L3:
+	tst	r2,r2
+	bt/s	.L12
+	mov	#-1,r0
+
+	.
+
+	mov.l	@r4,r2
+	tst	r2,r2
+	bra	.L3
+	movt	r2
+
+   In this reduced code the movt insns were only present in the
+   unwanted sequences.  Thus, if we see any movt insns, something is not
+   working as expected.  This test requires -O2 because the T bit stores
+   in question will be eliminated in additional insn split passes after
+   reload.  */
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O2" } */
+/* { dg-skip-if "" { "sh*-*-*" } { "-m5*" } { "" } } */
+/* { dg-final { scan-assembler-not "movt" } } */
+
+struct request
+{
+ unsigned long nr_sectors;
+};
+
+struct request_list
+{
+ int count;
+};
+
+struct request_queue
+{
+ struct request_list rq;
+ volatile int nr_sectors;
+ int max_queue_sectors;
+ int can_throttle;
+ unsigned long bounce_pfn;
+};
+
+typedef struct request_queue request_queue_t;
+
+static inline int
+blk_oversized_queue (request_queue_t* q)
+{
+  if (q->can_throttle)
+return q->nr_sectors > q->max_queue_sectors;
+  return q->rq.count == 0;
+}
+
+struct request*
+get_request (request_queue_t* q, int rw)
+{
+  struct request* rq = ((void*)0);
+  struct request_list *rl = &q->rq;
+
+  if (blk_oversized_queue (q))
+{
+  if ((rw == 1) || (rw == 0))
+	return ((void*)0);
+  if (blk_oversized_queue (q))
+	return ((void*)0);
+}
+
+  return (void*)-100;
+}
Index: gcc/testsuite/gcc.target/sh/pr51244-18.c
===
--- gcc/testsuite/gcc.target/sh/pr51244-18.c	(revision 0)
+++ gcc/testsuite/gcc.target/sh/pr51244-18.c	(revision 0)
@@ -0,0 +1,102 @@
+/* Check that no unnecessary T bit stores are done before conditional
+   branches.
+   This case was extracted from the CSiBE set and contained the following
+   sequence:
+	cmp/hi	r1,r0
+	movt	r1
+	tst	r1,r1
+	bt	.L12
+	mov.l	@r10,r1
+   In this reduced code the movt and tst insns were only present in the
+   unwanted sequence.  Thus, if we see any tst or movt insns, something is
+   not working as expected.  This test requires -O2 because the T bit sto

[SH] Use some more multi-line asm in sh.c

2012-11-02 Thread Oleg Endo
Hello,

This mainly reformats some of the asm output code in sh.c to use
multi-line strings.
Tested on rev 193061 with
make -k check RUNTESTFLAGS="--target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"

and no new failures.
OK?

Cheers,
Oleg

gcc/ChangeLog:

* config/sh/sh.c (output_movedouble, output_far_jump, 
output_ieee_ccmpeq): Use multi-line strings for asm.
(find_regmode_weight): Wrap lines.
(sh_optimize_target_register_callee_saved): Remove commented out
variable.
(emit_load_ptr): Remove prototype.
Index: gcc/config/sh/sh.c
===
--- gcc/config/sh/sh.c	(revision 193061)
+++ gcc/config/sh/sh.c	(working copy)
@@ -2600,21 +2600,25 @@
 
   if (MEM_P (dst)
   && GET_CODE (XEXP (dst, 0)) == PRE_DEC)
-return "mov.l	%T1,%0\n\tmov.l	%1,%0";
+return "mov.l	%T1,%0"	"\n"
+	   "	mov.l	%1,%0";
 
   if (register_operand (dst, mode)
   && register_operand (src, mode))
 {
   if (REGNO (src) == MACH_REG)
-	return "sts	mach,%S0\n\tsts	macl,%R0";
+	return "sts	mach,%S0" "\n"
+	   "	sts	macl,%R0";
 
   /* When mov.d r1,r2 do r2->r3 then r1->r2;
  when mov.d r1,r0 do r1->r0 then r2->r1.  */
 
   if (REGNO (src) + 1 == REGNO (dst))
-	return "mov	%T1,%T0\n\tmov	%1,%0";
+	return "mov	%T1,%T0" "\n"
+	   "	mov	%1,%0";
   else
-	return "mov	%1,%0\n\tmov	%T1,%T0";
+	return "mov	%1,%0" "\n"
+	   "	mov	%T1,%T0";
 }
   else if (CONST_INT_P (src))
 {
@@ -2654,19 +2658,23 @@
 	  break;
 	  
 	case LABEL_REF:
-	  return "mov.l	%1,%0\n\tmov.l	%1+4,%T0";
+	  return   "mov.l	%1,%0" "\n"
+		 "	mov.l	%1+4,%T0";
 	case POST_INC:
-	  return "mov.l	%1,%0\n\tmov.l	%1,%T0";
+	  return   "mov.l	%1,%0" "\n"
+		 "	mov.l	%1,%T0";
 	default:
 	  gcc_unreachable ();
 	}
 
   /* Work out the safe way to copy.  Copy into the second half first.  */
   if (dreg == ptrreg)
-	return "mov.l	%T1,%T0\n\tmov.l	%1,%0";
+	return "mov.l	%T1,%T0" "\n"
+	   "	mov.l	%1,%0";
 }
 
-  return "mov.l	%1,%0\n\tmov.l	%T1,%T0";
+  return   "mov.l	%1,%0" "\n"
+	 "	mov.l	%T1,%T0";
 }
 
 /* Print an instruction which would have gone into a delay slot after
@@ -2698,7 +2706,8 @@
   && offset - get_attr_length (insn) <= 32766)
 {
   far = 0;
-  jump = "mov.w	%O0,%1; braf	%1";
+  jump =   "mov.w	%O0,%1" "\n"
+	 "	braf	%1";
 }
   else
 {
@@ -2706,12 +2715,19 @@
   if (flag_pic)
 	{
 	  if (TARGET_SH2)
-	jump = "mov.l	%O0,%1; braf	%1";
+	jump = "mov.l	%O0,%1" "\n"
+		   "	braf	%1";
 	  else
-	jump = "mov.l	r0,@-r15; mova	%O0,r0; mov.l	@r0,%1; add	r0,%1; mov.l	@r15+,r0; jmp	@%1";
+	jump = "mov.l	r0,@-r15"	"\n"
+		   "	mova	%O0,r0"		"\n"
+		   "	mov.l	@r0,%1"		"\n"
+		   "	add	r0,%1"		"\n"
+		   "	mov.l	@r15+,r0"	"\n"
+		   "	jmp	@%1";
 	}
   else
-	jump = "mov.l	%O0,%1; jmp	@%1";
+	jump = "mov.l	%O0,%1" "\n"
+	   "	jmp	@%1";
 }
   /* If we have a scratch register available, use it.  */
   if (NONJUMP_INSN_P ((prev = prev_nonnote_insn (insn)))
@@ -2719,7 +2735,12 @@
 {
   this_jmp.reg = SET_DEST (XVECEXP (PATTERN (prev), 0, 0));
   if (REGNO (this_jmp.reg) == R0_REG && flag_pic && ! TARGET_SH2)
-	jump = "mov.l	r1,@-r15; mova	%O0,r0; mov.l	@r0,r1; add	r1,r0; mov.l	@r15+,r1; jmp	@%1";
+	jump = "mov.l	r1,@-r15"	"\n"
+	   "	mova	%O0,r0"		"\n"
+	   "	mov.l	@r0,r1"		"\n"
+	   "	add	r1,r0"		"\n"
+	   "	mov.l	@r15+,r1"	"\n"
+	   "	jmp	@%1";
   output_asm_insn (jump, &this_jmp.lab);
   if (dbr_sequence_length ())
 	print_slot (final_sequence);
@@ -2738,12 +2759,12 @@
 	 need its value across jumps, so save r13 in it instead of in
 	 the stack.  */
   if (TARGET_SH5)
-	output_asm_insn ("lds	r13, macl", 0);
+	output_asm_insn ("lds	r13,macl", 0);
   else
 	output_asm_insn ("mov.l	r13,@-r15", 0);
   output_asm_insn (jump, &this_jmp.lab);
   if (TARGET_SH5)
-	output_asm_insn ("sts	macl, r13", 0);
+	output_asm_insn ("sts	macl,r13", 0);
   else
 	output_asm_insn ("mov.l	@r15+,r13", 0);
 }
@@ -2911,7 +2932,8 @@
 const char *
 output_ieee_ccmpeq (rtx insn, rtx *operands)
 {
-  return output_branchy_insn (NE, "bt\t%l9\n\tfcmp/eq\t%1,%0",
+  return output_branchy_insn (NE,  "bt	%l9" "\n"
+  "	fcmp/eq	%1,%0",
 			  insn, operands);
 }
 
@@ -11051,10 +11073,12 @@
 
   if (mode == SFmode)
 	INSN_REGMODE_WEIGHT (insn, mode) =
-	  find_insn_regmode_weight (insn, mode) + 2 * find_insn_regmode_weight (insn, DFmode);
+	  find_insn_regmode_weight (insn, mode)
+	  + 2 * find_insn_regmode_weight (insn, DFmode);
   else if (mode == SImode)
 	INSN_REGMODE_WEIGHT (insn, mode) =
-	  find_insn_regmode_weight (insn, mode) + 2 * find_insn_regmode_weight (insn, DImode);
+	  find_insn_regmode_weight (insn, mode)
+	  + 2 * find_insn_regmode_weight (insn, DImode);
 }
 }
 
@@ -11350,15 +

Re: libstdc++/55169

2012-11-02 Thread Paolo Carlini
... and this is what I'm actually going to commit, a shorter version in 
4_7-branch too. The issue I mentioned yesterday was actually trivial, we 
were just missing an overload. Note that I'm not convinced we couldn't 
clean up things even more, but certainly the issue as reported is 
completely fixed.


Tested x86_&4-linux.

Thanks,
Paolo.

/
2012-11-02  Paolo Carlini  

PR libstdc++/55169
* include/bits/random.h: Remove all uses of param().
(chi_squared_distribution<>::__generate_impl(_ForwardIterator,
_ForwardIterator, _UniformRandomNumberGenerator&): Declare
* include/bits/random.tcc: ... define.
* include/ext/random: Remove all uses of param().
Index: include/ext/random
===
--- include/ext/random  (revision 193087)
+++ include/ext/random  (working copy)
@@ -510,7 +510,7 @@
   template
result_type
operator()(_UniformRandomNumberGenerator& __urng)
-   { return this->operator()(__urng, this->param()); }
+   { return this->operator()(__urng, _M_param); }
 
   template
result_type
@@ -522,7 +522,7 @@
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
   _UniformRandomNumberGenerator& __urng)
-   { this->__generate(__f, __t, __urng, this->param()); }
+   { this->__generate(__f, __t, __urng, _M_param); }
 
   template
@@ -540,6 +540,16 @@
{ this->__generate_impl(__f, __t, __urng, __p); }
 
   /**
+   * @brief Return true if two beta distributions have the same
+   *parameters and the sequences that would be generated
+   *are equal.
+   */
+  friend bool
+  operator==(const beta_distribution& __d1,
+const beta_distribution& __d2)
+  { return __d1._M_param == __d2._M_param; }
+
+  /**
* @brief Inserts a %beta_distribution random number distribution
* @p __x into the output stream @p __os.
*
@@ -580,17 +590,6 @@
 };
 
   /**
-   * @brief Return true if two beta distributions have the same
-   *parameters and the sequences that would be generated
-   *are equal.
-   */
-  template
-inline bool
-operator==(const __gnu_cxx::beta_distribution<_RealType>& __d1,
-  const __gnu_cxx::beta_distribution<_RealType>& __d2)
-{ return __d1.param() == __d2.param(); }
-
-  /**
* @brief Return true if two beta distributions are different.
*/
   template
@@ -809,7 +808,7 @@
   template
result_type
operator()(_UniformRandomNumberGenerator& __urng)
-   { return this->operator()(__urng, this->param()); }
+   { return this->operator()(__urng, _M_param); }
 
   template
result_type
@@ -821,7 +820,7 @@
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
   _UniformRandomNumberGenerator& __urng)
-   { return this->__generate_impl(__f, __t, __urng, this->param()); }
+   { return this->__generate_impl(__f, __t, __urng, _M_param); }
 
   template
@@ -1073,7 +1072,7 @@
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
   _UniformRandomNumberGenerator& __urng)
-   { this->__generate(__f, __t, __urng, this->param()); }
+   { this->__generate(__f, __t, __urng, _M_param); }
 
   template
@@ -1098,7 +1097,7 @@
   friend bool
   operator==(const rice_distribution& __d1,
 const rice_distribution& __d2)
-  { return (__d1.param() == __d2.param()
+  { return (__d1._M_param == __d2._M_param
&& __d1._M_ndx == __d2._M_ndx
&& __d1._M_ndy == __d2._M_ndy); }
 
@@ -1296,7 +1295,7 @@
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
   _UniformRandomNumberGenerator& __urng)
-   { this->__generate(__f, __t, __urng, this->param()); }
+   { this->__generate(__f, __t, __urng, _M_param); }
 
   template
@@ -1321,7 +1320,7 @@
   friend bool
   operator==(const nakagami_distribution& __d1,
 const nakagami_distribution& __d2)
-  { return (__d1.param() == __d2.param()
+  { return (__d1._M_param == __d2._M_param
&& __d1._M_gd == __d2._M_gd); }
 
   /**
@@ -1532,7 +1531,7 @@
void
__generate(_ForwardIterator __f, _ForwardIterator __t,
   _UniformRandomNumberGenerator& __urng)
-   { this->__generate(__f, __t, __urng, this->param()); }
+   { this->__generate(__f, __t, __urng, _M_param); }
 
   template
@@ -1557,7 +1556,7 @@
   friend bool
   operator==(const pareto_distribution& __d1,
 const pareto_distribution& __d2)
-  { return (__d1.param() == __d2.param()
+  { return (__d1._M_param == __d2._M_param
&& __d1._M_ud == __d2._M_ud); }
 
   /**
@@ -1774,7 +1773,7 @@
void
__gener

Re: C++ (RFC) PATCH fix for PR55076 and PR53921

2012-11-02 Thread Markus Trippelsdorf
On 2012.10.27 at 09:02 +0200, Markus Trippelsdorf wrote:
> The problem here is that we end up with an INDIRECT_REF TREE_CODE with a
> null TREE_TYPE in lvalue_kind. Is this possible at that point, or does
> it point to a deeper underlying problem?

It looks like there is indeed a deeper problem. See PR53137, PR53697 and 
PR54431 (which are all dups of one another). 

For example:

templatestruct A
{
  void blah();
  void bar()
  {
[this] { blah(); } (); // crash without this->blah()
  }
};

int main()
{
  A a;
  a.bar();
}


-- 
Markus


Re: [PING^2] [C++ PATCH] Add overflow checking to __cxa_vec_new[23]

2012-11-02 Thread Florian Weimer

On 10/30/2012 05:30 PM, Florian Weimer wrote:

On 10/30/2012 05:17 PM, Paolo Carlini wrote:


Sorry, I don't know the code well enough to review your patch, but
since I'm in CC, I still don't understand why, instead of adding a
full libstdc++ testcase you are extending a C++ testcase, in old-deja
even, normally considered legacy.


AFAIK, this is the only place we have such a test.  I suppose I could it
put it into testsuite/18_support, but I would have to duplicate a bit of
the machinery of the original test case because I can't just write a
class and take the address of its constructor and destructor (whose
addresses are passed to the tested functions).  I really didn't want to
do that because there are some platform dependencies (the __ARM_EABI__
#ifdef).


I looked at this again and made a new copy of the test case instead.  It 
has been successfully tested on x86_64-redhat-linux-gnu.


Is this okay for trunk?

--
Florian Weimer / Red Hat Product Security Team

2012-11-02  Florian Weimer  

	* libsupc++/vec.cc (compute_size): New.
	(__cxa_vec_new2, __cxa_vec_new3): Use it.
	* testsuite/18_support/cxa_vec.cc: New.

diff --git a/libstdc++-v3/libsupc++/vec.cc b/libstdc++-v3/libsupc++/vec.cc
index 700c5ef..bfce117 100644
--- a/libstdc++-v3/libsupc++/vec.cc
+++ b/libstdc++-v3/libsupc++/vec.cc
@@ -1,6 +1,6 @@
 // New abi Support -*- C++ -*-
 
-// Copyright (C) 2000, 2001, 2003, 2004, 2009, 2011
+// Copyright (C) 2000-2012
 // Free Software Foundation, Inc.
 //  
 // This file is part of GCC.
@@ -59,6 +59,19 @@ namespace __cxxabiv1
   globals->caughtExceptions = p->nextException;
   globals->uncaughtExceptions += 1;
 }
+
+// Compute the total size with overflow checking.
+std::size_t compute_size(std::size_t element_count,
+			 std::size_t element_size,
+			 std::size_t padding_size)
+{
+  if (element_size && element_count > std::size_t(-1) / element_size)
+	throw std::bad_alloc();
+  std::size_t size = element_count * element_size;
+  if (size + padding_size < size)
+	throw std::bad_alloc();
+  return size + padding_size;
+}
   }
 
   // Allocate and construct array.
@@ -83,7 +96,8 @@ namespace __cxxabiv1
 		 void *(*alloc) (std::size_t),
 		 void (*dealloc) (void *))
   {
-std::size_t size = element_count * element_size + padding_size;
+std::size_t size
+  = compute_size(element_count, element_size, padding_size);
 char *base = static_cast  (alloc (size));
 if (!base)
   return base;
@@ -124,7 +138,8 @@ namespace __cxxabiv1
 		 void *(*alloc) (std::size_t),
 		 void (*dealloc) (void *, std::size_t))
   {
-std::size_t size = element_count * element_size + padding_size;
+std::size_t size
+  = compute_size(element_count, element_size, padding_size);
 char *base = static_cast(alloc (size));
 if (!base)
   return base;
diff --git a/libstdc++-v3/testsuite/18_support/cxa_vec.cc b/libstdc++-v3/testsuite/18_support/cxa_vec.cc
new file mode 100644
index 000..5558f22
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/cxa_vec.cc
@@ -0,0 +1,64 @@
+// { dg-do run }
+// Avoid use of none-overridable new/delete operators in shared
+// { dg-options "-static" { target *-*-mingw* } }
+// Test __cxa_vec routines
+// Copyright (C) 2000-2012 Free Software Foundation, Inc.
+// Contributed by Nathan Sidwell 7 Apr 2000 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// Allocate enough padding to hold an array cookie.
+#ifdef __ARM_EABI__
+static const size_t padding = 8;
+#else
+static const size_t padding = (sizeof (std::size_t));
+#endif
+
+// our pseudo ctors and dtors
+static abi::__cxa_cdtor_return_type ctor (void *x)
+{
+  abort ();
+}
+
+static abi::__cxa_cdtor_return_type dtor (void *x)
+{
+  abort ();
+}
+
+static const std::size_t large_size = std::size_t(1) << (sizeof(std::size_t) * 8 - 2);
+
+// allocate an array whose size causes an overflow during addition
+void test1 ()
+{
+  try
+{
+  abi::__cxa_vec_new (large_size, 4, padding, ctor, dtor);
+  abort ();
+}
+  catch (std::bad_alloc &)
+{
+}
+}
+
+// allocate an array whose size causes an overflow during multiplication
+void test2 ()
+{
+  try
+{
+  abi::__cxa_vec_new (std::size_t(-1) / 4, 4, padding, ctor, dtor);
+  abort ();
+}
+  catch (std::bad_alloc &)
+{
+}
+}
+
+int main ()
+{
+  test1 ();
+  test2 ();
+}


Fix minor inaccuracy with EDGE_SIBCALL

2012-11-02 Thread Eric Botcazou
cfg-flags.def reads:

 /* Edge out of a basic block that ends with a CALL_INSN with abnormal
exit, like an exception, or a sibcall.
This flag is only used for the RTL CFG.  */
 DEF_EDGE_FLAG(ABNORMAL_CALL, 2)

That's wrong, ABNORMAL_CALL isn't set for a sibcall, only ABNORMAL is.
That's even asserted in purge_dead_edges:

  else if (CALL_P (insn) && SIBLING_CALL_P (insn))
{
  /* First, there should not be any EH or ABCALL edges resulting
 from non-local gotos and the like.  If there were, we shouldn't
 have created the sibcall in the first place.  Second, there
 should of course never have been a fallthru edge.  */
  gcc_assert (single_succ_p (bb));
  gcc_assert (single_succ_edge (bb)->flags
  == (EDGE_SIBCALL | EDGE_ABNORMAL));

  return 0;
}

This means that the EDGE_ABNORMAL check in rtl_verify_flow_info_1 is wrong as 
well.  But it contains a thinko that masks the bug. :-)

Tested on x86_64-suse-linux, applied on the mainline.


2012-11-02  Eric Botcazou  

* cfg-flags.def (ABNORMAL_CALL): Fix comment.
(EH): Likewise.
(SIBCALL): Likewise.
* cfgrtl.c (rtl_verify_flow_info_1): Adjust error messages.
Deal with EDGE_SIBCALL and fix the EDGE_ABNORMAL check.


-- 
Eric BotcazouIndex: cfg-flags.def
===
--- cfg-flags.def	(revision 193090)
+++ cfg-flags.def	(working copy)
@@ -115,13 +115,14 @@ DEF_EDGE_FLAG(FALLTHRU, 0)
 DEF_EDGE_FLAG(ABNORMAL, 1)
 
 /* Edge out of a basic block that ends with a CALL_INSN with abnormal
-   exit, like an exception, or a sibcall.
+   exit, like an exception or a non-local goto.
+   ABNORMAL_CALL edges also have ABNORMAL set.
This flag is only used for the RTL CFG.  */
 DEF_EDGE_FLAG(ABNORMAL_CALL, 2)
 
 /* Exception edge.  Exception handling edges represent possible control
-   transfers from a trapping instruction to an exception handler.  EH
-   edges also have EDGE_ABNORMAL set.  */
+   transfers from a trapping instruction to an exception handler.
+   EH edges also have ABNORMAL set for the RTL CFG.  */
 DEF_EDGE_FLAG(EH, 3)
 
 /* Never merge blocks via this edge.  This is used for exception handling,
@@ -158,6 +159,7 @@ DEF_EDGE_FLAG(EXECUTABLE, 10)
 DEF_EDGE_FLAG(CROSSING, 11)
 
 /* Edge from a sibcall CALL_INSN to exit.
+   SIBCALL edges also have ABNORMAL set.
This flag is only used for the RTL CFG.  */
 DEF_EDGE_FLAG(SIBCALL, 12)
 
Index: cfgrtl.c
===
--- cfgrtl.c	(revision 193090)
+++ cfgrtl.c	(working copy)
@@ -2095,7 +2095,8 @@ rtl_verify_flow_info_1 (void)
   /* Now check the basic blocks (boundaries etc.) */
   FOR_EACH_BB_REVERSE (bb)
 {
-  int n_fallthru = 0, n_eh = 0, n_call = 0, n_abnormal = 0, n_branch = 0;
+  int n_fallthru = 0, n_branch = 0, n_abnormal_call = 0, n_sibcall = 0;
+  int n_eh = 0, n_abnormal = 0;
   edge e, fallthru = NULL;
   rtx note;
   edge_iterator ei;
@@ -2132,13 +2133,13 @@ rtl_verify_flow_info_1 (void)
 		}
 	  if (e->flags & EDGE_FALLTHRU)
 		{
-		  error ("fallthru edge crosses section boundary (bb %i)",
+		  error ("fallthru edge crosses section boundary in bb %i",
 			 e->src->index);
 		  err = 1;
 		}
 	  if (e->flags & EDGE_EH)
 		{
-		  error ("EH edge crosses section boundary (bb %i)",
+		  error ("EH edge crosses section boundary in bb %i",
 			 e->src->index);
 		  err = 1;
 		}
@@ -2158,22 +2159,26 @@ rtl_verify_flow_info_1 (void)
 	n_branch++;
 
 	  if (e->flags & EDGE_ABNORMAL_CALL)
-	n_call++;
+	n_abnormal_call++;
+
+	  if (e->flags & EDGE_SIBCALL)
+	n_sibcall++;
 
 	  if (e->flags & EDGE_EH)
 	n_eh++;
-	  else if (e->flags & EDGE_ABNORMAL)
+
+	  if (e->flags & EDGE_ABNORMAL)
 	n_abnormal++;
 	}
 
   if (n_eh && !find_reg_note (BB_END (bb), REG_EH_REGION, NULL_RTX))
 	{
-	  error ("missing REG_EH_REGION note in the end of bb %i", bb->index);
+	  error ("missing REG_EH_REGION note at the end of bb %i", bb->index);
 	  err = 1;
 	}
   if (n_eh > 1)
 	{
-	  error ("too many eh edges %i", bb->index);
+	  error ("too many exception handling edges in bb %i", bb->index);
 	  err = 1;
 	}
   if (n_branch
@@ -2186,29 +2191,35 @@ rtl_verify_flow_info_1 (void)
 	}
   if (n_fallthru && any_uncondjump_p (BB_END (bb)))
 	{
-	  error ("fallthru edge after unconditional jump %i", bb->index);
+	  error ("fallthru edge after unconditional jump in bb %i", bb->index);
 	  err = 1;
 	}
   if (n_branch != 1 && any_uncondjump_p (BB_END (bb)))
 	{
-	  error ("wrong number of branch edges after unconditional jump %i",
-		 bb->index);
+	  error ("wrong number of branch edges after unconditional jump"
+		 " in bb %i", bb->index);
 	  err = 1;
 	}
   if (n_branch != 1 && any_condjump_p (BB_END (bb))
 	  && JUMP_LABEL (BB_END (bb)) != BB_HEAD (fallthru->dest))
 	{
-	  error ("wrong amount of branch edges after conditio

Re: [PING^2] [C++ PATCH] Add overflow checking to __cxa_vec_new[23]

2012-11-02 Thread Paolo Carlini

On 11/02/2012 01:09 PM, Florian Weimer wrote:
I looked at this again and made a new copy of the test case instead.  
It has been successfully tested on x86_64-redhat-linux-gnu.


Is this okay for trunk?
Looks very nice to me, and after all the issue seems rather simple. 
Let's say we wait another 2-3 days in case Jason and others have 
comments, and then it's Ok for mainline.


Thanks!
Paolo.



Re: [patch, lra, pr55103, committed] Save lra_int struct.

2012-11-02 Thread Vladimir Makarov

On 12-11-01 7:15 PM, Steve Ellcey wrote:

I checked in this patch as obvious.  It fixes PR 55103 which is a compiler
abort on MIPS with the -mips16 flag.  After committing I realized I forgot
to put the bug number in the ChangeLog, I will update PR 55103 by hand.


Thanks, Steve.



Re: [ping] Re: [patch v2] support for multiarch systems

2012-11-02 Thread Matthias Klose

On 07.08.2012 16:07, Ian Lance Taylor wrote:

On Tue, Aug 7, 2012 at 3:31 AM, Matthias Klose  wrote:

ping?

On 08.07.2012 20:48, Matthias Klose wrote:

Please find attached v2 of the patch updated for trunk 20120706, x86 only, 
tested on
x86-linux-gnu, KFreeBSD and the Hurd.



+[case "${withval}" in
+yes|no|auto-detect) enable_multiarch=$withval;;
+*) AC_MSG_ERROR(bad value ${withval} given for --enable-multiarch option) ;;


Please just use "auto", not "auto-detect", as in libgcc/configure.ac.


ok.


+# needed for setting the multiarch name on ARM
+AC_SUBST(with_float)


This seems like it should be in a different patch.


+with_float = @with_float@


Likewise.


I was asked to split the ix86 and infrastructure bits from the bits for all
other architectures. I think it does belong here. The with_float macro is then
used for e.g. ARM to distinguish between hard and soft float triplets.


+ifeq ($(enable_multiarch),yes)
+  if_multiarch = $(1)
+else ifeq ($(enable_multiarch),auto-detect)
+  if_multiarch = $(if $(wildcard $(shell echo
$(SYSTEM_HEADER_DIR))/../../usr/lib/*/crti.o),$(1))
+else
+  if_multiarch =
+endif

This is nicely tricky but I don't understand why you are doing this in
such a confusing way.  Why not simply set the names in config.gcc?
What information do you have at make time that you don't have at
configure time?


this is for the auto case. SYSTEM_HEADER_DIR is not accessible/available from
config.gcc. This is the same approach as taken for MULTILIB_OSDDIRNAMES. Also 
setting the names for the multiarch directories in the same place as done for 
for the MULTILIB_OSDIRNAMES seems to be better choice.



The auto case is not general.  When cross-compiling without --sysroot,
or when using --native-system-header-dir, the test won't work.
Without --sysroot there may not be much that you can do to auto-detect
multiarch.  And with --sysroot, there should be no need to use
SYSTEM_HEADER_DIR at all; just look in the sysroot.


+@item --enable-multiarch
+Specify wether to enable or disable multiarch support.  The default is
+to detect for glibc start files in a multiarch location, and enable it
+if the files are found.


This is quite obscure for anybody who does not already know what multiarch is.


I did add the pointer to multiarch, which already is in fragments.texi:

  More documentation about multiarch can be found at
  @uref{http://wiki.debian.org/Multiarch}.

The feedback about what and where information about multiarch should be added, 
changes from reviewer to reviewer.


Attaching the updated patch.


I'm sorry, I have to repeat my extreme annoyance that this scheme
breaks all earlier GCC releases.


yes, this is mentioned at http://bugs.debian.org/637232 too. I proposed a patch 
to add a libc6-dev-compat binary package which can be installed together with 
the existing libc6-dev packages.


  Matthias
2012-11-02  Matthias Klose  

	* doc/invoke.texi: Document -print-multiarch.
	* doc/install.texi: Document --enable-multiarch.
	* doc/fragments.texi: Document MULTILIB_OSDIRNAMES, MULTIARCH_DIRNAME.
	* configure.ac: Add --enable-multiarch option.
	* configure: Regenerate.
	* Makefile.in (s-mlib): Pass MULTIARCH_DIRNAME to genmultilib.
	enable_multiarch, with_float: New macros.
	if_multiarch: New macro, define in terms of enable_multiarch.
	* genmultilib: Add new argument for the multiarch name.
	* gcc.c (multiarch_dir): Define.
	(for_each_path): Search for multiarch suffixes.
	(driver_handle_option): Handle multiarch option.
	(do_spec_1): Pass -imultiarch if defined.
	(main): Print multiarch.
	(set_multilib_dir): Separate multilib and multiarch names
	from multilib_select.
	(print_multilib_info): Ignore multiarch names in multilib_select.
	* incpath.c (add_standard_paths): Search the multiarch include dirs.
	* cppdeault.h (default_include): Document multiarch in multilib
	member.
	* cppdefault.c: [LOCAL_INCLUDE_DIR, STANDARD_INCLUDE_DIR] Add an
include directory for multiarch directories.
	* common.opt: New options --print-multiarch and -imultilib.
	* config.gcc  (tmake_file):
	Include i386/t-linux.
	 (tmake_file):
	Include i386/t-kfreebsd.
	 (tmake_file): Include i386/t-gnu.
	* config/i386/t-linux64: Add multiarch names in
	MULTILIB_OSDIRNAMES, define MULTIARCH_DIRNAME.
	* config/i386/t-gnu: New file.
	* config/i386/t-kfreebsd: Likewise.
	* config/i386/t-linux: Likewise.


Index: gcc/config/i386/t-linux64
===
--- gcc/config/i386/t-linux64	(revision 193062)
+++ gcc/config/i386/t-linux64	(working copy)
@@ -34,6 +34,6 @@
 comma=,
 MULTILIB_OPTIONS= $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
 MULTILIB_DIRNAMES   = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
-MULTILIB_OSDIRNAMES = m64=../lib64
-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)
-MULTILIB_OSDIRNAMES+= mx32=../libx32
+MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-

Re: [tsan] ThreadSanitizer instrumentation part

2012-11-02 Thread Martin Jambor
Hi,

On Thu, Nov 01, 2012 at 11:11:13AM -0700, Xinliang David Li wrote:
> 

...

> The TREE_ADDRESSABLE check seems redundant -- if the var_decl (instead
> of ssa name) appears in the assignment, why would it not be
> 'addressable'? 

There are other reason beside being TREE_ADDRESSABLE that may cause a
"gimple scalar" type variable not to be in SSA form.  Usually this
means that there is a write access to only a part of it.  This happens
often with vector or complex types which are deemed scalar types by
gimple but are obviously quite special.  Such decls have their
DECL_GIMPLE_REG_P cleared.

Martin


[PATCH, i386]: Fix PR55175, i386/sfp-exceptions.c:52:7: error: impossible constraint in 'asm'

2012-11-02 Thread Uros Bizjak
Hello!

Attached patch disable exceptions and rounding mode handling code in
soft-fp when _SOFT_FLOAT is enabled. We need real hardware (x87 or
SSE) to generate exceptions and real control register to know current
rounding mode.

RTEMS defines _SOFT_FLOAT, when -msoft-float is in effetct and this
macro is what patch uses to disable relevant code.

2012-11-02  Uros Bizjak  

PR target/55175
* config/i386/sfp-exceptions.c: Guard with _SOFT_FLOAT.
* config/i386/sfp-machine.h: Guard exception handling
code with _SOFT_FLOAT.
* config/i386/32/sfp-machine.h: Guard rounding handling
code with _SOFT_FLOAT.
* config/i386/64/sfp-machine.h: Ditto.

Patch was bootstrapped and regression tested on x86_64-pc-linux-gnu,
also bootstrapped on RTEMS by Joel.

Patch was committed to mainline SVN.

Uros.
Index: config/i386/32/sfp-machine.h
===
--- config/i386/32/sfp-machine.h(revision 193091)
+++ config/i386/32/sfp-machine.h(working copy)
@@ -77,6 +77,7 @@
 #define _FP_NANFRAC_E  _FP_QNANBIT_E, 0, 0, 0
 #define _FP_NANFRAC_Q  _FP_QNANBIT_Q, 0, 0, 0
 
+#ifndef _SOFT_FLOAT
 #define FP_RND_NEAREST 0
 #define FP_RND_ZERO0xc00
 #define FP_RND_PINF0x800
@@ -91,3 +92,4 @@
   do { \
 __asm__ __volatile__ ("fnstcw\t%0" : "=m" (_fcw)); \
   } while (0)
+#endif
Index: config/i386/64/sfp-machine.h
===
--- config/i386/64/sfp-machine.h(revision 193091)
+++ config/i386/64/sfp-machine.h(working copy)
@@ -18,6 +18,7 @@
 #define _FP_NANFRAC_E  _FP_QNANBIT_E, 0
 #define _FP_NANFRAC_Q  _FP_QNANBIT_Q, 0
 
+#ifndef _SOFT_FLOAT
 #define FP_RND_NEAREST 0
 #define FP_RND_ZERO0x6000
 #define FP_RND_PINF0x4000
@@ -32,3 +33,4 @@
   do { \
 __asm__ __volatile__ ("%vstmxcsr\t%0" : "=m" (_fcw));  \
   } while (0)
+#endif
Index: config/i386/sfp-exceptions.c
===
--- config/i386/sfp-exceptions.c(revision 193091)
+++ config/i386/sfp-exceptions.c(working copy)
@@ -21,6 +21,7 @@
  * .
  */
 
+#ifndef _SOFT_FLOAT
 #include "sfp-machine.h"
 
 struct fenv
@@ -88,3 +89,4 @@
   asm volatile ("fwait");
 }
 };
+#endif
Index: config/i386/sfp-machine.h
===
--- config/i386/sfp-machine.h   (revision 193091)
+++ config/i386/sfp-machine.h   (working copy)
@@ -40,6 +40,7 @@
 R##_c = FP_CLS_NAN;\
   } while (0)
 
+#ifndef _SOFT_FLOAT
 #define FP_EX_INVALID  0x01
 #define FP_EX_DENORM   0x02
 #define FP_EX_DIVZERO  0x04
@@ -56,6 +57,7 @@
   } while (0);
 
 #define FP_ROUNDMODE   (_fcw & FP_RND_MASK)
+#endif
 
 #define__LITTLE_ENDIAN 1234
 #define__BIG_ENDIAN4321


Re: [PATCH 06/13] Implement protection of stack variables

2012-11-02 Thread Dodji Seketeli
Konstantin Serebryany  writes:

>> [A cultural question I've kept asking myself is Why has address
>>  sanitizer authors called these red zones (LEFT, MIDDLE, RIGHT)
>>  instead of e.g, (BOTTOM, MIDDLE, TOP).  Maybe they can step up and
>>  educate me so that I get less confused in the future.  :-)]
>>
>
> Ha! Good question. I guess that's related to the way we explained it in the
> paper,
> where the chunk of memory was typeset horizontally to save space.

Ah, which paper?  The only 'paper' I have seen is the pdf of you talk
you gave at GNU Cauldron this summer[1] and it didn't explain the stack
protection scheme in those terms or detail.

[1]: 
http://gcc.gnu.org/wiki/cauldron2012?action=AttachFile&do=get&target=kcc.pdf

> Btw, are we still using -fasan option, or did we change it to
> -faddress-sanitizer?

The later.  As I said in my reply to David, I am going to resubmit a
patch that exposes that change as part of the initial import patch of
the series.

Cheers.

-- 
Dodji


patch to fix PR55130

2012-11-02 Thread Vladimir Makarov

  The following patch fixes PR55130

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

  The reason for the crash was in missed processing clobber insn with 
pseudo changed on its equivalent memory.  It resulted in presence of the 
pseudo and in trying to remove equiv initialization insn the second time.


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

  Committed as rev. 193096.

2012-11-02  Vladimir Makarov  

PR middle-end/55130
* lra-constraints.c (debug_loc_equivalence_change_p): Rename to
loc_equivalence_change_p.
(lra_constraints): Check equiv_insn_bitmap for debug insn.  Call
loc_equivalence_change_p for non-transformed insn.

2012-11-02  Vladimir Makarov  

PR middle-end/55150
* gcc.target/i386/pr55130.c: New test.


Index: lra-constraints.c
===
--- lra-constraints.c   (revision 193065)
+++ lra-constraints.c   (working copy)
@@ -3095,10 +3095,10 @@ contains_reg_p (rtx x, bool hard_reg_p,
   return false;
 }
 
-/* Process all regs in debug location *LOC and change them on
-   equivalent substitution.  Return true if any change was done.  */
+/* Process all regs in location *LOC and change them on equivalent
+   substitution.  Return true if any change was done.  */
 static bool
-debug_loc_equivalence_change_p (rtx *loc)
+loc_equivalence_change_p (rtx *loc)
 {
   rtx subst, reg, x = *loc;
   bool result = false;
@@ -3130,11 +3130,11 @@ debug_loc_equivalence_change_p (rtx *loc
   for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
 {
   if (fmt[i] == 'e')
-   result = debug_loc_equivalence_change_p (&XEXP (x, i)) || result;
+   result = loc_equivalence_change_p (&XEXP (x, i)) || result;
   else if (fmt[i] == 'E')
for (j = XVECLEN (x, i) - 1; j >= 0; j--)
  result
-   = debug_loc_equivalence_change_p (&XVECEXP (x, i, j)) || result;
+   = loc_equivalence_change_p (&XVECEXP (x, i, j)) || result;
 }
   return result;
 }
@@ -3322,7 +3322,6 @@ lra_constraints (bool first_p)
  substituted by their equivalences.  */
   EXECUTE_IF_SET_IN_BITMAP (&equiv_insn_bitmap, 0, uid, bi)
 lra_push_insn_by_uid (uid);
-  bitmap_clear (&equiv_insn_bitmap);
   lra_eliminate (false);
   min_len = lra_insn_stack_length ();
   new_insns_num = 0;
@@ -3353,7 +3352,8 @@ lra_constraints (bool first_p)
  /* We need to check equivalence in debug insn and change
 pseudo to the equivalent value if necessary.  */
  curr_id = lra_get_insn_recog_data (curr_insn);
- if (debug_loc_equivalence_change_p (curr_id->operand_loc[0]))
+ if (bitmap_bit_p (&equiv_insn_bitmap, INSN_UID (curr_insn))
+ && loc_equivalence_change_p (curr_id->operand_loc[0]))
{
  lra_update_insn_regno_info (curr_insn);
  changed_p = true;
@@ -3417,8 +3417,18 @@ lra_constraints (bool first_p)
  init_curr_operand_mode ();
  if (curr_insn_transform ())
changed_p = true;
+ /* Check non-transformed insns too for equiv change as USE
+or CLOBBER don't need reloads but can contain pseudos
+being changed on their equivalences.  */
+ else if (bitmap_bit_p (&equiv_insn_bitmap, INSN_UID (curr_insn))
+  && loc_equivalence_change_p (&PATTERN (curr_insn)))
+   {
+ lra_update_insn_regno_info (curr_insn);
+ changed_p = true;
+   }
}
 }
+  bitmap_clear (&equiv_insn_bitmap);
   /* If we used a new hard regno, changed_p should be true because the
  hard reg is assigned to a new pseudo.  */
 #ifdef ENABLE_CHECKING
Index: testsuite/gcc.target/i386/pr55130.c
===
--- testsuite/gcc.target/i386/pr55130.c (revision 0)
+++ testsuite/gcc.target/i386/pr55130.c (working copy)
@@ -0,0 +1,15 @@
+/* PR middle-end/55130 */
+/* { dg-do compile { target ia32 } } */
+/* { dg-options "-O1 -mregparm=3 -mpreferred-stack-boundary=2" } */
+
+extern void bar(long long);
+
+int foo(long long a, char b, long long c, long long d)
+{
+  if (c == 0)
+c = d;
+
+  bar(b + c);
+
+  return a == d;
+}


Re: patch to fix PR55130

2012-11-02 Thread Vladimir Makarov

On 12-11-02 10:45 AM, Vladimir Makarov wrote:

  The following patch fixes PR55130

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

  The reason for the crash was in missed processing clobber insn with 
pseudo changed on its equivalent memory.  It resulted in presence of 
the pseudo and in trying to remove equiv initialization insn the 
second time.


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

  Committed as rev. 193096.

2012-11-02  Vladimir Makarov  

PR middle-end/55150
Sorry, I've made a mistake.  It should be PR middle-end/55130.   I just 
fixed the typo.

* gcc.target/i386/pr55130.c: New test.






Re: [PATCH 06/13] Implement protection of stack variables

2012-11-02 Thread Dodji Seketeli
Xinliang David Li  writes:

> Changing the option is part of the plan.

Indeed.

> Dodji, can you make the option change part of one the patches (e.g,
> the first one that introduces it) -- there seems no need for a
> separate patch for it.

Sure thing.  I have done the change on my local tree.  I'll re-submit
the patch a bit later.  I am doing a bit of patch merging along with
that one, in reply to the comments made by Joseph in another subtread.

Cheers.

-- 
Dodji


Re: [tsan] ThreadSanitizer instrumentation part

2012-11-02 Thread Xinliang David Li
Thanks, good to know that.

David

On Fri, Nov 2, 2012 at 6:31 AM, Martin Jambor  wrote:
> Hi,
>
> On Thu, Nov 01, 2012 at 11:11:13AM -0700, Xinliang David Li wrote:
>>
>
> ...
>
>> The TREE_ADDRESSABLE check seems redundant -- if the var_decl (instead
>> of ssa name) appears in the assignment, why would it not be
>> 'addressable'?
>
> There are other reason beside being TREE_ADDRESSABLE that may cause a
> "gimple scalar" type variable not to be in SSA form.  Usually this
> means that there is a write access to only a part of it.  This happens
> often with vector or complex types which are deemed scalar types by
> gimple but are obviously quite special.  Such decls have their
> DECL_GIMPLE_REG_P cleared.
>
> Martin


Re: [tsan] ThreadSanitizer instrumentation part

2012-11-02 Thread Jakub Jelinek
On Fri, Nov 02, 2012 at 08:54:42AM -0700, Xinliang David Li wrote:
> Thanks, good to know that.

But note that such vars, even when accessed only partially, don't
need to be tracked by tsan just because of that.
TREE_ADDRESSABLE (decl) || is_global_var (decl) is really a conservative
check for what needs to be tracked, and perhaps less conservative one using
points-to.

Jakub


Re: [PATCH 06/13] Implement protection of stack variables

2012-11-02 Thread Dodji Seketeli
Konstantin Serebryany  writes:

> http://research.google.com/pubs/archive/37752.pdf
> The horizontal drawing is given in section 3.3 and hence the redzones there
> are called left/right.
> The stack poisoning is only explained using an example in C.

Great, thanks.  This makes it easier to understand the whole thing than
starring at source code and asm dumps of asan@{llvm,gcc}.  :)

Cheers.

-- 
Dodji


Re: [tsan] ThreadSanitizer instrumentation part

2012-11-02 Thread Xinliang David Li
Yes, agree.  For now using the !(TREE_ADDRESSABLE (decl)  ||
is_global_var (decl)) can be used to skip instrumentation if the
points-to interface is not available for use.

David

On Fri, Nov 2, 2012 at 8:58 AM, Jakub Jelinek  wrote:
> On Fri, Nov 02, 2012 at 08:54:42AM -0700, Xinliang David Li wrote:
>> Thanks, good to know that.
>
> But note that such vars, even when accessed only partially, don't
> need to be tracked by tsan just because of that.
> TREE_ADDRESSABLE (decl) || is_global_var (decl) is really a conservative
> check for what needs to be tracked, and perhaps less conservative one using
> points-to.
>
> Jakub


[PATCH] Add check for x32 support

2012-11-02 Thread Jack Howarth
  Currently on targets like x86_64 darwin which don't support -mx32 
-maddress-mode=short,
tests that pass those on dg-options fail with excessive errors at -m64. The 
attached patch
resolves this by adding a check_effective_target_maybe_x32 proc to test if the 
-mx32
-maddress-mode=short flags are supported. Tested on x86_64-apple-darwin12. Okay 
for
gcc trunk?
 Jack

2012-11-02  H.J. Lu  
Jack Howarth  

* lib/target-supports.exp (check_effective_target_maybe_x32): New proc.
* gcc.target/i386/pr54457.c: Use dg-require-effective-target maybe_x32.
* gcc.target/i386/pr53249.c: Likewise.


Index: gcc/testsuite/gcc.target/i386/pr54457.c
===
--- gcc/testsuite/gcc.target/i386/pr54457.c (revision 193097)
+++ gcc/testsuite/gcc.target/i386/pr54457.c (working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target { ! { ia32 } } } } */
+/* { dg-require-effective-target maybe_x32 } */
 /* { dg-options "-O2 -mx32 -maddress-mode=short" } */
 
 extern char array[40];
Index: gcc/testsuite/gcc.target/i386/pr53249.c
===
--- gcc/testsuite/gcc.target/i386/pr53249.c (revision 193097)
+++ gcc/testsuite/gcc.target/i386/pr53249.c (working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile { target { ! { ia32 } } } } */
+/* { dg-require-effective-target maybe_x32 } */
 /* { dg-options "-O2 -mx32 -ftls-model=initial-exec -maddress-mode=short" } */
 
 struct gomp_task
Index: gcc/testsuite/lib/target-supports.exp
===
--- gcc/testsuite/lib/target-supports.exp   (revision 193097)
+++ gcc/testsuite/lib/target-supports.exp   (working copy)
@@ -4608,6 +4608,14 @@ proc check_effective_target_lto { } {
 return [info exists ENABLE_LTO]
 }
 
+# Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
+
+proc check_effective_target_maybe_x32 { } {
+return [check_no_compiler_messages maybe_x32 object {
+void foo (void) {}
+} "-mx32 -maddress-mode=short"]
+}
+
 # Return 1 if this target supports the -fsplit-stack option, 0
 # otherwise.
 


[patch, committed] libquadmath: Small fmaq and lgamma update

2012-11-02 Thread Tobias Burnus
The attached patch ports Joseph's GLIBC fmal patch from today; 
additionally, I made a small adjustment to lgamma's signgam handling.


Build and tested on x86-64-gnu-linux and applied as Rev. 193099


Otherwise, it still applies what I wrote at 
http://gcc.gnu.org/ml/gcc-patches/2012-11/msg00042.html:


Besides those isses [i.e. the test failures], one should - as mentioned 
in the yesterday's thread - update strtod and printf; the GLIBC test 
should be modified in such a way that they work properly. I would also 
like to see the test automatically be run (with "make test") and 
possibly to have some additional DejaGNU support for 
libquadmath-specific tests. (One could also add support for __complex__ 
__float128 as Andreas suggested.)


Tobias
2012-11-01  Tobias Burnus  
	Joseph Myers  

* math/fmaq.c (fmaq): Merge from GLIBC. Handle cases
	with small x * y using scaling, not as x * y + z.
	* math/lgammaq.c (lgammaq): Fix to signgam handling.

diff --git a/libquadmath/math/fmaq.c b/libquadmath/math/fmaq.c
index 5616c1a..e5a9d37 100644
--- a/libquadmath/math/fmaq.c
+++ b/libquadmath/math/fmaq.c
@@ -73,6 +73,37 @@ fmaq (__float128 x, __float128 y, __float128 z)
 	  || u.ieee.exponent + v.ieee.exponent
 	 < IEEE854_FLOAT128_BIAS - FLT128_MANT_DIG - 2)
 	return x * y + z;
+  /* If x * y is less than 1/4 of FLT128_DENORM_MIN, neither the
+	 result nor whether there is underflow depends on its exact
+	 value, only on its sign.  */
+  if (u.ieee.exponent + v.ieee.exponent
+	  < IEEE854_FLT128_DOUBLE_BIAS - FLT128_MANT_DIG - 2)
+	{
+	  int neg = u.ieee.negative ^ v.ieee.negative;
+	  __float128 tiny = neg ? -0x1p-16494L : 0x1p-16494L;
+	  if (w.ieee.exponent >= 3)
+	return tiny + z;
+	  /* Scaling up, adding TINY and scaling down produces the
+	 correct result, because in round-to-nearest mode adding
+	 TINY has no effect and in other modes double rounding is
+	 harmless.  But it may not produce required underflow
+	 exceptions.  */
+	  v.value = z * 0x1p114L + tiny;
+	  if (TININESS_AFTER_ROUNDING
+	  ? v.ieee.exponent < 115
+	  : (w.ieee.exponent == 0
+		 || (w.ieee.exponent == 1
+		 && w.ieee.negative != neg
+		 && w.ieee.mantissa3 == 0
+		 && w.ieee.mantissa2 == 0
+		 && w.ieee.mantissa1 == 0
+		 && w.ieee.mantissa0 == 0)))
+	{
+	  volatile __float128 force_underflow = x * y;
+	  (void) force_underflow;
+	}
+	  return v.value * 0x1p-114L;
+	}
   if (u.ieee.exponent + v.ieee.exponent
 	  >= 0x7fff + IEEE854_FLOAT128_BIAS - FLT128_MANT_DIG)
 	{
@@ -228,17 +259,17 @@ fmaq (__float128 x, __float128 y, __float128 z)
 	 for proper rounding.  */
   if (v.ieee.exponent == 226)
 	{
- /* If the exponent would be in the normal range when
-rounding to normal precision with unbounded exponent
-range, the exact result is known and spurious underflows
-must be avoided on systems detecting tininess after
-rounding.  */
- if (TININESS_AFTER_ROUNDING)
-   {
- w.value = a1 + u.value;
- if (w.ieee.exponent == 227)
-   return w.value * 0x1p-226L;
-   }
+	  /* If the exponent would be in the normal range when
+	 rounding to normal precision with unbounded exponent
+	 range, the exact result is known and spurious underflows
+	 must be avoided on systems detecting tininess after
+	 rounding.  */
+	  if (TININESS_AFTER_ROUNDING)
+	{
+	  w.value = a1 + u.value;
+	  if (w.ieee.exponent == 227)
+		return w.value * 0x1p-226L;
+	}
 	  /* v.ieee.mant_low & 2 is LSB bit of the result before rounding,
 	 v.ieee.mant_low & 1 is the round bit and j is our sticky
 	 bit. */
diff --git a/libquadmath/math/lgammaq.c b/libquadmath/math/lgammaq.c
index 361f703..485939a 100644
--- a/libquadmath/math/lgammaq.c
+++ b/libquadmath/math/lgammaq.c
@@ -759,7 +759,8 @@ lgammaq (__float128 x)
 {
   __float128 p, q, w, z, nx;
   int i, nn;
-  int sign;
+
+  signgam = 1;
 
   if (! finiteq (x))
 return x * x;
@@ -767,11 +768,9 @@ lgammaq (__float128 x)
   if (x == 0.0Q)
 {
   if (signbitq (x))
-	sign = -1;
+	signgam = -1;
 }
 
-  signgam = sign;
-
   if (x < 0.0Q)
 {
   q = -x;
@@ -780,9 +779,9 @@ lgammaq (__float128 x)
 	return (one / (p - p));
   i = p;
   if ((i & 1) == 0)
-	sign = -1;
+	signgam = -1;
   else
-	sign = 1;
+	signgam = 1;
   z = q - p;
   if (z > 0.5Q)
 	{
@@ -790,10 +789,8 @@ lgammaq (__float128 x)
 	  z = p - q;
 	}
   z = q * sinq (PIQ * z);
-  signgam = sign;
-
   if (z == 0.0Q)
-	return (sign * huge * huge);
+	return (signgam * huge * huge);
   w = lgammaq (q);
   z = logq (PIQ / z) - w;
   return (z);
@@ -1025,7 +1022,7 @@ lgammaq (__float128 x)
 }
 
   if (x > MAXLGM)
-return (sign * huge * huge);
+return (signgam * huge * huge);
 
   q = ls2pi - x;
   q = (x - 0.5Q) * logq (x) + q;


Re: [PR54693] loss of debug info in jump threading and loop ivopts

2012-11-02 Thread Jeff Law

On 11/02/2012 02:08 AM, Jakub Jelinek wrote:

On Thu, Nov 01, 2012 at 10:27:57AM +0100, Jakub Jelinek wrote:

The patch unfortunately doesn't speed test-tgmath2.i compilation
significantly, but decreases number of debug stmts from ~ 36000 to ~ 16000,
the 2+ were clearly redundant.


Testing found a buglet in the patch (doing is_gimple_debug (gsi_stmt (gsi))
even when there might be no stmts after labels in the successor at all),
fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2012-11-02  Jakub Jelinek  

PR debug/54402
* tree-ssa-threadedge.c (thread_around_empty_block): Don't copy over
debug stmts if the successor bb already starts with a debug stmt for
the same var.

OK.
Jeff



[RFC PATCH] Masked load/store vectorization

2012-11-02 Thread Jakub Jelinek
Hi!

This is a RFC patch which implements masked (conditional) vector
loads/stores roughly as discussed with richi (i.e. internal function
calls, added during if-conversion pass, and if not vectorized
removed after vectorization again).
The if-unconversion pass is just very basic, I guess it could often
do better job by trying to guess which statements in the bb with
MASK_LOAD/MASK_STORE were in which bb, depending on what condition,
because right now vrp2 is able to fix up something, but not undo
COND_EXPRs on PHI nodes, and there is no sink pass after vect.

Testcases it can handle include e.g.
extern void abort (void);

__attribute__((noinline, noclone)) void
foo (float *__restrict x, float *__restrict y, float *__restrict z)
{
  float *__restrict p = __builtin_assume_aligned (x, 32);
  float *__restrict q = __builtin_assume_aligned (y, 32);
  float *__restrict r = __builtin_assume_aligned (z, 32);
  int i;
  for (i = 0; i < 1024; i++)
{
  if (p[i] < 0.0f)
q[i] = p[i] + 2.0f;
  else
p[i] = r[i] + 3.0f;
}
}

float a[1024] __attribute__((aligned (32)));
float b[1024] __attribute__((aligned (32)));
float c[1024] __attribute__((aligned (32)));

int
main ()
{
  int i;
  for (i = 0; i < 1024; i++)
{
  a[i] = (i & 1) ? -i : i;
  b[i] = 7 * i;
  c[i] = a[i] - 3.0f;
}
  foo (a, b, c);
  for (i = 0; i < 1024; i++)
if (a[i] != ((i & 1) ? -i : i)
|| b[i] != ((i & 1) ? a[i] + 2.0f : 7 * i)
|| c[i] != a[i] - 3.0f)
  abort ();
  for (i = 0; i < 500; i++)
foo (a, b, c);
  return 0;  
}
or
void
foo (double *x, double *y)
{
  double *p = __builtin_assume_aligned (x, 16);
  double *q = __builtin_assume_aligned (y, 16);
  double z, h;
  int i;
  for (i = 0; i < 1024; i++)
{
  if (p[i] < 0.0)
z = q[i], h = q[i] * 7.0 + 3.0;
  else
z = p[i] + 6.0, h = p[1024 + i];
  p[i] = z + 2.0 * h;
}
}
or
#define N 1024
float vf1[N+16], vf2[N], vf3[N];
double vd1[N+16], vd2[N];
int k[N];
long l[N];
short n[N];

__attribute__((noinline, noclone)) void
f1 (void)
{
  int i;
  for (i = 0; i < N; i++)
{
  float f;
  if (vf3[i] < 0.0f)
f = vf1[k[i]];
  else
f = 7.0f;
  vf2[i] = f;
}
}

(all with -O3 -mavx resp. -O3 -mavx2).  vmaskmov*/vpmaskmov* and
masked gather insns are then used.

2012-11-02  Jakub Jelinek  

* Makefile.in (tree-if-conv.o): Depend on $(TARGET_H), $(EXPR_H)
and $(OPTABS_H).
* config/i386/sse.md (maskload, maskstore): New expanders.
* tree-data-ref.c (struct data_ref_loc_d): Replace pos field with ref.
(get_references_in_stmt): Don't record operand addresses, but
operands themselves.  Handle MASK_LOAD and MASK_STORE.
(find_data_references_in_stmt, graphite_find_data_references_in_stmt,
create_rdg_vertices): Adjust users of pos field of data_ref_loc_d.
* internal-fn.def (MASK_LOAD, MASK_STORE): New internal fns.
* tree-if-conv.c: Add target.h, expr.h and optabs.h includes.
(if_convertible_phi_p, insert_gimplified_predicates): Add
any_mask_load_store argument, if true, handle it like
flag_tree_loop_if_convert_stores.
(ifcvt_can_use_mask_load_store): New function.
(if_convertible_gimple_assign_stmt_p): Add any_mask_load_store
argument, check if some conditional loads or stores can't be
converted into MASK_LOAD or MASK_STORE.
(if_convertible_stmt_p): Add any_mask_load_store argument,
pass it down to if_convertible_gimple_assign_stmt_p.
(if_convertible_loop_p_1): Add any_mask_load_store argument,
pass it down to if_convertible_stmt_p and if_convertible_phi_p,
call if_convertible_phi_p only after all if_convertible_stmt_p
calls.
(if_convertible_loop_p): Add any_mask_load_store argument,
pass it down to if_convertible_loop_p_1.
(predicate_mem_writes): Emit MASK_LOAD and/or MASK_STORE calls.
(combine_blocks): Add any_mask_load_store argument, pass
it down to insert_gimplified_predicates and call predicate_mem_writes
if it is set.
(tree_if_conversion): Add any_mask_load_store_p argument,
adjust if_convertible_loop_p, combine_blocks calls and gather
whether any mask loads/stores have been generated.
(need_if_unconversion): New variable.
(main_tree_if_conversion): Adjust tree_if_conversion caller,
if any masked loads/stores have been created, set
need_if_unconversion and return TODO_update_ssa_only_virtuals.
(gate_tree_if_unconversion, main_tree_if_unconversion): New
functions.
(pass_if_unconversion): New pass descriptor.
* tree-vect-data-refs.c (vect_check_gather): Handle
MASK_LOAD/MASK_STORE.
(vect_analyze_data_refs, vect_supportable_dr_alignment): Likewise.
* gimple.h (gimple_expr_type): Handle MASK_STORE.
* internal-fn.c (expand_

Re: [ping] Re: [patch v2] support for multiarch systems

2012-11-02 Thread Ian Lance Taylor
On Fri, Nov 2, 2012 at 6:26 AM, Matthias Klose  wrote:
>
>> +ifeq ($(enable_multiarch),yes)
>> +  if_multiarch = $(1)
>> +else ifeq ($(enable_multiarch),auto-detect)
>> +  if_multiarch = $(if $(wildcard $(shell echo
>> $(SYSTEM_HEADER_DIR))/../../usr/lib/*/crti.o),$(1))
>> +else
>> +  if_multiarch =
>> +endif
>>
>> This is nicely tricky but I don't understand why you are doing this in
>> such a confusing way.  Why not simply set the names in config.gcc?
>> What information do you have at make time that you don't have at
>> configure time?
>
>
> this is for the auto case. SYSTEM_HEADER_DIR is not accessible/available
> from
> config.gcc. This is the same approach as taken for MULTILIB_OSDDIRNAMES.
> Also setting the names for the multiarch directories in the same place as
> done for for the MULTILIB_OSDIRNAMES seems to be better choice.

SYSTEM_HEADER_DIR is available in gcc/configure.ac, and you could do
the $(if $(wildcard $(shell echo
>> $(SYSTEM_HEADER_DIR))/../../usr/lib/*/crti.o) there.  I can't see any reason 
>> to do it at make time rather than configure time.

> +   if (*q2 == ':')
> + end = q2;

Don't reuse end here.  Use a new variable.

Please update the comment for set_multilib_dir.  It's not a very good
comment, but it does describe the syntax, and you seem to be changing
the syntax.

> -  if (this_path[0] == '.' && this_path[1] == ':')
> +  if (this_path[0] == '.' && this_path[1] == ':' && this_path[2] != ':')

The existing comment here is reasonably clear.  Please update the
comment to show why this change is correct.

> +Specify wether to enable or disable multiarch support.  The default is

s/wether/whether/

> +to detect for glibc start files in a multiarch location, and enable it

s/detect/check/ or something along those lines.

Ian


Re: [PR54693] loss of debug info in jump threading and loop ivopts

2012-11-02 Thread Alexandre Oliva
On Nov  1, 2012, Jakub Jelinek  wrote:

> Even for stmt frontiers it is IMHO undesirable to duplicate
> (perhaps many times) the whole sequence, as one would then reply the var
> changing sequence in the debugger perhaps once in the original bb, then
> once or many times again in the successor bb.

Quite the opposite: when we do jump threading, we're *bypassing* the
entire block, so in order to retain proper history we'd have to
propagate all the source-expected changes into the short-circuited
path.  To wit, we start with a computation log like this:

  jump to block A

A:
  # set foo to expr1
  # advance to line n
  # set foo to expr2
  jump to block B

B:
  # advance to line m
  # set foo to expr3

in which we can see foo bound to all 3 expressions, to a computation log
like this:

  jump to block B

B:
  # advance to line m
  # set foo to expr3

or:

  jump to block B

B:
  # set foo to expr1
  # advance to line n
  # set foo to expr2
  # advance to line m
  # set foo to expr3

which ones seems like a more faithful representation of the computation
described in the source code to you?

-- 
Alexandre Oliva, freedom fighterhttp://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist  Red Hat Brazil Compiler Engineer


Re: [PATCH] New configuration options to enable additional executable/startfile/shared library prefixes

2012-11-02 Thread Michael Meissner
On Fri, Nov 02, 2012 at 12:22:07AM +0100, Gerald Pfeifer wrote:
> On Thu, 1 Nov 2012, Michael Meissner wrote:
> > * doc/install.texi (--with-extra-prefix=): Document new configure
> > switches.
> > (--with-extra-exec-prefix=): Likewise.
> > (--with-extra-startfile-prefix=): Likewise.
> > (--with-extra-rpath-prefix=): Likewise.
> 
> +On powerpc64-linux systems, the dynamic linker will be searched for in
> +the directories specified by the prefixed, that is used instead of the
>   
> +standard system dynamic linker.
> 
> Is the use of "prefixed" correct her, or would that be "prefixes"?

You are right that doesn't make sense.  The paragraph should read:

On powerpc64-linux systems, the dynamic linker will be searched for in
the directories specified by the prefixes before falling back to the
standard system dynamic linker which is used if an alternate dynamic
linker could not be found.

> +In addition on powerpc64-linux systems, if the user used static
> 
> "the user used" comes across a bit oddly.  How about "requests"?
> 
> +linking, as well as the @option{-mcpu=} option, the linker will be
> 
> Do I understand this correctly that both must hold?  Perhaps say "plus"
> to avoid any ambiguity?
> 
> +for that particular machine.  If dynamic linking is used, these cpu
> +tuned libraries will not be searched, since the dynamic linker will
> +load the appropriate cpu tuned library, based on the system that is
> +executing the code.

Yes.  The paragraph should read:

In addition on powerpc64-linux systems, if the user used static
linking and the @option{-mcpu=} option at the same time, the linker
will be told to search in appropriate directories for libraries that
are built for that particular machine.  If dynamic linking is used,
these cpu tuned libraries will not be searched, since the dynamic
linker will load the appropriate cpu tuned library, based on the
system that is executing the code.

> CPU (uppercase) in two cases.
> 
> +@item --with-extra-rpath-prefix=@var{prefixes}
> +Specify additional directories for finding shared libraries when
> +the compiler is run.  Each prefix is separated by the standard path
> +sepator (usually colon, @option{:}).  By default no extra prefixes are
> +used.  If this option is used, each of the directories if they exist
> +will be specified to the linker via the @option{-rpath=} option.
> 
> "each of the directories if they exist" is a bit confusing ("each"
> versus "they").
> 
> Do you mean "each of the directories that exists on the build system
> will be..." or something like that?

What the compiler does is search for the directories to exist when the compiler
is run (not when it is built).  If they exist, the linker on powerpc64-linux
will be told via -rpath to add these paths so that when the program is run, the
right libraries are loaded.

For example, if I have AT 6.0 installed on my Sles 11SP1 system, it is
installed in:

/opt/at6.0

Normally when you build the compiler using the host libraries, the linker gets
passed:

-dynamic-linker /lib64/ld64.so.1

With the alternatate configuration support, the linker would get passed:

-rpath=/home/meissner/fsf-install-ppc64/atdirs2/lib64
-rpath=/opt/at6.0/lib64
-dynamic-linker /opt/at6.0/lib64/ld64.so.1

where /home/meissner/fsf-install-ppc64/atdirs2/lib64 happens to be the install
directory for the compiler being built, so its libraries override the AT 6
libraries.

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899



Re: [patch, committed] libquadmath: Small fmaq and lgamma update

2012-11-02 Thread Paolo Carlini

On 11/02/2012 05:59 PM, Tobias Burnus wrote:
The attached patch ports Joseph's GLIBC fmal patch from today; 
additionally, I made a small adjustment to lgamma's signgam handling.


Build and tested on x86-64-gnu-linux and applied as Rev. 193099
My builds are now failing in libquadmath with IEEE854_FLT128_DOUBLE_BIAS 
undeclared. I'm not doing anything special...


Paolo.


Re: [patch, committed] libquadmath: Small fmaq and lgamma update

2012-11-02 Thread Tobias Burnus

Paolo Carlini wrote:

On 11/02/2012 05:59 PM, Tobias Burnus wrote:
The attached patch ports Joseph's GLIBC fmal patch from today; 
additionally, I made a small adjustment to lgamma's signgam handling.


Build and tested on x86-64-gnu-linux and applied as Rev. 193099
My builds are now failing in libquadmath with 
IEEE854_FLT128_DOUBLE_BIAS undeclared. I'm not doing anything special...


Sorry, I seemingly applied an old premature version of the patch instead 
of the one I had build and tested. Fixed by the attached patch (Rev. 
193100).


Tobias


Re: [patch, committed] libquadmath: Small fmaq and lgamma update

2012-11-02 Thread Tobias Burnus

Tobias Burnus:
Sorry, I seemingly applied an old premature version of the patch 
instead of the one I had build and tested. Fixed by the attached patch 
(Rev. 193100).


Now with a nonzero file as attachment, it helps diffing -r193099:193100 
instead of -r193109:193100.


I think I need a break…

Tobias
Index: math/fmaq.c
===
--- math/fmaq.c	(Revision 193099)
+++ math/fmaq.c	(Revision 193100)
@@ -77,7 +77,7 @@
 	 result nor whether there is underflow depends on its exact
 	 value, only on its sign.  */
   if (u.ieee.exponent + v.ieee.exponent
-	  < IEEE854_FLT128_DOUBLE_BIAS - FLT128_MANT_DIG - 2)
+	  < IEEE854_FLOAT128_BIAS - FLT128_MANT_DIG - 2)
 	{
 	  int neg = u.ieee.negative ^ v.ieee.negative;
 	  __float128 tiny = neg ? -0x1p-16494L : 0x1p-16494L;
@@ -94,10 +94,8 @@
 	  : (w.ieee.exponent == 0
 		 || (w.ieee.exponent == 1
 		 && w.ieee.negative != neg
-		 && w.ieee.mantissa3 == 0
-		 && w.ieee.mantissa2 == 0
-		 && w.ieee.mantissa1 == 0
-		 && w.ieee.mantissa0 == 0)))
+		 && w.ieee.mant_low == 0
+		 && w.ieee.mant_high == 0)))
 	{
 	  volatile __float128 force_underflow = x * y;
 	  (void) force_underflow;


Re: [patch, committed] libquadmath: Small fmaq and lgamma update

2012-11-02 Thread Paolo Carlini

On 11/02/2012 07:10 PM, Tobias Burnus wrote:

Paolo Carlini wrote:

On 11/02/2012 05:59 PM, Tobias Burnus wrote:
The attached patch ports Joseph's GLIBC fmal patch from today; 
additionally, I made a small adjustment to lgamma's signgam handling.


Build and tested on x86-64-gnu-linux and applied as Rev. 193099
My builds are now failing in libquadmath with 
IEEE854_FLT128_DOUBLE_BIAS undeclared. I'm not doing anything special...
Sorry, I seemingly applied an old premature version of the patch 
instead of the one I had build and tested. Fixed by the attached patch 
(Rev. 193100).

Thanks!

Paolo.


[patch, committed] Pass -fno-ident to tests that make sure "pow" is not called

2012-11-02 Thread Michael Meissner
During development, I often times have powerpc in the name of the compiler.
This trips up several tests that want to make sure the various pow
optimizations are done and the pow function is not called, since "powerpc" is
in the compiler identification string.

I committed the following patch as obvious, after doing build/compare.

[gcc/testsuite]
2012-11-02  Michael Meissner  

* gcc.target/powerpc/pr46728-1.c: Pass -fno-ident to eliminate
failures in case 'pow', such as 'powerpc' is used in the compiler
version name.
* gcc.target/powerpc/pr46728-2.c: Likewise.
* gcc.target/powerpc/pr46728-3.c: Likewise.
* gcc.target/powerpc/pr46728-4.c: Likewise.
* gcc.target/powerpc/pr46728-5.c: Likewise.
* gcc.target/powerpc/pr46728-7.c: Likewise.
* gcc.target/powerpc/pr46728-8.c: Likewise.
* gcc/testsuite/gcc.dg/pr46728-6.c: Likewise.

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899
Index: gcc/testsuite/gcc.target/powerpc/pr46728-3.c
===
--- gcc/testsuite/gcc.target/powerpc/pr46728-3.c(revision 193095)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-3.c(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt" } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt -fno-ident" } */
 
 #include 
 
Index: gcc/testsuite/gcc.target/powerpc/pr46728-4.c
===
--- gcc/testsuite/gcc.target/powerpc/pr46728-4.c(revision 193095)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-4.c(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-skip-if "No __builtin_cbrt" { powerpc*-*-darwin* } } */
-/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt" } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt -fno-ident" } */
 
 #include 
 
Index: gcc/testsuite/gcc.target/powerpc/pr46728-5.c
===
--- gcc/testsuite/gcc.target/powerpc/pr46728-5.c(revision 193095)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-5.c(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-skip-if "No __builtin_cbrt" { powerpc*-*-darwin* } } */
-/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt" } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt -fno-ident" } */
 
 #include 
 
Index: gcc/testsuite/gcc.target/powerpc/pr46728-7.c
===
--- gcc/testsuite/gcc.target/powerpc/pr46728-7.c(revision 193095)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-7.c(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt" } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt -fno-ident" } */
 
 #include 
 
Index: gcc/testsuite/gcc.target/powerpc/pr46728-8.c
===
--- gcc/testsuite/gcc.target/powerpc/pr46728-8.c(revision 193095)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-8.c(working copy)
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
 /* { dg-skip-if "No __builtin_cbrt" { powerpc*-*-darwin* } } */
-/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt" } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt -fno-ident" } */
 
 #include 
 
Index: gcc/testsuite/gcc.target/powerpc/pr46728-1.c
===
--- gcc/testsuite/gcc.target/powerpc/pr46728-1.c(revision 193095)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-1.c(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt" } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt -fno-ident" } */
 
 #include 
 
Index: gcc/testsuite/gcc.target/powerpc/pr46728-2.c
===
--- gcc/testsuite/gcc.target/powerpc/pr46728-2.c(revision 193095)
+++ gcc/testsuite/gcc.target/powerpc/pr46728-2.c(working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt" } */
+/* { dg-options "-O2 -ffast-math -fno-inline -fno-unroll-loops -lm 
-mpowerpc-gpopt -fno-ident" } */
 
 #include 
 
Index: gcc/testsuite/gcc.dg/pr46728-6.c
===
--- gcc/testsuite/gcc.dg/pr46728-6.c  

[patch] Fix powerpc pr48258-2

2012-11-02 Thread Michael Meissner
David pointed out to me that pr48258-2 was failing on AIX, and it was failing
under Linux as well.  In terms of the Linux failures, this was because the test
was failing if the xxsldwi was generated.  I decided the test conditions were
too specific, and loosened them to just check that the compiler did vectorize
the reductions, but not to count how many instructions were generated.

David does this also fix the AIX side of things and can be checked in?

[gcc/testsuite]
2012-11-02  Michael Meissner  

* gcc.target/powerpc/pr48258-2.c: Simplfy the acceptance
conditions to verify the reduction code is vectorized.

Index: gcc/testsuite/gcc.target/powerpc/pr48258-2.c
===
--- gcc/testsuite/gcc.target/powerpc/pr48258-2.c(revision 193095)
+++ gcc/testsuite/gcc.target/powerpc/pr48258-2.c(working copy)
@@ -1,17 +1,10 @@
 /* { dg-do compile } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
 /* { dg-require-effective-target powerpc_vsx_ok } */
-/* { dg-options "-O3 -mcpu=power7 -mabi=altivec -ffast-math -fno-unroll-loops" 
} */
-/* { dg-final { scan-assembler-times "xvadddp" 1 } } */
-/* { dg-final { scan-assembler-times "xvmindp" 1 } } */
-/* { dg-final { scan-assembler-times "xvmaxdp" 1 } } */
-/* { dg-final { scan-assembler-times "xsadddp" 1 } } */
-/* { dg-final { scan-assembler-times "xsmindp" 1 } } */
-/* { dg-final { scan-assembler-times "xsmaxdp" 1 } } */
-/* { dg-final { scan-assembler-not "xxsldwi" } } */
-/* { dg-final { scan-assembler-not "stvx" } } */
-/* { dg-final { scan-assembler-not "stxvd2x" } } */
-/* { dg-final { scan-assembler-not "stxvw4x" } } */
+/* { dg-options "-O3 -mcpu=power7 -mabi=altivec -ffast-math" } */
+/* { dg-final { scan-assembler "xvadddp" } } */
+/* { dg-final { scan-assembler "xvmindp" } } */
+/* { dg-final { scan-assembler "xvmaxdp" } } */
 
 #include 

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899



Re: Parts 3 and 4 to the vxworks/fixincludes patches

2012-11-02 Thread rbmj

On 11/1/2012 10:48 AM, Bruce Korb wrote:

Hi Robert,

On Thu, Nov 1, 2012 at 6:35 AM, rbmj  wrote:

 and now my patches will build on top of
trunk.  Bruce, can you give steps on how to reproduce the error you
reported?


rm -rf gcc-bld gcc-ins
cp -l gcc-svn gcc-bld
pfx=$PWD/gcc-ins
cd gcc-bld
./configure --enable-languages=c,c++ --prefix=$pfx CFLAGS='-g2 -Wall'
make

I never build in my source tree.



Doing (roughly) equivalent in git:

gcc$ git reset --hard HEAD #clean stuff up
gcc$ git clean -f -d # more cleaning
gcc$ git checkout -b test # new branch at current HEAD
gcc$ git am ../patches/* # applies my patches
gcc$ cd ../build
build$ ../gcc/configure --enable-languages=c,c++ --prefix=$pfx 
--disable-multilib CFLAGS='-g2 -Wall' #need to use disable-multilib or 
the whole thing dies...

build$ make -j2
build$ make install

I get no errors on a fresh fedora vm rev193071

I build using my vc tree as it's significantly quicker to tell git to 
make a new branch to build and then just throw that branch away than it 
is to copy my whole source tree.


Are you sure that those three *minor* changes are what is breaking your 
build?


--
rbmj



Minor predict.c improvement

2012-11-02 Thread Jan Hubicka
hi,
this patch makes predict_loop to predict even loop with exits not
dominating the latch when their iteration bound is known.

Honza

Index: ChangeLog
===
--- ChangeLog   (revision 193101)
+++ ChangeLog   (working copy)
@@ -1,5 +1,10 @@
 2012-11-02  Jan Hubicka  
 
+   * predict.c (predict_loops): Predict also exits not dominating
+   latch.
+
+2012-11-02  Jan Hubicka  
+
* predict.c (predict_loops): Do not predict infinite loops.
 
 2012-11-02  Jan Hubicka  
Index: predict.c
===
--- predict.c   (revision 193101)
+++ predict.c   (working copy)
@@ -1419,7 +1419,7 @@ predict_loops (void)
 
  predict_extra_loop_exits (ex);
 
- if (number_of_iterations_exit (loop, ex, &niter_desc, false))
+ if (number_of_iterations_exit (loop, ex, &niter_desc, false, false))
niter = niter_desc.niter;
  if (!niter || TREE_CODE (niter_desc.niter) != INTEGER_CST)
niter = loop_niter_by_eval (loop, ex);


[contrib] Compare against a clean build in validate_failures.py

2012-11-02 Thread Diego Novillo
Lawrence, this is the change I was referring to yesterday.  See
if it helps in comparing your results against clean builds.


Add a new option --clean_build to validate_failures.py

This is useful when you have two builds of the same compiler.  One with
your changes.  The other one, a clean build at the same revision.
Instead of using a manifest file, --clean_build will compare the
results it gather from the patched build against those it gathers from
the clean build.

Usage

$ cd /top/of/patched/gcc/bld
$ validate_failures.py --clean_build=clean/bld-gcc
Source directory: /usr/local/google/home/dnovillo/gcc/trunk
Build target: x86_64-unknown-linux-gnu
Getting actual results from build directory .
./x86_64-unknown-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum
./x86_64-unknown-linux-gnu/libffi/testsuite/libffi.sum
./x86_64-unknown-linux-gnu/libgomp/testsuite/libgomp.sum
./x86_64-unknown-linux-gnu/libgo/libgo.sum
./x86_64-unknown-linux-gnu/boehm-gc/testsuite/boehm-gc.sum
./x86_64-unknown-linux-gnu/libatomic/testsuite/libatomic.sum
./x86_64-unknown-linux-gnu/libmudflap/testsuite/libmudflap.sum
./x86_64-unknown-linux-gnu/libitm/testsuite/libitm.sum
./x86_64-unknown-linux-gnu/libjava/testsuite/libjava.sum
./gcc/testsuite/g++/g++.sum
./gcc/testsuite/gnat/gnat.sum
./gcc/testsuite/ada/acats/acats.sum
./gcc/testsuite/gcc/gcc.sum
./gcc/testsuite/gfortran/gfortran.sum
./gcc/testsuite/obj-c++/obj-c++.sum
./gcc/testsuite/go/go.sum
./gcc/testsuite/objc/objc.sum
Getting actual results from build directory clean/bld-gcc

clean/bld-gcc/x86_64-unknown-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum
clean/bld-gcc/x86_64-unknown-linux-gnu/libffi/testsuite/libffi.sum
clean/bld-gcc/x86_64-unknown-linux-gnu/libgomp/testsuite/libgomp.sum
clean/bld-gcc/x86_64-unknown-linux-gnu/libgo/libgo.sum
clean/bld-gcc/x86_64-unknown-linux-gnu/boehm-gc/testsuite/boehm-gc.sum
clean/bld-gcc/x86_64-unknown-linux-gnu/libatomic/testsuite/libatomic.sum

clean/bld-gcc/x86_64-unknown-linux-gnu/libmudflap/testsuite/libmudflap.sum
clean/bld-gcc/x86_64-unknown-linux-gnu/libitm/testsuite/libitm.sum
clean/bld-gcc/x86_64-unknown-linux-gnu/libjava/testsuite/libjava.sum
clean/bld-gcc/gcc/testsuite/g++/g++.sum
clean/bld-gcc/gcc/testsuite/gnat/gnat.sum
clean/bld-gcc/gcc/testsuite/ada/acats/acats.sum
clean/bld-gcc/gcc/testsuite/gcc/gcc.sum
clean/bld-gcc/gcc/testsuite/gfortran/gfortran.sum
clean/bld-gcc/gcc/testsuite/obj-c++/obj-c++.sum
clean/bld-gcc/gcc/testsuite/go/go.sum
clean/bld-gcc/gcc/testsuite/objc/objc.sum

SUCCESS: No unexpected failures.

2012-11-02  Diego Novillo  

* testsuite-management/validate_failures.py: Add option
--clean_build to compare test results against another
build.

diff --git a/contrib/testsuite-management/validate_failures.py 
b/contrib/testsuite-management/validate_failures.py
index be13cfd..7391937 100755
--- a/contrib/testsuite-management/validate_failures.py
+++ b/contrib/testsuite-management/validate_failures.py
@@ -292,7 +292,7 @@ def PrintSummary(msg, summary):
 
 def GetSumFiles(results, build_dir):
   if not results:
-print 'Getting actual results from build'
+print 'Getting actual results from build directory %s' % build_dir
 sum_files = CollectSumFiles(build_dir)
   else:
 print 'Getting actual results from user-provided results'
@@ -300,6 +300,27 @@ def GetSumFiles(results, build_dir):
   return sum_files
 
 
+def PerformComparison(expected, actual, ignore_missing_failures):
+  actual_vs_expected, expected_vs_actual = CompareResults(expected, actual)
+
+  tests_ok = True
+  if len(actual_vs_expected) > 0:
+PrintSummary('Unexpected results in this build (new failures)',
+ actual_vs_expected)
+tests_ok = False
+
+  if not ignore_missing_failures and len(expected_vs_actual) > 0:
+PrintSummary('Expected results not present in this build (fixed tests)'
+ '\n\nNOTE: This is not a failure.  It just means that these '
+ 'tests were expected\nto fail, but they worked in this '
+ 'configuration.\n', expected_vs_actual)
+
+  if tests_ok:
+print '\nSUCCESS: No unexpected failures.'
+
+  return tests_ok
+
+
 def CheckExpectedResults(options):
   if not options.manifest:
 (srcdir, target, valid_build) = GetBuildData(options)
@@ -320,24 +341,7 @@ def CheckExpectedResults(options):
 PrintSummary('Tests expected to fail', manifest)
 PrintSummary('\nActual test results', actual)
 
-  actual_vs_manifest, manifest_vs_actual = CompareResults(manifest, actual)
-
-  tests_ok = True
-  if len(actual_vs_manifest) > 0:
-PrintSummary('Build results not in the manifest', actual_vs_manifest)
-tests_ok = False
-
-  if not options.ignore_missing

Re: [patch] Fix powerpc pr48258-2

2012-11-02 Thread David Edelsohn
On Fri, Nov 2, 2012 at 3:29 PM, Michael Meissner
 wrote:
> David pointed out to me that pr48258-2 was failing on AIX, and it was failing
> under Linux as well.  In terms of the Linux failures, this was because the 
> test
> was failing if the xxsldwi was generated.  I decided the test conditions were
> too specific, and loosened them to just check that the compiler did vectorize
> the reductions, but not to count how many instructions were generated.
>
> David does this also fix the AIX side of things and can be checked in?
>
> [gcc/testsuite]
> 2012-11-02  Michael Meissner  
>
> * gcc.target/powerpc/pr48258-2.c: Simplfy the acceptance
> conditions to verify the reduction code is vectorized.

This patch will fix AIX.

Please check it in.

Thanks, David


[wwwdocs,Java] java/faq.html -- remove non-FAQ covered by installation documentation

2012-11-02 Thread Gerald Pfeifer
This is covered in the installation documentation and really not
specific to GCJ (and probably predates the merge of GCJ into GCC).
Also, it's not really an FAQ in this context.

Better focus on what is really relevant..

Applied.

Gerald

2012-11-02  Gerald Pfeifer  
 
* faq.html: Remove question about building in the source tree.

Index: faq.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/java/faq.html,v
retrieving revision 1.68
diff -u -3 -p -r1.68 faq.html
--- faq.html1 Nov 2012 23:25:30 -   1.68
+++ faq.html2 Nov 2012 19:58:38 -
@@ -37,7 +37,6 @@
 I need something more recent than the last 
release; how
   should I build it?
 Linker bug on Solaris
-Can I configure/build in the source 
tree?
   
 
 Gcj Compile/Link Questions 
@@ -306,26 +305,6 @@ collect2: ld returned 1 exit status
 
   
 
-  
-  3.3 Can I configure/build in the source tree?
-   
-
-  No.  You cannot configure/build in the source tree.  If you try,
-  you'll see something like:
-  
-$ ./configure [...]
-Configuring for a i686-pc-linux-gnu host.
-*** Cannot currently configure in source tree.
-  
-  Instead, you must build in another directory.  E.g.:
-  
-$ mkdir build
-$ cd build
-$ ../configure [...]
-  
-
-  
-  
   Gcj Compile/Link Questions
  
   4.1 Why do I get undefined reference to 
`main' 


Re: [patch] Apply conditional down cast to cgraph.h et.al.

2012-11-02 Thread Lawrence Crowl
On 11/2/12, Eric Botcazou  wrote:
>> Index: gcc/ChangeLog
>>
>> 2012-10-31  Lawrence Crowl  
>>
>>  * is-a.h: New.
>>  (is_a  (U*)): New.  Test for is-a relationship.
>>  (as_a  (U*)): New.  Treat as a derived type.
>>  (dyn_cast  (U*)): New.  Conditionally cast based on is_a.
>>  * cgraph.h (varpool_node): Rename to varpool_node_for_decl.
>>  Adjust callers to match.
>>  (is_a_helper ::test (symtab_node_def *)): New.
>>  (is_a_helper ::test (symtab_node_def *)): New.
>>  (symtab_node_def::try_function): New.  Change most calls to
>>  symtab_function_p with calls to dyn_cast  (p).
>>  (symtab_node_def::try_variable): New.  Change most calls to
>>  symtab_variable_p with calls to dyn_cast  (p).
>>  (symtab_function_p): Remove.  Change callers to use
>> is_a  (p) instead.
>>  (symtab_variable_p): Remove.  Change callers to use
>> is_a  (p) instead.
>>  * cgraph.c (cgraph_node_for_asm): Remove redundant call to
>>  symtab_node_for_asm.
>>  * cgraphunit.c (symbol_finalized_and_needed): New.
>>  (symbol_finalized): New.
>>  (cgraph_analyze_functions): Split complicated conditionals out into
>>  above new functions.
>>  * Makefile.in (CGRAPH_H): Add is-a.h as used by cgraph.h.
>
> The installed patch touches the ada/, cp/ and lto/ subdirectories without
> modifying their ChangeLog files.  Please add the missing entries.
>
> [Some people, like me, do use these ChangeLogs to synchronize trees]

Done and committed.


Update ChangeLog files as requested for cgraph change to checked down cast.


Index: gcc/cp/ChangeLog

2012-10-31  Lawrence Crowl  

* decl2.c (var_finalized_p): Rename varpool_node to
varpool_node_for_decl.
(maybe_emit_vtables): Likewise.

Index: gcc/ada/ChangeLog

2012-10-31  Lawrence Crowl  

* gcc-interface/utils.c (gnat_write_global_declarations):
Rename varpool_node to varpool_node_for_decl.

Index: gcc/lto/ChangeLog

2012-10-31  Lawrence Crowl  

* lto.c (lto_wpa_write_files): Change symtab checking to a checked
down-cast via dyn_cast.
* lto-partition.c (add_symbol_to_partition_1): Likewise.
(undo_partition): Likewise.
(lto_balanced_map): Likewise.
(get_symbol_class): Likewise and via is_a.
(lto_balanced_map): Change symtab checking to is_a.


-- 
Lawrence Crowl


Re: [patch, committed] Pass -fno-ident to tests that make sure "pow" is not called

2012-11-02 Thread David Edelsohn
On Fri, Nov 2, 2012 at 3:24 PM, Michael Meissner
 wrote:
> During development, I often times have powerpc in the name of the compiler.
> This trips up several tests that want to make sure the various pow
> optimizations are done and the pow function is not called, since "powerpc" is
> in the compiler identification string.
>
> I committed the following patch as obvious, after doing build/compare.
>
> [gcc/testsuite]
> 2012-11-02  Michael Meissner  
>
> * gcc.target/powerpc/pr46728-1.c: Pass -fno-ident to eliminate
> failures in case 'pow', such as 'powerpc' is used in the compiler
> version name.
> * gcc.target/powerpc/pr46728-2.c: Likewise.
> * gcc.target/powerpc/pr46728-3.c: Likewise.
> * gcc.target/powerpc/pr46728-4.c: Likewise.
> * gcc.target/powerpc/pr46728-5.c: Likewise.
> * gcc.target/powerpc/pr46728-7.c: Likewise.
> * gcc.target/powerpc/pr46728-8.c: Likewise.
> * gcc/testsuite/gcc.dg/pr46728-6.c: Likewise.

I see similar failures on AIX, but I think that "powerpc" appears in
other strings in XCOFF.

But thanks for cleaning up these spurious failures in the testsuite.
I want the testsuite failures to be meaningful and accurate.

Thanks, David


[4.7 branch] Backport fix for 54985

2012-11-02 Thread Jeff Law
Just backporting the fix for 54985 from the trunk to gcc-4_7-branch. 
Bootstrapped and regression tested on x86_64-unknown-linux-gnu.


2012-11-02  Jeff Law  

PR tree-optimization/54985
* tree-ssa-threadedge.c (cond_arg_set_in_bb): New function extracted
from thread_across_edge.
(thread_across_edge): Use it in all cases where we might thread
across a back edge.

* gcc.c-torture/execute/pr54985.c: New test.

Index: gcc/testsuite/gcc.c-torture/execute/pr54985.c
===
--- gcc/testsuite/gcc.c-torture/execute/pr54985.c   (revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/pr54985.c   (working copy)
@@ -0,0 +1,36 @@
+
+typedef struct st {
+int a;
+} ST;
+
+int __attribute__((noinline,noclone))
+foo(ST *s, int c)
+{
+  int first = 1;
+  int count = c;
+  ST *item = s;
+  int a = s->a;
+  int x;
+
+  while (count--)
+{
+  x = item->a;
+  if (first)
+first = 0;
+  else if (x >= a)
+return 1;
+  a = x;
+  item++;
+}
+  return 0;
+}
+
+extern void abort (void);
+
+int main ()
+{
+  ST _1[2] = {{2}, {1}};
+  if (foo(_1, 2) != 0)
+abort ();
+  return 0;
+}
Index: gcc/tree-ssa-threadedge.c
===
--- gcc/tree-ssa-threadedge.c   (revision 193086)
+++ gcc/tree-ssa-threadedge.c   (working copy)
@@ -574,6 +574,44 @@
   return cached_lhs;
 }
 
+/* Return TRUE if the statement at the end of e->dest depends on
+   the output of any statement in BB.   Otherwise return FALSE.
+
+   This is used when we are threading a backedge and need to ensure
+   that temporary equivalences from BB do not affect the condition
+   in e->dest.  */
+
+static bool
+cond_arg_set_in_bb (edge e, basic_block bb)
+{
+  ssa_op_iter iter;
+  use_operand_p use_p;
+  gimple last = last_stmt (e->dest);
+
+  /* E->dest does not have to end with a control transferring
+ instruction.  This can occurr when we try to extend a jump
+ threading opportunity deeper into the CFG.  In that case
+ it is safe for this check to return false.  */
+  if (!last)
+return false;
+
+  if (gimple_code (last) != GIMPLE_COND
+  && gimple_code (last) != GIMPLE_GOTO
+  && gimple_code (last) != GIMPLE_SWITCH)
+return false;
+
+  FOR_EACH_SSA_USE_OPERAND (use_p, last, iter, SSA_OP_USE | SSA_OP_VUSE)
+{
+  tree use = USE_FROM_PTR (use_p);
+
+  if (TREE_CODE (use) == SSA_NAME
+ && gimple_code (SSA_NAME_DEF_STMT (use)) != GIMPLE_PHI
+ && gimple_bb (SSA_NAME_DEF_STMT (use)) == bb)
+   return true;
+}
+  return false;
+}
+
 /* TAKEN_EDGE represents the an edge taken as a result of jump threading.
See if we can thread around TAKEN_EDGE->dest as well.  If so, return
the edge out of TAKEN_EDGE->dest that we can statically compute will be
@@ -707,19 +745,8 @@
  safe to thread this edge.  */
   if (e->flags & EDGE_DFS_BACK)
 {
-  ssa_op_iter iter;
-  use_operand_p use_p;
-  gimple last = gsi_stmt (gsi_last_bb (e->dest));
-
-  FOR_EACH_SSA_USE_OPERAND (use_p, last, iter, SSA_OP_USE | SSA_OP_VUSE)
-   {
- tree use = USE_FROM_PTR (use_p);
-
-  if (TREE_CODE (use) == SSA_NAME
- && gimple_code (SSA_NAME_DEF_STMT (use)) != GIMPLE_PHI
- && gimple_bb (SSA_NAME_DEF_STMT (use)) == e->dest)
-   goto fail;
-   }
+  if (cond_arg_set_in_bb (e, e->dest))
+   goto fail;
 }
 
   stmt_count = 0;
@@ -760,7 +787,9 @@
 address.  If DEST is not null, then see if we can thread
 through it as well, this helps capture secondary effects
 of threading without having to re-run DOM or VRP.  */
- if (dest)
+ if (dest
+ && ((e->flags & EDGE_DFS_BACK) == 0
+ || ! cond_arg_set_in_bb (taken_edge, e->dest)))
{
  /* We don't want to thread back to a block we have already
 visited.  This may be overly conservative.  */
@@ -818,11 +847,16 @@
e3 = taken_edge;
do
  {
-   e2 = thread_around_empty_block (e3,
-   dummy_cond,
-   handle_dominating_asserts,
-   simplify,
-   visited);
+   if ((e->flags & EDGE_DFS_BACK) == 0
+   || ! cond_arg_set_in_bb (e3, e->dest))
+ e2 = thread_around_empty_block (e3,
+ dummy_cond,
+ handle_dominating_asserts,
+ simplify,
+ visited);
+   else
+ e2 = NULL;
+
if (e2)
  {
e3 = e2;


[wwwdocs,Java] Obsolete GCJ FAQ entry for Solaris?

2012-11-02 Thread Gerald Pfeifer
Rainer (or others),

the FAQ entry below seems obsolete to me (dates back more than a
decade).  Shall we remove it, or is there something else we still
should document (in addition to gcc/doc/install.texi)?

Gerald

Index: faq.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/java/faq.html,v
retrieving revision 1.69
diff -u -3 -p -r1.69 faq.html
--- faq.html2 Nov 2012 19:59:34 -   1.69
+++ faq.html2 Nov 2012 20:29:12 -
@@ -36,7 +36,6 @@
   
 I need something more recent than the last 
release; how
   should I build it?
-Linker bug on Solaris
   
 
 Gcj Compile/Link Questions 
@@ -278,33 +277,6 @@ $ gij HelloWorld
 
   
 
-  
-  3.2 Linker bug on Solaris
-   
-
-  There is a known problem with the http://gcc.gnu.org/ml/gcc-bugs/1999-10/msg00159.html";> 
-  native Solaris linker when using gcc/gcj. A good indication 
you've 
-  run into this problem is if you get an error that looks like the 
following 
-  when building libgcj: 
-  
-ld: warning: option -o appears more than once, first setting taken
-ld: fatal: file libfoo.so: cannot open file: No such file or directory
-ld: fatal: File processing errors. No output written to .libs/libfoo.so
-collect2: ld returned 1 exit status
-  
-  A known workaround for this and other reported link problems on the 
-  various releases of Solaris is to build gcc/gcj with the ftp://sources.redhat.com/pub/binutils/snapshots";> 
-  latest GNU binutils instead of the native Solaris ld. 
The 
-  most straightforward way to do this is to build and install 
binutils, 
-  and then reference it in the configure for gcc via 
--with-ld=/path_to_binutils_install/bin/ld 
-  (--with-as may also be similarly specified but is not 
believed 
-  to be required).
-  
-  Please note, gcc/gcj must be built using GNU ld prior to doing a 
-  clean build of libgcj! 
-
-  
-
   Gcj Compile/Link Questions
  
   4.1 Why do I get undefined reference to 
`main' 



Re: Minimize downward code motion during reassociation

2012-11-02 Thread Easwaran Raman
Ping.

- Easwaran

On Wed, Oct 31, 2012 at 12:16 PM, Easwaran Raman  wrote:
> On Wed, Oct 31, 2012 at 4:36 AM, Richard Biener
>  wrote:
>> On Wed, Oct 24, 2012 at 4:02 AM, Easwaran Raman  wrote:
>>> On Tue, Oct 23, 2012 at 2:52 AM, Richard Biener
>>>  wrote:
 On Mon, Oct 22, 2012 at 8:31 PM, Easwaran Raman  wrote:
> On Mon, Oct 22, 2012 at 12:59 AM, Richard Biener
>  wrote:
>> On Fri, Oct 19, 2012 at 12:36 AM, Easwaran Raman  
>> wrote:
>>> Hi,
>>>
>>> During expression reassociation, statements are conservatively moved
>>> downwards to ensure that dependences are correctly satisfied after
>>> reassocation. This could lead to lengthening of live ranges. This
>>> patch moves statements only to the extent necessary. Bootstraps and no
>>> test regression on x86_64/linux. OK for trunk?
>>>
>>> Thanks,
>>> Easwaran
>>>
>>> 2012-10-18   Easwaran Raman  
>>> * tree-ssa-reassoc.c(assign_uids): New function.
>>> (assign_uids_in_relevant_bbs): Likewise.
>>> (ensure_ops_are_available): Likewise.
>>> (rewrite_expr_tree): Do not move statements beyond what is
>>> necessary. Remove call to swap_ops_for_binary_stmt...
>>> (reassociate_bb): ... and move it here.
>>>
>>>
>>>
>>> Index: gcc/tree-ssa-reassoc.c
>>> ===
>>> --- gcc/tree-ssa-reassoc.c (revision 192487)
>>> +++ gcc/tree-ssa-reassoc.c (working copy)
>>> @@ -2250,6 +2250,128 @@ swap_ops_for_binary_stmt (VEC(operand_entry_t, 
>>> hea
>>>  }
>>>  }
>>>
>>> +/* Assign UIDs to statements in basic block BB.  */
>>> +
>>> +static void
>>> +assign_uids (basic_block bb)
>>> +{
>>> +  unsigned uid = 0;
>>> +  gimple_stmt_iterator gsi;
>>> +  /* First assign uids to phis.  */
>>> +  for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
>>> +{
>>> +  gimple stmt = gsi_stmt (gsi);
>>> +  gimple_set_uid (stmt, uid++);
>>> +}
>>> +
>>> +  /* Then assign uids to stmts.  */
>>> +  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
>>> +{
>>> +  gimple stmt = gsi_stmt (gsi);
>>> +  gimple_set_uid (stmt, uid++);
>>> +}
>>> +}
>>> +
>>> +/* For each operand in OPS, find the basic block that contains the 
>>> statement
>>> +   which defines the operand. For all such basic blocks, assign UIDs.  
>>> */
>>> +
>>> +static void
>>> +assign_uids_in_relevant_bbs (VEC(operand_entry_t, heap) * ops)
>>> +{
>>> +  operand_entry_t oe;
>>> +  int i;
>>> +  struct pointer_set_t *seen_bbs = pointer_set_create ();
>>> +
>>> +  for (i = 0; VEC_iterate (operand_entry_t, ops, i, oe); i++)
>>> +{
>>> +  gimple def_stmt;
>>> +  basic_block bb;
>>> +  if (TREE_CODE (oe->op) != SSA_NAME)
>>> +continue;
>>> +  def_stmt = SSA_NAME_DEF_STMT (oe->op);
>>> +  bb = gimple_bb (def_stmt);
>>> +  if (!pointer_set_contains (seen_bbs, bb))
>>> +{
>>> +  assign_uids (bb);
>>> +  pointer_set_insert (seen_bbs, bb);
>>> +}
>>> +}
>>> +  pointer_set_destroy (seen_bbs);
>>> +}
>>
>> Please assign UIDs once using the existing renumber_gimple_stmt_uids ().
>> You seem to call the above multiple times and thus do work bigger than
>> O(number of basic blocks).
>
> The reason I call the above multiple times is that gsi_move_before
> might get called between two calls to the above. For instance, after
> rewrite_expr_tree is called once, the following sequence of calls
> could happen:
> reassociate_bb -> linearize_expr_tree -> linearize_expr ->
> gsi_move_before.  So it is not sufficient to call
> renumber_gimple_stmt_uids once per do_reassoc. Or do you want me to
> use renumber_gimple_stmt_uids_in_blocks instead of
> assign_uids_in_relevant_bbs?

 It's sufficient to call it once if you conservatively update UIDs at stmt
 move / insert time (assign the same UID as the stmt before/after).
>>>
>>> I was worried that that would make the code brittle, but looking at
>>> the places where a new statement is added or moved, I think it is
>>> fine.  I have made the change in the new patch.
>>
>> Thanks.
>>
>
>
>>> +/* Ensure that operands in the OPS vector starting from OPINDEXth
>>> entry are live
>>> +   at STMT.  This is accomplished by moving STMT if needed.  */
>>> +
>>> +static void
>>> +ensure_ops_are_available (gimple stmt, VEC(operand_entry_t, heap) *
>>> ops, int opindex)
>>> +{
>>> +  int i;
>>> +  int len = VEC_length (operand_entry_t, ops);
>>> +  gimple insert_stmt = stmt;
>>> +  basic_block insert_bb = gimple_bb (stmt);
>>> +  gimple_stmt_iterator gsi_insert, gsistmt;

[PATCH] Do not change scope for unknown locations

2012-11-02 Thread Dehao Chen
Hi,

As Richard suggested, if a location is UNKNOWN_LOCATION, instead of
change_scope to DECL_INITIAL (cfun->decl), we should let it inherit
location from its previous instructions. This is implemented in the
attached patch.

Bootstrapped and passed gcc regression tests and gdb regression tests.

Is it okay for trunk?

Thanks,
Dehao

gcc/ChangeLog:
2012-11-02  Dehao Chen  

* final.c (reemit_insn_block_notes): Do not change scope if insn
location is UNKNOWN_LOCATION.


block.patch
Description: Binary data


[libstdc++,doc] Some link housekeeping

2012-11-02 Thread Gerald Pfeifer
Next installment in my "so that libstdc++ hackers do not feel
neglected" series. ;-)

Applied.

Any volunteer to regenerate the HTML docs after my patches now?

Gerald

2012-11-02  Gerald Pfeifer  

* doc/xml/manual/configure.xml: Adjust GNU libc link.

* doc/xml/manual/debug.xml: Adjust GDB documentation link.
Use GCC instead of gcc.

* doc/xml/manual/prerequisites.xml: Remove detailed reference
to binutils downloads.

Index: doc/xml/manual/configure.xml
===
--- doc/xml/manual/configure.xml(revision 193108)
+++ doc/xml/manual/configure.xml(working copy)
@@ -106,7 +106,7 @@
choices are 'ieee_1003.1-2001' to specify an X/Open, Standard Unix
(IEEE Std. 1003.1-2001) model based on langinfo/iconv/catgets,
'gnu' to specify a model based on functionality from the GNU C
-   library (langinfo/iconv/gettext) (from http://www.w3.org/1999/xlink"; 
xlink:href="http://sources.redhat.com/glibc/";>glibc, the GNU C
+   library (langinfo/iconv/gettext) (from http://www.w3.org/1999/xlink"; 
xlink:href="https://www.gnu.org/software/libc/";>glibc, the GNU C
library), 'generic' to use a generic "C" abstraction which consists
of "C" locale info, 'newlib' to specify the Newlib C library model
which only differs from the 'generic' model in the handling of
Index: doc/xml/manual/debug.xml
===
--- doc/xml/manual/debug.xml(revision 193108)
+++ doc/xml/manual/debug.xml(working copy)
@@ -49,7 +49,7 @@
   shown in GDB. Expressiveness can be enhanced by flags like
   -g3. The default debug information for a particular
   platform can be identified via the value set by the
-  PREFERRED_DEBUGGING_TYPE macro in the gcc sources.
+  PREFERRED_DEBUGGING_TYPE macro in the GCC sources.
 
 
 
@@ -260,7 +260,7 @@
   
 
 
-  Many options are available for GDB itself: please see http://www.w3.org/1999/xlink"; 
xlink:href="http://sources.redhat.com/gdb/current/onlinedocs/gdb/";>
+  Many options are available for GDB itself: please see http://www.w3.org/1999/xlink"; 
xlink:href="http://sourceware.org/gdb/current/onlinedocs/gdb/";>
   "GDB features for C++"  in the GDB documentation. Also
   recommended: the other parts of this manual.
 
Index: doc/xml/manual/prerequisites.xml
===
--- doc/xml/manual/prerequisites.xml(revision 193108)
+++ doc/xml/manual/prerequisites.xml(working copy)
@@ -30,10 +30,7 @@
   
 
As of GCC 4.0.1 the minimum version of binutils required to build
-  libstdc++ is 2.15.90.0.1.1. You can get snapshots
-  (as well as releases) of binutils from
-  http://www.w3.org/1999/xlink"; 
xlink:href="ftp://sources.redhat.com/pub/binutils/";>
-  ftp://sources.redhat.com/pub/binutils.
+  libstdc++ is 2.15.90.0.1.1.
   Older releases of libstdc++ do not require such a recent version,
   but to take full advantage of useful space-saving features and
   bug-fixes you should use a recent binutils whenever possible.


Re: [PATCH] Add check for x32 support

2012-11-02 Thread H.J. Lu
On Fri, Nov 2, 2012 at 9:28 AM, Jack Howarth  wrote:
>   Currently on targets like x86_64 darwin which don't support -mx32 
> -maddress-mode=short,
> tests that pass those on dg-options fail with excessive errors at -m64. The 
> attached patch
> resolves this by adding a check_effective_target_maybe_x32 proc to test if 
> the -mx32
> -maddress-mode=short flags are supported. Tested on x86_64-apple-darwin12. 
> Okay for
> gcc trunk?
>  Jack
>
> 2012-11-02  H.J. Lu  
> Jack Howarth  
>
> * lib/target-supports.exp (check_effective_target_maybe_x32): New 
> proc.
> * gcc.target/i386/pr54457.c: Use dg-require-effective-target 
> maybe_x32.
> * gcc.target/i386/pr53249.c: Likewise.
>
>
> Index: gcc/testsuite/gcc.target/i386/pr54457.c
> ===
> --- gcc/testsuite/gcc.target/i386/pr54457.c (revision 193097)
> +++ gcc/testsuite/gcc.target/i386/pr54457.c (working copy)
> @@ -1,4 +1,5 @@
>  /* { dg-do compile { target { ! { ia32 } } } } */
> +/* { dg-require-effective-target maybe_x32 } */
>  /* { dg-options "-O2 -mx32 -maddress-mode=short" } */
>
>  extern char array[40];
> Index: gcc/testsuite/gcc.target/i386/pr53249.c
> ===
> --- gcc/testsuite/gcc.target/i386/pr53249.c (revision 193097)
> +++ gcc/testsuite/gcc.target/i386/pr53249.c (working copy)
> @@ -1,4 +1,5 @@
>  /* { dg-do compile { target { ! { ia32 } } } } */
> +/* { dg-require-effective-target maybe_x32 } */
>  /* { dg-options "-O2 -mx32 -ftls-model=initial-exec -maddress-mode=short" } 
> */
>
>  struct gomp_task
> Index: gcc/testsuite/lib/target-supports.exp
> ===
> --- gcc/testsuite/lib/target-supports.exp   (revision 193097)
> +++ gcc/testsuite/lib/target-supports.exp   (working copy)
> @@ -4608,6 +4608,14 @@ proc check_effective_target_lto { } {
>  return [info exists ENABLE_LTO]
>  }
>
> +# Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
> +
> +proc check_effective_target_maybe_x32 { } {
> +return [check_no_compiler_messages maybe_x32 object {
> +void foo (void) {}
> +} "-mx32 -maddress-mode=short"]
> +}
> +
>  # Return 1 if this target supports the -fsplit-stack option, 0
>  # otherwise.
>

Looks good to me.  But I can't approve it.

-- 
H.J.


Re: [PATCH 02/13] Rename tree-asan.[ch] to asan.[ch]

2012-11-02 Thread Dodji Seketeli
"Joseph S. Myers"  writes:

> On Thu, 1 Nov 2012, do...@redhat.com wrote:
>
>> From: dnovillo 
>> 
>> Following a discussion we had on this list, this patch renames the
>> file tree-asan.* into asan.*.
>> 
>>  * asan.c: Rename from tree-asan.c.
>>  Update all users.
>>  * asan.h: Rename from tree-asan.h
>>  Update all users.
>
> Patch series submissions for mainline should be cleanly rebased, with each 
> patch as a logical part of the intended eventual changes; they should not 
> be a dump of the successive stages by which the patch was developed.
>
> It's reasonable to have an initial patch that adds the skeleton of a 
> feature, then subsequent patches that add well-defined additional features 
> to it.  The following are examples of patch series structures that are not 
> appropriate:
>
> * This sort of adding a file under one name in one patch, then renaming in 
> a later patch of the series.
>
> * Introducing a known bug in one patch in the series, where a subsequent 
> patch in the series is the fix, unless the fix really depends on 
> intermediate patches in the series

I agree with this line of reasoning;  I tried to squash and split
the patches of the set to comply abide by your request.  I'll be
posting a new patch set accordingly.

Sorry for the nuisance.

-- 
Dodji


[wwwdocs] PATCH for Re: GCC 4.8.0 Status Report (2012-10-29), Stage 1 to end soon

2012-11-02 Thread Gerald Pfeifer
On Mon, 29 Oct 2012, Jakub Jelinek wrote:
> I'd like to close the stage 1 phase of GCC 4.8 development

Documented via the patch below.  I also changed "Active Development"
to "Development" to reduce text density and improve formatting on a
wider range of window/text sizes.

Gerald

Index: index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/index.html,v
retrieving revision 1.863
diff -u -3 -p -r1.863 index.html
--- index.html  20 Sep 2012 15:35:43 -  1.863
+++ index.html  2 Nov 2012 22:48:54 -
@@ -171,12 +171,12 @@ Any additions?  Don't be shy, send them 
   
 
 
-Active development:
+Development:
   GCC 4.8.0 (changes, release criteria)
 
   Status:
   
-  http://gcc.gnu.org/ml/gcc/2012-03/msg00011.html";>2012-03-02
+  http://gcc.gnu.org/ml/gcc/2012-10/msg00434.html";>2012-10-29
   
   (general development, stage 1).
   


Re: [PATCH 00/13] Request to merge Address Sanitizer in

2012-11-02 Thread Dodji Seketeli
do...@redhat.com writes:

> The first patch is the initial import of the asan state from the
> Google branch into the [asan] branch.  Subsequent patches clean the
> code up, add features like protection of stack and global variables,
> instrumentation of memory access through built-in functions, and, last
> but not least, the import of the runtime library.

In reply to requests in this thread, I am going to post another patch
set that follows the same grouping that the one above, but that avoids
being a dump of the different commits that happen on the branch.

I made some changes that were requested by some reviewers, like changing
the -fasan flag into -faddress-sanitizer, incorporating the last changes
(to the runtime time library directory layout) from Wei that got
committed to the asan branch, and removing the uselessly included
headers from the asan.c file.  I also rebased the patches on top of
trunk of today.

Below is the new summary of the patch set.  It has been bootstrapped and
passed regression testing on x86_64-unknown-linux-gnu against trunk.

Diego Novillo (1):
  Initial import of asan from the Google branch

Dodji Seketeli (3):
  Make build_check_stmt accept an SSA_NAME for its base
  Factorize condition insertion code out of build_check_stmt
  Instrument built-in memory access function calls

Jakub Jelinek (5):
  Initial asan cleanups
  Emit GIMPLE directly instead of gimplifying GENERIC.
  Allow asan at -O0
  Implement protection of stack variables
  Implement protection of global variables

Wei Mi (1):
  Import the asan runtime library into GCC tree

 ChangeLog.asan |16 +
 Makefile.def   | 2 +
 Makefile.in|   487 +-
 configure  | 1 +
 configure.ac   | 1 +
 gcc/ChangeLog.asan |   159 +
 gcc/Makefile.in|10 +-
 gcc/asan.c |  1483 ++
 gcc/asan.h |70 +
 gcc/cfgexpand.c|   165 +-
 gcc/common.opt | 4 +
 gcc/config/i386/i386.c |11 +
 gcc/doc/invoke.texi|13 +-
 gcc/doc/tm.texi| 6 +
 gcc/doc/tm.texi.in | 2 +
 gcc/gcc.c  | 1 +
 gcc/passes.c   | 2 +
 gcc/target.def |11 +
 gcc/toplev.c   |14 +
 gcc/tree-pass.h| 2 +
 gcc/varasm.c   |22 +
 libsanitizer/ChangeLog.asan| 3 +
 libsanitizer/LICENSE.TXT   |97 +
 libsanitizer/Makefile.am   |46 +
 libsanitizer/Makefile.in   |   773 +
 libsanitizer/README.gcc| 4 +
 libsanitizer/aclocal.m4|  9599 ++
 libsanitizer/asan/Makefile.am  |76 +
 libsanitizer/asan/Makefile.in  |   631 +
 libsanitizer/asan/asan_allocator.cc|  1045 ++
 libsanitizer/asan/asan_allocator.h |   177 +
 libsanitizer/asan/asan_flags.h |   103 +
 libsanitizer/asan/asan_globals.cc  |   206 +
 libsanitizer/asan/asan_intercepted_functions.h |   217 +
 libsanitizer/asan/asan_interceptors.cc |   704 +
 libsanitizer/asan/asan_interceptors.h  |39 +
 libsanitizer/asan/asan_internal.h  |   169 +
 libsanitizer/asan/asan_linux.cc|   150 +
 libsanitizer/asan/asan_lock.h  |40 +
 libsanitizer/asan/asan_mac.cc  |   526 +
 libsanitizer/asan/asan_mac.h   |54 +
 libsanitizer/asan/asan_malloc_linux.cc |   142 +
 libsanitizer/asan/asan_malloc_mac.cc   |   427 +
 libsanitizer/asan/asan_malloc_win.cc   |   140 +
 libsanitizer/asan/asan_mapping.h   |   120 +
 libsanitizer/asan/asan_new_delete.cc   |54 +
 libsanitizer/asan/asan_poisoning.cc|   151 +
 libsanitizer/asan/asan_posix.cc|   118 +
 libsanitizer/asan/asan_report.cc   |   492 +
 libsanitizer/asan/asan_report.h|51 +
 libsanitizer/asan/asan_rtl.cc  |   404 +
 libsanitizer/asan/asan_stack.cc|35 +
 libsanitizer/asan/asan_stack.h |52 +
 libsanitizer/asan/asan_stats.cc|86 +
 libsanitizer/asan/asan_stats.h   

[PATCH 01/10] Initial import of asan from the Google branch into trunk

2012-11-02 Thread Dodji Seketeli
This patch imports the initial state of asan as it was in the
Google branch.

It provides basic infrastructure for asan to instrument memory
accesses on the heap, at -O3.  Note that it supports neither stack nor
global variable protection.

The rest of the patches of the set is intended to further improve this
base.

* Makefile.in: Add asan.c and its dependencies.
* common.opt: Add -fasan option.
* invoke.texi: Document the new flag.
* passes.c: Add the asan pass.
* toplev.c (compile_file): Call asan_finish_file.
* asan.c: New file.
* asan.h: New file.
* tree-pass.h: Declare pass_asan.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/asan@192360 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.asan  |  12 ++
 gcc/Makefile.in |   5 +
 gcc/asan.c  | 404 
 gcc/asan.h  |  26 
 gcc/common.opt  |   4 +
 gcc/doc/invoke.texi |  13 +-
 gcc/passes.c|   1 +
 gcc/toplev.c|   5 +
 gcc/tree-pass.h |   1 +
 9 files changed, 468 insertions(+), 3 deletions(-)
 create mode 100644 gcc/ChangeLog.asan
 create mode 100644 gcc/asan.c
 create mode 100644 gcc/asan.h

diff --git a/gcc/ChangeLog.asan b/gcc/ChangeLog.asan
new file mode 100644
index 000..704aa61
--- /dev/null
+++ b/gcc/ChangeLog.asan
@@ -0,0 +1,12 @@
+2012-10-10  Wei Mi 
+   Diego Novillo 
+   Dodji Seketeli 
+
+   * Makefile.in: Add asan.c and its dependencies.
+   * common.opt: Add -faddress-sanitizer option.
+   * invoke.texi: Document the new flag.
+   * passes.c: Add the asan pass.
+   * toplev.c (compile_file): Call asan_finish_file.
+   * asan.c: New file.
+   * asan.h: New file.
+   * tree-pass.h: Declare pass_asan.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 9aea03d..3bade7f 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1348,6 +1348,7 @@ OBJS = \
tracer.o \
trans-mem.o \
tree-affine.o \
+   asan.o \
tree-call-cdce.o \
tree-cfg.o \
tree-cfgcleanup.o \
@@ -2206,6 +2207,10 @@ stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) 
coretypes.h $(TM_H) \
$(TREE_H) $(PARAMS_H) $(FLAGS_H) $(FUNCTION_H) $(EXPR_H) $(RTL_H) \
$(GGC_H) $(TM_P_H) $(TARGET_H) langhooks.h $(REGS_H) gt-stor-layout.h \
$(DIAGNOSTIC_CORE_H) $(CGRAPH_H) $(TREE_INLINE_H) $(TREE_DUMP_H) $(GIMPLE_H)
+asan.o : asan.c asan.h $(CONFIG_H) pointer-set.h \
+   $(SYSTEM_H) $(TREE_H) $(GIMPLE_H) \
+   output.h $(DIAGNOSTIC_H) coretypes.h $(TREE_DUMP_H) $(FLAGS_H) \
+   tree-pretty-print.h
 tree-ssa-tail-merge.o: tree-ssa-tail-merge.c \
$(SYSTEM_H) $(CONFIG_H) coretypes.h $(TM_H) $(BITMAP_H) \
$(FLAGS_H) $(TM_P_H) $(BASIC_BLOCK_H) \
diff --git a/gcc/asan.c b/gcc/asan.c
new file mode 100644
index 000..4b07c96
--- /dev/null
+++ b/gcc/asan.c
@@ -0,0 +1,404 @@
+/* AddressSanitizer, a fast memory error detector.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   Contributed by Kostya Serebryany 
+
+This file is part of GCC.
+
+GCC 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.
+
+GCC 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 GCC; see the file COPYING3.  If not see
+.  */
+
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tree.h"
+#include "tm_p.h"
+#include "basic-block.h"
+#include "flags.h"
+#include "function.h"
+#include "tree-inline.h"
+#include "gimple.h"
+#include "tree-iterator.h"
+#include "tree-flow.h"
+#include "tree-dump.h"
+#include "tree-pass.h"
+#include "diagnostic.h"
+#include "demangle.h"
+#include "langhooks.h"
+#include "ggc.h"
+#include "cgraph.h"
+#include "gimple.h"
+#include "asan.h"
+#include "gimple-pretty-print.h"
+
+/*
+ AddressSanitizer finds out-of-bounds and use-after-free bugs 
+ with <2x slowdown on average.
+
+ The tool consists of two parts:
+ instrumentation module (this file) and a run-time library.
+ The instrumentation module adds a run-time check before every memory insn.
+   For a 8- or 16- byte load accessing address X:
+ ShadowAddr = (X >> 3) + Offset
+ ShadowValue = *(char*)ShadowAddr;  // *(short*) for 16-byte access.
+ if (ShadowValue)
+   __asan_report_load8(X);
+   For a load of N bytes (N=1, 2 or 4) from address X:
+ ShadowAddr = (X >> 3) + Offset
+ ShadowValue = *(char*)ShadowAddr;
+ if (ShadowValue)
+   if ((X & 7) + N - 1 > ShadowValue)
+ __asan_report_loadN(X);
+ Stores are instrumented similarly, bu

[PATCH 02/10] Initial asan cleanups

2012-11-02 Thread Dodji Seketeli
This patch defines a new asan_shadow_offset target macro, instead of
having a mere macro in the asan.c file.  It becomes thus cleaner to
define the target macro for targets that supports asan, namely x86 for
now.  The ASAN_SHADOW_SHIFT (which, along with the asan_shadow_offset
constant, is used to compute the address of the shadow memory byte for
a given memory address) is defined in asan.h.

* toplev.c (process_options): Warn and turn off
-faddress-sanitizer if not supported by target.
* asan.c: Include target.h.
(asan_scale, asan_offset_log_32, asan_offset_log_64,
asan_offset_log): Removed.
(build_check_stmt): Use ASAN_SHADOW_SHIFT and
targetm.asan_shadow_offset ().
(asan_instrument): Don't initialize asan_offset_log.
* asan.h (ASAN_SHADOW_SHIFT): Define.
* target.def (TARGET_ASAN_SHADOW_OFFSET): New hook.
* doc/tm.texi.in (TARGET_ASAN_SHADOW_OFFSET): Add it.
* doc/tm.texi: Regenerated.
* Makefile.in (asan.o): Depend on $(TARGET_H).
* config/i386/i386.c (ix86_asan_shadow_offset): New function.
(TARGET_ASAN_SHADOW_OFFSET): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/asan@192372 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.asan | 18 ++
 gcc/Makefile.in|  2 +-
 gcc/asan.c | 25 ++---
 gcc/asan.h |  6 +-
 gcc/config/i386/i386.c | 11 +++
 gcc/doc/tm.texi|  6 ++
 gcc/doc/tm.texi.in |  2 ++
 gcc/target.def | 11 +++
 gcc/toplev.c   |  7 +++
 9 files changed, 67 insertions(+), 21 deletions(-)

diff --git a/gcc/ChangeLog.asan b/gcc/ChangeLog.asan
index 704aa61..d13a584 100644
--- a/gcc/ChangeLog.asan
+++ b/gcc/ChangeLog.asan
@@ -1,3 +1,21 @@
+2012-10-11  Jakub Jelinek  
+
+   * toplev.c (process_options): Warn and turn off
+   -faddress-sanitizer if not supported by target.
+   * asan.c: Include target.h.
+   (asan_scale, asan_offset_log_32, asan_offset_log_64,
+   asan_offset_log): Removed.
+   (build_check_stmt): Use ASAN_SHADOW_SHIFT and
+   targetm.asan_shadow_offset ().
+   (asan_instrument): Don't initialize asan_offset_log.
+   * asan.h (ASAN_SHADOW_SHIFT): Define.
+   * target.def (TARGET_ASAN_SHADOW_OFFSET): New hook.
+   * doc/tm.texi.in (TARGET_ASAN_SHADOW_OFFSET): Add it.
+   * doc/tm.texi: Regenerated.
+   * Makefile.in (asan.o): Depend on $(TARGET_H).
+   * config/i386/i386.c (ix86_asan_shadow_offset): New function.
+   (TARGET_ASAN_SHADOW_OFFSET): Define.
+
 2012-10-10  Wei Mi 
Diego Novillo 
Dodji Seketeli 
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 3bade7f..c86bbeb 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2210,7 +2210,7 @@ stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) 
coretypes.h $(TM_H) \
 asan.o : asan.c asan.h $(CONFIG_H) pointer-set.h \
$(SYSTEM_H) $(TREE_H) $(GIMPLE_H) \
output.h $(DIAGNOSTIC_H) coretypes.h $(TREE_DUMP_H) $(FLAGS_H) \
-   tree-pretty-print.h
+   tree-pretty-print.h $(TARGET_H)
 tree-ssa-tail-merge.o: tree-ssa-tail-merge.c \
$(SYSTEM_H) $(CONFIG_H) coretypes.h $(TM_H) $(BITMAP_H) \
$(FLAGS_H) $(TM_P_H) $(BASIC_BLOCK_H) \
diff --git a/gcc/asan.c b/gcc/asan.c
index 4b07c96..6cd9625 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1,5 +1,5 @@
 /* AddressSanitizer, a fast memory error detector.
-   Copyright (C) 2011 Free Software Foundation, Inc.
+   Copyright (C) 2011, 2012 Free Software Foundation, Inc.
Contributed by Kostya Serebryany 
 
 This file is part of GCC.
@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple.h"
 #include "asan.h"
 #include "gimple-pretty-print.h"
+#include "target.h"
 
 /*
  AddressSanitizer finds out-of-bounds and use-after-free bugs 
@@ -78,15 +79,6 @@ along with GCC; see the file COPYING3.  If not see
  to create redzones for stack and global object and poison them.
 */
 
-/* The shadow address is computed as (X>>asan_scale) + (1<> asan_scale) + (1 << asan_offset_log).  */
+  /* Build
+ (base_addr >> ASAN_SHADOW_SHIFT) | targetm.asan_shadow_offset ().  */
 
   t = build2 (RSHIFT_EXPR, uintptr_type, base_addr,
-  build_int_cst (uintptr_type, asan_scale));
+ build_int_cst (uintptr_type, ASAN_SHADOW_SHIFT));
   t = build2 (PLUS_EXPR, uintptr_type, t,
-  build2 (LSHIFT_EXPR, uintptr_type,
-  build_int_cst (uintptr_type, 1),
-  build_int_cst (uintptr_type, asan_offset_log)
- ));
+ build_int_cst (uintptr_type, targetm.asan_shadow_offset ()));
   t = build1 (INDIRECT_REF, shadow_type,
   build1 (VIEW_CONVERT_EXPR, shadow_ptr_type, t));
   t = force_gimple_operand (t, &stmts, false, NULL_TREE);
@@ -367,9 +357,6 @@ static unsigned int
 asan_instrument (void)
 {
   struct gimplify_ctx gctx;
-  tree uintp

[PATCH 03/10] Emit GIMPLE directly instead of gimplifying GENERIC.

2012-11-02 Thread Dodji Seketeli
This patch cleanups the instrumentation code generation by emitting
GIMPLE directly, as opposed to emitting GENERIC tree and then
gimplifying them.  It also does some cleanups here and there

* Makefile.in (GTFILES): Add $(srcdir)/asan.c.
(asan.o): Update the dependencies of asan.o.
* asan.c (tm.h, tree.h, tm_p.h, basic-block.h, flags.h
function.h, tree-inline.h, tree-dump.h, diagnostic.h, demangle.h,
langhooks.h, ggc.h, cgraph.h, gimple.h): Remove these unused but
included headers.
(shadow_ptr_types): New variable.
(report_error_func): Change is_store argument to bool, don't append
newline to function name.
(PROB_VERY_UNLIKELY, PROB_ALWAYS): Define.
(build_check_stmt): Change is_store argument to bool.  Emit GIMPLE
directly instead of creating trees and gimplifying them.  Mark
the error reporting function as very unlikely.
(instrument_derefs): Change is_store argument to bool.  Use
int_size_in_bytes to compute size_in_bytes, simplify size check.
Use build_fold_addr_expr instead of build_addr.
(transform_statements): Adjust instrument_derefs caller.
Use gimple_assign_single_p as stmt test.  Don't look at MEM refs
in rhs2.
(asan_init_shadow_ptr_types): New function.
(asan_instrument): Don't push/pop gimplify context.
Call asan_init_shadow_ptr_types if not yet initialized.
* asan.h (ASAN_SHADOW_SHIFT): Adjust comment.
---
 gcc/ChangeLog.asan |  27 +
 gcc/Makefile.in|   9 +-
 gcc/asan.c | 284 +++--
 gcc/asan.h |   2 +-
 4 files changed, 199 insertions(+), 123 deletions(-)

diff --git a/gcc/ChangeLog.asan b/gcc/ChangeLog.asan
index d13a584..973ee6b 100644
--- a/gcc/ChangeLog.asan
+++ b/gcc/ChangeLog.asan
@@ -1,4 +1,31 @@
 2012-10-11  Jakub Jelinek  
+   Dodji Seketeli 
+
+   * Makefile.in (GTFILES): Add $(srcdir)/asan.c.
+   (asan.o): Update the dependencies of asan.o.
+   * asan.c (tm.h, tree.h, tm_p.h, basic-block.h, flags.h
+   function.h, tree-inline.h, tree-dump.h, diagnostic.h, demangle.h,
+   langhooks.h, ggc.h, cgraph.h, gimple.h): Remove these unused but
+   included headers.
+   (shadow_ptr_types): New variable.
+   (report_error_func): Change is_store argument to bool, don't append
+   newline to function name.
+   (PROB_VERY_UNLIKELY, PROB_ALWAYS): Define.
+   (build_check_stmt): Change is_store argument to bool.  Emit GIMPLE
+   directly instead of creating trees and gimplifying them.  Mark
+   the error reporting function as very unlikely.
+   (instrument_derefs): Change is_store argument to bool.  Use
+   int_size_in_bytes to compute size_in_bytes, simplify size check.
+   Use build_fold_addr_expr instead of build_addr.
+   (transform_statements): Adjust instrument_derefs caller.
+   Use gimple_assign_single_p as stmt test.  Don't look at MEM refs
+   in rhs2.
+   (asan_init_shadow_ptr_types): New function.
+   (asan_instrument): Don't push/pop gimplify context.
+   Call asan_init_shadow_ptr_types if not yet initialized.
+   * asan.h (ASAN_SHADOW_SHIFT): Adjust comment.
+
+2012-10-11  Jakub Jelinek  
 
* toplev.c (process_options): Warn and turn off
-faddress-sanitizer if not supported by target.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index c86bbeb..1536800 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2207,10 +2207,10 @@ stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) 
coretypes.h $(TM_H) \
$(TREE_H) $(PARAMS_H) $(FLAGS_H) $(FUNCTION_H) $(EXPR_H) $(RTL_H) \
$(GGC_H) $(TM_P_H) $(TARGET_H) langhooks.h $(REGS_H) gt-stor-layout.h \
$(DIAGNOSTIC_CORE_H) $(CGRAPH_H) $(TREE_INLINE_H) $(TREE_DUMP_H) $(GIMPLE_H)
-asan.o : asan.c asan.h $(CONFIG_H) pointer-set.h \
-   $(SYSTEM_H) $(TREE_H) $(GIMPLE_H) \
-   output.h $(DIAGNOSTIC_H) coretypes.h $(TREE_DUMP_H) $(FLAGS_H) \
-   tree-pretty-print.h $(TARGET_H)
+asan.o : asan.c asan.h $(CONFIG_H) $(SYSTEM_H) $(GIMPLE_H) \
+   output.h coretypes.h $(GIMPLE_PRETTY_PRINT_H) \
+   tree-iterator.h $(TREE_FLOW_H) $(TREE_PASS_H) \
+   $(TARGET_H)
 tree-ssa-tail-merge.o: tree-ssa-tail-merge.c \
$(SYSTEM_H) $(CONFIG_H) coretypes.h $(TM_H) $(BITMAP_H) \
$(FLAGS_H) $(TM_P_H) $(BASIC_BLOCK_H) \
@@ -3723,6 +3723,7 @@ GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h 
$(srcdir)/coretypes.h \
   $(srcdir)/lto-streamer.h \
   $(srcdir)/target-globals.h \
   $(srcdir)/ipa-inline.h \
+  $(srcdir)/asan.c \
   @all_gtfiles@
 
 # Compute the list of GT header files from the corresponding C sources,
diff --git a/gcc/asan.c b/gcc/asan.c
index 6cd9625..baaec0f 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -22,24 +22,10 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "tm.h"
-#include "tree.h"
-#include 

[PATCH 04/10] Allow asan at -O0

2012-11-02 Thread Dodji Seketeli
This patch defines a new asan pass gate that is activated at -O0, in
addition to the pass that was initially activated at -O3 level The
patch also does some comment cleanups here and there.

* asan.c (build_check_stmt): Rename join_bb variable to else_bb.
(gate_asan_O0): New function.
(pass_asan_O0): New variable.
* passes.c (init_optimization_passes): Add pass_asan_O0.
* tree-pass.h (pass_asan_O0): New declaration.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/asan@192415 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.asan |  8 
 gcc/asan.c | 45 -
 gcc/passes.c   |  1 +
 gcc/tree-pass.h|  1 +
 4 files changed, 46 insertions(+), 9 deletions(-)

diff --git a/gcc/ChangeLog.asan b/gcc/ChangeLog.asan
index 973ee6b..131afc7 100644
--- a/gcc/ChangeLog.asan
+++ b/gcc/ChangeLog.asan
@@ -1,3 +1,11 @@
+2012-10-12  Jakub Jelinek  
+
+   * asan.c (build_check_stmt): Rename join_bb variable to else_bb.
+   (gate_asan_O0): New function.
+   (pass_asan_O0): New variable.
+   * passes.c (init_optimization_passes): Add pass_asan_O0.
+   * tree-pass.h (pass_asan_O0): New declaration.
+
 2012-10-11  Jakub Jelinek  
Dodji Seketeli 
 
diff --git a/gcc/asan.c b/gcc/asan.c
index baaec0f..e7f4943 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -123,7 +123,7 @@ build_check_stmt (tree base,
   location_t location, bool is_store, int size_in_bytes)
 {
   gimple_stmt_iterator gsi;
-  basic_block cond_bb, then_bb, join_bb;
+  basic_block cond_bb, then_bb, else_bb;
   edge e;
   tree t, base_addr, shadow;
   gimple g;
@@ -144,23 +144,23 @@ build_check_stmt (tree base,
   else
 e = split_block_after_labels (cond_bb);
   cond_bb = e->src;
-  join_bb = e->dest;
+  else_bb = e->dest;
 
-  /* A recap at this point: join_bb is the basic block at whose head
+  /* A recap at this point: else_bb is the basic block at whose head
  is the gimple statement for which this check expression is being
  built.  cond_bb is the (possibly new, synthetic) basic block the
  end of which will contain the cache-lookup code, and a
  conditional that jumps to the cache-miss code or, much more
- likely, over to join_bb.  */
+ likely, over to else_bb.  */
 
   /* Create the bb that contains the crash block.  */
   then_bb = create_empty_bb (cond_bb);
   e = make_edge (cond_bb, then_bb, EDGE_TRUE_VALUE);
   e->probability = PROB_VERY_UNLIKELY;
-  make_single_succ_edge (then_bb, join_bb, EDGE_FALLTHRU);
+  make_single_succ_edge (then_bb, else_bb, EDGE_FALLTHRU);
 
-  /* Mark the pseudo-fallthrough edge from cond_bb to join_bb.  */
-  e = find_edge (cond_bb, join_bb);
+  /* Mark the pseudo-fallthrough edge from cond_bb to else_bb.  */
+  e = find_edge (cond_bb, else_bb);
   e->flags = EDGE_FALSE_VALUE;
   e->count = cond_bb->count;
   e->probability = PROB_ALWAYS - PROB_VERY_UNLIKELY;
@@ -170,7 +170,7 @@ build_check_stmt (tree base,
   if (dom_info_available_p (CDI_DOMINATORS))
 {
   set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
-  set_immediate_dominator (CDI_DOMINATORS, join_bb, cond_bb);
+  set_immediate_dominator (CDI_DOMINATORS, else_bb, cond_bb);
 }
 
   base = unshare_expr (base);
@@ -293,7 +293,7 @@ build_check_stmt (tree base,
   gimple_set_location (g, location);
   gsi_insert_after (&gsi, g, GSI_NEW_STMT);
 
-  *iter = gsi_start_bb (join_bb);
+  *iter = gsi_start_bb (else_bb);
 }
 
 /* If T represents a memory access, add instrumentation code before ITER.
@@ -436,4 +436,31 @@ struct gimple_opt_pass pass_asan =
  }
 };
 
+static bool
+gate_asan_O0 (void)
+{
+  return flag_asan != 0 && !optimize;
+}
+
+struct gimple_opt_pass pass_asan_O0 =
+{
+ {
+  GIMPLE_PASS,
+  "asan0", /* name  */
+  OPTGROUP_NONE,/* optinfo_flags */
+  gate_asan_O0,/* gate  */
+  asan_instrument, /* execute  */
+  NULL,/* sub  */
+  NULL,/* next  */
+  0,   /* static_pass_number  */
+  TV_NONE, /* tv_id  */
+  PROP_ssa | PROP_cfg | PROP_gimple_leh,/* properties_required  */
+  0,   /* properties_provided  */
+  0,   /* properties_destroyed  */
+  0,   /* todo_flags_start  */
+  TODO_verify_flow | TODO_verify_stmts
+  | TODO_update_ssa/* todo_flags_finish  */
+ }
+};
+
 #include "gt-asan.h"
diff --git a/gcc/passes.c b/gcc/passes.c
index 66a2f74..d4115b3 100644
--- a/gcc/passes.c
+++ b/gcc/passes.c
@@ -1562,6 +1562,7 @@ init_optimization_passes (void)
   NEXT_PASS (pass_tm_edges);
 }
   NEXT_PASS (pass_lower_complex_O0);
+  NEXT_PASS (pass_asan_O0);
   NEXT_PASS (pass_cleanup_eh);
   NEXT_PASS (pass_

Re: [SH] PR 51244 - catch more unnecessary T bit stores

2012-11-02 Thread Kaz Kojima
Oleg Endo  wrote:
> With this patch a few more cases are handled where the T bit is stored
> and then re-tested again before conditional branches.
> Tested on rev 193061 with
> make -k check RUNTESTFLAGS="--target_board=sh-sim
> \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"
> 
> and no new failures.
> OK?

OK.

Regards,
kaz


Re: [SH] Use some more multi-line asm in sh.c

2012-11-02 Thread Kaz Kojima
Oleg Endo  wrote:
> This mainly reformats some of the asm output code in sh.c to use
> multi-line strings.
> Tested on rev 193061 with
> make -k check RUNTESTFLAGS="--target_board=sh-sim
> \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"
> 
> and no new failures.
> OK?

OK.

Regards,
kaz


[PATCH 05/10] Implement protection of stack variables

2012-11-02 Thread Dodji Seketeli
This patch implements the protection of stack variables.

To understand how this works, lets look at this example on x86_64
where the stack grows downward:

 int
 foo ()
 {
   char a[23] = {0};
   int b[2] = {0};

   a[5] = 1;
   b[1] = 2;

   return a[5] + b[1];
 }

For this function, the stack protected by asan will be organized as
follows, from the top of the stack to the bottom:

Slot 1/ [red zone of 32 bytes called 'RIGHT RedZone']

Slot 2/ [24 bytes for variable 'a']

Slot 3/ [8 bytes of red zone, that adds up to the space of 'a' to make
 the next slot be 32 bytes aligned; this one is called Partial
 Redzone; this 32 bytes alignment is an asan constraint]

Slot 4/ [red zone of 32 bytes called 'Middle RedZone']

Slot 5/ [8 bytes for variable 'b']

Slot 6/ [24 bytes of Partial Red Zone (similar to slot 3]

Slot 7/ [32 bytes of Red Zone at the bottom of the stack, called 'LEFT
 RedZone']

[A cultural question I've kept asking myself is Why has address
 sanitizer authors called these red zones (LEFT, MIDDLE, RIGHT)
 instead of e.g, (BOTTOM, MIDDLE, TOP).  Maybe they can step up and
 educate me so that I get less confused in the future.  :-)]

The 32 bytes of LEFT red zone at the bottom of the stack can be
decomposed as such:

1/ The first 8 bytes contain a magical asan number that is always
0x41B58AB3.

2/ The following 8 bytes contains a pointer to a string (to be
parsed at runtime by the runtime asan library), which format is
the following:

 "  
 (<32-bytes-aligned-offset-in-bytes-of-variable> 
  ){n} "

where '(...){n}' means the content inside the parenthesis occurs 'n'
times, with 'n' being the number of variables on the stack.

 3/ The following 16 bytes of the red zone have no particular
 format.

The shadow memory for that stack layout is going to look like this:

- content of shadow memory 8 bytes for slot 7: 0xF1F1F1F1.
  The F1 byte pattern is a magic number called
  ASAN_STACK_MAGIC_LEFT and is a way for the runtime to know that
  the memory for that shadow byte is part of a the LEFT red zone
  intended to seat at the bottom of the variables on the stack.

- content of shadow memory 8 bytes for slots 6 and 5:
  0xF4F4F400.  The F4 byte pattern is a magic number
  called ASAN_STACK_MAGIC_PARTIAL.  It flags the fact that the
  memory region for this shadow byte is a PARTIAL red zone
  intended to pad a variable A, so that the slot following
  {A,padding} is 32 bytes aligned.

  Note that the fact that the least significant byte of this
  shadow memory content is 00 means that 8 bytes of its
  corresponding memory (which corresponds to the memory of
  variable 'b') is addressable.

- content of shadow memory 8 bytes for slot 4: 0xF2F2F2F2.
  The F2 byte pattern is a magic number called
  ASAN_STACK_MAGIC_MIDDLE.  It flags the fact that the memory
  region for this shadow byte is a MIDDLE red zone intended to
  seat between two 32 aligned slots of {variable,padding}.

- content of shadow memory 8 bytes for slot 3 and 2:
  0xF400.  This represents is the concatenation of
  variable 'a' and the partial red zone following it, like what we
  had for variable 'b'.  The least significant 3 bytes being 00
  means that the 3 bytes of variable 'a' are addressable.

- content of shadow memory 8 bytes for slot 1: 0xF3F3F3F3.
  The F3 byte pattern is a magic number called
  ASAN_STACK_MAGIC_RIGHT.  It flags the fact that the memory
  region for this shadow byte is a RIGHT red zone intended to seat
  at the top of the variables of the stack.

So, the patch lays out stack variables as well as the different red
zones, emits some prologue code to populate the shadow memory as to
poison (mark as non-accessible) the regions of the red zones and mark
the regions of stack variables as accessible, and emit some epilogue
code to un-poison (mark as accessible) the regions of red zones right
before the function exits.

* Makefile.in (asan.o): Depend on $(EXPR_H) $(OPTABS_H).
(cfgexpand.o): Depend on asan.h.
* asan.c: Include expr.h and optabs.h.
(asan_shadow_set): New variable.
(asan_shadow_cst, asan_emit_stack_protection): New functions.
(asan_init_shadow_ptr_types): Initialize also asan_shadow_set.
* cfgexpand.c: Include asan.h.  Define HOST_WIDE_INT heap vector.
(partition_stack_vars): If i is large alignment and j small
alignment or vice versa, break out of the loop instead of continue,
and put the test earlier.  If flag_asan, break out of the loop
if for small alignment size is different.
(struct stack_vars_data): New type.
(expand_stack_vars): Add DATA argument.  Change PRED type to
function taking size_t argument instead of tree.  Adjust pred calls.
Fill 

[PATCH 06/10] Implement protection of global variables

2012-11-02 Thread Dodji Seketeli
This patch implements the protection of global variables.

The basic idea is to insert a red zone between two global variables
and install a constructor function that calls the asan runtime to do
the populating of the relevant shadow memory regions at load time.

So the patch lays out the global variables as to insert a red zone
between them. The size of the red zones is so that each variable
starts on a 32 bytes boundary.

Then it installs a constructor function that, for each global
variable, calls the runtime asan library function
__asan_register_globals_with an instance of this type:

struct __asan_global
{
  /* Address of the beginning of the global variable.  */
  const void *__beg;

  /* Initial size of the global variable.  */
  uptr __size;

  /* Size of the global variable + size of the red zone.  This
 size is 32 bytes aligned.  */
  uptr __size_with_redzone;

  /*  Name of the global variable.  */
  const void *__name;

  /* This is always set to NULL for now.  */
  uptr __has_dynamic_init;
}

The patch also installs a destructor function that calls the
runtime asan library function _asan_unregister_globals.

* varasm.c: Include asan.h.
(assemble_noswitch_variable): Grow size by asan_red_zone_size
if decl is asan protected.
(place_block_symbol): Likewise.
(assemble_variable): If decl is asan protected, increase
DECL_ALIGN if needed, and for decls emitted using
assemble_variable_contents append padding zeros after it.
* Makefile.in (varasm.o): Depend on asan.h.
* asan.c: Include output.h.
(asan_pp, asan_pp_initialized, asan_ctor_statements): New variables.
(asan_pp_initialize, asan_pp_string): New functions.
(asan_emit_stack_protection): Use asan_pp{,_initialized}
instead of local pp{,_initialized} vars, use asan_pp_initialize
and asan_pp_string helpers.
(asan_needs_local_alias, asan_protect_global,
asan_global_struct, asan_add_global): New functions.
(asan_finish_file): Protect global vars that can be protected. Use
asan_ctor_statements instead of ctor_statements
* asan.h (asan_protect_global): New prototype.
(asan_red_zone_size): New inline function.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/asan@192541 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.asan |  24 +
 gcc/Makefile.in|   2 +-
 gcc/asan.c | 306 ++---
 gcc/asan.h |  11 ++
 gcc/varasm.c   |  22 
 5 files changed, 328 insertions(+), 37 deletions(-)

diff --git a/gcc/ChangeLog.asan b/gcc/ChangeLog.asan
index 14a0b98..a2e18ce 100644
--- a/gcc/ChangeLog.asan
+++ b/gcc/ChangeLog.asan
@@ -1,4 +1,28 @@
 2012-10-17  Jakub Jelinek  
+   Wei Mi 
+
+   * varasm.c: Include asan.h.
+   (assemble_noswitch_variable): Grow size by asan_red_zone_size
+   if decl is asan protected.
+   (place_block_symbol): Likewise.
+   (assemble_variable): If decl is asan protected, increase
+   DECL_ALIGN if needed, and for decls emitted using
+   assemble_variable_contents append padding zeros after it.
+   * Makefile.in (varasm.o): Depend on asan.h.
+   * asan.c: Include output.h.
+   (asan_pp, asan_pp_initialized, asan_ctor_statements): New variables.
+   (asan_pp_initialize, asan_pp_string): New functions.
+   (asan_emit_stack_protection): Use asan_pp{,_initialized}
+   instead of local pp{,_initialized} vars, use asan_pp_initialize
+   and asan_pp_string helpers.
+   (asan_needs_local_alias, asan_protect_global,
+   asan_global_struct, asan_add_global): New functions.
+   (asan_finish_file): Protect global vars that can be protected. Use
+   asan_ctor_statements instead of ctor_statements
+   * asan.h (asan_protect_global): New prototype.
+   (asan_red_zone_size): New inline function.
+
+2012-10-17  Jakub Jelinek  
 
* Makefile.in (asan.o): Depend on $(EXPR_H) $(OPTABS_H).
(cfgexpand.o): Depend on asan.h.
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 988574e..3251a55 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2718,7 +2718,7 @@ varasm.o : varasm.c $(CONFIG_H) $(SYSTEM_H) coretypes.h 
$(TM_H) $(TREE_H) \
output.h $(DIAGNOSTIC_CORE_H) xcoffout.h debug.h $(GGC_H) $(TM_P_H) \
$(HASHTAB_H) $(TARGET_H) langhooks.h gt-varasm.h $(BASIC_BLOCK_H) \
$(CGRAPH_H) $(TARGET_DEF_H) tree-mudflap.h \
-   pointer-set.h $(COMMON_TARGET_H)
+   pointer-set.h $(COMMON_TARGET_H) asan.h
 function.o : function.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) 
$(RTL_ERROR_H) \
$(TREE_H) $(GIMPLE_H) $(FLAGS_H) $(FUNCTION_H) $(EXPR_H) \
$(OPTABS_H) $(LIBFUNCS_H) $(REGS_H) hard-reg-set.h insn-config.h $(RECOG_H) 
\
diff --git a/gcc/asan.c b/gcc/asan.c
index 578bb02..6880270 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -31,6 +31,7 @@ along wit

[PATCH 07/10] Make build_check_stmt accept an SSA_NAME for its base

2012-11-02 Thread Dodji Seketeli
This patch makes build_check_stmt accept its memory access parameter
to be an SSA name.  This is useful for a subsequent patch that will
re-use.

Tested by running cc1 -fasan on the program below with and without the
patch and inspecting the gimple output to see that there is no change.

void
foo ()
{
  char foo[1] = {0};

  foo[0] = 1;
}

gcc/
* asan.c (build_check_stmt): Accept the memory access to be
represented by an SSA_NAME.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/asan@192843 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.asan |  5 +
 gcc/asan.c | 36 +++-
 2 files changed, 28 insertions(+), 13 deletions(-)

diff --git a/gcc/ChangeLog.asan b/gcc/ChangeLog.asan
index a2e18ce..395ba4f 100644
--- a/gcc/ChangeLog.asan
+++ b/gcc/ChangeLog.asan
@@ -1,3 +1,8 @@
+2012-10-26  Dodji Seketeli  
+
+   * asan.c (build_check_stmt): Accept the memory access to be
+   represented by an SSA_NAME.
+
 2012-10-17  Jakub Jelinek  
Wei Mi 
 
diff --git a/gcc/asan.c b/gcc/asan.c
index 6880270..7c99173 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -383,16 +383,18 @@ asan_init_func (void)
 #define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 2000 - 1)
 #define PROB_ALWAYS(REG_BR_PROB_BASE)
 
-/* Instrument the memory access instruction BASE.
-   Insert new statements before ITER.
-   LOCATION is source code location.
-   IS_STORE is either 1 (for a store) or 0 (for a load).
+/* Instrument the memory access instruction BASE.  Insert new
+   statements before ITER.
+
+   Note that the memory access represented by BASE can be either an
+   SSA_NAME, or a non-SSA expression.  LOCATION is the source code
+   location.  IS_STORE is TRUE for a store, FALSE for a load.
SIZE_IN_BYTES is one of 1, 2, 4, 8, 16.  */
 
 static void
-build_check_stmt (tree base,
-  gimple_stmt_iterator *iter,
-  location_t location, bool is_store, int size_in_bytes)
+build_check_stmt (tree base, gimple_stmt_iterator *iter,
+  location_t location, bool is_store,
+ int size_in_bytes)
 {
   gimple_stmt_iterator gsi;
   basic_block cond_bb, then_bb, else_bb;
@@ -403,6 +405,7 @@ build_check_stmt (tree base,
   tree shadow_type = TREE_TYPE (shadow_ptr_type);
   tree uintptr_type
 = build_nonstandard_integer_type (TYPE_PRECISION (TREE_TYPE (base)), 1);
+  tree base_ssa = base;
 
   /* We first need to split the current basic block, and start altering
  the CFG.  This allows us to insert the statements we're about to
@@ -448,15 +451,22 @@ build_check_stmt (tree base,
   base = unshare_expr (base);
 
   gsi = gsi_last_bb (cond_bb);
-  g = gimple_build_assign_with_ops (TREE_CODE (base),
-   make_ssa_name (TREE_TYPE (base), NULL),
-   base, NULL_TREE);
-  gimple_set_location (g, location);
-  gsi_insert_after (&gsi, g, GSI_NEW_STMT);
+
+  /* BASE can already be an SSA_NAME; in that case, do not create a
+ new SSA_NAME for it.  */
+  if (TREE_CODE (base) != SSA_NAME)
+{
+  g = gimple_build_assign_with_ops (TREE_CODE (base),
+   make_ssa_name (TREE_TYPE (base), NULL),
+   base, NULL_TREE);
+  gimple_set_location (g, location);
+  gsi_insert_after (&gsi, g, GSI_NEW_STMT);
+  base_ssa = gimple_assign_lhs (g);
+}
 
   g = gimple_build_assign_with_ops (NOP_EXPR,
make_ssa_name (uintptr_type, NULL),
-   gimple_assign_lhs (g), NULL_TREE);
+   base_ssa, NULL_TREE);
   gimple_set_location (g, location);
   gsi_insert_after (&gsi, g, GSI_NEW_STMT);
   base_addr = gimple_assign_lhs (g);
-- 
Dodji


[PATCH 08/10] Factorize condition insertion code out of build_check_stmt

2012-11-02 Thread Dodji Seketeli
This patch splits a new create_cond_insert_point_before_iter function
out of build_check_stmt, to be used by a later patch.

Tested by running cc1 -fasan on the test program below with and
without the patch and by inspecting the gimple output to see that
there is no change.

void
foo ()
{
  char foo[1] = {0};

  foo[0] = 1;
}

gcc/

* asan.c (create_cond_insert_point_before_iter): Factorize out of ...
(build_check_stmt): ... here.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/asan@192844 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.asan |   5 +++
 gcc/asan.c | 120 +
 2 files changed, 81 insertions(+), 44 deletions(-)

diff --git a/gcc/ChangeLog.asan b/gcc/ChangeLog.asan
index 395ba4f..903dc52 100644
--- a/gcc/ChangeLog.asan
+++ b/gcc/ChangeLog.asan
@@ -1,5 +1,10 @@
 2012-10-26  Dodji Seketeli  
 
+   * asan.c (create_cond_insert_point_before_iter): Factorize out of ...
+   (build_check_stmt): ... here.
+
+2012-10-26  Dodji Seketeli  
+
* asan.c (build_check_stmt): Accept the memory access to be
represented by an SSA_NAME.
 
diff --git a/gcc/asan.c b/gcc/asan.c
index 7c99173..cc107f8 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -383,6 +383,75 @@ asan_init_func (void)
 #define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 2000 - 1)
 #define PROB_ALWAYS(REG_BR_PROB_BASE)
 
+/* Split the current basic block and create a condition statement
+   insertion point right before the statement pointed to by ITER.
+   Return an iterator to the point at which the caller might safely
+   insert the condition statement.
+
+   THEN_BLOCK must be set to the address of an uninitialized instance
+   of basic_block.  The function will then set *THEN_BLOCK to the
+   'then block' of the condition statement to be inserted by the
+   caller.
+
+   Similarly, the function will set *FALLTRHOUGH_BLOCK to the 'else
+   block' of the condition statement to be inserted by the caller.
+
+   Note that *FALLTHROUGH_BLOCK is a new block that contains the
+   statements starting from *ITER, and *THEN_BLOCK is a new empty
+   block.
+
+   *ITER is adjusted to still point to the same statement it was
+   *pointing to initially.  */
+
+static gimple_stmt_iterator
+create_cond_insert_point_before_iter (gimple_stmt_iterator *iter,
+ bool then_more_likely_p,
+ basic_block *then_block,
+ basic_block *fallthrough_block)
+{
+  gimple_stmt_iterator gsi = *iter;
+
+  if (!gsi_end_p (gsi))
+gsi_prev (&gsi);
+
+  basic_block cur_bb = gsi_bb (*iter);
+
+  edge e = split_block (cur_bb, gsi_stmt (gsi));
+
+  /* Get a hold on the 'condition block', the 'then block' and the
+ 'else block'.  */
+  basic_block cond_bb = e->src;
+  basic_block fallthru_bb = e->dest;
+  basic_block then_bb = create_empty_bb (cond_bb);
+
+  /* Set up the newly created 'then block'.  */
+  e = make_edge (cond_bb, then_bb, EDGE_TRUE_VALUE);
+  int fallthrough_probability =
+then_more_likely_p
+? PROB_VERY_UNLIKELY
+: PROB_ALWAYS - PROB_VERY_UNLIKELY;
+  e->probability = PROB_ALWAYS - fallthrough_probability;
+  make_single_succ_edge (then_bb, fallthru_bb, EDGE_FALLTHRU);
+
+  /* Set up the fallthrough basic block.  */
+  e = find_edge (cond_bb, fallthru_bb);
+  e->flags = EDGE_FALSE_VALUE;
+  e->count = cond_bb->count;
+  e->probability = fallthrough_probability;
+
+  /* Update dominance info for the newly created then_bb; note that
+ fallthru_bb's dominance info has already been updated by
+ split_bock.  */
+  if (dom_info_available_p (CDI_DOMINATORS))
+set_immediate_dominator (CDI_DOMINATORS, then_bb, cond_bb);
+
+  *then_block = then_bb;
+  *fallthrough_block = fallthru_bb;
+  *iter = gsi_start_bb (fallthru_bb);
+
+  return gsi_last_bb (cond_bb);
+}
+
 /* Instrument the memory access instruction BASE.  Insert new
statements before ITER.
 
@@ -397,8 +466,7 @@ build_check_stmt (tree base, gimple_stmt_iterator *iter,
  int size_in_bytes)
 {
   gimple_stmt_iterator gsi;
-  basic_block cond_bb, then_bb, else_bb;
-  edge e;
+  basic_block then_bb, else_bb;
   tree t, base_addr, shadow;
   gimple g;
   tree shadow_ptr_type = shadow_ptr_types[size_in_bytes == 16 ? 1 : 0];
@@ -407,51 +475,15 @@ build_check_stmt (tree base, gimple_stmt_iterator *iter,
 = build_nonstandard_integer_type (TYPE_PRECISION (TREE_TYPE (base)), 1);
   tree base_ssa = base;
 
-  /* We first need to split the current basic block, and start altering
- the CFG.  This allows us to insert the statements we're about to
- construct into the right basic blocks.  */
-
-  cond_bb = gimple_bb (gsi_stmt (*iter));
-  gsi = *iter;
-  gsi_prev (&gsi);
-  if (!gsi_end_p (gsi))
-e = split_block (cond_bb, gsi_stmt (gsi));
-  else
-e = split_block_after_labels (cond_bb);
-  cond_bb = e->src;
-  else_bb = e->dest;
-
-  /* A recap at 

[PATCH 09/10] Instrument built-in memory access function calls

2012-11-02 Thread Dodji Seketeli
This patch instruments many memory access patterns through builtins.

Basically, for a call like:

 __builtin_memset (from, 0, n_bytes);

the patch would only instrument the accesses at the beginning and at
the end of the memory region [from, from + n_bytes].  This is the
strategy used by the llvm implementation of asan.

This instrumentation is done for all the memory access builtin
functions that expose a well specified memory region -- one that
explicitly states the number of bytes accessed in the region.

A special treatment is used for __builtin_strlen.  The patch
instruments the access to the first byte of its argument, as well as
the access to the byte (of the argument) at the offset returned by
strlen.

For the __sync_* and __atomic* calls the patch instruments the access
to the bytes pointed to by the argument.

While doing this, I have added a new parameter to build_check_stmt to
decide whether to insert the instrumentation code before or after the
statement iterator.  This allows us to do away with the
gsi_{next,prev} dance we were doing in the callers of this function.

Tested by running cc1 -fasan on variations of simple programs like:

int
foo ()
{
  char foo[10] = {0};

  foo[0] = 't';
  foo[1] = 'e';
  foo[2] = 's';
  foo[3] = 't';
  int l = __builtin_strlen (foo);
  int n = sizeof (foo);
  __builtin_memset (&foo[4], 0, n - 4);
  __sync_fetch_and_add (&foo[11], 1);

  return l;
}

and by starring at the gimple output which for this function is:

;; Function foo (foo, funcdef_no=0, decl_uid=1714, cgraph_uid=0)

foo ()
{
  int n;
  int l;
  char foo[10];
  int D.1725;
  char * D.1724;
  int D.1723;
  long unsigned int D.1722;
  int D.1721;
  long unsigned int D.1720;
  long unsigned int _1;
  int _4;
  long unsigned int _5;
  int _6;
  char * _7;
  int _8;
  char * _9;
  unsigned long _10;
  unsigned long _11;
  unsigned long _12;
  signed char * _13;
  signed char _14;
  _Bool _15;
  unsigned long _16;
  signed char _17;
  _Bool _18;
  _Bool _19;
  char * _20;
  unsigned long _21;
  unsigned long _22;
  unsigned long _23;
  signed char * _24;
  signed char _25;
  _Bool _26;
  unsigned long _27;
  signed char _28;
  _Bool _29;
  _Bool _30;
  char * _31;
  unsigned long _32;
  unsigned long _33;
  unsigned long _34;
  signed char * _35;
  signed char _36;
  _Bool _37;
  unsigned long _38;
  signed char _39;
  _Bool _40;
  _Bool _41;
  char * _42;
  unsigned long _43;
  unsigned long _44;
  unsigned long _45;
  signed char * _46;
  signed char _47;
  _Bool _48;
  unsigned long _49;
  signed char _50;
  _Bool _51;
  _Bool _52;
  char * _53;
  unsigned long _54;
  unsigned long _55;
  unsigned long _56;
  signed char * _57;
  signed char _58;
  _Bool _59;
  unsigned long _60;
  signed char _61;
  _Bool _62;
  _Bool _63;
  char[10] * _64;
  unsigned long _65;
  unsigned long _66;
  unsigned long _67;
  signed char * _68;
  signed char _69;
  _Bool _70;
  unsigned long _71;
  signed char _72;
  _Bool _73;
  _Bool _74;
  unsigned long _75;
  unsigned long _76;
  unsigned long _77;
  signed char * _78;
  signed char _79;
  _Bool _80;
  unsigned long _81;
  signed char _82;
  _Bool _83;
  _Bool _84;
  long unsigned int _85;
  long unsigned int _86;
  char * _87;
  char * _88;
  unsigned long _89;
  unsigned long _90;
  unsigned long _91;
  signed char * _92;
  signed char _93;
  _Bool _94;
  unsigned long _95;
  signed char _96;
  _Bool _97;
  _Bool _98;
  char * _99;
  unsigned long _100;
  unsigned long _101;
  unsigned long _102;
  signed char * _103;
  signed char _104;
  _Bool _105;
  unsigned long _106;
  signed char _107;
  _Bool _108;
  _Bool _109;

  :
  foo = {};
  _9 = &foo[0];
  _10 = (unsigned long) _9;
  _11 = _10 >> 3;
  _12 = _11 + 17592186044416;
  _13 = (signed char *) _12;
  _14 = *_13;
  _15 = _14 != 0;
  _16 = _10 & 7;
  _17 = (signed char) _16;
  _18 = _17 >= _14;
  _19 = _15 & _18;
  if (_19 != 0)
goto ;
  else
goto ;

  :
  __asan_report_store1 (_10);

  :
  foo[0] = 116;
  _20 = &foo[1];
  _21 = (unsigned long) _20;
  _22 = _21 >> 3;
  _23 = _22 + 17592186044416;
  _24 = (signed char *) _23;
  _25 = *_24;
  _26 = _25 != 0;
  _27 = _21 & 7;
  _28 = (signed char) _27;
  _29 = _28 >= _25;
  _30 = _26 & _29;
  if (_30 != 0)
goto ;
  else
goto ;

  :
  __asan_report_store1 (_21);

  :
  

[wwwdocs] Switch to UTF-8

2012-11-02 Thread Gerald Pfeifer
I believe the time has come (and probably was overdue) to switch the
web pages to UTF-8.

Which actually should not require any hanges to contents since we
have been generally using ä instead of ä and so forth.

Applied and htdocs/ on gcc.gnu.org regenerated; spot tests all were
fine (in fact, silenced a warning from validator.w3.org) and I have
a thorough validation run going on (one page every 61s as not to be
blocked by the server).

Gerald

Index: style.mhtml
===
RCS file: /cvs/gcc/wwwdocs/htdocs/style.mhtml,v
retrieving revision 1.118
diff -u -3 -p -r1.118 style.mhtml
--- style.mhtml 25 Mar 2012 03:17:52 -  1.118
+++ style.mhtml 2 Nov 2012 22:51:54 -
@@ -32,13 +32,13 @@
 
 
  
+
   http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
  >
  
+  
   
  >
 >
@@ -65,13 +65,13 @@
  
  
   
+   
 mailto:g...@gcc.gnu.org"; />
 http://gcc.gnu.org/favicon.ico"; />
 http://gcc.gnu.org/gcc.css"; />
   >
   
+   
 mailto:g...@gcc.gnu.org";>
 http://gcc.gnu.org/favicon.ico";>
 

Re: [PATCH] Add check for x32 support

2012-11-02 Thread Mike Stump
On Nov 2, 2012, at 9:28 AM, Jack Howarth  wrote:
>  Currently on targets like x86_64 darwin which don't support -mx32 
> -maddress-mode=short,
> tests that pass those on dg-options fail with excessive errors at -m64. The 
> attached patch
> resolves this by adding a check_effective_target_maybe_x32 proc to test if 
> the -mx32
> -maddress-mode=short flags are supported. Tested on x86_64-apple-darwin12. 
> Okay for
> gcc trunk?

Ok.


libgo patch committed: Fix reflect.Call

2012-11-02 Thread Ian Lance Taylor
Part of my initial 64-bit support patch was bogus: I shadowed a variable
in a couple of functions used for reflect.Call.  This patch fixes it.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r cecca11207b7 libgo/runtime/go-reflect-call.c
--- a/libgo/runtime/go-reflect-call.c	Thu Nov 01 14:42:39 2012 -0700
+++ b/libgo/runtime/go-reflect-call.c	Fri Nov 02 16:15:20 2012 -0700
@@ -75,15 +75,15 @@
 const struct __go_slice_type *descriptor __attribute__ ((unused)))
 {
   ffi_type *ret;
-  ffi_type *intgo;
+  ffi_type *ffi_intgo;
 
   ret = (ffi_type *) __go_alloc (sizeof (ffi_type));
   ret->type = FFI_TYPE_STRUCT;
   ret->elements = (ffi_type **) __go_alloc (4 * sizeof (ffi_type *));
   ret->elements[0] = &ffi_type_pointer;
-  intgo = sizeof (intgo) == 4 ? &ffi_type_sint32 : &ffi_type_sint64;
-  ret->elements[1] = intgo;
-  ret->elements[2] = intgo;
+  ffi_intgo = sizeof (intgo) == 4 ? &ffi_type_sint32 : &ffi_type_sint64;
+  ret->elements[1] = ffi_intgo;
+  ret->elements[2] = ffi_intgo;
   ret->elements[3] = NULL;
   return ret;
 }
@@ -117,14 +117,14 @@
 go_string_to_ffi (void)
 {
   ffi_type *ret;
-  ffi_type *intgo;
+  ffi_type *ffi_intgo;
 
   ret = (ffi_type *) __go_alloc (sizeof (ffi_type));
   ret->type = FFI_TYPE_STRUCT;
   ret->elements = (ffi_type **) __go_alloc (3 * sizeof (ffi_type *));
   ret->elements[0] = &ffi_type_pointer;
-  intgo = sizeof (intgo) == 4 ? &ffi_type_sint32 : &ffi_type_sint64;
-  ret->elements[1] = intgo;
+  ffi_intgo = sizeof (intgo) == 4 ? &ffi_type_sint32 : &ffi_type_sint64;
+  ret->elements[1] = ffi_intgo;
   ret->elements[2] = NULL;
   return ret;
 }


[Committed] Fix 54524: Wrong code with some 64bit addition with registers as 32bits

2012-11-02 Thread Andrew Pinski
Hi,
  For some reason cse produced:
(insn 27 43 28 2 (set (reg:SI 231 [+4 ])
(plus:SI (reg:SI 229 [+4 ])
(const_int 0 [0]))) t.c:24 10 {*addsi3}
 (nil))

(insn 28 27 29 2 (set (reg:SI 212)
(ltu:SI (reg:SI 231 [+4 ])
(reg:SI 229 [+4 ]))) t.c:24 521 {*sltu_sisi}
 (nil))

And then forwprop goes and does the following:
In insn 28, replacing
 (ltu:SI (reg:SI 231 [+4 ])
(reg:SI 229 [+4 ]))
 with (const_int 1 [0x1])

This is due to simplify-rtx.c (simplify_relational_operation_1) Having
the following optimization:
  /* (LTU/GEU (PLUS a C) C), where C is constant, can be simplified to
 (GEU/LTU a -C).  Likewise for (LTU/GEU (PLUS a C) a).  */

But this is wrong when C is 0.  Anyways I committed this patch as
obvious to fix the issue in simplify-rtx.c but I have not looked into
why CSE does simplify the plus.

Thanks,
Andrew Pinski

ChangeLog:

PR rtl-opt/54524
* simplify-rtx.c (simplify_relational_operation_1): Don't simplify
(LTU/GEU (PLUS a 0) 0) into (GEU/LTU a 0) since they are not equivalent.
Index: simplify-rtx.c
===
--- simplify-rtx.c  (revision 193110)
+++ simplify-rtx.c  (working copy)
@@ -4546,7 +4546,9 @@ simplify_relational_operation_1 (enum rt
   && GET_CODE (op0) == PLUS
   && CONST_INT_P (XEXP (op0, 1))
   && (rtx_equal_p (op1, XEXP (op0, 0))
- || rtx_equal_p (op1, XEXP (op0, 1
+ || rtx_equal_p (op1, XEXP (op0, 1)))
+  /* (LTU/GEU (PLUS a 0) 0) is not the same as (GEU/LTU a 0). */
+  && XEXP (op0, 1) != const0_rtx)
 {
   rtx new_cmp
= simplify_gen_unary (NEG, cmp_mode, XEXP (op0, 1), cmp_mode);


libgo patch committed: Prepare syscall for 64-bit int

2012-11-02 Thread Ian Lance Taylor
This patch prepares the syscall package for the change to 64-bit int on
x86_64.  This introduces a new type _C_int to the syscall package for
the C type int, and uses it for libc calls as needed.  The Pipe and
Socketpair functions had to be adjusted.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r ac3d4ff96d58 libgo/go/syscall/errstr.go
--- a/libgo/go/syscall/errstr.go	Fri Nov 02 16:16:00 2012 -0700
+++ b/libgo/go/syscall/errstr.go	Fri Nov 02 16:34:28 2012 -0700
@@ -7,7 +7,7 @@
 package syscall
 
 //sysnb	strerror_r(errnum int, buf []byte) (err error)
-//strerror_r(errnum int, buf *byte, buflen Size_t) int
+//strerror_r(errnum _C_int, buf *byte, buflen Size_t) _C_int
 
 func Errstr(errnum int) string {
 	for len := 128; ; len *= 2 {
diff -r ac3d4ff96d58 libgo/go/syscall/errstr_linux.go
--- a/libgo/go/syscall/errstr_linux.go	Fri Nov 02 16:16:00 2012 -0700
+++ b/libgo/go/syscall/errstr_linux.go	Fri Nov 02 16:34:28 2012 -0700
@@ -9,7 +9,7 @@
 import "unsafe"
 
 //sysnb	strerror_r(errnum int, b []byte) (errstr *byte)
-//strerror_r(errnum int, b *byte, len Size_t) *byte
+//strerror_r(errnum _C_int, b *byte, len Size_t) *byte
 
 func Errstr(errnum int) string {
 	a := make([]byte, 128)
diff -r ac3d4ff96d58 libgo/go/syscall/errstr_nor.go
--- a/libgo/go/syscall/errstr_nor.go	Fri Nov 02 16:16:00 2012 -0700
+++ b/libgo/go/syscall/errstr_nor.go	Fri Nov 02 16:34:28 2012 -0700
@@ -12,7 +12,7 @@
 )
 
 //sysnb	strerror(errnum int) (buf *byte)
-//strerror(errnum int) *byte
+//strerror(errnum _C_int) *byte
 
 var errstr_lock sync.Mutex
 
diff -r ac3d4ff96d58 libgo/go/syscall/exec_linux.go
--- a/libgo/go/syscall/exec_linux.go	Fri Nov 02 16:16:00 2012 -0700
+++ b/libgo/go/syscall/exec_linux.go	Fri Nov 02 16:34:28 2012 -0700
@@ -11,7 +11,7 @@
 )
 
 //sysnb	raw_prctl(option int, arg2 int, arg3 int, arg4 int, arg5 int) (ret int, err Errno)
-//prctl(option int, arg2 _C_long, arg3 _C_long, arg4 _C_long, arg5 _C_long) int
+//prctl(option _C_int, arg2 _C_long, arg3 _C_long, arg4 _C_long, arg5 _C_long) _C_int
 
 type SysProcAttr struct {
 	Chroot string  // Chroot.
diff -r ac3d4ff96d58 libgo/go/syscall/exec_unix.go
--- a/libgo/go/syscall/exec_unix.go	Fri Nov 02 16:16:00 2012 -0700
+++ b/libgo/go/syscall/exec_unix.go	Fri Nov 02 16:34:28 2012 -0700
@@ -21,34 +21,34 @@
 //setsid() Pid_t
 
 //sysnb raw_setpgid(pid int, pgid int) (err Errno)
-//setpgid(pid Pid_t, pgid Pid_t) int
+//setpgid(pid Pid_t, pgid Pid_t) _C_int
 
 //sysnb	raw_chroot(path *byte) (err Errno)
-//chroot(path *byte) int
+//chroot(path *byte) _C_int
 
 //sysnb	raw_chdir(path *byte) (err Errno)
-//chdir(path *byte) int
+//chdir(path *byte) _C_int
 
 //sysnb	raw_fcntl(fd int, cmd int, arg int) (val int, err Errno)
-//fcntl(fd int, cmd int, arg int) int
+//fcntl(fd _C_int, cmd _C_int, arg _C_int) _C_int
 
 //sysnb	raw_close(fd int) (err Errno)
-//close(fd int) int
+//close(fd _C_int) _C_int
 
 //sysnb	raw_ioctl(fd int, cmd int, val int) (rval int, err Errno)
-//ioctl(fd int, cmd int, val int) int
+//ioctl(fd _C_int, cmd _C_int, val _C_int) _C_int
 
 //sysnb	raw_execve(argv0 *byte, argv **byte, envv **byte) (err Errno)
-//execve(argv0 *byte, argv **byte, envv **byte) int
+//execve(argv0 *byte, argv **byte, envv **byte) _C_int
 
 //sysnb	raw_write(fd int, buf *byte, count int) (err Errno)
-//write(fd int, buf *byte, count Size_t) Ssize_t
+//write(fd _C_int, buf *byte, count Size_t) Ssize_t
 
 //sysnb	raw_exit(status int)
-//_exit(status int)
+//_exit(status _C_int)
 
 //sysnb raw_dup2(oldfd int, newfd int) (err Errno)
-//dup2(oldfd int, newfd int) int
+//dup2(oldfd _C_int, newfd _C_int) _C_int
 
 // Lock synchronizing creation of new file descriptors with fork.
 //
diff -r ac3d4ff96d58 libgo/go/syscall/libcall_posix.go
--- a/libgo/go/syscall/libcall_posix.go	Fri Nov 02 16:16:00 2012 -0700
+++ b/libgo/go/syscall/libcall_posix.go	Fri Nov 02 16:34:28 2012 -0700
@@ -17,21 +17,21 @@
  * Wrapped
  */
 
-//sysnb	pipe(p *[2]int) (err error)
-//pipe(p *[2]int) int
+//sysnb	pipe(p *[2]_C_int) (err error)
+//pipe(p *[2]_C_int) _C_int
 func Pipe(p []int) (err error) {
 	if len(p) != 2 {
 		return EINVAL
 	}
-	var pp [2]int
+	var pp [2]_C_int
 	err = pipe(&pp)
-	p[0] = pp[0]
-	p[1] = pp[1]
+	p[0] = int(pp[0])
+	p[1] = int(pp[1])
 	return
 }
 
 //sys	utimes(path string, times *[2]Timeval) (err error)
-//utimes(path *byte, times *[2]Timeval) int
+//utimes(path *byte, times *[2]Timeval) _C_int
 func Utimes(path string, tv []Timeval) (err error) {
 	if len(tv) != 2 {
 		return EINVAL
@@ -74,7 +74,7 @@
 }
 
 //sysnb	getgroups(size int, list *Gid_t) (nn int, err error)
-//getgroups(size int, list *Gid_t) int
+//getgroups(size int, list *Gid_t) _C_int
 
 func Getgroups() (gids []int, err error) {
 	n, err := getgroups(0, nil)
@@ -103,7 +103,7 @@
 }
 
 //sysnb	setgroups(n int, list *Gid_t) (err error)
-//setgroups(n Size_t, list *Gid_t) int
+//setgroups(n Size_t, list *Gid_t) _C_int
 
 func Setgroups(gids []int) (err error) {
 	if le

Re: [libstdc++,doc] Some link housekeeping

2012-11-02 Thread Jonathan Wakely
On 2 November 2012 22:00, Gerald Pfeifer wrote:
> Next installment in my "so that libstdc++ hackers do not feel
> neglected" series. ;-)
>
> Applied.
>
> Any volunteer to regenerate the HTML docs after my patches now?

Thanks, I've regenerated them.


Fix bootstrap on 32bit hosts

2012-11-02 Thread Jan Hubicka
Hi,
my patch on loop bound estimation had missing cast that shows up as a bootstrap 
problem
on 32bit hosts.  Fixed thus as obvious.  I am sorry for the breakage.

Honza

Index: ChangeLog
===
--- ChangeLog   (revision 193116)
+++ ChangeLog   (working copy)
@@ -1,3 +1,8 @@
+2012-11-02  Jan Hubicka  
+
+   * tree-ssa-loop-niter.c (discover_iteration_bound_by_body_walk): Add
+   missing sign to unsigned.
+
 2012-11-02  Andrew Pinski  
 
PR rtl-opt/54524
Index: tree-ssa-loop-niter.c
===
--- tree-ssa-loop-niter.c   (revision 193104)
+++ tree-ssa-loop-niter.c   (working copy)
@@ -3161,7 +3161,7 @@ discover_iteration_bound_by_body_walk (s
 }
 
   gcc_assert (latch_index >= 0);
-  if (latch_index < VEC_length (double_int, bounds))
+  if ((unsigned)latch_index < VEC_length (double_int, bounds))
 {
   if (dump_file && (dump_flags & TDF_DETAILS))
{
Index: testsuite/ChangeLog
===
--- testsuite/ChangeLog (revision 193116)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2012-11-02  Jan Hubicka  
+
+   * gcc.dg/tree-ssa/loop-38.c: Correct testcase.
+
 2012-11-02  Michael Meissner  
 
* gcc.target/powerpc/pr48258-2.c: Simplfy the acceptance
Index: testsuite/gcc.dg/tree-ssa/loop-38.c
===
--- testsuite/gcc.dg/tree-ssa/loop-38.c (revision 193104)
+++ testsuite/gcc.dg/tree-ssa/loop-38.c (working copy)
@@ -13,6 +13,6 @@ t(int n)
sum+=b[i];
   return sum;
 }
-/* { dg-final { scan-tree-dump "Found better loop bound 10" "cunrolli" } } */
-/* { dg-final { scan-tree-dump "Loop 1 iterates at most 10 times" "cunrolli" } 
} */
+/* { dg-final { scan-tree-dump "Found better loop bound 11" "cunrolli" } } */
+/* { dg-final { scan-tree-dump "Loop 1 iterates at most 11 times" "cunrolli" } 
} */
 /* { dg-final { cleanup-tree-dump "cunrolli" } } */


Re: [tsan] ThreadSanitizer instrumentation part

2012-11-02 Thread Wei Mi
Hi,

Thanks for so many useful comments! I update the file according to the
comments. The major changes include adding sanitizer.def and
generating gimple directly. New patch file is attached.

> On Wed, Oct 31, 2012 at 11:34:10AM -0700, Wei Mi wrote:
>> gcc/ChangeLog:
>> 2012-10-31  Wei Mi  
>
> If Dmitry wrote parts of the patch, it would be nice to mention
> him in the ChangeLog too.

> All ChangeLog entries should end with a dot.

Changed.

2012-10-31  Dmitry Vyukov  
 Wei Mi  

* Makefile.in (tsan.o): New.
(BUILTINS_DEF): Add sanitizer.def.
* sanitizer.def: New.
* passes.c (init_optimization_passes): Add tsan passes.
* tree-pass.h (register_pass_info): Ditto.
* cfghooks.h (GCC_CFGHOOKS_H): Avoid including duplicate headers.
* doc/invoke.texi: Document tsan related options.
* toplev.c (compile_file): Add tsan pass in driver.
* gcc.c (LINK_COMMAND_SPEC): Add -lasan in link command if there
-fthread_sanitizer is on.
* tsan.c: New file about tsan.
* tsan.h: Ditto.


>>  struct cfg_hooks
>> @@ -219,3 +222,4 @@ extern void gimple_register_cfg_hooks (v
>>  extern struct cfg_hooks get_cfg_hooks (void);
>>  extern void set_cfg_hooks (struct cfg_hooks);
>>
>> +#endif  /* GCC_CFGHOOKS_H */
>
> Why this?  Simply don't include that header in tsan.c, it is already
> included by basic-block.h.

Remove cfghooks.h from tsan.c. Remove the #ifdef GCC_CFGHOOKS_H from cfghooks.h

> Can't google just assign the code to FSF, and use a standard boilerplate
> as everything else in gcc/ ?

Copy from asan header and make some change.

>> +static tree
>> +get_vptr_update_decl (void)
>> +{
>> +  tree typ;
>> +  static tree decl;
>> +
>> +  if (decl != NULL)
>> +return decl;
>> +  typ = build_function_type_list (void_type_node,
>> +  ptr_type_node, ptr_type_node, NULL_TREE);
>> +  decl = build_func_decl (typ, "__tsan_vptr_update");
>> +  return decl;
>> +}
> ...
>
> Instead of this (but same applies to asan), I think we should just consider
> putting it into builtins.def (or have sanitizer.def like there is sync.def
> or omp-builtins.def).  The problem might be non-C/C++ family frontends
> though.

Create sanitizer.def and use builtin_decl_implicit to create builtin decls.

>> +  while (TREE_CODE (expr_type) == ARRAY_TYPE)
>> +expr_type = TREE_TYPE (expr_type);
>> +  size = (TREE_INT_CST_LOW (TYPE_SIZE (expr_type))) / BITS_PER_UNIT;
>
> int_size_in_bytes.

Changed.

> preferrably without building everything as trees, then gimplifying it.

Generate gimple directly. Remove funcs: instr_memory_access,
instr_vptr_update, instr_func_entry, instr_func_exit

> For func_calls and func_mops, I believe why you need two variables instead
> of just one, and why the function can't just return a bool whether
> entry/exit needs to be instrumented or not.

instrument_memory_accesses return a bool indicating whether or not
entry/exit needs to be instrumented. func_calls and func_mops removed.

>> +set_location (gimple_seq seq, location_t loc)
>> +{
>> +  gimple_seq_node n;
>> +
>> +  for (n = gimple_seq_first (seq); n != NULL; n = n->gsbase.next)
>
> This really should use a stmt iterator.

set_location removed. set gimple location using gimple_set_location
everytime a new gimple statement is inserted.

>> +  FOR_EACH_BB (bb)
>> +{
>> +  for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
>> +{
>> +  instrument_gimple (gsi);
>> +}
>> +}
>
> Extraneous two pairs of {}s.

Fixed.

>> +struct gimple_opt_pass pass_tsan = {{
>
> Please watch formatting of other gimple_opt_pass structures.
> {{ isn't used anywhere.

Fixed.

> Is that the option that LLVM uses (I'm talking about -faddress-sanitizer
> in LLVM vs. -fasan right now in GCC, isn't that similar?).

Fixed.

> +static tree
> +get_init_decl (void)
> +{
> +  tree typ;
> +  static tree decl;
> +
> +  if (decl != NULL)
> +return decl;
> +  typ = build_function_type_list (void_type_node, NULL_TREE);
> +  decl = build_func_decl (typ, "__tsan_init");
> +  return decl;
> +}
>
> The above can crash the compiler btw, as that static tree decl
> (in many other functions) is not GTY(()) marked (must be file scope for
> that), thus ggc_collect might free it.  Also, please use type
> instead of typ for variable names.

Func get_init_decl removed after generating gimple directly.

>> +  /* Instrumentation for assignment of a function result
>> + must be inserted after the call.  Instrumentation for
>> + reads of function arguments must be inserted before the call.
>> + That's because the call can contain synchronization.  */
>> +  if (is_gimple_call (stmt) && is_write)
>> +gsi_insert_seq_after (&gsi, gs, GSI_NEW_STMT);
>
> Inserting stmts after a call may or may not work.  E.g. if the call
> can throw, it must be the last stmt in a basic block, so then the
> stmts need to be inserted on a su

[RFA:] PR55186 - gcc.dg/const-uniq-1.c fails due to vector not in the constant pool

2012-11-02 Thread Hans-Peter Nilsson
Due to weird circumstances detailed in the PR, this test briefly
passed (it has always failed before), so technically I'm fixing
a regression. :)

The test checks that a certain label is mentioned twice; being
mentioned once infers that there are two identical initializer
vectors in the constant-pool.

But, for cris-elf (and reasonably the same for other targets)
there might not be such a constant-pool entry in the first
place: the vectors are too short to rule out piecewise
initialization as optimal for size (counting the vectors once
per use).  Let's increase them.  Twice might just break-even for
cris-elf so let's make them four times as long.  Sanity-checked
for x86_64 w/w.o -m32 for a gcc-version that includes the
optimization for which the test-case tests (CCing author).

Ok to commit?

gcc/testsuite:
PR testsuite/55186
* gcc/testsuite/gcc.dg/const-uniq-1.c (a): Increase length four times.

Index: gcc/testsuite/gcc.dg/const-uniq-1.c
===
--- gcc/testsuite/gcc.dg/const-uniq-1.c (revision 193117)
+++ gcc/testsuite/gcc.dg/const-uniq-1.c (working copy)
@@ -5,13 +5,18 @@
 
 int lookup1 (int i)
 {
-  int a[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+  /* We use vectors long enough that piece-wise initialization is not
+ reasonably preferable even for size (when including the constant
+ vectors for initialization) for any target.  */
+  int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };
   return a[i];
 }
 
 int lookup2 (int i)
 {
-  int a[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+  int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };
   return a[i+1];
 }
 
brgds, H-P