Re: [google] Patch to support calling multi-versioned functions via new GCC builtin. (issue4440078)

2011-05-07 Thread Richard Guenther
On Fri, May 6, 2011 at 7:57 PM, Xinliang David Li  wrote:
>>> I want propose a more general solution.
>>>
>>> 1) Generic Annotation Support for gcc IR -- it is used attach to
>>> application/optimization specific annotation to gimple statements and
>>> annotations can be passed around across passes. In gcc, I only see
>>> HISTOGRAM annotation for value profiling, which is not general enough
>>> 2) Support of CallInfo for each callsite. This is an annotation, but
>>> more standardized. The callinfo can be used to record information such
>>> as call attributes, call side effects, mod-ref information etc ---
>>> current gimple_call_flags can be folded into this Info structure.
>>
>> I don't like generic annotation facilities.  What should passes to with
>> annotated stmts that are a) transformed, b) removed?  See RTL notes
>> and all the interesting issues they cause.
>
>
> Then how do you store information that needs to be passed across
> optimization passes -- you can not possibly dump all of them into the
> core IR. In fact, anything that is derived from (via analysis) but not
> part of the core IR need to worry about update and maintenance. In
> current GIMPLE, we can find many such instances -- DU chains, Memory
> SSA, control flow information, as well as flags like visited,
> no_warning, PLF (?), etc. Have a unified way of representing them is a
> good thing so that 1) make the IR lean and mean; 2) avoid too many
> different side data structures.  The important thing is to have a good
> verifier to catch insanity and inconsistency of the annotation after
> each pass.

Well, as soon as you have a verifier it's no longer generic but _is_
part of the "core IL".  Similar to how EH info is part of the "core IL",
or alias info, or loop information.

Richard.


Re: Minor type merging optimization

2011-05-07 Thread Richard Guenther
On Fri, May 6, 2011 at 10:24 PM, Jan Hubicka  wrote:
> Hi,
> while looking at type merging code I noticed that type pairs can be managed
> to be ordered by their UIDs.  This save some of hashing overhead in one of
> most intensively querried hashes.
>
> Also gimple_lookup_type_leader is hot function that is better to be inlined.
>
> I also wonder, why unionfind algorithm is not used here to maintain the
> positive answers?

Can you elaborate?

> Bootstrapped/regtested x86_64-linux, OK?

Ok.

Thanks,
Richard.

