Re: [PATCH] IPA ICF: memory leak fix

2014-11-23 Thread Markus Trippelsdorf
On 2014.11.22 at 17:46 +0100, Markus Trippelsdorf wrote:
 On 2014.11.22 at 16:04 +0100, Martin Liška wrote:
  On 11/22/2014 10:09 AM, Markus Trippelsdorf wrote:
   On 2014.11.22 at 09:05 +0100, Martin Liška wrote:
  
   Following patch removes memory leak that was introduced by very first 
   IPA ICF patch.
   I would like to thank David for hunting the leak.
  
   Patch an bootstrap on x86_86-linux-pc and no regression is introduced.
   
   I gave the patch a quick spin on gcc112:
   
   *** Error in `/home/trippels/gcc_build_dir/./prev-gcc/lto1': free(): 
   invalid next size (fast): 0x01000a5fc160 ***
   === Backtrace: =
   /lib64/libc.so.6(+0xa3d9c)[0x3fff7b6b3d9c]
   /lib64/libc.so.6(+0xaf0b4)[0x3fff7b6bf0b4]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1(_ZN3vecIi7va_heap6vl_ptrE7releaseEv-0x1d4bc00)[0x1025dd88]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1(_ZN7ipa_icf12sem_function14equals_privateEPNS_8sem_itemER8hash_mapIP11symtab_nodeS2_22default_hashmap_traitsE-0x9c083c)[0x116586bc]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1(_ZN7ipa_icf12sem_function6equalsEPNS_8sem_itemER8hash_mapIP11symtab_nodeS2_22default_hashmap_traitsE-0x9c0578)[0x11658998]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1(_ZN7ipa_icf18sem_item_optimizer7executeEv-0x9b8774)[0x11660a84]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1(_ZN7ipa_icf12pass_ipa_icf7executeEP8function-0x9b0314)[0x11668efc]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1(_Z16execute_one_passP8opt_pass-0x1647588)[0x1098a0a8]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1(_Z21execute_ipa_pass_listP8opt_pass-0x1644c2c)[0x1098ca7c]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1(_Z8lto_mainv-0x1df20e4)[0x101b494c]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1[0x10b599b8]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1(_ZN6toplev4mainEiPPc-0x1e8be70)[0x101507b8]
   /home/trippels/gcc_build_dir/./prev-gcc/lto1(main-0x1ec8d8c)[0x1015493c]
   /lib64/libc.so.6(+0x447ac)[0x3fff7b6547ac]
   /lib64/libc.so.6(__libc_start_main-0x19cbf4)[0x3fff7b6549d4]
   === Memory map: 
   ...
   
  
  Thank you for testing, problem is that I should grow the vector by 1, 
  because '0' is used as NULL value.
  
  Please try my fixed patch.
 
 This one survives bootstrap-lto. Thanks.

But Firefox doesn't build:

/home/trippels/gcc_test/usr/local/bin/c++ -fPIC -Wall -Wempty-body 
-Woverloaded-virtual -Wsign-compare -Wwrite-strings -Werror=endif-labels 
-Werror=int-to-pointer-cast -Werror=missing-braces -Werror=pointer-arith 
-Werror=return-type -Werror=sequence-point -Werror=unused-label 
-Werror=trigraphs -Werror=type-limits -Wno-invalid-offsetof -Wcast-align 
-flto=160 --param lto-partitions=160 -mcpu=power8 -ffunction-sections 
-fdata-sections -fno-exceptions -fno-strict-aliasing -frtti -fno-exceptions 
-fno-math-errno -std=gnu++0x -pthread -pipe -UDEBUG -DNDEBUG -O3 
-DU_STATIC_IMPLEMENTATION -fvisibility=hidden -W -Wall -pedantic 
-Wpointer-arith -Wwrite-strings -Wno-long-long -Wno-unused 
-Wno-unused-parameter   -lpthread 
-Wl,--hash-style=gnu,--as-needed,--gc-sections,--icf=all -Wl,-z,noexecstack 
-Wl,-z,text -Wl,--build-id -Wl,--gc-sections  -o ../../bin/makeconv makeconv.o 
ucnvstat.o genmbcs.o gencnvex.o -L../../lib -licutu -L../../lib -licui18n 
-L../../lib -licuuc -L../../stubdata -licudata -lpthread -ldl -lm
lto1: internal compiler error: in operator[], at vec.h:736
0x10122377 vecint, va_heap, vl_embed::operator[](unsigned int)
../../gcc/gcc/vec.h:736
0x10d1a0f3 vecint, va_heap, vl_embed::operator[](unsigned int)
../../gcc/gcc/ipa-icf.c:963
0x10d1a0f3 vecint, va_heap, vl_ptr::operator[](unsigned int)
../../gcc/gcc/vec.h:1202
0x10d1a0f3 ipa_icf::sem_function::bb_dict_test(auto_vecint, 0ul, int, int)
../../gcc/gcc/ipa-icf.c:970
0x10d1aa73 ipa_icf::sem_function::equals_private(ipa_icf::sem_item*, 
hash_mapsymtab_node*, ipa_icf::sem_item*, default_hashmap_traits)
../../gcc/gcc/ipa-icf.c:512
0x10d1afb3 ipa_icf::sem_function::equals(ipa_icf::sem_item*, 
hash_mapsymtab_node*, ipa_icf::sem_item*, default_hashmap_traits)
../../gcc/gcc/ipa-icf.c:384
0x10d1dba3 ipa_icf::sem_item_optimizer::subdivide_classes_by_equality(bool)
../../gcc/gcc/ipa-icf.c:1833
0x10d2397f ipa_icf::sem_item_optimizer::execute()
../../gcc/gcc/ipa-icf.c:1652
0x10d24a93 ipa_icf_driver
../../gcc/gcc/ipa-icf.c:2382
0x10d24a93 ipa_icf::pass_ipa_icf::execute(function*)
../../gcc/gcc/ipa-icf.c:2430
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See http://gcc.gnu.org/bugs.html for instructions.
lto-wrapper: fatal error: /home/trippels/gcc_test/usr/local/bin/c++ returned 1 
exit status
compilation terminated.
/home/trippels/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[8]: *** [../../bin/makeconv] Error 1

-- 
Markus


[RFC,PATCH,testsuite] Set gcc_force_conventional_output even without LTO linker plugin

2014-11-23 Thread Matthew Fortune
Hi,

I have had to use this patch several times when performing cross testing
but I'm not sure if it is the right fix. The MIPS target testsuite runs
all tests regardless of the current compiler configuration and downgrades
run tests to link tests and then to assembly tests depending on what
libraries and hardware is available in the current run.

In order to experiment with how the tests behave for a different
configurations I add things like:

--target_board=multi-sim/-msoft-float

Where the option I am trying may not have libraries available.

The problem comes when the LTO options are tested. The choice of which
LTO options are used is based on a test for whether the LTO linker plugin
is available.  This test fails in my case because there are no suitable
libraries to link against.

if [check_effective_target_lto] {
# When having plugin test both slim and fat LTO and plugin/nonplugin
# path.
if [check_linker_plugin_available] {
  set LTO_TORTURE_OPTIONS [list \
  { -O2 -flto -fno-use-linker-plugin -flto-partition=none } \
  { -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects }
  ]
  set gcc_force_conventional_output -ffat-lto-objects
} else {
  set LTO_TORTURE_OPTIONS [list \
  { -O2 -flto -flto-partition=none } \
  { -O2 -flto }
  ]
}
}

The problem as I see it is that the gcc_force_conventional_output line
only applies to the first case. I understand why this is generally OK
but if the linker plugin is seen to be available at GCC config time
but is not available for a specific test configuration then there is
a problem.

I'd therefore like to apply the following. Any suggestions on the
testing that this needs? Would a build + regression run of GCC
with binutils configured --disable-plugins be sufficient?

Matthew

gcc/testsuite/

* lib/gcc-dg.exp: Set gcc_force_conventional_output for whenever
LTO is used.

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 6df8ae1..8d5bf9b 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -88,13 +88,13 @@ if [check_effective_target_lto] {
  { -O2 -flto -fno-use-linker-plugin -flto-partition=none } \
  { -O2 -flto -fuse-linker-plugin -fno-fat-lto-objects }
   ]
-  set gcc_force_conventional_output -ffat-lto-objects
 } else {
   set LTO_TORTURE_OPTIONS [list \
  { -O2 -flto -flto-partition=none } \
  { -O2 -flto }
   ]
 }
+set gcc_force_conventional_output -ffat-lto-objects
 }
 
 global orig_environment_saved


[Patch, Fortran] -Wtabs cleanup

2014-11-23 Thread Tobias Burnus
This patch moves -Wtabs closer to the common diagnostics - and changed 
the odd reversed logic of flags = 0 meaning off.


This brings nice common diagnostic features to fixed-form source code 
for the initial indentation [tab = 6 spaces] (which doesn't show a 
location), but not to free-form source code or in-line tabs (also in 
fixed-form) as that shows a location %C but gfc_current_location doesn't 
contain a valid localtion for the common diagnostics.


For the fixed-form initial-tab diagnostic of -Wtabs, the colored output 
is not new, but it now also shows the [-Wtabs] or [-Werror=tabs] and 
handles the latter.


Note: The Wpedantic (with alias -pedantic and --pedantic) had to be 
added as otherwise the LangEnabledBy for Wall (!) didn't work; as known, 
-(W)pedantic itself is not a new option.


Note 2: As -pedantic enables -Wtabs, -pedantic-errors now also enabled 
-Werror=tabs. The testsuite seems to be run with -pedantic-errors, 
hence, I had to change a test case. Alternatively, one could either 
explicitly (dg-options) or in the general test setup change 
-pedantic-errors to -pedantic.


Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias
2014-11-23  Tobias Burnus  bur...@net-b.de
	Manuel López-Ibáñez  m...@gcc.gnu.org

gcc/fortran/
	* gfortran.h (gfc_option_t): Remove warn_tabs.
	* lang.opt (Wpedantic): Add.
	(Wtabs): Use Var and LangEnabledBy.
	* options.c (gfc_init_options, gfc_post_options,
	set_Wall): Remove -Wtabs handling.
	(gfc_handle_option): Update -std=, remove OPT_Wtabs.
	* scanner.c (gfc_gobble_whitespace): Update for
	flag-variable renaming.
	(load_line): Ditto. Pass warn flag to diagnostic.

gcc/testsuite/
	* gfortran.dg/tab_continuation.f: Update dg-*.

diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index b0f15b4..1ee7dd4 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2452,7 +2452,6 @@ typedef struct
   int warn_implicit_procedure;
   int warn_line_truncation;
   int warn_surprising;
-  int warn_tabs;
   int warn_underflow;
   int warn_intrinsic_shadow;
   int warn_intrinsics_std;
diff --git a/gcc/fortran/lang.opt b/gcc/fortran/lang.opt
index d6fe603..5da0453 100644
--- a/gcc/fortran/lang.opt
+++ b/gcc/fortran/lang.opt
@@ -269,6 +269,10 @@ Wopenmp-simd
 Fortran
 ; Documented in C
 
+Wpedantic
+Fortran
+; Documented in common.opt
+
 Wreal-q-constant
 Fortran Warning
 Warn about real-literal-constants with 'q' exponent-letter
@@ -294,9 +298,13 @@ Fortran Warning
 Warn about \suspicious\ constructs
 
 Wtabs
-Fortran Warning
+Fortran Warning Var(warn_tabs) LangEnabledBy(Fortran,Wall)
 Permit nonconforming uses of the tab character
 
+Wtabs
+LangEnabledBy(Fortran,Wpedantic)
+;
+
 Wunderflow
 Fortran Warning
 Warn about underflow of numerical constant expressions
diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c
index bbbd6ab..dee1af4 100644
--- a/gcc/fortran/options.c
+++ b/gcc/fortran/options.c
@@ -104,7 +104,6 @@ gfc_init_options (unsigned int decoded_options_count,
   gfc_option.warn_implicit_interface = 0;
   gfc_option.warn_line_truncation = 0;
   gfc_option.warn_surprising = 0;
-  gfc_option.warn_tabs = 1;
   gfc_option.warn_underflow = 1;
   gfc_option.warn_intrinsic_shadow = 0;
   gfc_option.warn_intrinsics_std = 0;
@@ -430,10 +429,7 @@ gfc_post_options (const char **pfilename)
 gfc_option.flag_max_stack_var_size = 0;
   
   if (pedantic)
-{ 
-  gfc_option.warn_ampersand = 1;
-  gfc_option.warn_tabs = 0;
-}
+gfc_option.warn_ampersand = 1;
 
   /* Optimization implies front end optimization, unless the user
  specified it directly.  */
@@ -461,7 +457,6 @@ set_Wall (int setting)
   gfc_option.gfc_warn_conversion = setting;
   gfc_option.warn_line_truncation = setting;
   gfc_option.warn_surprising = setting;
-  gfc_option.warn_tabs = !setting;
   gfc_option.warn_underflow = setting;
   gfc_option.warn_intrinsic_shadow = setting;
   gfc_option.warn_intrinsics_std = setting;
@@ -720,10 +715,6 @@ gfc_handle_option (size_t scode, const char *arg, int value,
   gfc_option.warn_surprising = value;
   break;
 
-case OPT_Wtabs:
-  gfc_option.warn_tabs = value;
-  break;
-
 case OPT_Wtarget_lifetime:
   gfc_option.warn_target_lifetime = value;
   break;
@@ -1038,7 +1029,7 @@ gfc_handle_option (size_t scode, const char *arg, int value,
   gfc_option.max_continue_free = 39;
   gfc_option.max_identifier_length = 31;
   gfc_option.warn_ampersand = 1;
-  gfc_option.warn_tabs = 0;
+  warn_tabs = 1;
   break;
 
 case OPT_std_f2003:
@@ -1047,7 +1038,7 @@ gfc_handle_option (size_t scode, const char *arg, int value,
   gfc_option.warn_std = GFC_STD_F95_OBS;
   gfc_option.max_identifier_length = 63;
   gfc_option.warn_ampersand = 1;
-  gfc_option.warn_tabs = 0;
+  warn_tabs = 1;
   break;
 
 case OPT_std_f2008:
@@ -1056,7 +1047,7 @@ gfc_handle_option (size_t scode, const char *arg, int value,
   

Re: Fix vectorizer conditions on updating alignment

2014-11-23 Thread Eric Botcazou
 It's quite recent and it will break Ada iirc.

I don't think so, it will break the case for which it was added, possibly 
something to do with Altivec.  But doing svn annotate is easy enough.

-- 
Eric Botcazou


[Committed] Add some more testcases

2014-11-23 Thread Andrew Pinski
Hi,
  While looking at what patches I had in the internal tree here at
Cavium, I noticed two more testcases which I did upstream already.
One testcase for PR 53135 (reduced from dhcp-server) and another one
for an ICE which showed up while improving PHI-OPT (reduced from
gnupg-2.0.18).

Committed as obvious after a test.

Thanks,
Andrew

ChangeLog:
* gcc.c-torture/compile/20120927-1.c: New testcase.
* gcc.c-torture/compile/20120830-1.c: New testcase.
Index: testsuite/gcc.c-torture/compile/20120927-1.c
===
--- testsuite/gcc.c-torture/compile/20120927-1.c(revision 0)
+++ testsuite/gcc.c-torture/compile/20120927-1.c(revision 0)
@@ -0,0 +1,43 @@
+void ff(int);
+int isc_fsaccess_set(unsigned int access) {
+ unsigned int mode;
+ unsigned int bits;
+ mode = 0;
+ bits = 0x0021;
+ if ((access  bits) != 0) 
+  {
+   mode |= 0400;
+   access = ~bits;
+  }
+ access = ~bits; 
+ bits = (10);
+ if ((access  bits) != 0)
+   access = ~bits; 
+ bits = 0x0012;
+ if ((access  bits) != 0)
+ {
+   mode |= 0200; 
+   access = ~bits; 
+ }
+ mode |= (0200  3);
+ access = ~bits; 
+ bits = (10);
+ if ((access  bits) != 0)
+   mode |= ((0200  3)  3);
+ bits = 0x0044;
+ if ((access  bits) != 0)
+ { 
+mode |= 0100;
+access = ~bits;
+ }
+ if ((access  bits) != 0)
+ {
+   mode |= (0100  3);
+   access = ~bits; 
+ }; 
+ bits = (10);
+ if ((access  bits) != 0)
+   mode |= ((0100  3)  3);
+ ff(mode) ;
+}
+
Index: testsuite/gcc.c-torture/compile/20120830-1.c
===
--- testsuite/gcc.c-torture/compile/20120830-1.c(revision 0)
+++ testsuite/gcc.c-torture/compile/20120830-1.c(revision 0)
@@ -0,0 +1,14 @@
+int keyring_search(void);
+int keydb_search2 (int *hdfound, int *hdcurrent, int *a)
+{
+int rc = -1;
+while (rc == -1) {
+if (*a == 1)
+rc = keyring_search ();
+if (rc == -1)
+*hdcurrent++;
+   if (!rc)
+*hdfound = *hdcurrent;
+}
+return rc;
+}


[C++ Patch, trivial?] PR 63905

2014-11-23 Thread Paolo Carlini

Hi,

submitter noticed that when Honza in r201994 changed 
DECL_CONSTRUCTOR_P/DECL_DESTRUCTOR_P to use middle-end flags forgot to 
remove the unused front-end flags. Tested x86_64-linux.


Thanks!
Paolo.

PS: FWIW, the issue still exists in 4_9-branch too.

///
2014-11-23  Paolo Carlini  paolo.carl...@oracle.com

PR c++/63905
* cp-tree.h (lang_decl_fn): Remove constructor_attr, destructor_attr.

Index: cp-tree.h
===
--- cp-tree.h   (revision 217980)
+++ cp-tree.h   (working copy)
@@ -2051,8 +2051,6 @@ struct GTY(()) lang_decl_fn {
 
   unsigned global_ctor_p : 1;
   unsigned global_dtor_p : 1;
-  unsigned constructor_attr : 1;
-  unsigned destructor_attr : 1;
   unsigned assignment_operator_p : 1;
   unsigned static_function : 1;
   unsigned pure_virtual : 1;
@@ -2066,7 +2064,7 @@ struct GTY(()) lang_decl_fn {
   unsigned this_thunk_p : 1;
   unsigned hidden_friend_p : 1;
   unsigned omp_declare_reduction_p : 1;
-  /* No spare bits on 32-bit hosts, 32 on 64-bit hosts.  */
+  /* 2 spare bits on 32-bit hosts, 34 on 64-bit hosts.  */
 
   /* For a non-thunk function decl, this is a tree list of
  friendly classes. For a thunk function decl, it is the


Re: Localize symbols used only from comdat groups

2014-11-23 Thread H.J. Lu
On Sun, May 18, 2014 at 4:56 PM, Jan Hubicka hubi...@ucw.cz wrote:
 Hi,
 this patch adds simple IPA pass that brings symbols used only from
 comdat groups into the groups.  This prevents dead code in cases
 where the comdat group is replaced by a copy from different unit.

 The patch saves about 0.5% of libreoffice binary and about 1%
 of firefox binary with section GC disabled.

 One limitation of the pass is that it won't privatize data used by a function
 or vice versa, as doing so probably require inveting new comdat group for the
 data and turing the symbols into hidden symbols. Something that may make sense
 to implement as followup. (in a way we do so for string literals).

 Bootstrapped/regtested x86_64-linux, will commit it after some further
 testing.

 Honza

 * tree-pass.h (make_pass_ipa_comdats): New pass.
 * timevar.def (TV_IPA_COMDATS): New timevar.
 * passes.def (pass_ipa_comdats): Add.
 * Makefile.in (OBJS): Add ipa-comdats.o
 * ipa-comdats.c: New file.


This caused:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61324

-- 
H.J.


Re: [Patch, Fortran] -Wtabs cleanup

2014-11-23 Thread FX
 Build and regtested on x86-64-gnu-linux.
 OK for the trunk?

OK. One question: I don’t understand why you need two separate Wtabs lines in 
lang.opt.

FX

Re: [Patch, Fortran] -Wtabs cleanup

2014-11-23 Thread Tobias Burnus

FX wrote:
OK. One question: I don’t understand why you need two separate Wtabs 
lines in lang.opt.


Thanks for the review!

Because EnabledByLanguage(Fortran,Wall || Wpedantic) isn't supported – 
using two separate Wtabs is the work around.


Cf. https://gcc.gnu.org/ml/gcc-patches/2014-11/msg02895.html

Tobias


Re: [Patch, Fortran] -Wtabs cleanup

2014-11-23 Thread FX
 Because EnabledByLanguage(Fortran,Wall || Wpedantic) isn't supported – using 
 two separate Wtabs is the work around.
 Cf. https://gcc.gnu.org/ml/gcc-patches/2014-11/msg02895.html

You’re the best :)

FX



[patch fortran/44054] handle %L using the common diagnostics machinery

2014-11-23 Thread Manuel López-Ibáñez
Exactly what the subject says. I'm not sure if this is appropriate for
stage3, I'll leave that to the Fortran maintainers.

Bootstrapped  regression tested on x86_64-linux-gnu.

Cheers,

Manuel.


gcc/fortran/ChangeLog:

2014-11-23  Manuel López-Ibáñez  m...@gcc.gnu.org

PR fortran/44054
* decl.c (gfc_verify_c_interop_param): Use gfc_error_now_2.
(gfc_set_constant_character_len): Use gfc_warning_now_2.
* resolve.c (resolve_ordinary_assign): Likewise.
* gfortran.h (warn_character_truncation): Do not declare here.
* error.c (gfc_format_decoder): Handle %L.
* lang.opt (Wcharacter-truncation): Add Var and LangEnabledBy.
* options.c (gfc_init_options): Do not handle
warn_character_truncation explicitly.
(set_Wall): Likewise.
(gfc_handle_option): Likewise.
Index: gcc/fortran/decl.c
===
--- gcc/fortran/decl.c  (revision 217971)
+++ gcc/fortran/decl.c  (working copy)
@@ -988,14 +988,13 @@ gfc_verify_c_interop_param (gfc_symbol *
  interoperable.  */
   if (sym-attr.flavor == FL_PROCEDURE)
 {
   if (sym-attr.is_bind_c == 0)
 {
-  gfc_error_now (Procedure '%s' at %L must have the BIND(C) 
- attribute to be C interoperable, sym-name,
- (sym-declared_at));
-
+  gfc_error_now_2 (Procedure %qs at %L must have the BIND(C) 
+  attribute to be C interoperable, sym-name,
+  (sym-declared_at));
   return false;
 }
   else
 {
   if (sym-attr.is_c_interop == 1)
@@ -1222,13 +1221,14 @@ gfc_set_constant_character_len (int len,
   memcpy (s, expr-value.character.string,
  MIN (len, slen) * sizeof (gfc_char_t));
   if (len  slen)
gfc_wide_memset (s[slen], ' ', len - slen);
 
-  if (gfc_option.warn_character_truncation  slen  len)
-   gfc_warning_now (CHARACTER expression at %L is being truncated 
-(%d/%d), expr-where, slen, len);
+  if (warn_character_truncation  slen  len)
+   gfc_warning_now_2 (OPT_Wcharacter_truncation,
+  CHARACTER expression at %L is being truncated 
+  (%d/%d), expr-where, slen, len);
 
   /* Apply the standard by 'hand' otherwise it gets cleared for
 initializers.  */
   if (check_len != -1  slen != check_len
!(gfc_option.allow_std  GFC_STD_GNU))
Index: gcc/fortran/gfortran.h
===
--- gcc/fortran/gfortran.h  (revision 217971)
+++ gcc/fortran/gfortran.h  (working copy)
@@ -2454,11 +2454,10 @@ typedef struct
   int warn_surprising;
   int warn_tabs;
   int warn_underflow;
   int warn_intrinsic_shadow;
   int warn_intrinsics_std;
-  int warn_character_truncation;
   int warn_array_temp;
   int warn_align_commons;
   int warn_real_q_constant;
   int warn_unused_dummy_argument;
   int warn_zerotrip;
Index: gcc/fortran/error.c
===
--- gcc/fortran/error.c (revision 217971)
+++ gcc/fortran/error.c (working copy)
@@ -962,29 +962,36 @@ gfc_warning_now (const char *gmsgid, ...
 
 /* Called from output_format -- during diagnostic message processing
to handle Fortran specific format specifiers with the following meanings:
 
%C  Current locus (no argument)
+   %L  Takes locus argument
 */
 static bool
 gfc_format_decoder (pretty_printer *pp,
text_info *text, const char *spec,
int precision ATTRIBUTE_UNUSED, bool wide ATTRIBUTE_UNUSED,
bool plus ATTRIBUTE_UNUSED, bool hash ATTRIBUTE_UNUSED)
 {
   switch (*spec)
 {
 case 'C':
+case 'L':
   {
static const char *result = (1);
-   gcc_assert (gfc_current_locus.nextc - gfc_current_locus.lb-line = 0);
-   unsigned int c1 = gfc_current_locus.nextc - gfc_current_locus.lb-line;
+   locus *loc;
+   if (*spec == 'C')
+ loc = gfc_current_locus;
+   else
+ loc = va_arg (*text-args_ptr, locus *);
+   gcc_assert (loc-nextc - loc-lb-line = 0);
+   unsigned int offset = loc-nextc - loc-lb-line;
gcc_assert (text-locus);
*text-locus
  = linemap_position_for_loc_and_offset (line_table,
-gfc_current_locus.lb-location,
-c1);
+loc-lb-location,
+offset);
global_dc-caret_char = '1';
pp_string (pp, result);
return true;
   }
 default:
Index: gcc/fortran/lang.opt
===
--- gcc/fortran/lang.opt(revision 217971)
+++ gcc/fortran/lang.opt(working copy)
@@ -216,11 +216,11 @@ Warn if the type of a variable 

[PATCH] pr63856 - test case

2014-11-23 Thread tsaunders
From: Trevor Saunders tsaund...@mozilla.com

Hi,

bug was already fixed, so just add the test case.

tested this only passes with r217909 where it is fixed, ok?

Trev


diff --git a/gcc/testsuite/gcc.dg/pr63856.c b/gcc/testsuite/gcc.dg/pr63856.c
new file mode 100644
index 000..8fb65c6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr63856.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options -O2 -fPIC } */
+typedef int v2si __attribute__ ((vector_size (8)));
+typedef short v4hi __attribute__ ((vector_size (8)));
+
+int __attribute__ ((noinline, noclone)) f (v2si A, int N)
+{
+  return ((v4hi) A)[N];
+}
+
+int __attribute__ ((noinline, noclone)) g (v2si A, int N)
+{
+  return ((v4hi) A)[N];
+}
-- 
2.1.3



Re: [Patch, Fortran] -Wtabs cleanup

2014-11-23 Thread Manuel López-Ibáñez
On 23 November 2014 at 10:27, Tobias Burnus bur...@net-b.de wrote:
 This patch moves -Wtabs closer to the common diagnostics - and changed the
 odd reversed logic of flags = 0 meaning off.

You may wish to update the documentation to reflect this change in
behavior (invoke.texi, lang.opt and perhaps changes.html).

Cheers,

Manuel.


Re: [PATCH] pr63856 - test case

2014-11-23 Thread Jakub Jelinek
On Sun, Nov 23, 2014 at 01:32:27PM -0500, tsaund...@mozilla.com wrote:
 bug was already fixed, so just add the test case.
 
 tested this only passes with r217909 where it is fixed, ok?
 
 Trev
 
 
 diff --git a/gcc/testsuite/gcc.dg/pr63856.c b/gcc/testsuite/gcc.dg/pr63856.c
 new file mode 100644
 index 000..8fb65c6
 --- /dev/null
 +++ b/gcc/testsuite/gcc.dg/pr63856.c
 @@ -0,0 +1,14 @@
 +/* { dg-do compile } */
 +/* { dg-options -O2 -fPIC } */
 +typedef int v2si __attribute__ ((vector_size (8)));
 +typedef short v4hi __attribute__ ((vector_size (8)));
 +
 +int __attribute__ ((noinline, noclone)) f (v2si A, int N)

Vector arguments or return values often result in -Wpsabi warnings,
so you certainly want -Wno-psabi in dg-options.
On the other side, -fPIC should be only used for { target pic },
so better put that into dg-additional-options.

 +{
 +  return ((v4hi) A)[N];
 +}
 +
 +int __attribute__ ((noinline, noclone)) g (v2si A, int N)
 +{
 +  return ((v4hi) A)[N];
 +}
 -- 
 2.1.3

Jakub


[PATCH] pr61324 pr 63649 - fix crash in ipa_comdats

2014-11-23 Thread tsaunders
From: Trevor Saunders tsaund...@mozilla.com

Hi,

the interesting symbol in the test case for pr61324 is __GLOBAL__sub_I_s.  It
refers to nothing, and is called by nothing, however it is kept (I believe
because of -fkeep-inline-functions).  That means ipa_comdats never tries to put
it in a comdat, and so it never ends up in the hash table.  It seems like the
simplest solution is to just check if symbol is not in the map before trying to
get the comdat it should go in, but another approach might be to keep separate
hash maps for comdat functions and functions that can't be in any comdat, and
then iterate over only the functions that belong in a comdat.

boottstrapped + regtested x86_64-unknown-linux-gnu, ok?

Trev

gcc/

* ipa-comdats.c (ipa_commdats): check if map contains symbol before
trying to put symbol in a comdat.

diff --git a/gcc/ipa-comdats.c b/gcc/ipa-comdats.c
index af2aef8..8695a7e 100644
--- a/gcc/ipa-comdats.c
+++ b/gcc/ipa-comdats.c
@@ -327,18 +327,18 @@ ipa_comdats (void)
   !symbol-alias
   symbol-real_symbol_p ())
{
- tree group = *map.get (symbol);
+ tree *group = map.get (symbol);
 
- if (group == error_mark_node)
+ if (!group || *group == error_mark_node)
continue;
  if (dump_file)
{
  fprintf (dump_file, Localizing symbol\n);
  symbol-dump (dump_file);
- fprintf (dump_file, To group: %s\n, IDENTIFIER_POINTER (group));
+ fprintf (dump_file, To group: %s\n, IDENTIFIER_POINTER 
(*group));
}
  symbol-call_for_symbol_and_aliases (set_comdat_group,
-*comdat_head_map.get (group),
+*comdat_head_map.get (*group),
 true);
}
 }
diff --git a/gcc/testsuite/g++.dg/pr61324.C b/gcc/testsuite/g++.dg/pr61324.C
new file mode 100644
index 000..6102574
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr61324.C
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-options -O -fkeep-inline-functions -fno-use-cxa-atexit }
+void foo ();
+
+struct S
+{
+  ~S ()
+  {
+foo ();
+  }
+};
+
+S s;
-- 
2.1.3



Re: [patch fortran/44054] handle %L using the common diagnostics machinery

2014-11-23 Thread Tobias Burnus

Manuel López-Ibáñez wrote:

Exactly what the subject says. I'm not sure if this is appropriate for
stage3, I'll leave that to the Fortran maintainers.

Bootstrapped  regression tested on x86_64-linux-gnu.


Looks good to me - and is a rather simple patch.
Thanks!

Tobias


gcc/fortran/ChangeLog:

2014-11-23  Manuel López-Ibáñez  m...@gcc.gnu.org

 PR fortran/44054
 * decl.c (gfc_verify_c_interop_param): Use gfc_error_now_2.
 (gfc_set_constant_character_len): Use gfc_warning_now_2.
 * resolve.c (resolve_ordinary_assign): Likewise.
 * gfortran.h (warn_character_truncation): Do not declare here.
 * error.c (gfc_format_decoder): Handle %L.
 * lang.opt (Wcharacter-truncation): Add Var and LangEnabledBy.
 * options.c (gfc_init_options): Do not handle
 warn_character_truncation explicitly.
 (set_Wall): Likewise.
 (gfc_handle_option): Likewise.


[Patch, Fortran] Remove gfc_fatal_error_1

2014-11-23 Thread Tobias Burnus

This patch depends on Manuel's %L patch.

It converts the remaining fatal error calls to the common diagnostic 
infrastructure and retires (removes) the old gfc_fatal_error_1.


I will build and regtest it after Manuel's commit.
OK, when it succeeds?

Tobias
2014-11-23  Tobias Burnus  bur...@net-b.de

	* error.c (gfc_fatal_error_1): Remove.
	* gfortran.h (gfc_fatal_error_1): Remove.
	* check.c (check_co_collective): Change gfc_fatal_error_1 to
	gfc_fatal_error.
	* match.c (gfc_match_name): Ditto.
	* trans-array.c (gfc_conv_array_initializer): Ditto.
	* trans-stmt.c (gfc_trans_sync): Ditto.

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 034b329..8da59d5 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -1482,8 +1482,8 @@ check_co_collective (gfc_expr *a, gfc_expr *image_idx, gfc_expr *stat,
 
   if (gfc_option.coarray == GFC_FCOARRAY_NONE)
 {
-  gfc_fatal_error_1 (Coarrays disabled at %L, use -fcoarray= to enable,
-			 a-where);
+  gfc_fatal_error (Coarrays disabled at %L, use %-fcoarray=% to enable,
+		   a-where);
   return false;
 }
 
diff --git a/gcc/fortran/error.c b/gcc/fortran/error.c
index 3a508fa..2378a4b 100644
--- a/gcc/fortran/error.c
+++ b/gcc/fortran/error.c
@@ -1141,7 +1141,6 @@ gfc_error_now_2 (const char *gmsgid, ...)
 
 
 /* Fatal error, never returns.  */
-/* This function uses the common diagnostics, but does not support %L, yet.  */
 
 void
 gfc_fatal_error (const char *gmsgid, ...)
@@ -1265,24 +1264,6 @@ gfc_error_now (const char *gmsgid, ...)
 }
 
 
-/* Fatal error, never returns.  */
-/* Use gfc_fatal_error instead, unless gmsgid contains a %L.  */
-
-void
-gfc_fatal_error_1 (const char *gmsgid, ...)
-{
-  va_list argp;
-
-  buffer_flag = 0;
-
-  va_start (argp, gmsgid);
-  error_print (_(Fatal Error:), _(gmsgid), argp);
-  va_end (argp);
-
-  exit (FATAL_EXIT_CODE);
-}
-
-
 /* This shouldn't happen... but sometimes does.  */
 
 void
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 1ee7dd4..e6effba 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2706,7 +2706,6 @@ void gfc_warning_check (void);
 void gfc_error (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
 void gfc_error_now (const char *, ...) ATTRIBUTE_GCC_GFC(1,2);
 void gfc_error_now_2 (const char *gmsgid, ...) ATTRIBUTE_GCC_GFC(1,2);
-void gfc_fatal_error_1 (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2);
 void gfc_fatal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2);
 void gfc_internal_error (const char *, ...) ATTRIBUTE_NORETURN ATTRIBUTE_GCC_GFC(1,2);
 void gfc_clear_error (void);
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index a03b5f1..a157fe7 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -557,8 +557,8 @@ gfc_match_name (char *buffer)
 
   if (c == '$'  !gfc_option.flag_dollar_ok)
 {
-  gfc_fatal_error_1 (Invalid character '$' at %L. Use -fdollar-ok to allow
-			  it as an extension, old_loc);
+  gfc_fatal_error (Invalid character %$% at %L. Use %-fdollar-ok% to 
+		   allow it as an extension, old_loc);
   return MATCH_ERROR;
 }
 
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index 4e5fd68..218d274 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -5425,11 +5425,12 @@ gfc_conv_array_initializer (tree type, gfc_expr * expr)
 {
   /* Problems occur when we get something like
  integer :: a(lots) = (/(i, i=1, lots)/)  */
-  gfc_fatal_error_1 (The number of elements in the array 
- constructor at %L requires an increase of 
- the allowed %d upper limit. See 
- -fmax-array-constructor option, expr-where,
- gfc_option.flag_max_array_constructor);
+  gfc_fatal_error (The number of elements in the array 
+			   constructor at %L requires an increase of 
+			   the allowed %d upper limit. See 
+			   %-fmax-array-constructor% option,
+			   expr-where,
+			   gfc_option.flag_max_array_constructor);
 	  return NULL_TREE;
 	}
   if (mpz_cmp_si (c-offset, 0) != 0)
diff --git a/gcc/fortran/trans-stmt.c b/gcc/fortran/trans-stmt.c
index a95809c..d17b075 100644
--- a/gcc/fortran/trans-stmt.c
+++ b/gcc/fortran/trans-stmt.c
@@ -865,9 +865,9 @@ gfc_trans_sync (gfc_code *code, gfc_exec_op type)
 	{
 	  /* FIXME.  */
 	  if (code-expr1-ts.kind != gfc_c_int_kind)
-	gfc_fatal_error_1 (Sorry, only support for integer kind %d 
-			   implemented for image-set at %L,
-			   gfc_c_int_kind, code-expr1-where);
+	gfc_fatal_error (Sorry, only support for integer kind %d 
+			 implemented for image-set at %L,
+			 gfc_c_int_kind, code-expr1-where);
 
 	  gfc_conv_array_parameter (se, code-expr1, true, NULL, NULL, len);
 	  images = se.expr;


Re: [Patch, option handling] optc-gen.awk - support || in EnabledBy()

2014-11-23 Thread Tobias Burnus

Manuel López-Ibáñez wrote:

For what is worth, the patch looks good to me, except that the form
EnabledBy(@var{opt} || @var{opt2} needs documentation in
doc/options.texi.

Done.


Perhaps it could be more condensed as (untested!):

Seems to work - hence: Done.


A version handling LangEnabledBy(Lang, Wx || Wy) should be fairly
similar and probably even more useful, if you wish to fix also that.

Done.


If I recall correctly, there are several -W* flags in common.opt and
c-family/c.opt that benefit from this cleanup (Wpointer-sign being
one). It would be nice to convert them to the new format together with
the patch.


I did so. Remarks:

* Wnonnull cannot be converted due to the =1 condition:
LangEnabledBy(C ObjC C++ ObjC++,Wformat=,warn_format = 1,0)
LangEnabledBy(C ObjC C++ ObjC++,Wall)

* Wsign-compare has:
LangEnabledBy(C++ ObjC++,Wall)
EnabledBy(Wextra)
Hence, -Wextra is enabled for all languages and not only C languages. Is 
this intended? Combining would still not be possible as only for C++ 
languages it is enabled by -Wall.


* Wmain: Similarly, -Wall is only for C/ObjC while -Wpedantic is also 
for C++/ObjC++.


Thus, I didn't touch those.


Build on x86-64-gnu-linux with checking that the resulting options.c 
remains the same.

OK for the trunk?

Tobias
2014-11-23  Tobias Burnus  bur...@net-b.de
	Manuel López-Ibáñez  m...@gcc.gnu.org

gcc/c-family/
	* c.opt (Wdelete-non-virtual-dtor, Wenum-compare, Wnarrowing,
	Wpointer-sign, Wvariadic-macros): Combine duplicated warning
	lines into a single one using || for LangEnabledBy.
gcc/
	* opt-functions.awk (lang_enabled_by): Support || for
	enabled-by.
	* optc-gen.awk: Ditto.
	* doc/options.texi (LangEnabledBy, EnabledBy): Document the
	|| syntax.

fortran/
	* lang.opt (Wtabs): Combine duplicated item into a single
	one using || for LangEnabledBy.

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 85dcb98..b9f7c65 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -372,13 +372,9 @@ C++ ObjC++ Var(warn_delete_incomplete) Init(1) Warning
 Warn when deleting a pointer to incomplete type
 
 Wdelete-non-virtual-dtor
-C++ ObjC++ Var(warn_delnonvdtor) Warning LangEnabledBy(C++ ObjC++,Wall)
+C++ ObjC++ Var(warn_delnonvdtor) Warning LangEnabledBy(C++ ObjC++,Wall || Weffc++)
 Warn about deleting polymorphic objects with non-virtual destructors
 
-Wdelete-non-virtual-dtor
-LangEnabledBy(C++ ObjC++,Weffc++)
-;
-
 Wdeprecated
 C C++ ObjC ObjC++ CPP(cpp_warn_deprecated) CppReason(CPP_W_DEPRECATED) Var(warn_deprecated) Init(1) Warning
 Warn if a deprecated compiler feature, class, method, or field is used
@@ -408,13 +404,9 @@ C ObjC C++ ObjC++ CPP(warn_endif_labels) CppReason(CPP_W_ENDIF_LABELS) Var(cpp_w
 Warn about stray tokens after #elif and #endif
 
 Wenum-compare
-C ObjC C++ ObjC++ Var(warn_enum_compare) Init(-1) Warning LangEnabledBy(C ObjC,Wall)
+C ObjC C++ ObjC++ Var(warn_enum_compare) Init(-1) Warning LangEnabledBy(C ObjC,Wall || Wc++-compat)
 Warn about comparison of different enum types
 
-Wenum-compare
-LangEnabledBy(C ObjC,Wc++-compat)
-;
-
 Werror
 C ObjC C++ ObjC++
 ; Documented in common.opt
@@ -614,13 +606,9 @@ C ObjC C++ ObjC++ CPP(warn_multichar) CppReason(CPP_W_MULTICHAR) Var(cpp_warn_mu
 Warn about use of multi-character character constants
 
 Wnarrowing
-C ObjC C++ ObjC++ Warning Var(warn_narrowing) Init(-1) LangEnabledBy(C++ ObjC++,Wall)
+C ObjC C++ ObjC++ Warning Var(warn_narrowing) Init(-1) LangEnabledBy(C++ ObjC++,Wall || Wc++0x-compat)
 Warn about narrowing conversions within { } that are ill-formed in C++11
 
-Wnarrowing
-C ObjC C++ ObjC++ LangEnabledBy(C++ ObjC++,Wc++0x-compat)
-;
-
 Wnested-externs
 C ObjC Var(warn_nested_externs) Warning
 Warn about \extern\ declarations not at file scope
@@ -721,13 +709,9 @@ C ObjC C++ ObjC++ Var(warn_pointer_arith) Warning LangEnabledBy(C ObjC C++ ObjC+
 Warn about function pointer arithmetic
 
 Wpointer-sign
-C ObjC Var(warn_pointer_sign) Warning LangEnabledBy(C ObjC,Wall)
+C ObjC Var(warn_pointer_sign) Warning LangEnabledBy(C ObjC,Wall || Wpedantic)
 Warn when a pointer differs in signedness in an assignment
 
-Wpointer-sign
-C ObjC LangEnabledBy(C ObjC,Wpedantic)
-;
-
 Wpointer-to-int-cast
 C ObjC Var(warn_pointer_to_int_cast) Init(1) Warning
 Warn when a pointer is cast to an integer of a different size
@@ -877,13 +861,9 @@ C ObjC C++ ObjC++ Var(warn_unused_result) Init(1) Warning
 Warn if a caller of a function, marked with attribute warn_unused_result, does not use its return value
 
 Wvariadic-macros
-C ObjC C++ ObjC++ CPP(warn_variadic_macros) CppReason(CPP_W_VARIADIC_MACROS) Var(cpp_warn_variadic_macros) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic)
+C ObjC C++ ObjC++ CPP(warn_variadic_macros) CppReason(CPP_W_VARIADIC_MACROS) Var(cpp_warn_variadic_macros) Init(0) Warning LangEnabledBy(C ObjC C++ ObjC++,Wpedantic || Wtraditional)
 Warn about using variadic macros
 
-Wvariadic-macros
-LangEnabledBy(C ObjC C++ ObjC++,Wtraditional)
-;
-
 Wvarargs
 C ObjC 

[Fortran, Patch, committed] Fix coloring of : in diagnostic messages

2014-11-23 Thread Tobias Burnus
In C etc., the colon is colored the same way as the preceeding word 
(warning:), in Fortran, it wasn't.


Fixed as obvious; committed as Rev. 217986.

Tobias
Index: gcc/fortran/ChangeLog
===
--- gcc/fortran/ChangeLog	(Revision 217985)
+++ gcc/fortran/ChangeLog	(Arbeitskopie)
@@ -1,4 +1,9 @@
 2014-11-23  Tobias Burnus  bur...@net-b.de
+
+	* error.c (gfc_diagnostic_build_prefix): Correct coloring
+	of the colon of the prefix.
+
+2014-11-23  Tobias Burnus  bur...@net-b.de
 	Manuel López-Ibáñez  m...@gcc.gnu.org
 
 	* gfortran.h (gfc_option_t): Remove warn_tabs.
Index: gcc/fortran/error.c
===
--- gcc/fortran/error.c	(Revision 217985)
+++ gcc/fortran/error.c	(Arbeitskopie)
@@ -1021,7 +1021,7 @@ gfc_diagnostic_build_prefix (diagnostic_context *c
 diagnostic_kind_color[diagnostic-kind]);
   text_ce = colorize_stop (pp_show_color (pp));
 }
-  return build_message_string (%s%s%s: , text_cs, text, text_ce);
+  return build_message_string (%s%s:%s , text_cs, text, text_ce);
 }
 
 /* Return a malloc'd string describing a location.  The caller is


Re: [PATCH] pr63856 - test case

2014-11-23 Thread Trevor Saunders
On Sun, Nov 23, 2014 at 07:58:30PM +0100, Jakub Jelinek wrote:
 On Sun, Nov 23, 2014 at 01:32:27PM -0500, tsaund...@mozilla.com wrote:
  bug was already fixed, so just add the test case.
  
  tested this only passes with r217909 where it is fixed, ok?
  
  Trev
  
  
  diff --git a/gcc/testsuite/gcc.dg/pr63856.c b/gcc/testsuite/gcc.dg/pr63856.c
  new file mode 100644
  index 000..8fb65c6
  --- /dev/null
  +++ b/gcc/testsuite/gcc.dg/pr63856.c
  @@ -0,0 +1,14 @@
  +/* { dg-do compile } */
  +/* { dg-options -O2 -fPIC } */
  +typedef int v2si __attribute__ ((vector_size (8)));
  +typedef short v4hi __attribute__ ((vector_size (8)));
  +
  +int __attribute__ ((noinline, noclone)) f (v2si A, int N)
 
 Vector arguments or return values often result in -Wpsabi warnings,
 so you certainly want -Wno-psabi in dg-options.
 On the other side, -fPIC should be only used for { target pic },
 so better put that into dg-additional-options.

ok, thanks how about this then?

Trev

 
  +{
  +  return ((v4hi) A)[N];
  +}
  +
  +int __attribute__ ((noinline, noclone)) g (v2si A, int N)
  +{
  +  return ((v4hi) A)[N];
  +}
  -- 
  2.1.3
 
   Jakub
From 1b9dc2c209614d598658579ad6faba112c64ca0f Mon Sep 17 00:00:00 2001
From: Trevor Saunders tsaund...@mozilla.com
Date: Sun, 23 Nov 2014 01:11:22 -0500
Subject: [PATCH] pr63856 - test case

---
 gcc/testsuite/gcc.dg/pr63856.c | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/pr63856.c

diff --git a/gcc/testsuite/gcc.dg/pr63856.c b/gcc/testsuite/gcc.dg/pr63856.c
new file mode 100644
index 000..6a987e2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr63856.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options -O2 -Wno-psabi } */
+/* { dg-additional-options -fPIC { target fpic } } */
+typedef int v2si __attribute__ ((vector_size (8)));
+typedef short v4hi __attribute__ ((vector_size (8)));
+
+int __attribute__ ((noinline, noclone)) f (v2si A, int N)
+{
+  return ((v4hi) A)[N];
+}
+
+int __attribute__ ((noinline, noclone)) g (v2si A, int N)
+{
+  return ((v4hi) A)[N];
+}
-- 
2.1.3



Re: [PATCH] pr63856 - test case

2014-11-23 Thread Jakub Jelinek
On Sun, Nov 23, 2014 at 03:42:43PM -0500, Trevor Saunders wrote:
  Vector arguments or return values often result in -Wpsabi warnings,
  so you certainly want -Wno-psabi in dg-options.
  On the other side, -fPIC should be only used for { target pic },
  so better put that into dg-additional-options.
 
 ok, thanks how about this then?

The __attribute__ ((noinline, noclone)) is useless, though not harmful,
sorry for missing that.

Ok for trunk either way.

 --- /dev/null
 +++ b/gcc/testsuite/gcc.dg/pr63856.c
 @@ -0,0 +1,15 @@
 +/* { dg-do compile } */
 +/* { dg-options -O2 -Wno-psabi } */
 +/* { dg-additional-options -fPIC { target fpic } } */
 +typedef int v2si __attribute__ ((vector_size (8)));
 +typedef short v4hi __attribute__ ((vector_size (8)));
 +
 +int __attribute__ ((noinline, noclone)) f (v2si A, int N)
 +{
 +  return ((v4hi) A)[N];
 +}
 +
 +int __attribute__ ((noinline, noclone)) g (v2si A, int N)
 +{
 +  return ((v4hi) A)[N];
 +}
 -- 
 2.1.3
 


Jakub


Re: [Patch, Fortran] Remove gfc_fatal_error_1

2014-11-23 Thread FX
 I will build and regtest it after Manuel's commit.
 OK, when it succeeds?

OK indeed.


[SH][committed] Handle complex edges in sh_optimize_sett_clrt

2014-11-23 Thread Oleg Endo
Hi,

As mentioned in the PR, a case has popped up which blew the
sh_optimize_sett_clrt pass away.  The quick fix was to bail out on
handle complex edges.  Tested with make all-gcc, running the sh.exp
tests.  Committed to trunk as r217987 and to 4.9 branch as r217989.

Cheers,
Oleg

gcc/ChangeLog:
PR target/53976
* config/sh/sh_optimize_sett_clrt.cc
(sh_optimize_sett_clrt::find_last_ccreg_values): Return bool instead
of void.  Abort at complex edges.
(sh_optimize_sett_clrt::execute): Do nothing if find_last_ccreg_values
returned false.
Index: gcc/config/sh/sh_optimize_sett_clrt.cc
===
--- gcc/config/sh/sh_optimize_sett_clrt.cc	(revision 217967)
+++ gcc/config/sh/sh_optimize_sett_clrt.cc	(working copy)
@@ -126,7 +126,7 @@
   // Given a start insn and its basic block, recursively determine all
   // possible ccreg values in all basic block paths that can lead to the
   // start insn.
-  void find_last_ccreg_values (rtx_insn *start_insn, basic_block bb,
+  bool find_last_ccreg_values (rtx_insn *start_insn, basic_block bb,
 			   std::vectorccreg_value values_out,
 			   std::vectorbasic_block prev_visited_bb) const;
 
@@ -239,8 +239,8 @@
 
 	ccreg_values.clear ();
 	visited_bbs.clear ();
-	find_last_ccreg_values (PREV_INSN (i), bb, ccreg_values,
-visited_bbs);
+	bool ok = find_last_ccreg_values (PREV_INSN (i), bb, ccreg_values,
+	  visited_bbs);
 
 	log_msg (number of ccreg values collected: %u\n,
 		 (unsigned int)ccreg_values.size ());
@@ -248,7 +248,7 @@
 	// If all the collected values are equal and are equal to the
 	// constant value of the setcc insn, the setcc insn can be
 	// removed.
-	if (all_ccreg_values_equal (ccreg_values)
+	if (ok  all_ccreg_values_equal (ccreg_values)
 		 rtx_equal_p (ccreg_values.front ().value, setcc_val))
 	  {
 		log_msg (all values are );
@@ -322,7 +322,7 @@
 gcc_unreachable ();
 }
 
-void
+bool
 sh_optimize_sett_clrt
 ::find_last_ccreg_values (rtx_insn *start_insn, basic_block bb,
 			  std::vectorccreg_value values_out,
@@ -361,7 +361,7 @@
 	  log_msg (\n);
 
 	  values_out.push_back (v);
-	  return;
+	  return true;
 	}
 
   if (any_condjump_p (i)  onlyjump_p (i)  !prev_visited_bb.empty ())
@@ -385,7 +385,7 @@
 	  log_msg (\n);
 
 	  values_out.push_back (v);
-	  return;
+	  return true;
 	}
 }
 
@@ -406,10 +406,14 @@
   for (edge_iterator ei = ei_start (bb-preds); !ei_end_p (ei);
 	   ei_next (ei))
 	{
+	  if (ei_edge (ei)-flags  EDGE_COMPLEX)
+	log_return (false, aborting due to complex edge\n);
+
 	  basic_block pred_bb = ei_edge (ei)-src;
 	  pred_bb_count += 1;
-	  find_last_ccreg_values (BB_END (pred_bb), pred_bb, values_out,
-  prev_visited_bb);
+	  if (!find_last_ccreg_values (BB_END (pred_bb), pred_bb, values_out,
+   prev_visited_bb))
+	return false;
 	}
 
   prev_visited_bb.pop_back ();
@@ -432,6 +436,8 @@
 
 values_out.push_back (v);
   }
+
+  return true;
 }
 
 bool
Index: gcc/config/sh/sh_optimize_sett_clrt.cc
===
--- gcc/config/sh/sh_optimize_sett_clrt.cc	(revision 217987)
+++ gcc/config/sh/sh_optimize_sett_clrt.cc	(working copy)
@@ -111,7 +111,7 @@
   // Given a start insn and its basic block, recursively determine all
   // possible ccreg values in all basic block paths that can lead to the
   // start insn.
-  void find_last_ccreg_values (rtx start_insn, basic_block bb,
+  bool find_last_ccreg_values (rtx start_insn, basic_block bb,
 			   std::vectorccreg_value values_out,
 			   std::vectorbasic_block prev_visited_bb) const;
 
@@ -226,8 +226,8 @@
 
 	ccreg_values.clear ();
 	visited_bbs.clear ();
-	find_last_ccreg_values (PREV_INSN (i), bb, ccreg_values,
-visited_bbs);
+	bool ok = find_last_ccreg_values (PREV_INSN (i), bb, ccreg_values,
+	  visited_bbs);
 
 	log_msg (number of ccreg values collected: %u\n,
 		 (unsigned int)ccreg_values.size ());
@@ -235,7 +235,7 @@
 	// If all the collected values are equal and are equal to the
 	// constant value of the setcc insn, the setcc insn can be
 	// removed.
-	if (all_ccreg_values_equal (ccreg_values)
+	if (ok  all_ccreg_values_equal (ccreg_values)
 		 rtx_equal_p (ccreg_values.front ().value, setcc_val))
 	  {
 		log_msg (all values are );
@@ -309,7 +309,7 @@
 gcc_unreachable ();
 }
 
-void
+bool
 sh_optimize_sett_clrt
 ::find_last_ccreg_values (rtx start_insn, basic_block bb,
 			  std::vectorccreg_value values_out,
@@ -348,7 +348,7 @@
 	  log_msg (\n);
 
 	  values_out.push_back (v);
-	  return;
+	  return true;
 	}
 
   if (any_condjump_p (i)  onlyjump_p (i)  !prev_visited_bb.empty ())
@@ -372,7 +372,7 @@
 	  log_msg (\n);
 
 	  values_out.push_back (v);
-	  return;
+	  return true;
 	}
 }
 
@@ -393,10 +393,14 @@
   for 

[Patch, Fortran, committed] invoke.texi - updated -Wtabs description

2014-11-23 Thread Tobias Burnus
Fix -Wtabs description, matching current implementation. Committed as 
Rev. 217990.


Tobias
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 12ec7e2..41169a8 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,5 +1,10 @@
 2014-11-23  Tobias Burnus  bur...@net-b.de
 
+	* invoke.texi (-Wtabs): Swap -Wtabs/-Wno-tabs now that
+	-Wtabs enables the warning.
+
+2014-11-23  Tobias Burnus  bur...@net-b.de
+
 	* error.c (gfc_diagnostic_build_prefix): Correct coloring
 	of the colon of the prefix.
 
diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi
index 18d0c9e..69c3655 100644
--- a/gcc/fortran/invoke.texi
+++ b/gcc/fortran/invoke.texi
@@ -875,10 +875,10 @@ A @code{CHARACTER} variable is declared with negative length.
 @cindex tabulators
 By default, tabs are accepted as whitespace, but tabs are not members
 of the Fortran Character Set.  For continuation lines, a tab followed
-by a digit between 1 and 9 is supported.  @option{-Wno-tabs} will cause
-a warning to be issued if a tab is encountered. Note, @option{-Wno-tabs}
+by a digit between 1 and 9 is supported.  @option{-Wtabs} will cause
+a warning to be issued if a tab is encountered. Note, @option{-Wtabs}
 is active for @option{-pedantic}, @option{-std=f95}, @option{-std=f2003},
-@option{-std=f2008} and @option{-Wall}.
+@option{-std=f2008}, @option{-std=f2008ts} and @option{-Wall}.
 
 @item -Wunderflow
 @opindex @code{Wunderflow}


Re: [Patch] Improving jump-thread pass for PR 54742

2014-11-23 Thread Sebastian Pop
Jeff Law wrote:
 PS: I have run some perf analysis with the patch:
 - on a bootstrap of GCC I see 3209 FSM jump threads
 - libpng and libjpeg contain FSM jump threads, the perf increase is in the 1%
(measured on simulators and reduced data sets)
 - coremark gets jump threaded (as expected)
 - I'm setting up the llvm test-suite and I will report perf differences
 So that's *far* more jump threads than I would expect this to find
 in a bootstrap of GCC -- like 3 orders of magnitude more than I'd
 expect to find.

The second patch attached limits the search for FSM jump threads to loops.  With
that patch, we are now down to 470 jump threads in an x86_64-linux bootstrap
(and 424 jump threads on powerpc64-linux bootstrap.)

 I haven't dug deep, but the first level analysis is not encouraging.
 
 Basically I used the trunk compiler with and without your patch to
 build gcc-4.7.3's cc1 (4.7.3 simply because that's what I last used
 this testing framework).  So that gives me two cc1s that I then use
 to compile a bunch of .i files under valgrind's (cachegrind)
 control.
 
 valgrind --tool=cachegrind --cache-sim=no --branch-sim=yes ..
 
 That gives me two hunks of data for each input file I test.
 Specifically I get the dynamic number of instructions and the
 dynamic number of branches executed.
 
 For jump threading those values correspond directly to the effect
 we're looking for -- a reduction in dynamic conditional jumps and a
 reduction in dynamic instructions executed.  Typically the change in
 dynamic instructions executed is 2-3X the change in dynamic
 conditional jumps -- which makes sense as removing the conditional
 jump usually means we remove a comparison and possibly some setup
 code as well.
 
 Consistently with your patch those values get worse.   Across the
 entire set of .i files I get
 
 For the trunk:
 
 instructions:1339016494968
 branches: 243568982489
 
 With your patch:
 
 instructions:1339739533291
 branches: 243806615986
 
 
 So that's 723038323 more instructions and 237633497 more branches
 after installing your patch.  While we're looking a just under .1%
 regression in dynamic branches, that's a terrible result for this
 work.

One of the reasons I think we see more branches is that in sese region copying 
we
do not use the knowledge of the value of the condition for the last branch in a
jump-thread path: we rely on other propagation passes to remove the branch.  The
last attached patch adds:

  /* Remove the last branch in the jump thread path.  */
  remove_ctrl_stmt_and_useless_edges (region_copy[n_region - 1], exit-dest);

Please let me know if the attached patches are producing better results on gcc.

I rebased the original patch on trunk and all patches bootstrapped together on
x86_64-linux and powerpc64-linux.

Thanks,
Sebastian
From 120d5490598b1a09a06c04796b4fda46be7fd7db Mon Sep 17 00:00:00 2001
From: Sebastian Pop s@samsung.com
Date: Fri, 26 Sep 2014 14:54:20 -0500
Subject: [PATCH 1/4] extend jump thread for finite state automata PR 54742

Adapted from a patch from James Greenhalgh.

	* params.def (max-fsm-thread-path-insns, max-fsm-thread-length,
	max-fsm-thread-paths): New.

	* doc/invoke.texi (max-fsm-thread-path-insns, max-fsm-thread-length,
	max-fsm-thread-paths): Documented.

	* testsuite/gcc.dg/tree-ssa/ssa-dom-thread-6.c: New.

	* tree-cfg.c (gimple_duplicate_sese_region): Save and restore loop
	header and latch.

	* tree-ssa-threadedge.c (simplify_control_stmt_condition): Restore the
	original value of cond when simplification fails.
	(fsm_find_thread_path): New.
	(fsm_find_control_statement_thread_paths): New.
	(fsm_thread_through_normal_block): Call find_control_statement_thread_paths.

	* tree-ssa-threadupdate.c (dump_jump_thread_path): Pretty print
	EDGE_START_FSM_THREAD.
	(thread_through_all_blocks): Generate code for EDGE_START_FSM_THREAD edges
	calling gimple_duplicate_sese_region.

	* tree-ssa-threadupdate.h (jump_thread_edge_type): Add EDGE_START_FSM_THREAD.
---
 gcc/doc/invoke.texi  |  12 ++
 gcc/params.def   |  15 ++
 gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-6.c |  38 +
 gcc/tree-cfg.c   |  26 ++-
 gcc/tree-ssa-threadedge.c| 203 ++-
 gcc/tree-ssa-threadupdate.c  |  52 +-
 gcc/tree-ssa-threadupdate.h  |   1 +
 7 files changed, 342 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-thread-6.c

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 89edddb..074183f 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -10624,6 +10624,18 @@ large and significantly increase compile time at optimization level
 @option{-O1} and higher.  This parameter is a maximum nubmer of statements
 in a single generated constructor.  Default value is 5000.
 
+@item max-fsm-thread-path-insns
+Maximum number of instructions 

PR 13631 Problems in messages

2014-11-23 Thread François Dumont

Hello

As we are at doing some evolution in the ABI I would like to take 
the opportunity to merge branch libstdcxx_so_7-2. The first fix was 
about a messages facet issue. So here is the version for the trunk which 
is the one from the branch plus management of the charset part. This way 
messageswchar_t works too.


There are still some uncovered points in this patch:
- I had to make codecvt _M_c_locale_codecvt public to access it from the 
messages facet code. How do you want to handle it properly ? A friend 
function to access it or do I make messages facet friend ?
- I haven't use the ABI tag yet. I know that there is a plan to tag 
locale facets, will it work for what I am doing ?


Note that I could use std::tuple instead of combination of 
std::pair and std::unique_ptr instead of wchar_buffer if we were 
building it in C++11 mode. Is it possible ?


François

Index: config/locale/gnu/messages_members.cc
===
--- config/locale/gnu/messages_members.cc	(revision 217816)
+++ config/locale/gnu/messages_members.cc	(working copy)
@@ -31,54 +31,281 @@
 #include locale
 #include bits/c++locale_internal.h
 
+#include algorithm
+#include utility
+#include ext/concurrence.h
+
+namespace
+{
+  using namespace std;
+
+  typedef messages_base::catalog catalog;
+  typedef paircatalog, pairconst char*, locale  _MapEntry;
+  typedef pairbool, pairconst char*, const locale*  _SearchRes;
+
+  struct Comp
+  {
+bool operator()(catalog __cat, const _MapEntry __entry) const
+{ return __cat  __entry.first; }
+
+bool operator()(const _MapEntry __entry, catalog __cat) const
+{ return __entry.first  __cat; }
+  };
+
+  class Catalogs
+  {
+  public:
+Catalogs() : _M_counter(0), _M_nb_entry(0) { }
+
+~Catalogs()
+{
+  if (_M_nb_entry)
+	{
+	  for (size_t i = 0; i != _M_nb_entry; ++i)
+	delete[] _M_map[i].second.first;
+	  delete[] _M_map;
+	}
+}
+
+catalog
+_M_add(const string __s, locale __l)
+{
+  __gnu_cxx::__scoped_lock lock(_M_mutex);
+
+  _MapEntry* __new_map = new _MapEntry[_M_nb_entry + 1];
+  __try
+	{
+	  copy(_M_map, _M_map + _M_nb_entry, __new_map);
+	  char* __s_copy = new char[__s.size() + 1];
+	  __s.copy(__s_copy, __s.size());
+	  __s_copy[__s.size()] = 0;
+	  __new_map[_M_nb_entry]
+	= make_pair(_M_counter, make_pair(__s_copy, __l));
+	}
+  __catch(...)
+	{
+	  delete[] __new_map;
+	  __throw_exception_again;
+	}
+
+  // The counter is not likely to roll unless catalogs keep on being
+  // open/close which is consider as an application mistake for the moment.
+  catalog __cat = _M_counter++;
+  delete[] _M_map;
+  _M_map = __new_map;
+  ++_M_nb_entry;
+
+  return __cat;
+}
+
+void
+_M_erase(catalog __c)
+{
+  __gnu_cxx::__scoped_lock lock(_M_mutex);
+
+  _MapEntry* __entry =
+	lower_bound(_M_map, _M_map + _M_nb_entry, __c, Comp());
+  if (__entry == _M_map + _M_nb_entry || __entry-first != __c)
+	return;
+  
+  _MapEntry* __new_map =
+	_M_nb_entry  1 ? new _MapEntry[_M_nb_entry - 1] : 0;
+  copy(__entry + 1, _M_map + _M_nb_entry,
+	   copy(_M_map, __entry, __new_map));
+
+  delete[] __entry-second.first;
+  delete[] _M_map;
+  _M_map = __new_map;
+  --_M_nb_entry;
+}
+
+_SearchRes
+_M_get(catalog __c) const
+{
+  __gnu_cxx::__scoped_lock lock(_M_mutex);
+
+  const _MapEntry* __entry =
+	lower_bound(_M_map, _M_map + _M_nb_entry, __c, Comp());
+  if (__entry != _M_map + _M_nb_entry  __entry-first == __c)
+	return _SearchRes(true,
+			  make_pair(__entry-second.first, (__entry-second.second)));
+  return _SearchRes(false, make_pair((const char*)0, (locale*)0));
+}
+
+  private:
+mutable __gnu_cxx::__mutex _M_mutex;
+catalog _M_counter;
+_MapEntry* _M_map;
+size_t _M_nb_entry;
+  };
+
+  Catalogs
+  get_catalogs()
+  {
+static Catalogs __catalogs;
+return __catalogs;
+  }
+
+  struct wchar_buffer
+  {
+wchar_buffer(std::size_t __size)
+  : _M_buffer(new wchar_t[__size])
+{ }
+
+~wchar_buffer()
+{ delete[] _M_buffer; }
+
+wchar_t*
+get()
+{ return _M_buffer; }
+
+  private:
+wchar_t* _M_buffer;
+  };
+
+  const char*
+  get_glibc_msg(__c_locale __attribute__((unused)) __locale_messages,
+		const char* __domainname,
+		const char* __dfault)
+  {
+#if __GLIBC__  2 || (__GLIBC__ == 2  __GLIBC_MINOR__  2)
+std::__c_locale __old = __uselocale(__locale_messages);
+const char* __msg =
+  const_castconst char*(dgettext(__domainname, __dfault));
+__uselocale(__old);
+#else
+char* __old = setlocale(LC_ALL, 0);
+const size_t __len = strlen(__old) + 1;
+char* __sav = new char[__len];
+memcpy(__sav, __old, __len);
+setlocale(LC_ALL, _M_name_messages);
+const char* __msg = dgettext(__domainname, __dfault);
+setlocale(LC_ALL, __sav);
+delete [] __sav;
+#endif

Re: [Patch, Fortran] Remove gfc_fatal_error_1

2014-11-23 Thread Manuel López-Ibáñez
On 23 November 2014 at 21:21, Tobias Burnus bur...@net-b.de wrote:
 This patch depends on Manuel's %L patch.

 It converts the remaining fatal error calls to the common diagnostic
 infrastructure and retires (removes) the old gfc_fatal_error_1.

 I will build and regtest it after Manuel's commit.

FYI, committed as revision 217992.

Cheers,

Manuel.


[patch, build] Restore bootstrap in building libcc1 on darwin

2014-11-23 Thread FX
tl;dr: One question to build maintainers, and one patch submitted to toplevel 
configure.ac

---

I’m looked into the issue some more, and am comparing two builds of trunk 
(exact same source), one configured with system compiler (clang) in PATH, the 
other with GCC 4.9.2 in PATH.
At the toplevel configure, the only meaningful difference is that the gcc-based 
build sets stage1_ldflags='-static-libstdc++ -static-libgcc' while the 
clang-based has stage1_ldflags='' (clang doesn’t recognized -static-libstdc++).

This is included into the toplevel Makefile as STAGE1_LDFLAGS (the comment 
appropriately says Linker flags to use on the host, for stage1 or when not 
bootstrapping”).
Those are exported by HOST_EXPORTS, which is are then used by configure-libcc1, 
all-libcc1, etc. Thus, we end up using STAGE1_LDFLAGS, which correspond to the 
system compiler, instead of the stage3 compiler (as we should).

So, this is “false negative” part of the problem (namely, why we don’t see the 
failure when bootstrapping with clang): we use STAGE1_LDFLAGS in building 
libcc1, and with clang as system compiler we don’t use static linking of the 
C++ library. This part, I don’t know how to fix: it is for the build experts to 
address. It is a real problem: it leads to libcc1.so being linked dynamically 
to libstdc++ and libgcc, instead of statically (as it should).

---

Second part of the question: when the freshly built g++ is used, we need to 
pass the appropriate -B options. As I understand it, the appropriate place for 
that is in the toplevel configure.ac, where we already pass down the respective 
-L options. Indeed, the attached patch restores bootstrap on 
x86_64-apple-darwin14 with gcc as system compiler (and doesn’t break the 
bootstrap with clang as system compiler).

OK to commit?

FX



PS: HJ, the reason only don’t see this on Linux is that only Darwin (AFAIK) 
plays spec tricks with static-libstdc++ (in gcc/config/darwin.h)




libcc1.ChangeLog
Description: Binary data


libcc1.diff
Description: Binary data


Re: PR 13631 Problems in messages

2014-11-23 Thread Jonathan Wakely

On 24/11/14 00:13 +0100, François Dumont wrote:

Hello

   As we are at doing some evolution in the ABI I would like to take 
the opportunity to merge branch libstdcxx_so_7-2. The first fix was 


I don't think we want to merge everything, but it's certainly worth
looking to see if there are some fixes on that branch worth taking.

It would have been better to do during stage 1 though :-\

about a messages facet issue. So here is the version for the trunk 
which is the one from the branch plus management of the charset part. 
This way messageswchar_t works too.


   There are still some uncovered points in this patch:
- I had to make codecvt _M_c_locale_codecvt public to access it from 
the messages facet code. How do you want to handle it properly ? A 
friend function to access it or do I make messages facet friend ?
- I haven't use the ABI tag yet. I know that there is a plan to tag 
locale facets, will it work for what I am doing ?


Unless I'm missing something you're not making any ABI changes to
std::messages, just making the definitiosn of some functions no longer
inline.

   Note that I could use std::tuple instead of combination of 
std::pair and std::unique_ptr instead of wchar_buffer if we were 
building it in C++11 mode. Is it possible ?


Yes, the symlink to the messages_members.cc file would need to be
moved from src/c++98/Makefile.am to src/c++11/Makefile.am


Index: include/bits/locale_facets_nonio.h
===
--- include/bits/locale_facets_nonio.h  (revision 217816)
+++ include/bits/locale_facets_nonio.h  (working copy)
@@ -1842,22 +1842,6 @@
  */
  virtual void
  do_close(catalog) const;
-
-  // Returns a locale and codeset-converted string, given a char* message.
-  char*
-  _M_convert_to_char(const string_type __msg) const
-  {
-   // XXX
-   return reinterpret_castchar*(const_cast_CharT*(__msg.c_str()));
-  }
-
-  // Returns a locale and codeset-converted string, given a char* message.
-  string_type
-  _M_convert_from_char(char*) const
-  {
-   // XXX
-   return string_type();
-  }
 };


Those members are used by the ieee_1003.1-2001 locale.



[PATCH, committed] AIX gcc.dg testsuite patches

2014-11-23 Thread David Edelsohn
This fixes a few more testsuite failures on AIX.  -fcompare-debug does
not work correctly on AIX and some vector tests generate extra
warnings about use of a non-standard ABI.

Bootstrapped on powerpc-ibm-aix7.1.0.0

Thanks, David

* gcc.dg/autopar/pr46799.c: XFAIL on AIX.
* gcc.dg/torture/pr59166.c: XFAIL on AIX.
* gcc.dg/pr63914.c: Ignore non-standard ABI warning.
* gcc.dg/pr63594-[12].c: Ignore non-standard ABI warning.

Index: gcc.dg/autopar/pr46799.c
===
--- gcc.dg/autopar/pr46799.c(revision 217982)
+++ gcc.dg/autopar/pr46799.c(working copy)
@@ -1,7 +1,9 @@
 /* PR debug/46799 */
 /* { dg-do compile } */
 /* { dg-options -O -ftree-parallelize-loops=2 -fno-tree-dce -ftree-pre -fcompa
re-debug } */
+/* { dg-xfail-if compare-debug failure { powerpc-ibm-aix* } { * } {  } }
*/

 int
 foo (int i, int *a)
 {
Index: gcc.dg/pr63594-1.c
===
--- gcc.dg/pr63594-1.c  (revision 217982)
+++ gcc.dg/pr63594-1.c  (working copy)
@@ -2,6 +2,7 @@
 /* { dg-do compile } */
 /* { dg-options -O2 -Wno-psabi } */
 /* { dg-additional-options -mno-mmx { target i?86-*-* x86_64-*-* } } */
+/* { dg-prune-output non-standard ABI extension } */

 #define C1 c
 #define C2 C1, C1
Index: gcc.dg/torture/pr59166.c
===
--- gcc.dg/torture/pr59166.c(revision 217982)
+++ gcc.dg/torture/pr59166.c(working copy)
@@ -1,6 +1,6 @@
 /* PR rtl-optimization/59166 */
 /* { dg-additional-options -fcompare-debug } */
-/* { dg-xfail-if  { powerpc-ibm-aix* } { * } {  } } */
+/* { dg-xfail-if compare-debug failure { powerpc-ibm-aix* } { * } {  } }
*/

 int a, b, c, f, g;

Index: gcc.dg/pr63914.c
===
--- gcc.dg/pr63914.c(revision 217982)
+++ gcc.dg/pr63914.c(working copy)
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options -O2 -ffast-math } */
+/* { dg-prune-output non-standard ABI extension } */

 typedef float __m128 __attribute__ ((__vector_size__ (16)));
 __m128 a, d, e;
Index: gcc.dg/pr63594-2.c
===
--- gcc.dg/pr63594-2.c  (revision 217982)
+++ gcc.dg/pr63594-2.c  (working copy)
@@ -2,6 +2,7 @@
 /* { dg-do run } */
 /* { dg-options -O2 -Wno-psabi } */
 /* { dg-additional-options -mno-mmx { target i?86-*-* x86_64-*-* } } */
+/* { dg-prune-output non-standard ABI extension } */

 #define C1 c
 #define C2 C1, C1


Re: [C++ Patch, trivial?] PR 63905

2014-11-23 Thread Jason Merrill

OK.

Jason


[PATCH, PR c++/58561] dbxout.c and TEMPLATE_TYPE_PARM

2014-11-23 Thread David Edelsohn
The patch for PR c++/58561 fixed DWARF, but did not fix Stabs
debugging.  The follow patch at least stops G++ from ICE'ing for a
return type of auto.  I'm not sure what type of debugging stabs should
generate, if it can represent it.

Thanks, David

PR c++/58561
* dbxout.c: Include stringpool.h
(dbxout_type) [default]: Ignore auto type.

Index: dbxout.c
===
--- dbxout.c(revision 217982)
+++ dbxout.c(working copy)
@@ -103,6 +103,7 @@ along with GCC; see the file COPYING3.  If not see
 #include plugin-api.h
 #include ipa-ref.h
 #include cgraph.h
+#include stringpool.h

 #ifdef XCOFF_DEBUGGING_INFO
 #include xcoffout.h
@@ -2329,6 +2330,17 @@ dbxout_type (tree type, int full)
   break;

 default:
+  /* A C++ function with deduced return type can have a TEMPLATE_TYPE_PARM
+named 'auto' in its type.
+No debug info for TEMPLATE_TYPE_PARM type supported yet.  */
+  if (lang_GNU_CXX ())
+   {
+ tree name = TYPE_IDENTIFIER (type);
+ if (name == get_identifier (auto)
+ || name == get_identifier (decltype(auto)))
+   break;
+   }
+
   gcc_unreachable ();
 }
 }


Re: [PATCH, PR c++/58561] dbxout.c and TEMPLATE_TYPE_PARM

2014-11-23 Thread Jason Merrill

OK.

Jason


RE: [PATCH, ifcvt] Fix PR63917

2014-11-23 Thread Zhenqiang Chen

 -Original Message-
 From: Richard Henderson [mailto:r...@redhat.com]
 Sent: Friday, November 21, 2014 2:27 AM
 To: Zhenqiang Chen; gcc-patches@gcc.gnu.org
 Subject: Re: [PATCH, ifcvt] Fix PR63917
 
 On 11/20/2014 10:48 AM, Zhenqiang Chen wrote:
  +/* Check X clobber CC reg or not.  */
  +
  +static bool
  +clobber_cc_p (rtx x)
  +{
  +  RTX_CODE code = GET_CODE (x);
  +  int i;
  +
  +  if (code == CLOBBER
  +   REG_P (XEXP (x, 0))
  +   (GET_MODE_CLASS (GET_MODE (XEXP (x, 0))) == MODE_CC))
  +return TRUE;
  +  else if (code == PARALLEL)
  +for (i = 0; i  XVECLEN (x, 0); i++)
  +  if (clobber_cc_p (XVECEXP (x, 0, i)))
  +   return TRUE;
  +  return FALSE;
  +}
 
 Why would you need something like this when modified_between_p or one
 of its kin ought to do the job?

Thanks for the comments. Patch is updated to use set_of.

And it is also enhanced to make sure that the new generated insns can not
clobber CC.

Bootstrap and no make check regression on X86-64 and IA32.

OK for trunk?

Thanks!
-Zhenqiang

ChangeLog:
2014-11-24  Zhenqiang Chen  zhenqiang.c...@arm.com

PR rtl-optimization/63917
* ifcvt.c (cc_in_cond): New function.
(end_ifcvt_sequence): Make sure new generated insns do not clobber
CC.
(noce_process_if_block, check_cond_move_block): Check CC references.

testsuite/ChangeLog:
2014-11-24  Zhenqiang Chen  zhenqiang.c...@arm.com

* gcc.dg/pr63917.c: New test.

diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 21f08c2..1acd0ff 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -1016,6 +1016,18 @@ noce_emit_move_insn (rtx x, rtx y)
   0, 0, outmode, y);
 }
 
+/* Return the CC reg if it is used in COND.  */
+
+static rtx
+cc_in_cond (rtx cond)
+{
+  if ((HAVE_cbranchcc4)  cond
+   (GET_MODE_CLASS (GET_MODE (XEXP (cond, 0))) == MODE_CC))
+return XEXP (cond, 0);
+
+  return NULL_RTX;
+}
+
 /* Return sequence of instructions generated by if conversion.  This
function calls end_sequence() to end the current stream, ensures
that are instructions are unshared, recognizable non-jump insns.
@@ -1026,6 +1038,7 @@ end_ifcvt_sequence (struct noce_if_info *if_info)
 {
   rtx_insn *insn;
   rtx_insn *seq = get_insns ();
+  rtx cc = cc_in_cond (if_info-cond);
 
   set_used_flags (if_info-x);
   set_used_flags (if_info-cond);
@@ -1040,7 +1053,9 @@ end_ifcvt_sequence (struct noce_if_info *if_info)
  allows proper placement of required clobbers.  */
   for (insn = seq; insn; insn = NEXT_INSN (insn))
 if (JUMP_P (insn)
-   || recog_memoized (insn) == -1)
+   || recog_memoized (insn) == -1
+  /* Make sure new generated code does not clobber CC.  */
+   || (cc  set_of (cc, insn)))
   return NULL;
 
   return seq;
@@ -2544,6 +2559,7 @@ noce_process_if_block (struct noce_if_info *if_info)
   rtx_insn *insn_a, *insn_b;
   rtx set_a, set_b;
   rtx orig_x, x, a, b;
+  rtx cc;
 
   /* We're looking for patterns of the form
 
@@ -2655,6 +2671,13 @@ noce_process_if_block (struct noce_if_info *if_info)
   if_info-a = a;
   if_info-b = b;
 
+  /* Skip it if the instruction to be moved might clobber CC.  */
+  cc = cc_in_cond (cond);
+  if (cc)
+if (set_of (cc, insn_a)
+   || (insn_b  set_of (XEXP (cond, 0), insn_b)))
+  return FALSE;
+
   /* Try optimizations in some approximation of a useful order.  */
   /* ??? Should first look to see if X is live incoming at all.  If it
  isn't, we don't need anything but an unconditional set.  */
@@ -2811,6 +2834,7 @@ check_cond_move_block (basic_block bb,
   rtx cond)
 {
   rtx_insn *insn;
+  rtx cc = cc_in_cond (cond);
 
/* We can only handle simple jumps at the end of the basic block.
   It is almost impossible to update the CFG otherwise.  */
@@ -2868,6 +2892,10 @@ check_cond_move_block (basic_block bb,
   modified_between_p (src, insn, NEXT_INSN (BB_END (bb
return FALSE;
 
+  /* Skip it if the instruction to be moved might clobber CC.  */
+  if (cc  set_of (cc, insn))
+   return FALSE;
+
   vals-put (dest, src);
 
   regs-safe_push (dest);
diff --git a/gcc/testsuite/gcc.dg/pr63917.c b/gcc/testsuite/gcc.dg/pr63917.c
new file mode 100644
index 000..422b15d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr63917.c
@@ -0,0 +1,45 @@
+/* { dg-options  -O3  } */
+
+int d, i;
+
+struct S
+{
+  int f0;
+} *b, c, e, h, **g = b;
+
+static struct S *f = e;
+
+int
+fn1 (int p)
+{
+  int a = 0;
+  return a || p  0 || p = 2 || 1  p;
+}
+
+int
+main ()
+{
+  int k = 1, l, *m = c.f0;
+
+  for (;;)
+{
+  l = fn1 (i);
+  *m = k  i;
+  if (l)
+   {
+ int n[1] = {0};
+   }
+  break;
+}
+
+  *g = h;
+
+  if (d)
+(*m)--;
+  d = (f != 0) | (i = 0);
+
+  if (c.f0 != 0)
+__builtin_abort ();
+
+  return 0;
+}





[PATCH 0/3] Finish removing param_is and if_marked

2014-11-23 Thread tsaunders
From: Trevor Saunders tsaund...@mozilla.com

HI,

unfortunately this got finished up later than I hoped, but I don't see a reason
to keep it private till next stage 1.  The nvptx port snuck in a few more uses
of if_marked, and I forgot about the silly use of ggc in lto.c, which are taken
care of by patches 1/3 and 2/3.

The combination of patches has been bootstrapped on x86_64-unknown-linux-gnu, 
but I'll hold off on regtesting until I'm ready to commit this.  Are these 
patches ok for next stage 1?

Trev

Trevor Saunders (3):
  remove param_is from nvptx
  move gimple_canonical_types htab out of gc memory
  remove gengtype support for param_is use_param, if_marked and splay
tree allocators

 gcc/config/nvptx/nvptx.c |  56 ++---
 gcc/doc/gty.texi |  65 --
 gcc/doc/plugins.texi |  27 ++-
 gcc/gcc-plugin.h |   4 +-
 gcc/gengtype-lex.l   |   4 -
 gcc/gengtype-parse.c |   4 -
 gcc/gengtype-state.c | 145 +---
 gcc/gengtype.c   | 592 +--
 gcc/gengtype.h   |  31 +--
 gcc/ggc-common.c |  75 --
 gcc/ggc.h|  40 
 gcc/lto/lto.c|   4 +-
 gcc/plugin.c |   5 -
 gcc/plugin.def   |   3 -
 include/hashtab.h|  10 +-
 include/splay-tree.h |  20 +-
 16 files changed, 119 insertions(+), 966 deletions(-)

-- 
2.1.3



[PATCH 2/3] move gimple_canonical_types htab out of gc memory

2014-11-23 Thread tsaunders
From: Trevor Saunders tsaund...@mozilla.com

Hi,

The memory allocated for the hash table is never rooted by anything, so keeping
it in gc memory only works if it never needs to survive a gc.

Trev

lto/

* lto.c (read_cgraph_and_symbols): allocate gimple_canonical_types
htab with malloc instead of ggc.
---
 gcc/lto/lto.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index a1cd958..1ff02f8 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -2926,8 +2926,8 @@ read_cgraph_and_symbols (unsigned nfiles, const char 
**fnames)
   symtab-state = LTO_STREAMING;
 
   canonical_type_hash_cache = new hash_mapconst_tree, hashval_t (251);
-  gimple_canonical_types = htab_create_ggc (16381, gimple_canonical_type_hash,
-   gimple_canonical_type_eq, 0);
+  gimple_canonical_types = htab_create (16381, gimple_canonical_type_hash,
+   gimple_canonical_type_eq, NULL);
   gcc_obstack_init (tree_scc_hash_obstack);
   tree_scc_hash = new hash_tabletree_scc_hasher (4096);
 
-- 
2.1.3



[PATCH 1/3] remove param_is from nvptx

2014-11-23 Thread tsaunders
From: Trevor Saunders tsaund...@mozilla.com

Hi,

$subject

Trev

gcc/

* config/nvptx/nvptx.c: Convert htabs to hash_table.
---
 gcc/config/nvptx/nvptx.c | 56 
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index c1fd271..ebc419f 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -56,12 +56,24 @@
 /* Record the function decls we've written, and the libfuncs and function
decls corresponding to them.  */
 static std::stringstream func_decls;
-static GTY((if_marked (ggc_marked_p), param_is (struct rtx_def)))
-  htab_t declared_libfuncs_htab;
-static GTY((if_marked (ggc_marked_p), param_is (union tree_node)))
-  htab_t declared_fndecls_htab;
-static GTY((if_marked (ggc_marked_p), param_is (union tree_node)))
-  htab_t needed_fndecls_htab;
+
+struct declared_libfunc_hasher : ggc_cache_hasherrtx
+{
+  static hashval_t hash (rtx x) { return htab_hash_pointer (x); }
+  static bool equal (rtx a, rtx b) { return a == b; }
+};
+
+static GTY((cache))
+  hash_tabledeclared_libfunc_hasher *declared_libfuncs_htab;
+
+  struct tree_hasher : ggc_cache_hashertree
+{
+  static hashval_t hash (tree t) { return htab_hash_pointer (t); }
+  static bool equal (tree a, tree b) { return a == b; }
+};
+
+static GTY((cache)) hash_tabletree_hasher *declared_fndecls_htab;
+static GTY((cache)) hash_tabletree_hasher *needed_fndecls_htab;
 
 /* Allocate a new, cleared machine_function structure.  */
 
@@ -86,12 +98,10 @@ nvptx_option_override (void)
   write_symbols = NO_DEBUG;
   debug_info_level = DINFO_LEVEL_NONE;
 
-  declared_fndecls_htab
-= htab_create_ggc (17, htab_hash_pointer, htab_eq_pointer, NULL);
-  needed_fndecls_htab
-= htab_create_ggc (17, htab_hash_pointer, htab_eq_pointer, NULL);
+  declared_fndecls_htab = hash_tabletree_hasher::create_ggc (17);
+  needed_fndecls_htab = hash_tabletree_hasher::create_ggc (17);
   declared_libfuncs_htab
-= htab_create_ggc (17, htab_hash_pointer, htab_eq_pointer, NULL);
+= hash_tabledeclared_libfunc_hasher::create_ggc (17);
 }
 
 /* Return the mode to be used when declaring a ptx object for OBJ.
@@ -455,7 +465,7 @@ nvptx_record_fndecl (tree decl, bool force = false)
   if (!force  TYPE_ARG_TYPES (TREE_TYPE (decl)) == NULL_TREE)
 return false;
 
-  void **slot = htab_find_slot (declared_fndecls_htab, decl, INSERT);
+  tree *slot = declared_fndecls_htab-find_slot (decl, INSERT);
   if (*slot == NULL)
 {
   *slot = decl;
@@ -476,7 +486,7 @@ nvptx_record_needed_fndecl (tree decl)
   if (nvptx_record_fndecl (decl))
 return;
 
-  void **slot = htab_find_slot (needed_fndecls_htab, decl, INSERT);
+  tree *slot = needed_fndecls_htab-find_slot (decl, INSERT);
   if (*slot == NULL)
 *slot = decl;
 }
@@ -818,7 +828,7 @@ nvptx_expand_call (rtx retval, rtx address)
(decl_type == NULL_TREE
  || (external_decl  TYPE_ARG_TYPES (decl_type) == NULL_TREE)))
 {
-  void **slot = htab_find_slot (declared_libfuncs_htab, callee, INSERT);
+  rtx *slot = declared_libfuncs_htab-find_slot (callee, INSERT);
   if (*slot == NULL)
{
  *slot = callee;
@@ -2012,25 +2022,15 @@ nvptx_file_start (void)
   fputs (// END PREAMBLE\n, asm_out_file);
 }
 
-/* Called through htab_traverse; call nvptx_record_fndecl for every
-   SLOT.  */
-
-static int
-write_one_fndecl (void **slot, void *)
-{
-  tree decl = (tree)*slot;
-  nvptx_record_fndecl (decl, true);
-  return 1;
-}
-
 /* Write out the function declarations we've collected.  */
 
 static void
 nvptx_file_end (void)
 {
-  htab_traverse (needed_fndecls_htab,
-write_one_fndecl,
-NULL);
+  hash_tabletree_hasher::iterator iter;
+  tree decl;
+  FOR_EACH_HASH_TABLE_ELEMENT (*needed_fndecls_htab, decl, tree, iter)
+nvptx_record_fndecl (decl, true);
   fputs (func_decls.str().c_str(), asm_out_file);
 }
 
-- 
2.1.3



[PATCH 3/3] remove gengtype support for param_is use_param, if_marked and splay tree allocators

2014-11-23 Thread tsaunders
From: Trevor Saunders tsaund...@mozilla.com

Hi,

The one interesting part of this is what we do about plugins.  As you can tell
from the diff removing support for these gengtype features makes things much
simpler, and I think the only way to do that is to remove the plugin hook for
adding caches.  Plugins should be fine converting to the new scheme with
hash_table we use in gcc so long as they can hook in at a point where they can
drop caches, and mark objects they need to stay alive.  Its a little odd, but
the PLUGIN_GGC_MARKING hook is actually called at a point they can do both.  We
could add a separate PLUGIN_GGC_DROP_CACHES hook, but I'm not sure what the
point would be.

Trev

gcc/

* plugin.c, plugin.def, ggc.h, ggc-common.c, gengtype.h, gengtype.c,
gengtype-state.c, gengtype-parse.c, gentype-lex.l, gcc-plugin.h,
doc/plugins.texi, doc/gty.texi: Remove support for if_marked and
param_is.

include/

* hashtab.h, splay-tree.h: Remove GTY markers.
---
 gcc/doc/gty.texi |  65 --
 gcc/doc/plugins.texi |  27 ++-
 gcc/gcc-plugin.h |   4 +-
 gcc/gengtype-lex.l   |   4 -
 gcc/gengtype-parse.c |   4 -
 gcc/gengtype-state.c | 145 +
 gcc/gengtype.c   | 592 +--
 gcc/gengtype.h   |  31 +--
 gcc/ggc-common.c |  75 ---
 gcc/ggc.h|  40 
 gcc/plugin.c |   5 -
 gcc/plugin.def   |   3 -
 include/hashtab.h|  10 +-
 include/splay-tree.h |  20 +-
 14 files changed, 89 insertions(+), 936 deletions(-)

diff --git a/gcc/doc/gty.texi b/gcc/doc/gty.texi
index e4d2b60..aa6f84f 100644
--- a/gcc/doc/gty.texi
+++ b/gcc/doc/gty.texi
@@ -245,54 +245,6 @@ The @code{desc} and @code{tag} options can also be used 
for inheritance
 to denote which subclass an instance is.  See @ref{Inheritance and GTY}
 for more information.
 
-@findex param_is
-@findex use_param
-@item param_is (@var{type})
-@itemx use_param
-
-Sometimes it's convenient to define some data structure to work on
-generic pointers (that is, @code{PTR}) and then use it with a specific
-type.  @code{param_is} specifies the real type pointed to, and
-@code{use_param} says where in the generic data structure that type
-should be put.
-
-For instance, to have a @code{htab_t} that points to trees, one would
-write the definition of @code{htab_t} like this:
-@smallexample
-typedef struct GTY(()) @{
-  @dots{}
-  void ** GTY ((use_param, @dots{})) entries;
-  @dots{}
-@} htab_t;
-@end smallexample
-and then declare variables like this:
-@smallexample
-  static htab_t GTY ((param_is (union tree_node))) ict;
-@end smallexample
-
-@findex param@var{n}_is
-@findex use_param@var{n}
-@item param@var{n}_is (@var{type})
-@itemx use_param@var{n}
-
-In more complicated cases, the data structure might need to work on
-several different types, which might not necessarily all be pointers.
-For this, @code{param1_is} through @code{param9_is} may be used to
-specify the real type of a field identified by @code{use_param1} through
-@code{use_param9}.
-
-@findex use_params
-@item use_params
-
-When a structure contains another structure that is parameterized,
-there's no need to do anything special, the inner structure inherits the
-parameters of the outer one.  When a structure contains a pointer to a
-parameterized structure, the type machinery won't automatically detect
-this (it could, it just doesn't yet), so it's necessary to tell it that
-the pointed-to structure should use the same parameters as the outer
-structure.  This is done by marking the pointer with the
-@code{use_params} option.
-
 @findex cache
 @item cache
 
@@ -309,23 +261,6 @@ garbage collection runs, there's no need to mark anything 
pointed to
 by this variable, it can just be set to @code{NULL} instead.  This is used
 to keep a list of free structures around for re-use.
 
-@findex if_marked
-@item if_marked (@var{expression})
-
-Suppose you want some kinds of object to be unique, and so you put them
-in a hash table.  If garbage collection marks the hash table, these
-objects will never be freed, even if the last other reference to them
-goes away.  GGC has special handling to deal with this: if you use the
-@code{if_marked} option on a global hash table, GGC will call the
-routine whose name is the parameter to the option on each hash table
-entry.  If the routine returns nonzero, the hash table entry will
-be marked as usual.  If the routine returns zero, the hash table entry
-will be deleted.
-
-The routine @code{ggc_marked_p} can be used to determine if an element
-has been marked already; in fact, the usual case is to use
-@code{if_marked (ggc_marked_p)}.
-
 @findex mark_hook
 @item mark_hook (@var{hook-routine-name})
 
diff --git a/gcc/doc/plugins.texi b/gcc/doc/plugins.texi
index 4a839b8..96df506 100644
--- a/gcc/doc/plugins.texi
+++ b/gcc/doc/plugins.texi
@@ -185,7 +185,6 @@ enum plugin_event
   PLUGIN_GGC_MARKING,   /* Extend the GGC marking. */
   

[PATCH, AARCH64] Fix ICE in CCMP (PR64015)

2014-11-23 Thread Zhenqiang Chen
Hi,

Expand pass always uses sign-extend to represent constant value. For the
case in the patch, a 8-bit unsigned value 252 is represented as -4,
which pass the ccmn check. After mode conversion, -4 becomes 252, which
leads to mismatch.

The patch adds another operand check after mode conversion.

No make check regression with qemu.

OK for trunk?

Thanks!
-Zhenqiang

ChangeLog:
2014-11-24  Zhenqiang Chen  zhenqiang.c...@arm.com

PR target/64015
* config/aarch64/aarch64.c (aarch64_gen_ccmp_first): Recheck operand
after mode conversion.
(aarch64_gen_ccmp_next): Likewise.

testsuite/ChangeLog:
2014-11-24  Zhenqiang Chen  zhenqiang.c...@arm.com

* gcc.target/aarch64/pr64015.c: New test.

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 1809513..203d095 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -10311,7 +10311,10 @@ aarch64_gen_ccmp_first (int code, rtx op0, rtx op1)
   if (!aarch64_plus_operand (op1, GET_MODE (op1)))
 op1 = force_reg (mode, op1);
 
-  if (!aarch64_convert_mode (op0, op1, unsignedp))
+  if (!aarch64_convert_mode (op0, op1, unsignedp)
+/* Some negative value might be transformed into a positive one.
+   So need recheck here.  */
+  || !aarch64_plus_operand (op1, GET_MODE (op1)))
 return NULL_RTX;
 
   mode = aarch64_code_to_ccmode ((enum rtx_code) code);
@@ -10344,7 +10347,10 @@ aarch64_gen_ccmp_next (rtx prev, int cmp_code, rtx
op0, rtx op1, int bit_code)
   || !aarch64_ccmp_operand (op1, GET_MODE (op1)))
 return NULL_RTX;
 
-  if (!aarch64_convert_mode (op0, op1, unsignedp))
+  if (!aarch64_convert_mode (op0, op1, unsignedp)
+/* Some negative value might be transformed into a positive one.
+   So need recheck here.  */
+  || !aarch64_ccmp_operand (op1, GET_MODE (op1)))
 return NULL_RTX;
 
   mode = aarch64_code_to_ccmode ((enum rtx_code) cmp_code);

diff --git a/gcc/testsuite/gcc.target/aarch64/pr64015.c
b/gcc/testsuite/gcc.target/aarch64/pr64015.c
new file mode 100644
index 000..eeed665
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr64015.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options  -O2  } */
+int
+test (unsigned short a, unsigned char b)
+{
+  return a  0xfff2  b  252;
+}





Re: [PATCH, AARCH64] Fix ICE in CCMP (PR64015)

2014-11-23 Thread Andrew Pinski
On Sun, Nov 23, 2014 at 9:11 PM, Zhenqiang Chen zhenqiang.c...@arm.com wrote:
 Hi,

 Expand pass always uses sign-extend to represent constant value. For the
 case in the patch, a 8-bit unsigned value 252 is represented as -4,
 which pass the ccmn check. After mode conversion, -4 becomes 252, which
 leads to mismatch.

 The patch adds another operand check after mode conversion.

 No make check regression with qemu.

 OK for trunk?

 Thanks!
 -Zhenqiang

 ChangeLog:
 2014-11-24  Zhenqiang Chen  zhenqiang.c...@arm.com

 PR target/64015
 * config/aarch64/aarch64.c (aarch64_gen_ccmp_first): Recheck operand
 after mode conversion.
 (aarch64_gen_ccmp_next): Likewise.

 testsuite/ChangeLog:
 2014-11-24  Zhenqiang Chen  zhenqiang.c...@arm.com

 * gcc.target/aarch64/pr64015.c: New test.

 diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
 index 1809513..203d095 100644
 --- a/gcc/config/aarch64/aarch64.c
 +++ b/gcc/config/aarch64/aarch64.c
 @@ -10311,7 +10311,10 @@ aarch64_gen_ccmp_first (int code, rtx op0, rtx op1)
if (!aarch64_plus_operand (op1, GET_MODE (op1)))
  op1 = force_reg (mode, op1);

 -  if (!aarch64_convert_mode (op0, op1, unsignedp))
 +  if (!aarch64_convert_mode (op0, op1, unsignedp)
 +/* Some negative value might be transformed into a positive one.
 +   So need recheck here.  */
 +  || !aarch64_plus_operand (op1, GET_MODE (op1)))
  return NULL_RTX;

Shouldn't we force it to a reg here instead?


mode = aarch64_code_to_ccmode ((enum rtx_code) code);
 @@ -10344,7 +10347,10 @@ aarch64_gen_ccmp_next (rtx prev, int cmp_code, rtx
 op0, rtx op1, int bit_code)
|| !aarch64_ccmp_operand (op1, GET_MODE (op1)))
  return NULL_RTX;

 -  if (!aarch64_convert_mode (op0, op1, unsignedp))
 +  if (!aarch64_convert_mode (op0, op1, unsignedp)
 +/* Some negative value might be transformed into a positive one.
 +   So need recheck here.  */
 +  || !aarch64_ccmp_operand (op1, GET_MODE (op1)))
  return NULL_RTX;


Also really the cost of forcing to a register is better really.
In the cases where we would not have forced to a register in a cmp
instruction, the constant would be one instruction and compared to the
cost of two cset and an and/or is better.
In the cases where we would have forced to a register for the cmp
instruction, two cost for doing the forcing is the same on both cases
but since we gaining from removing a cset and an and/or we are better.


mode = aarch64_code_to_ccmode ((enum rtx_code) cmp_code);

 diff --git a/gcc/testsuite/gcc.target/aarch64/pr64015.c
 b/gcc/testsuite/gcc.target/aarch64/pr64015.c
 new file mode 100644
 index 000..eeed665
 --- /dev/null
 +++ b/gcc/testsuite/gcc.target/aarch64/pr64015.c
 @@ -0,0 +1,7 @@
 +/* { dg-do compile } */
 +/* { dg-options  -O2  } */
 +int
 +test (unsigned short a, unsigned char b)
 +{
 +  return a  0xfff2  b  252;
 +}

Since this testcase is generic (except for the -O2), it really should
go into gcc.c-torture/compile instead of remove the two dg-*
directives so it can be tested on more than AARCH64 and on more
optimization levels.


Thanks,
Andrew Pinski






Re: [PATCH v3] gcc/ubsan.c: Use 'pretty_print' for 'pretty_name' to avoid memory overflow

2014-11-23 Thread Jakub Jelinek
On Sun, Nov 23, 2014 at 09:13:27AM +0800, Chen Gang wrote:
 2014-11-23  Chen Gang  gang.chen.5...@gmail.com
 
   * ubsan.c (ubsan_type_descriptor): Use 'pretty_print' for
   'pretty_name' to avoid memory overflow.

Ok, with a small nit below.

  gcc/ubsan.c | 63 
 +
  1 file changed, 34 insertions(+), 29 deletions(-)
 
 diff --git a/gcc/ubsan.c b/gcc/ubsan.c
 index b3d5343..3fceff7 100644
 --- a/gcc/ubsan.c
 +++ b/gcc/ubsan.c
 @@ -369,7 +369,7 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style 
 pstyle)
tree dtype = ubsan_get_type_descriptor_type ();
tree type2 = type;
const char *tname = NULL;
 -  char *pretty_name;
 +  pretty_printer pretty_name;
unsigned char deref_depth = 0;
unsigned short tkind, tinfo;
  
 @@ -408,54 +408,58 @@ ubsan_type_descriptor (tree type, enum 
 ubsan_print_style pstyle)
  /* We weren't able to determine the type name.  */
  tname = unknown;
  
 -  /* Decorate the type name with '', '*', struct, or union.  */
 -  pretty_name = (char *) alloca (strlen (tname) + 16 + deref_depth);
if (pstyle == UBSAN_PRINT_POINTER)
  {
 -  int pos = sprintf (pretty_name, '%s%s%s%s%s%s%s,
 -  TYPE_VOLATILE (type2) ? volatile  : ,
 -  TYPE_READONLY (type2) ? const  : ,
 -  TYPE_RESTRICT (type2) ? restrict  : ,
 -  TYPE_ATOMIC (type2) ? _Atomic  : ,
 -  TREE_CODE (type2) == RECORD_TYPE
 -  ? struct 
 -  : TREE_CODE (type2) == UNION_TYPE
 -? union  : , tname,
 -  deref_depth == 0 ?  :  );
 +  pp_printf (pretty_name, '%s%s%s%s%s%s%s,
 +  TYPE_VOLATILE (type2) ? volatile  : ,
 +  TYPE_READONLY (type2) ? const  : ,
 +  TYPE_RESTRICT (type2) ? restrict  : ,
 +  TYPE_ATOMIC (type2) ? _Atomic  : ,
 +  TREE_CODE (type2) == RECORD_TYPE
 +  ? struct 
 +  : TREE_CODE (type2) == UNION_TYPE
 +? union  : , tname,
 +  deref_depth == 0 ?  :  );
while (deref_depth--  0)
 -pretty_name[pos++] = '*';
 -  pretty_name[pos++] = '\'';
 -  pretty_name[pos] = '\0';
 + pp_star (pretty_name);
 +  pp_quote (pretty_name);
  }
else if (pstyle == UBSAN_PRINT_ARRAY)
  {
/* Pretty print the array dimensions.  */
gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
tree t = type;
 -  int pos = sprintf (pretty_name, '%s , tname);
 +  pp_printf (pretty_name, '%s , tname);
while (deref_depth--  0)
 -pretty_name[pos++] = '*';
 + pp_star (pretty_name);
while (TREE_CODE (t) == ARRAY_TYPE)
   {
 -   pretty_name[pos++] = '[';
 +   pp_left_bracket (pretty_name);
 tree dom = TYPE_DOMAIN (t);
 if (dom  TREE_CODE (TYPE_MAX_VALUE (dom)) == INTEGER_CST)
 - pos += sprintf (pretty_name[pos], HOST_WIDE_INT_PRINT_DEC,
 + {
 +   if (tree_fits_uhwi_p (TYPE_MAX_VALUE (dom))
 +tree_to_uhwi (TYPE_MAX_VALUE (dom)) + 1 != 0)
 + pp_printf (pretty_name, HOST_WIDE_INT_PRINT_DEC,
   tree_to_uhwi (TYPE_MAX_VALUE (dom)) + 1);
 +   else
 + pp_wide_int(pretty_name,
 + wi::add (wi::to_widest (TYPE_MAX_VALUE (dom)), 1),
 + TYPE_SIGN (TREE_TYPE (dom)));

Space still missing before ( (and reindenting the following 2 lines).

Jakub