> Honza
>
>        * gimple.c (type_pair_hash, type_pair_eq, lookup_type_pair):
>        Arrange type pairs to be UID ordered.
>        (gimple_lookup_type_leader): Make inline.
> Index: gimple.c
> ===
> --- gimple.c    (revision 173506)
> +++ gimple.c    (working copy)
> @@ -3240,8 +3240,7 @@ type_pair_hash (const void *p)
>   const struct type_pair_d *pair = (const struct type_pair_d *) p;
>   hashval_t val1 = pair->uid1;
>   hashval_t val2 = pair->uid2;
> -  return (iterative_hash_hashval_t (val2, val1)
> -         ^ iterative_hash_hashval_t (val1, val2));
> +  return iterative_hash_hashval_t (val1, val2);
>  }
>
>  /* Compare two type pairs pointed-to by P1 and P2.  */
> @@ -3251,8 +3250,7 @@ type_pair_eq (const void *p1, const void
>  {
>   const struct type_pair_d *pair1 = (const struct type_pair_d *) p1;
>   const struct type_pair_d *pair2 = (const struct type_pair_d *) p2;
> -  return ((pair1->uid1 == pair2->uid1 && pair1->uid2 == pair2->uid2)
> -         || (pair1->uid1 == pair2->uid2 && pair1->uid2 == pair2->uid1));
> +  return (pair1->uid1 == pair2->uid1 && pair1->uid2 == pair2->uid2);
>  }
>
>  /* Lookup the pair of types T1 and T2 in *VISITED_P.  Insert a new
> @@ -3271,8 +3269,16 @@ lookup_type_pair (tree t1, tree t2, htab
>       gcc_obstack_init (ob_p);
>     }
>
> -  pair.uid1 = TYPE_UID (t1);
> -  pair.uid2 = TYPE_UID (t2);
> +  if (TYPE_UID (t1) < TYPE_UID (t2))
> +    {
> +      pair.uid1 = TYPE_UID (t1);
> +      pair.uid2 = TYPE_UID (t2);
> +    }
> +  else
> +    {
> +      pair.uid1 = TYPE_UID (t2);
> +      pair.uid2 = TYPE_UID (t1);
> +    }
>   slot = htab_find_slot (*visited_p, &pair, INSERT);
>
>   if (*slot)
> @@ -3280,8 +3286,8 @@ lookup_type_pair (tree t1, tree t2, htab
>   else
>     {
>       p = XOBNEW (ob_p, struct type_pair_d);
> -      p->uid1 = TYPE_UID (t1);
> -      p->uid2 = TYPE_UID (t2);
> +      p->uid1 = pair.uid1;
> +      p->uid2 = pair.uid2;
>       p->same_p[0] = -2;
>       p->same_p[1] = -2;
>       *slot = (void *) p;
> @@ -3324,7 +3330,7 @@ static GTY((deletable, length("GIMPLE_TY
>  /* Lookup an existing leader for T and return it or NULL_TREE, if
>    there is none in the cache.  */
>
> -static tree
> +static inline tree
>  gimple_lookup_type_leader (tree t)
>  {
>   gimple_type_leader_entry *leader;
>


[patch] Tidy up global_bindings_p langhook

2011-05-07 Thread Eric Botcazou
Hi,

following the removal of pending sizes and the simplification of variable_size 
this patch changes the return type of the global_bindings_p langhook to bool 
and eliminates 3 calls (out of 4) present in fold-const.c; removing the 4th 
will require further investigation.

Bootstrapped/regtested (all languages) on x86_64-suse-linux, OK for mainline?


2011-05-07  Eric Botcazou  

* langhooks.h (lang_hooks_for_types): Change global_bindings_p's return
type to bool and adjust comment.
* fold-const.c (fold_range_test): Adjust call to global_bindings_p.
(fold_mathfn_compare): Remove calls to global_bindings_p.
(fold_inf_compare): Likewise.
* stor-layout.c (variable_size): Adjust call to global_bindings_p.
* c-tree.h (global_bindings_p): Adjust prototype.
* c-decl.c (global_bindings_p): Return bool and simplify.
ada/
* gcc-interface/gigi.h (global_bindings_p): Adjust prototype.
* gcc-interface/utils.c (global_bindings_p): Return bool and simplify.
cp/
* name-lookup.h (global_bindings_p): Adjust prototype.
* name-lookup.c (global_bindings_p): Return bool.
fortran/
* f95-lang.c (global_bindings_p): Return bool and simplify.
go/
* go-lang.c (global_bindings_p): Return bool and simplify.
java/
* java-tree.h (global_bindings_p): Adjust prototype.
* decl.c (global_bindings_p): Return bool.
lto/
* lto-lang.c (global_bindings_p): Return bool.


-- 
Eric Botcazou
Index: java/decl.c
===
--- java/decl.c	(revision 173422)
+++ java/decl.c	(working copy)
@@ -1302,9 +1302,9 @@ pushdecl_function_level (tree x)
   return t;
 }
 
-/* Nonzero if we are currently in the global binding level.  */
+/* Return true if we are in the global binding level.  */
 
-int
+bool
 global_bindings_p (void)
 {
   return current_binding_level == global_binding_level;
Index: java/java-tree.h
===
--- java/java-tree.h	(revision 173422)
+++ java/java-tree.h	(working copy)
@@ -983,7 +983,7 @@ extern tree ident_subst (const char *, i
 			 const char *);
 extern tree identifier_subst (const tree, const char *, int, int,
 			  const char *);
-extern int global_bindings_p (void);
+extern bool global_bindings_p (void);
 extern tree getdecls (void);
 extern void pushlevel (int);
 extern tree poplevel (int,int, int);
Index: fold-const.c
===
--- fold-const.c	(revision 173422)
+++ fold-const.c	(working copy)
@@ -4849,8 +4849,8 @@ fold_range_test (location_t loc, enum tr
 			   ? TRUTH_AND_EXPR : TRUTH_OR_EXPR,
 			   type, op0, op1);
 
-  else if (lang_hooks.decls.global_bindings_p () == 0
-	   && ! CONTAINS_PLACEHOLDER_P (lhs))
+  else if (!lang_hooks.decls.global_bindings_p ()
+	   && !CONTAINS_PLACEHOLDER_P (lhs))
 	{
 	  tree common = save_expr (lhs);
 
@@ -6148,10 +6148,6 @@ fold_mathfn_compare (location_t loc,
 build_real (TREE_TYPE (arg), dconst0));
 
 	  /* sqrt(x) < y is x >= 0 && x != +Inf, when y is large.  */
-	  if (lang_hooks.decls.global_bindings_p () != 0
-		  || CONTAINS_PLACEHOLDER_P (arg))
-		return NULL_TREE;
-
 	  arg = save_expr (arg);
 	  return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type,
   fold_build2_loc (loc, GE_EXPR, type, arg,
@@ -6168,18 +6164,14 @@ fold_mathfn_compare (location_t loc,
 build_real (TREE_TYPE (arg), c2));
 
 	  /* sqrt(x) < c is the same as x >= 0 && x < c*c.  */
-	  if (lang_hooks.decls.global_bindings_p () == 0
-	  && ! CONTAINS_PLACEHOLDER_P (arg))
-	{
-	  arg = save_expr (arg);
-	  return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type,
+	  arg = save_expr (arg);
+	  return fold_build2_loc (loc, TRUTH_ANDIF_EXPR, type,
   fold_build2_loc (loc, GE_EXPR, type, arg,
 	   build_real (TREE_TYPE (arg),
 			   dconst0)),
   fold_build2_loc (loc, code, type, arg,
 	   build_real (TREE_TYPE (arg),
 			   c2)));
-	}
 	}
 }
 
@@ -6226,13 +6218,8 @@ fold_inf_compare (location_t loc, enum t
 	return omit_one_operand_loc (loc, type, integer_one_node, arg0);
 
   /* x <= +Inf is the same as x == x, i.e. isfinite(x).  */
-  if (lang_hooks.decls.global_bindings_p () == 0
-	  && ! CONTAINS_PLACEHOLDER_P (arg0))
-	{
-	  arg0 = save_expr (arg0);
-	  return fold_build2_loc (loc, EQ_EXPR, type, arg0, arg0);
-	}
-  break;
+  arg0 = save_expr (arg0);
+  return fold_build2_loc (loc, EQ_EXPR, type, arg0, arg0);
 
 case EQ_EXPR:
 case GE_EXPR:
Index: cp/name-lookup.c
===
--- cp/name-lookup.c	(revision 173422)
+++ cp/name-lookup.c	(working copy)
@@ -1576,9 +1576,9 @@ maybe_push_cleanup_level (tree type)
 }
 }
 
-/* Nonzero if we are currently in the global binding level.  */
+/* Return true if we are in the global b

[x32] PATCH: Handle NULL TYPE argument in ix86_promote_function_mode

2011-05-07 Thread H.J. Lu
Hi,

TYPE may be NULL in ix86_promote_function_mode.  I checked in this patch
to handle it.

H.J.
---
commit 31770e61e70228463b70361c46ff6fa81eb856f8
Author: H.J. Lu 
Date:   Fri May 6 10:02:18 2011 -0700

Handle NULL TYPE argument.

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 57b2786..9426489 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,8 @@
+2011-05-06  H.J. Lu  
+
+   * config/i386/i386.c (ix86_promote_function_mode): Handle NULL
+   TYPE argument.
+
 2011-04-14  H.J. Lu  
 
* config/i386/gnu-user64.h (ASM_SPEC): Support x32.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 3e5169e..1a567f1 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -7673,7 +7673,7 @@ ix86_promote_function_mode (const_tree type, enum 
machine_mode mode,
int *punsignedp, const_tree fntype,
int for_return)
 {
-  if (for_return != 1 && POINTER_TYPE_P (type))
+  if (for_return != 1 && type != NULL_TREE && POINTER_TYPE_P (type))
 {
   *punsignedp = POINTERS_EXTEND_UNSIGNED;
   return Pmode;


Inliner speedup

2011-05-07 Thread Jan Hubicka
Hi,
while profiling Mozilla build I noticed that I inadvertly broke the 
optimization of lazily
updating priority queue. This patch restores the behaviour and gets inliner 
down to 30s.
(out of 10 minutes build)

bootstrapped/regtested x86_64 & comitted.

Honza

Index: ChangeLog
===
--- ChangeLog   (revision 173531)
+++ ChangeLog   (working copy)
@@ -1,5 +1,9 @@
 2011-05-06  Jan Hubicka  
 
+   * ipa-inline.c (update_callee_keys): Don't reset node growth cache.
+
+2011-05-06  Jan Hubicka  
+
* cgraph.c (cgraph_add_thunk): Create real function node instead
of alias node; finalize it and mark needed/reachale; arrange visibility
to be right and add it into the corresponding same comdat group list.
Index: ipa-inline.c
===
--- ipa-inline.c(revision 173531)
+++ ipa-inline.c(working copy)
@@ -957,9 +957,9 @@ update_callee_keys (fibheap_t heap, stru
   e = e->callee->callees;
 else
   {
-   /* We inlined and thus callees might have different number of calls.
-  Reset their caches  */
-reset_node_growth_cache (e->callee);
+   /* We do not reset callee growth cache here.  Since we added a new call,
+  growth chould have just increased and consequentely badness metric
+   don't need updating.  */
if (e->inline_failed
&& inline_summary (e->callee)->inlinable
&& cgraph_function_body_availability (e->callee) >= AVAIL_AVAILABLE


cleanup i386 prefetch_beneficial_p

2011-05-07 Thread Jan Hubicka
Hi,
we should use ix86_tune_indices instead of random predicates in i386.c code

Bootstrapped/regtested x86_64-linux, comitted.
Honza

Index: ChangeLog
===
--- ChangeLog   (revision 173532)
+++ ChangeLog   (working copy)
@@ -1,5 +1,13 @@
 2011-05-06  Jan Hubicka  
 
+   * i386.h (ix86_tune_indices): Add 
X86_TUNE_SOFTWARE_PREFETCHING_BENEFICIAL.
+   (TARGET_SOFTWARE_PREFETCHING_BENEFICIAL): New macor.
+   * i386.c (initial_ix86_tune_features): Add 
X86_SOFTARE_PREFETCHING_BENEFICIAL.
+   (software_prefetching_beneficial_p): Remove predicate.
+   (ix86_option_override_internal): Use new macro.
+
+2011-05-06  Jan Hubicka  
+
* ipa-inline.c (update_callee_keys): Don't reset node growth cache.
 
 2011-05-06  Jan Hubicka  
Index: config/i386/i386.h
===
--- config/i386/i386.h  (revision 173531)
+++ config/i386/i386.h  (working copy)
@@ -322,6 +322,7 @@ enum ix86_tune_indices {
   X86_TUNE_FUSE_CMP_AND_BRANCH,
   X86_TUNE_OPT_AGU,
   X86_TUNE_VECTORIZE_DOUBLE,
+  X86_TUNE_SOFTWARE_PREFETCHING_BENEFICIAL,
 
   X86_TUNE_LAST
 };
@@ -418,6 +419,8 @@ extern unsigned char ix86_tune_features[
 #define TARGET_OPT_AGU ix86_tune_features[X86_TUNE_OPT_AGU]
 #define TARGET_VECTORIZE_DOUBLE \
ix86_tune_features[X86_TUNE_VECTORIZE_DOUBLE]
+#define TARGET_SOFTWARE_PREFETCHING_BENEFICIAL \
+   ix86_tune_features[X86_TUNE_SOFTWARE_PREFETCHING_BENEFICIAL]
 
 /* Feature tests against the various architecture variations.  */
 enum ix86_arch_indices {
Index: config/i386/i386.c
===
--- config/i386/i386.c  (revision 173531)
+++ config/i386/i386.c  (working copy)
@@ -2083,6 +2083,11 @@ static unsigned int initial_ix86_tune_fe
   /* X86_TUNE_VECTORIZE_DOUBLE: Enable double precision vector
  instructions.  */
   ~m_ATOM,
+
+  /* X86_SOFTARE_PREFETCHING_BENEFICIAL: Enable software prefetching
+ at -O3.  For the moment, the prefetching seems badly tuned for Intel
+ chips.  */
+  m_K6_GEODE | m_AMD_MULTIPLE
 };
 
 /* Feature tests against the various architecture variations.  */
@@ -3257,27 +3262,6 @@ ix86_target_string (int isa, int flags, 
   return ret;
 }
 
-/* Return TRUE if software prefetching is beneficial for the
-   given CPU. */
-
-static bool
-software_prefetching_beneficial_p (void)
-{
-  switch (ix86_tune)
-{
-case PROCESSOR_GEODE:
-case PROCESSOR_K6:
-case PROCESSOR_ATHLON:
-case PROCESSOR_K8:
-case PROCESSOR_AMDFAM10:
-case PROCESSOR_BTVER1:
-  return true;
-
-default:
-  return false;
-}
-}
-
 /* Return true, if profiling code should be emitted before
prologue. Otherwise it returns false.
Note: For x86 with "hotfix" it is sorried.  */
@@ -4205,7 +4189,7 @@ ix86_option_override_internal (bool main
   if (flag_prefetch_loop_arrays < 0
   && HAVE_prefetch
   && optimize >= 3
-  && software_prefetching_beneficial_p ())
+  && TARGET_SOFTWARE_PREFETCHING_BENEFICIAL)
 flag_prefetch_loop_arrays = 1;
 
   /* If using typedef char *va_list, signal that __builtin_va_start (&ap, 0)


Updated^2: RFA: Fix middle-end/46500 (void * encapsulated)

2011-05-07 Thread Joern Rennecke

This is an update to this patch:
http://gcc.gnu.org/ml/gcc-patches/2010-11/msg01994.html

Tested with the contrib/config-list.mk
in svn mainline revision 173498 on gcc20.

No new failures; there are pre-existing failures in r173498 for the
following targets:

alpha-dec-osf5.1  lm32-uclinux
am33_2.0-linuxmicroblaze-elf
arm-freebsd6  microblaze-linux
arm-wince-pe  mips-openbsd
avr-elf   mn10300-elf
avr-rtems powerpc-wrs-vxworksae
i686-interix3 --enable-obsolete   rs6000-ibm-aix5.2.0
i686-openbsd3.0   rs6000-ibm-aix5.3.0
i686-pc-msdosdjgpprs6000-ibm-aix6.0
i686-wrs-vxworksaescore-elf --enable-obsolete
iq2000-elfvax-openbsd
lm32-elf  x86_64-knetbsd-gnu
lm32-rtems

For details of those failures, see PR target/47093.


pr46500-patch-20110507.gz
Description: GNU Zip compressed data


Re: Updated^2: RFA: Fix middle-end/46500 (void * encapsulated)

2011-05-07 Thread Joseph S. Myers
The c-opts.c change to include tm.h seems independent of the rest of the 
patch, and is incorrect since the file already has an explicit tm.h 
include with a comment saying why it's included.  I think it would be a 
good idea for the java/expr.c include (which I can't approve, Java patches 
should best be CC:ed to java-patches) to have a comment saying what target 
macros are used (BITS_PER_UNIT INT_TYPE_SIZE MODIFY_JNI_METHOD_CALL 
PARM_BOUNDARY TARGET_VTABLE_USES_DESCRIPTORS) - in general that applies to 
any tm.h includes in files that "shouldn't" include tm.h.

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


Re: Updated^2: RFA: Fix middle-end/46500 (void * encapsulated)

2011-05-07 Thread Joseph S. Myers
Similar comments also apply to the fortran/trans-types.c change: send to 
the fortran list as well as gcc-patches, include a comment listing the 
target macros involved (BOOL_TYPE_SIZE CHAR_TYPE_SIZE DOUBLE_TYPE_SIZE 
FLOAT_TYPE_SIZE INT_TYPE_SIZE LIBGCC2_HAS_TF_MODE LONG_DOUBLE_TYPE_SIZE 
LONG_LONG_TYPE_SIZE LONG_TYPE_SIZE POINTER_SIZE SHORT_TYPE_SIZE 
SIZE_TYPE).

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


[Patch, libfortran] Thread safety and simplification of error printing

2011-05-07 Thread Janne Blomqvist
Hi,

the error printing functionality (in io/unix.c) st_printf and
st_vprintf are not thread-safe as they use a static buffer. However,
since these routines are used when something has gone wrong, we
shouldn't use malloc() to allocate thread-specific buffers or anything
fancy like that. The way the buffer is used is that it is filled with
vs(n)printf() and then the buffer is written using write(); the
simplest way to fix this is to just print directly using vfprintf(),
which is what this patch does. Also, the patch uses
flockfile/funlockfile in a few places to increase the likelihood of
multiple related messages to end up together on the output.

As stderr is unbuffered and stdout is buffered, this patch also gets
rid of the functionality to choose where to send the error output, as
we don't want to deal with buffering in the error handling path. IMHO
this is no loss, as all targets/shells/batch schedulers/ etc. where
this might be relevant, offer functionality to redirect stderr to
wherever stdout goes. So there is no need for a gfortran-specific
mechanism for this.

Regtested on x86_64-unknown-linux-gnu, Ok for trunk?

2011-05-07  Janne Blomqvist  

* gfortran.texi: Remove GFORTRAN_USE_STDERR documentation.

2011-05-07  Janne Blomqvist  

* config.h.in: Regenerated.
* configure: Likewise.
* configure.ac: Check for flockfile, funlockfile.
* io/unix.c (st_vprintf): Remove.
(st_printf): Use vfprintf() instead of st_vprintf.
* libgfortran.h (flockfile,funlockfile): Define to empty if
functions not available.
(struct options_t): Remove use_stderr field.
(st_vprintf): Remove prototype.
* runtime/environ.c (variable_table[]): Remove GFORTRAN_USE_STDERR
entry.
* runtime/error.c (runtime_error): Use vfprintf instead of
st_vprintf.
(runtime_error_at): Likewise.
(runtime_warning_at): Likewise.


-- 
Janne Blomqvist
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 1284c3d..c810fe2 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -579,7 +579,6 @@ Malformed environment variables are silently ignored.
 * GFORTRAN_STDIN_UNIT:: Unit number for standard input
 * GFORTRAN_STDOUT_UNIT:: Unit number for standard output
 * GFORTRAN_STDERR_UNIT:: Unit number for standard error
-* GFORTRAN_USE_STDERR:: Send library output to standard error
 * GFORTRAN_TMPDIR:: Directory for scratch files
 * GFORTRAN_UNBUFFERED_ALL:: Don't buffer I/O for all units.
 * GFORTRAN_UNBUFFERED_PRECONNECTED:: Don't buffer I/O for preconnected units.
@@ -613,14 +612,6 @@ This environment variable can be used to select the unit number
 preconnected to standard error.  This must be a positive integer.
 The default value is 0.
 
-@node GFORTRAN_USE_STDERR
-@section @env{GFORTRAN_USE_STDERR}---Send library output to standard error
-
-This environment variable controls where library output is sent.
-If the first letter is @samp{y}, @samp{Y} or @samp{1}, standard
-error is used.  If the first letter is @samp{n}, @samp{N} or
-@samp{0}, standard output is used.
-
 @node GFORTRAN_TMPDIR
 @section @env{GFORTRAN_TMPDIR}---Directory for scratch files
 
diff --git a/libgfortran/config.h.in b/libgfortran/config.h.in
index 30da5fa..a48381d 100644
--- a/libgfortran/config.h.in
+++ b/libgfortran/config.h.in
@@ -393,6 +393,9 @@
 /* Define to 1 if you have the  header file. */
 #undef HAVE_FLOAT_H
 
+/* Define to 1 if you have the `flockfile' function. */
+#undef HAVE_FLOCKFILE
+
 /* libm includes floor */
 #undef HAVE_FLOOR
 
@@ -441,6 +444,9 @@
 /* Define to 1 if you have the `ftruncate' function. */
 #undef HAVE_FTRUNCATE
 
+/* Define to 1 if you have the `funlockfile' function. */
+#undef HAVE_FUNLOCKFILE
+
 /* Define to 1 if you have the `getcwd' function. */
 #undef HAVE_GETCWD
 
diff --git a/libgfortran/configure b/libgfortran/configure
index 833a0e1..9fa2b7f 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -16458,7 +16458,7 @@ _ACEOF
 fi
 done
 
-for ac_func in clock_gettime strftime
+for ac_func in clock_gettime strftime flockfile funlockfile
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
diff --git a/libgfortran/configure.ac b/libgfortran/configure.ac
index cf38fb0..e39ae17 100644
--- a/libgfortran/configure.ac
+++ b/libgfortran/configure.ac
@@ -264,7 +264,7 @@ AC_CHECK_FUNCS(sleep time ttyname signal alarm clock access fork execl)
 AC_CHECK_FUNCS(wait setmode execvp pipe dup2 close fdopen strcasestr getrlimit)
 AC_CHECK_FUNCS(gettimeofday stat fstat lstat getpwuid vsnprintf dup getcwd)
 AC_CHECK_FUNCS(localtime_r gmtime_r strerror_r getpwuid_r ttyname_r)
-AC_CHECK_FUNCS(clock_gettime strftime)
+AC_CHECK_FUNCS(clock_gettime strftime flockfile funlockfile)
 
 # Check for glibc backtrace functions
 AC_CHECK_FUNCS(backtrace backtrace_symbols)
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
inde

Re: [google] Patch to support calling multi-versioned functions via new GCC builtin. (issue4440078)

2011-05-07 Thread Xinliang David Li
On Sat, May 7, 2011 at 5:46 AM, Richard Guenther
 wrote:
> On Fri, May 6, 2011 at 7:57 PM, Xinliang David Li  wrote:
 I want propose a more general solution.

 1) Generic Annotation Support for gcc IR -- it is used attach to
 application/optimization specific annotation to gimple statements and
 annotations can be passed around across passes. In gcc, I only see
 HISTOGRAM annotation for value profiling, which is not general enough
 2) Support of CallInfo for each callsite. This is an annotation, but
 more standardized. The callinfo can be used to record information such
 as call attributes, call side effects, mod-ref information etc ---
 current gimple_call_flags can be folded into this Info structure.
>>>
>>> I don't like generic annotation facilities.  What should passes to with
>>> annotated stmts that are a) transformed, b) removed?  See RTL notes
>>> and all the interesting issues they cause.
>>
>>
>> Then how do you store information that needs to be passed across
>> optimization passes -- you can not possibly dump all of them into the
>> core IR. In fact, anything that is derived from (via analysis) but not
>> part of the core IR need to worry about update and maintenance. In
>> current GIMPLE, we can find many such instances -- DU chains, Memory
>> SSA, control flow information, as well as flags like visited,
>> no_warning, PLF (?), etc. Have a unified way of representing them is a
>> good thing so that 1) make the IR lean and mean; 2) avoid too many
>> different side data structures.  The important thing is to have a good
>> verifier to catch insanity and inconsistency of the annotation after
>> each pass.
>
> Well, as soon as you have a verifier it's no longer generic but _is_
> part of the "core IL".  Similar to how EH info is part of the "core IL",
> or alias info, or loop information.

The difference is that no-core IL can be thrown away anytime and be
recomputed if needed.

David


>
> Richard.
>


Re: [patch] Tidy up global_bindings_p langhook

2011-05-07 Thread Richard Guenther
On Sat, May 7, 2011 at 3:30 PM, Eric Botcazou  wrote:
> Hi,
>
> following the removal of pending sizes and the simplification of variable_size
> this patch changes the return type of the global_bindings_p langhook to bool
> and eliminates 3 calls (out of 4) present in fold-const.c; removing the 4th
> will require further investigation.
>
> Bootstrapped/regtested (all languages) on x86_64-suse-linux, OK for mainline?

The middle-end changes are ok.  I suppose the frontend changes are obvious.

Thanks,
Richard.

>
> 2011-05-07  Eric Botcazou  
>
>        * langhooks.h (lang_hooks_for_types): Change global_bindings_p's return
>        type to bool and adjust comment.
>        * fold-const.c (fold_range_test): Adjust call to global_bindings_p.
>        (fold_mathfn_compare): Remove calls to global_bindings_p.
>        (fold_inf_compare): Likewise.
>        * stor-layout.c (variable_size): Adjust call to global_bindings_p.
>        * c-tree.h (global_bindings_p): Adjust prototype.
>        * c-decl.c (global_bindings_p): Return bool and simplify.
> ada/
>        * gcc-interface/gigi.h (global_bindings_p): Adjust prototype.
>        * gcc-interface/utils.c (global_bindings_p): Return bool and simplify.
> cp/
>        * name-lookup.h (global_bindings_p): Adjust prototype.
>        * name-lookup.c (global_bindings_p): Return bool.
> fortran/
>        * f95-lang.c (global_bindings_p): Return bool and simplify.
> go/
>        * go-lang.c (global_bindings_p): Return bool and simplify.
> java/
>        * java-tree.h (global_bindings_p): Adjust prototype.
>        * decl.c (global_bindings_p): Return bool.
> lto/
>        * lto-lang.c (global_bindings_p): Return bool.
>
>
> --
> Eric Botcazou
>


Re: [google] Patch to support calling multi-versioned functions via new GCC builtin. (issue4440078)

2011-05-07 Thread Richard Guenther
On Sat, May 7, 2011 at 7:07 PM, Xinliang David Li  wrote:
> On Sat, May 7, 2011 at 5:46 AM, Richard Guenther
>  wrote:
>> On Fri, May 6, 2011 at 7:57 PM, Xinliang David Li  wrote:
> I want propose a more general solution.
>
> 1) Generic Annotation Support for gcc IR -- it is used attach to
> application/optimization specific annotation to gimple statements and
> annotations can be passed around across passes. In gcc, I only see
> HISTOGRAM annotation for value profiling, which is not general enough
> 2) Support of CallInfo for each callsite. This is an annotation, but
> more standardized. The callinfo can be used to record information such
> as call attributes, call side effects, mod-ref information etc ---
> current gimple_call_flags can be folded into this Info structure.

 I don't like generic annotation facilities.  What should passes to with
 annotated stmts that are a) transformed, b) removed?  See RTL notes
 and all the interesting issues they cause.
>>>
>>>
>>> Then how do you store information that needs to be passed across
>>> optimization passes -- you can not possibly dump all of them into the
>>> core IR. In fact, anything that is derived from (via analysis) but not
>>> part of the core IR need to worry about update and maintenance. In
>>> current GIMPLE, we can find many such instances -- DU chains, Memory
>>> SSA, control flow information, as well as flags like visited,
>>> no_warning, PLF (?), etc. Have a unified way of representing them is a
>>> good thing so that 1) make the IR lean and mean; 2) avoid too many
>>> different side data structures.  The important thing is to have a good
>>> verifier to catch insanity and inconsistency of the annotation after
>>> each pass.
>>
>> Well, as soon as you have a verifier it's no longer generic but _is_
>> part of the "core IL".  Similar to how EH info is part of the "core IL",
>> or alias info, or loop information.
>
> The difference is that no-core IL can be thrown away anytime and be
> recomputed if needed.

The same is true for all of the "core IL" pieces I listed above apart
from maybe EH info.

Richard.

> David
>
>
>>
>> Richard.
>>
>


Re: Updated^2: RFA: Fix middle-end/46500 (void * encapsulated)

2011-05-07 Thread Joern Rennecke

Quoting "Joseph S. Myers" :


The c-opts.c change to include tm.h seems independent of the rest of the
patch, and is incorrect since the file already has an explicit tm.h
include with a comment saying why it's included.


Yes, I've left this bit out now.  It used to be necessary, but it has been
obsoleted by your c-opts.c patch last month.


I think it would be a
good idea for the java/expr.c include (which I can't approve, Java patches
should best be CC:ed to java-patches) to have a comment saying what target
macros are used


Added.


Similar comments also apply to the fortran/trans-types.c change: send to
the fortran list as well as gcc-patches, include a comment listing the
target macros involved (BOOL_TYPE_SIZE CHAR_TYPE_SIZE DOUBLE_TYPE_SIZE
FLOAT_TYPE_SIZE INT_TYPE_SIZE LIBGCC2_HAS_TF_MODE LONG_DOUBLE_TYPE_SIZE
LONG_LONG_TYPE_SIZE LONG_TYPE_SIZE POINTER_SIZE SHORT_TYPE_SIZE
SIZE_TYPE).


Instead of including SIZE_TYPE in this list, I've removed the #if 0 code
that did (not) use it.
I've also added 2011 to the Copyright years in touched files that  
didn't already

have it.


pr46500-patch-20110507-2.gz
Description: GNU Zip compressed data


Re: copy_tree_r and STATEMENT_LIST (was Re: C++ PATCHes relating to c++/48834, c++/40975 (array new))

2011-05-07 Thread Eric Botcazou
> It seems pretty straightforward to me that a function named copy_tree_r
> should copy everything that isn't always shared (like decls).  It
> already copies SAVE_EXPR, after all; how is copying STATEMENT_LIST going
> to cause trouble in a context where copying SAVE_EXPR isn't?

OK, this can make sense, callers should handle special nodes like SAVE_EXPR, 
TARGET_EXPR, STATEMENT_LIST, etc themselves.  In light of this, they need to 
be audited and adjusted, as you did already a few days ago.  So I think I can 
live with your 40975-3.patch in the end.

Thanks for your patience.

-- 
Eric Botcazou


[Patch, libfortran] PR 48915 Fix incorrect return code with -fdump-core, error handling changes

2011-05-07 Thread Janne Blomqvist
Hi,

this simple bug led me to rethink normal and error termination and
thus the patch changes some other related stuff as well. So the
original problem was that when -fdump-core was enabled, STOP with a
numeric stop code made the program terminate with an incorrect return
code, since the core dump generation is done by the program killing
itself.

The real problem is that previously, we were mixing up normal
termination with a non-zero exit status (e.g. file not found) with
aborting the program (e.g. some serious error detected). The attached
patch reworks this so that normal termination (with a zero or non-zero
exit code) is done with exit(), and no backtrace or core dump is
generated in any circumstance. For serious errors, a backtrace and
core dump are generated.

Since OS'es contain widely used ways to control core dump generation
(e.g. ulimit -c), and we no longer "frivolously" try to generate a
core dump just because we're exiting with non-zero status, there is
IMHO no longer any need for a gfortran-specific option; if we hit a
serious error, we call abort() and a core dump is always generated if
the user environment is so configured (and the system supports core
dumps).

Also, since backtraces and core dumps are now only generated for
serious errors (not e.g. file not found). -fbacktrace is enabled by
default.

Regtested on x86_64-unknown-linux-gnu, Ok for trunk?

frontend ChangeLog:

2011-05-07  Janne Blomqvist  

PR libfortran/48915
* gfortran.h (gfc_option_t): Remove flag_dump_core.
* gfortran.texi (GFORTRAN_ERROR_DUMPCORE): Remove section.
(GFORTRAN_ERROR_BACKTRACE): Document that it's enabled by default.
* intrinsic.texi (ABORT): Remove explanation of -fdump-core.
* invoke.texi: Remove -fdump-core, document that -fbacktrace is
enabled by default.
* lang.opt: Remove -fdump-core.
* options.c (gfc_init_options): Make backtrace default to enabled,
remove dump_core.
(gfc_handle_option): Remove OPT_fdump-core.
* trans-decl.c: Pass a 0 to preserve ABI.

library ChangeLog:

2011-05-07  Janne Blomqvist  

PR libfortran/48915
* intrinsics/abort.c (abort): Call sys_abort().
* io/unix.c (st_vprintf): Call sys_abort().
* libgfortran.h (options_t): Remove dump_core member.
(handler): Rename to backtrace_handler.
(compile_options_t): Remove dump_core member.
(sys_exit): Remove.
(sys_abort): New function.
* runtime/backtrace.c (show_backtrace): Print a message if
backtrace is not available on target.
* runtime/compile_options.c (backtrace_handler): New
implementation based on example in Glibc manual.
(set_options): Remove dump_core handling, make signal handler
handle more signals.
(init_compile_options): Remove dump_core.
* runtime/environ.c (variable_table[]): Remove
GFORTRAN_ERROR_DUMPCORE element.
(show_variables): Update name, call exit().
* runtime/error.c (sys_exit): Remove.
(sys_abort): New function.
(recursion_check): Call sys_abort().
(os_error): Call exit().
(runtime_error): Likewise.
(runtime_error_at): Likewise.
(internal_error): Likewise.
(generate_error): Likewise.
(notify_std): Likewise.
* runtime/stop.c (stop_numeric): Call exit().
(stop_numeric_f08): Likewise.
(stop_string): Likewise.
(error_stop_string): Call sys_abort().
(error_stop_numeric): Print backtrace, exit with provided code.


-- 
Janne Blomqvist
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 92adf72..3b4967d 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2212,7 +2212,6 @@ typedef struct
   int flag_backslash;
   int flag_backtrace;
   int flag_allow_leading_underscore;
-  int flag_dump_core;
   int flag_external_blas;
   int blas_matmul_limit;
   int flag_cray_pointer;
diff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 1284c3d..9910574 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -588,7 +588,6 @@ Malformed environment variables are silently ignored.
 * GFORTRAN_DEFAULT_RECL:: Default record length for new files
 * GFORTRAN_LIST_SEPARATOR::  Separator for list output
 * GFORTRAN_CONVERT_UNIT::  Set endianness for unformatted I/O
-* GFORTRAN_ERROR_DUMPCORE:: Dump core on run-time errors
 * GFORTRAN_ERROR_BACKTRACE:: Show backtrace on run-time errors
 @end menu
 
@@ -754,26 +753,15 @@ environment variable will override the CONVERT specifier in the
 open statement}.  This is to give control over data formats to
 users who do not have the source code of their program available.
 
-@node GFORTRAN_ERROR_DUMPCORE
-@section @env{GFORTRAN_ERROR_DUMPCORE}---Dump core on run-time errors
-
-If the @env{GFORTRAN_ERROR_DUMPCORE} variable is set to
-@samp{y}, @samp{Y} or @samp{1} (only the first letter is rel

Put libgcc config headers in separate libgcc_tm.h

2011-05-07 Thread Joseph S. Myers
This patch creates a separate libgcc_tm_file config.gcc variable and
associated generated header libgcc_tm.h to avoid listing files in
../../libgcc/config/ in tm_file and so that macros moved to libgcc
headers can be poisoned on the host because those headers are no
longer included on the host.

The aim is that eventually files built for the target should include
libgcc_tm.h directly, and not tm.h at all, but that requires
completing the transition away from use of host tm.h macros in libgcc.
Until that is done, the constraint is still present that the files in
libgcc/config/ cannot have the same names as those in gcc/config/ (see
PR 46040), but poisoning the macros for the host reduces the risk of
incompletely moving a macro or a new target being added that defines a
macro in the wrong place.  (It doesn't prevent partial conversions
like that for arm-symbianelf fixed by this patch, where the main
target macro was moved but a macro used within the ARM port definition
of DECLARE_LIBRARY_RENAMES had a different definition in a subtarget's
header and that subtarget definition wasn't moved.)

This patch should facilitate moving about 30 target macros used only
in code built for the target into libgcc headers.

Bootstrapped with no regressions on x86_64-unknown-linux-gnu, and
tested with no regressions with cross to arm-none-eabi.  OK to commit?

gcc:
2011-05-07  Joseph Myers  

* config.gcc (libgcc_tm_file): Define instead of including files
from ../../libgcc/config/ in tm_file.
* configure.ac (libgcc_tm_file_list, libgcc_tm_include_list):
Define.
* configure: Regenerate.
* Makefile.in (libgcc_tm_file_list, libgcc_tm_include_list,
libgcc_tm.h, cs-libgcc_tm.h): New.
(TM_H): Include libgcc_tm.h and $(libgcc_tm_file_list).
(clean): Remove libgcc_tm.h.
* config/arm/symbian.h (RENAME_LIBRARY): Remove.
* mkconfig.sh: Include libgcc_tm.h in tm.h if USED_FOR_TARGET.
* system.h (DECLARE_LIBRARY_RENAMES): Poison.

libgcc:
2011-05-07  Joseph Myers  

* config/arm/symbian-lib.h: New.

Index: libgcc/config/arm/symbian-lib.h
===
--- libgcc/config/arm/symbian-lib.h (revision 0)
+++ libgcc/config/arm/symbian-lib.h (revision 0)
@@ -0,0 +1,28 @@
+/* Configuration file for Symbian OS on ARM processors, library renames.
+   Copyright (C) 2004, 2011 Free Software Foundation, Inc.
+
+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.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+.  */
+
+/* SymbianOS provides the BPABI routines in a separate library.
+   Therefore, we do not need to define any of them in libgcc.  */
+#undef RENAME_LIBRARY
+#define RENAME_LIBRARY(GCC_NAME, AEABI_NAME) /* empty */
Index: gcc/mkconfig.sh
===
--- gcc/mkconfig.sh (revision 173509)
+++ gcc/mkconfig.sh (working copy)
@@ -1,6 +1,7 @@
 #! /bin/sh
 
-# Copyright (C) 2001, 2002, 2006, 2007, 2010 Free Software Foundation, Inc.
+# Copyright (C) 2001, 2002, 2006, 2007, 2010, 2011
+# Free Software Foundation, Inc.
 # This file is part of GCC.
 
 # GCC is free software; you can redistribute it and/or modify
@@ -19,7 +20,7 @@
 
 
 # Generate gcc's various configuration headers:
-# config.h, tconfig.h, bconfig.h, tm.h, and tm_p.h.
+# config.h, tconfig.h, bconfig.h, tm.h, libgcc_tm.h, and tm_p.h.
 # $1 is the file to generate.  DEFINES, HEADERS, and possibly
 # TARGET_CPU_DEFAULT are expected to be set in the environment.
 
@@ -88,8 +89,9 @@
 fi
 
 # If this is tm.h, now include insn-flags.h only if IN_GCC is defined
-# but neither GENERATOR_FILE nor USED_FOR_TARGET is defined.  (Much of
-# this is temporary.)
+# but neither GENERATOR_FILE nor USED_FOR_TARGET is defined.  Also
+# include libgcc_tm.h if USED_FOR_TARGET is defined.  (Much of this is
+# temporary.)
 
 case $output in
 tm.h )
@@ -97,6 +99,9 @@
 #if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET
 # include "insn-flags.h"
 #endif
+#ifdef USED_FOR_TARGET
+# include "libgcc_tm.h"
+#endif
 EOF
 ;;
 esac
Index: gcc/configure
===

gcc-patches@gcc.gnu.org

2011-05-07 Thread Jan Hubicka
Hi,
while I plan to deffer the heuristics tunning once rest of IPA infrastructure 
updates
is on the place, I noticed that there are several obvious nonseces in the
badness computation.  This patch fix that.  The changes are:

 1) inline_call increases overall program size when inlining increase size
but does not decrease it when inlining decrease size.  This is illogical
and my recollection is that I handled this way tramp3d where there are tons
of unit decreasing inlines first. This was before early inliner was 
introduced
and at a time we did not update unit growth estimates when unit size shrinks
by inlining. So removed.
 2) Badness computation used funny log limits on overly large divisors.  This 
is nonsense
because it does not matter much if you divide by 1 or 10001, also the 
frequencies
are within known range and it is a lot better to use this knowledge.
 3) relative time benefit computation is factored out into separate functions
 4) all fixed point arithmetic is now power of 2 based instead of power of 10 
as previously.
Given that badness calculation became hot spot for Mozilla, there is no 
need to waste
cycles on this.
 5) update_edge_key dumping is fixed.

Bootstrapped/regtested x86_64-linux, will commit it shortly.

Honza

* ipa-inline-transform.c (inline_call): Account when program size 
decreases.
* ipa-inline.c (relative_time_benefit): New function.
(edge_badness): Reorganize to be power 2 based; fix
thinko when computing badness for negative growth; update
comments to match reality; better dumps.
(update_edge_key): Dump before updating.
Index: ipa-inline-transform.c
===
*** ipa-inline-transform.c  (revision 173531)
--- ipa-inline-transform.c  (working copy)
*** inline_call (struct cgraph_edge *e, bool
*** 184,190 
old_size = inline_summary (to)->size;
inline_merge_summary (e);
new_size = inline_summary (to)->size;
!   if (overall_size && new_size > old_size)
  *overall_size += new_size - old_size;
ncalls_inlined++;
  
--- 184,190 
old_size = inline_summary (to)->size;
inline_merge_summary (e);
new_size = inline_summary (to)->size;
!   if (overall_size)
  *overall_size += new_size - old_size;
ncalls_inlined++;
  
Index: ipa-inline.c
===
*** ipa-inline.c(revision 173532)
--- ipa-inline.c(working copy)
*** want_inline_function_called_once_p (stru
*** 666,671 
--- 666,702 
 return true;
  }
  
+ 
+ /* Return relative time improvement for inlining EDGE in range
+1...2^9.  */
+ 
+ static inline int
+ relative_time_benefit (struct inline_summary *callee_info,
+  struct cgraph_edge *edge,
+  int time_growth)
+ {
+   int relbenefit;
+   gcov_type uninlined_call_time;
+ 
+   uninlined_call_time =
+ ((gcov_type)
+  (callee_info->time
+   + inline_edge_summary (edge)->call_stmt_time
+   + CGRAPH_FREQ_BASE / 2) * edge->frequency
+  / CGRAPH_FREQ_BASE);
+   /* Compute relative time benefit, i.e. how much the call becomes faster.
+  ??? perhaps computing how much the caller+calle together become faster
+  would lead to more realistic results.  */
+   if (!uninlined_call_time)
+ uninlined_call_time = 1;
+   relbenefit =
+ (uninlined_call_time - time_growth) * 256 / (uninlined_call_time);
+   relbenefit = MIN (relbenefit, 512);
+   relbenefit = MAX (relbenefit, 1);
+   return relbenefit;
+ }
+ 
+ 
  /* A cost model driving the inlining heuristics in a way so the edges with
 smallest badness are inlined first.  After each inlining is performed
 the costs of all caller edges of nodes affected are recomputed so the
*** edge_badness (struct cgraph_edge *edge, 
*** 690,696 
fprintf (dump_file, "Badness calculation for %s -> %s\n",
   cgraph_node_name (edge->caller),
   cgraph_node_name (edge->callee));
!   fprintf (dump_file, "  growth size %i, time %i\n",
   growth,
   time_growth);
  }
--- 721,727 
fprintf (dump_file, "Badness calculation for %s -> %s\n",
   cgraph_node_name (edge->caller),
   cgraph_node_name (edge->callee));
!   fprintf (dump_file, "  size growth %i, time growth %i\n",
   growth,
   time_growth);
  }
*** edge_badness (struct cgraph_edge *edge, 
*** 698,723 
/* Always prefer inlining saving code size.  */
if (growth <= 0)
  {
!   badness = INT_MIN - growth;
if (dump)
!   fprintf (dump_file, "  %i: Growth %i < 0\n", (int) badness,
 growth);
  }
  
!   /* When profiling is available, base priorities -(#calls / growth).
!  So we optimize for overall number

Re: [patch] fix typos and grammar in -fuse-linker-plugin docs

2011-05-07 Thread Gerald Pfeifer
On Fri, 6 May 2011, Jonathan Wakely wrote:
> 2011-05-06  Jonathan Wakely  
> 
> * doc/invoke.texi (-fuse-linker-plugin): Improve grammar.
> 
> I was going to commit a smaller version of this patch as obvious (just
> the second of the three hunks in the patch) but I spotted a few other
> improvements that could be made. I think my changes preserve the
> intended meaning, but improve the English slightly and (I hope)
> clarify it.

This looks good, thank you!  (Some of the lines touched seem a bit
long? Perhaps wrap them?)

> Would removing "do" from "and shared libraries that do use hidden
> visibility" be a further improvement?

That I better leave to the native speakers here. :-)

Gerald


Re: [patch] fix typos and grammar in -fuse-linker-plugin docs

2011-05-07 Thread Jonathan Wakely
On 7 May 2011 22:33, Gerald Pfeifer  wrote:
> On Fri, 6 May 2011, Jonathan Wakely wrote:
>> 2011-05-06  Jonathan Wakely  
>>
>>         * doc/invoke.texi (-fuse-linker-plugin): Improve grammar.
>>
>> I was going to commit a smaller version of this patch as obvious (just
>> the second of the three hunks in the patch) but I spotted a few other
>> improvements that could be made. I think my changes preserve the
>> intended meaning, but improve the English slightly and (I hope)
>> clarify it.
>
> This looks good, thank you!  (Some of the lines touched seem a bit
> long? Perhaps wrap them?)

Done.

>> Would removing "do" from "and shared libraries that do use hidden
>> visibility" be a further improvement?
>
> That I better leave to the native speakers here. :-)

I made the call and removed the "do", and committed the attached
version to trunk.

Thanks,

Jonathan

2011-05-08  Jonathan Wakely  

* doc/invoke.texi (-fuse-linker-plugin): Improve grammar.
Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 173528)
+++ doc/invoke.texi (working copy)
@@ -7701,17 +7701,18 @@
 Disabled by default.
 
 @item -fuse-linker-plugin
-Enables the use of linker plugin during link time optimization.  This option
-relies on the linker plugin support in linker that is available in gold
+Enables the use of a linker plugin during link time optimization.  This
+option relies on plugin support in the linker, which is available in gold
 or in GNU ld 2.21 or newer.
 
-This option enables the extraction of object files with GIMPLE bytecode out of
-library archives. This improves the quality of optimization by exposing more
-code the link time optimizer.  This information specify what symbols
-can be accessed externally (by non-LTO object or during dynamic linking).
-Resulting code quality improvements on binaries (and shared libraries that do
-use hidden visibility) is similar to @code{-fwhole-program}.  See
-@option{-flto} for a description on the effect of this flag and how to use it.
+This option enables the extraction of object files with GIMPLE bytecode out
+of library archives. This improves the quality of optimization by exposing
+more code to the link time optimizer.  This information specifies what
+symbols can be accessed externally (by non-LTO object or during dynamic
+linking).  Resulting code quality improvements on binaries (and shared
+libraries that use hidden visibility) are similar to @code{-fwhole-program}.
+See @option{-flto} for a description of the effect of this flag and how to
+use it.
 
 Enabled by default when LTO support in GCC is enabled and GCC was compiled
 with a linker supporting plugins (GNU ld 2.21 or newer or gold).


[PATCH] C++0x, virt-specifier (final/override) support for member functions (parser and analysis both)

2011-05-07 Thread Ville Voutilainen
Tested on Linux/X86-32. Final on class is not yet supported,
that's probably what I'll be working on next. Changelog and
patch follow. Please holler if anything's wrong, as far as
I can see this works as it's supposed to.

2011-05-08 Ville Voutilainen  

   Implement final/override for member functions.
   * class.c (check_for_override): Check for DECL_OVERRIDE_P if the 
fndecl doesn't override anything and diagnose.
   * cp-tree.h: Add DECL_OVERRIDE_P and DECL_FINAL_P, add a new typedef 
cp_virt_specifiers, use cp_virt_specifiers in cp_declarator.
   * decl.c (set_virt_specifiers): New. Used for setting the 
virt-specifiers from cp_declarator to DECL_OVERRIDE_P and DECL_FINAL_P.
   * decl.c (grokdeclarator): ..and use them here. Diagnose 
virt-specifiers on non-fields here.
   * parser.c (make_call_declarator): add the virt-specifiers as a new 
parameter.
   * parser.c (cp_parser_lambda_declarator_opt, 
cp_parser_direct_declarator): ..and change the calls to make_call_declarator
   * parser.c (cp_parser_virt_specifier_seq_opt): New. Parses a 
virt-specifier-seq for a member function.
   * search.c (check_final_overrider): Diagnose attempts to override a 
final member function.
   * virtual9.C: New. Tests for virt-specifiers.
   * tree.h: Convert the #defines for cv-qualifier values into an enum, 
add a new enum for virt-specifier values.
   
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 9af238b..0c42281 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2477,6 +2477,11 @@ check_for_override (tree decl, tree ctype)
   if (DECL_DESTRUCTOR_P (decl))
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (ctype) = true;
 }
+  else if (DECL_OVERRIDE_P (decl))
+{
+  DECL_VINDEX (decl) = error_mark_node;
+  error ("%q+#D marked override, but does not override", decl);
+}
 }
 
 /* Warn about hidden virtual functions that are not overridden in t.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index a65998d..b729a3c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -73,6 +73,7 @@ c-common.h, not after.
   LAMBDA_EXPR_CAPTURES_THIS_P (in LAMBDA_EXPR)
   DECLTYPE_FOR_LAMBDA_CAPTURE (in DECLTYPE_TYPE)
   VEC_INIT_EXPR_IS_CONSTEXPR (in VEC_INIT_EXPR)
+  DECL_OVERRIDE_P (in FUNCTION_DECL)
1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE)
   TI_PENDING_TEMPLATE_FLAG.
   TEMPLATE_PARMS_FOR_INLINE.
@@ -85,6 +86,7 @@ c-common.h, not after.
   TARGET_EXPR_LIST_INIT_P (in TARGET_EXPR)
   LAMBDA_EXPR_MUTABLE_P (in LAMBDA_EXPR)
   DECLTYPE_FOR_LAMBDA_RETURN (in DECLTYPE_TYPE)
+  DECL_FINAL_P (in FUNCTION_DECL)
2: IDENTIFIER_OPNAME_P (in IDENTIFIER_NODE)
   ICS_THIS_FLAG (in _CONV)
   DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (in VAR_DECL)
@@ -2285,6 +2287,15 @@ struct GTY((variable_size)) lang_decl {
 #define DECL_INVALID_OVERRIDER_P(NODE) \
   (DECL_LANG_FLAG_4 (NODE))
 
+/* True (in a FUNCTION_DECL) if NODE is a function declared with
+   an override virt-specifier */
+#define DECL_OVERRIDE_P(NODE) (TREE_LANG_FLAG_0 (NODE))
+
+/* True (in a FUNCTION_DECL) if NODE is a function declared with
+   a final virt-specifier */
+#define DECL_FINAL_P(NODE) (TREE_LANG_FLAG_1 (NODE))
+
+
 /* The thunks associated with NODE, a FUNCTION_DECL.  */
 #define DECL_THUNKS(NODE) \
   (LANG_DECL_FN_CHECK (NODE)->context)
@@ -4426,6 +4437,11 @@ extern GTY(()) operator_name_info_t 
assignment_operator_name_info
 
 typedef int cp_cv_quals;
 
+/* A type-qualifier, or bitmask therefore, using the VIRT_SPEC
+   constants.  */
+
+typedef int cp_virt_specifiers;
+
 /* A storage class.  */
 
 typedef enum cp_storage_class {
@@ -4568,6 +4584,8 @@ struct cp_declarator {
   tree parameters;
   /* The cv-qualifiers for the function.  */
   cp_cv_quals qualifiers;
+  /* The virt-specifiers for the function.  */
+  cp_virt_specifiers virt_specifiers;
   /* The exception-specification for the function.  */
   tree exception_specification;
   /* The late-specified return type, if any.  */
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5bf637e..4593244 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7283,6 +7283,24 @@ grokfndecl (tree ctype,
   return decl;
 }
 
+/* decl is a FUNCTION_DECL.
+   specifiers are the parsed virt-specifiers.
+
+   Set flags to reflect the virt-specifiers.
+
+   Returns decl.  */
+
+static tree set_virt_specifiers (tree decl, cp_virt_specifiers specifiers)
+{
+  if (decl == NULL_TREE)
+return decl;
+  if (specifiers & VIRT_SPEC_OVERRIDE)
+DECL_OVERRIDE_P (decl) = 1;
+  if (specifiers & VIRT_SPEC_FINAL)
+DECL_FINAL_P (decl) = 1;
+  return decl;
+}
+
 /* DECL is a VAR_DECL for a static data member.  Set flags to reflect
the linkage that DECL will receive in the object file.  */
 
@@ -8057,6 +8075,9 @@ grokdeclarator (const cp_declarator *declarator,
   /* cv-qualifiers that apply to the declarator, for a declaration of

Re: [PATCH] C++0x, virt-specifier (final/override) support for member functions (parser and analysis both)

2011-05-07 Thread Jason Merrill

On 05/07/2011 07:48 PM, Ville Voutilainen wrote:

+static tree set_virt_specifiers (tree decl, cp_virt_specifiers specifiers)


The name of the function needs to be at the beginning of the line.


+  else
+  virt_specifier = VIRT_SPEC_UNSPECIFIED;
+
+  if (!virt_specifier)
+   break;


Using a named constant one one line and then testing for a boolean value 
on the next line is unclear.  How about just "else break;"?



+/* Non-static member functions have an optional virt-specifier-seq.
+   There is a VIRT_SPEC value for each virt-specifier.
+   They can be combined by bitwise-or to form the complete set of
+   virt-specifiers for a member function.  */
+enum virt_specifier
+  {
+VIRT_SPEC_UNSPECIFIED = 0x0,
+VIRT_SPEC_FINAL   = 0x1,
+VIRT_SPEC_OVERRIDE= 0x2
+  };


This should be in cp/cp-tree.h.

Otherwise, looks pretty good.

Jason


Re: [PATCH] C++0x, virt-specifier (final/override) support for member functions (parser and analysis both)

2011-05-07 Thread Jason Merrill

I might as well fix these issues myself, actually.

Jason


[PATCH, SMS 1/3] Support closing_branch_deps (second try)

2011-05-07 Thread Revital Eres
Hello,

The attached patch includes enhancements for SMS to support targets
that their doloop part is not decoupled from the rest of the loop's
instructions, as SMS currently requires. In this case, the branch can
not be placed wherever we want (as is currently done) due to the fact
it must honor dependencies and thus we schedule the branch instruction
with the rest of the loop's instructions and rotate it to be in row
ii-1 at the end of the scheduling procedure to make sure it's the last
instruction in the iteration.

The attached patch changes the current implementation to always schedule
the branch in order to support the above case.

As explained in http://gcc.gnu.org/ml/gcc-patches/2011-05/msg00250.html
by always scheduling the branch the code size might be effected due to
the fact SC can be increased by 1, which means adding instructions from
at most one iteration to the prologue and epilogue.  Also, it might
be that ii will be increased by one due to resources constraints --
unavailability of free slots to schedule the branch.

The patch was tested together with the rest of the patches in this series
and on top of the patch to support do-loop for ARM (not yet in mainline,
but approved http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01718.html).
On ppc64-redhat-linux regtest as well as bootstrap with SMS flags
enabling SMS also on loops with stage count 1.  Regtested on SPU.
On arm-linux-gnueabi regtseted on c,c++. Bootstrap c language with SMS
flags enabling SMS also on loops with stage count 1.

OK for mainline?

Thanks,
Revital

ChangeLog:

* ddg.c (create_ddg_dep_from_intra_loop_link): If a true dep edge
enters the branch create an anti edge in the opposite direction
to prevent the creation of reg-moves.
* modulo-sched.c: Adjust comment to reflect the fact we are
scheduling closing branch.
(PS_STAGE_COUNT): Rename to CALC_STAGE_COUNT and redefine.
(stage_count): New field in struct partial_schedule.
(calculate_stage_count): New function.
(normalize_sched_times): Rename to reset_sched_times and handle
incrementing the sched time of the nodes by a constant value
passed as parameter.
(duplicate_insns_of_cycles): Skip closing branch.
(sms_schedule_by_order): Schedule closing branch.
(ps_insn_find_column): Handle closing branch.
(sms_schedule): Call reset_sched_times and adjust the code to
support scheduling of the closing branch.
(ps_insert_empty_row): Update calls to normalize_sched_times
and rotate_partial_schedule functions.

testsuite Changlog:

* gcc.target/arm/sms-9.c: New file.
* gcc.target/arm/sms-10.c: New file.
Index: ddg.c
===
--- ddg.c   (revision 173296)
+++ ddg.c   (working copy)
@@ -197,6 +197,11 @@ create_ddg_dep_from_intra_loop_link (ddg
 }
 }
 
+  /* If a true dep edge enters the branch create an anti edge in the
+ opposite direction to prevent the creation of reg-moves.  */
+  if ((DEP_TYPE (link) == REG_DEP_TRUE) && JUMP_P (dest_node->insn))
+create_ddg_dep_no_link (g, dest_node, src_node, ANTI_DEP, REG_DEP, 1);
+
latency = dep_cost (link);
e = create_ddg_edge (src_node, dest_node, t, dt, latency, distance);
add_edge_to_ddg (g, e);
Index: modulo-sched.c
===
--- modulo-sched.c  (revision 173296)
+++ modulo-sched.c  (working copy)
@@ -84,14 +84,13 @@ along with GCC; see the file COPYING3.  
   II cycles (i.e. use register copies to prevent a def from overwriting
   itself before reaching the use).
 
-SMS works with countable loops (1) whose control part can be easily
-decoupled from the rest of the loop and (2) whose loop count can
-be easily adjusted.  This is because we peel a constant number of
-iterations into a prologue and epilogue for which we want to avoid
-emitting the control part, and a kernel which is to iterate that
-constant number of iterations less than the original loop.  So the
-control part should be a set of insns clearly identified and having
-its own iv, not otherwise used in the loop (at-least for now), which
+SMS works with countable loops whose loop count can be easily
+adjusted.  This is because we peel a constant number of iterations
+into a prologue and epilogue for which we want to avoid emitting
+the control part, and a kernel which is to iterate that constant
+number of iterations less than the original loop.  So the control
+part should be a set of insns clearly identified and having its
+own iv, not otherwise used in the loop (at-least for now), which
 initializes a register before the loop to the number of iterations.
 Currently SMS relies on the do-loop pattern to recognize such loops,
 where (1) the control part comprises of all insns definin

[PATCH, SMS 2/3] Skip DEBUG_INSNs while recognizing doloop

2011-05-07 Thread Revital Eres
Hello,

The attached patch adds code to skip DEBUG_INSNs while recognizing
doloop pattern.

The patch was tested together with the rest of the patches in this series
and on top of the patch to support do-loop for ARM (not yet in mainline,
but approved http://gcc.gnu.org/ml/gcc-patches/2011-01/msg01718.html).
On ppc64-redhat-linux regtest as well as bootstrap with SMS flags
enabling SMS also on loops with stage count 1.  Regtested on SPU.
On arm-linux-gnueabi regtseted on c,c++. Bootstrap c language with SMS
flags enabling SMS also on loops with stage count 1.

OK for mainline?

Thanks,
Revital

Changelog:

* modulo-sched.c (doloop_register_get): Ignore DEBUG_INSNs while
recognizing doloop.


Index: modulo-sched.c
===
--- modulo-sched.c  (revision 173368)
+++ modulo-sched.c  (working copy)
@@ -310,10 +313,10 @@ doloop_register_get (rtx head ATTRIBUTE_
  either a single (parallel) branch-on-count or a (non-parallel)
  branch immediately preceded by a single (decrement) insn.  */
   first_insn_not_to_check = (GET_CODE (PATTERN (tail)) == PARALLEL ? tail
- : PREV_INSN (tail));
+ : prev_nondebug_insn (tail));

   for (insn = head; insn != first_insn_not_to_check; insn = NEXT_INSN (insn))
-if (reg_mentioned_p (reg, insn))
+if (reg_mentioned_p (reg, insn) && !DEBUG_INSN_P (insn))
   {
 if (dump_file)
 {