Turn DECL_SECTION_NAME into string

2014-06-11 Thread Jan Hubicka
Hi,
this lenghtly patch makes the legwork to put section names out of tree 
representation.
Originally they were STRING_CST. I ended up implementing on-side reference 
counted
string voclabulary that is done in bit baroque way to be GGC and PCH safe (uff).
The memory savings on Firefox are about 60MB, becuase while reading symbol 
table we
now unify the many duplicated comdat group strings and also we free them after 
we bring
those local.

The old representation probably made sense when most of string came via 
__section__
attribute where they was readily parsed as string constants.

Bootstrapped/regtested x86_64-linux, comitted.

Honza

* symtab.c (section_hash): New hash.
(symtab_unregister_node): Clear section before freeing.
(hash_section_hash_entry): New haser.
(eq_sections): New function.
(symtab_node::set_section_for_node): New method.
(set_section_1): Update.
(symtab_node::set_section): Take string instead of tree as parameter.
(symtab_resolve_alias): Update.
* cgraph.h (section_hash_entry_d): New structure.
(section_hash_entry): New typedef.
(cgraph_node): Change comdat_group_ to x_comdat_group,
change section_ to x_section and turn into section_hash_entry;
update accestors; put set_section_for_node offline.
* tree.c (decl_section_name): Turn into string.
(set_decl_section_name): Change parameter to be string.
* tree.h (decl_section_name, set_decl_section_name): Update prototypes.
* sdbout.c (sdbout_one_type): Update.
* tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Update.
* varasm.c (IN_NAMED_SECTION, get_named_section, resolve_unique_section,
hot_function_section, get_named_text_section, 
USE_SELECT_SECTION_FOR_FUNCTIONS,
default_function_rodata_section, make_decl_rtl, default_unique_section):
Update.
* config/c6x/c6x.c (c6x_in_small_data_p): Update.
(c6x_elf_unique_section): Update.
* config/nios2/nios2.c (nios2_in_small_data_p): Update.
* config/pa/pa.c (pa_function_section): Update.
* config/pa/pa.h (IN_NAMED_SECTION_P): Update.
* config/ia64/ia64.c (ia64_in_small_data_p): Update.
* config/arc/arc.c (arc_in_small_data_p): Update.
* config/arm/unknown-elf.h (IN_NAMED_SECTION_P): Update.
* config/mcore/mcore.c (mcore_unique_section): Update.
* config/mips/mips.c (mips16_build_function_stub): Update.
(mips16_build_call_stub): Update.
(mips_function_rodata_section): Update.
(mips_in_small_data_p): Update.
* config/score/score.c (score_in_small_data_p): Update.
* config/rx/rx.c (rx_in_small_data): Update.
* config/rs6000/rs6000.c (rs6000_elf_in_small_data_p): Update.
(rs6000_xcoff_asm_named_section): Update.
(rs6000_xcoff_unique_section): Update.
* config/frv/frv.c (frv_string_begins_with): Update.
(frv_in_small_data_p): Update.
* config/v850/v850.c (v850_encode_data_area): Update.
* config/bfin/bfin.c (DECL_SECTION_NAME): Update.
(bfin_handle_l1_data_attribute): Update.
(bfin_handle_l2_attribute): Update.
* config/mep/mep.c (mep_unique_section): Update.
* config/microblaze/microblaze.c (microblaze_elf_in_small_data_p): 
Update.
* config/h8300/h8300.c (h8300_handle_eightbit_data_attribute): Update.
(h8300_handle_tiny_data_attribute): Update.
* config/m32r/m32r.c (m32r_in_small_data_p): Update.
(m32r_in_small_data_p): Update.
* config/alpha/alpha.c (alpha_in_small_data_p): Update.
* config/i386/i386.c (ix86_in_large_data_p): Update.
* config/i386/winnt.c (i386_pe_unique_section): Update.
* config/darwin.c (darwin_function_section): Update.
* config/lm32/lm32.c (lm32_in_small_data_p): Update.
* tree-emutls.c (get_emutls_init_templ_addr): Update.
(new_emutls_decl): Update.
* lto-cgraph.c (lto_output_node, input_node, input_varpool_node,
input_varpool_node): Update.
(ead_string_cst): Turn to ...
(read_string): ... this one.
* dwarf2out.c (secname_for_decl): Update.
* asan.c (asan_protect_global): Update.

* c-family/c-common.c (handle_section_attribute): Update handling for
section names that are no longer trees.

* java/class.c (build_utf8_ref): Update handling for section names
that are no longer trees.
(emit_register_classes_in_jcr_section): Update.

* vtable-class-hierarchy.c: Update handling for section names
that are no longer trees.
* decl.c (duplicate_decls): Likewise.

* gcc-interface/utils.c:  Update handling for section names
that are no longer trees.
Index: sdbout.c
===
--- sdbout.c(revision 211433)
+++ sdbout.c(working 

Re: [PATCH, PR52252] Alternative way of vectorization for load groups of size 2 and 3.

2014-06-11 Thread Evgeny Stupachenko
Testing finished. No new regressions.
Is the following patch ok?

2014-06-11  Evgeny Stupachenko  

* config/i386/i386.c (ix86_reassociation_width): Add alternative for
vector case.
* config/i386/i386.h (TARGET_VECTOR_PARALLEL_EXECUTION): New.
* config/i386/x86-tune.def (X86_TUNE_VECTOR_PARALLEL_EXECUTION): New.
* tree-vect-data-refs.c (vect_shift_permute_load_chain): New.
Introduces alternative way of loads group permutaions.
(vect_transform_grouped_load): Try alternative way of permutations.

Thanks,
Evgeny

On Tue, Jun 10, 2014 at 4:43 PM, Evgeny Stupachenko  wrote:
> ix86_reassociation_width checks INTEGRAL_MODE_P and FLOAT_MODE_P which
> include vector mode.
> I'll try to separate this into scalar and vector part, but it will
> require more testing (under the testing now).
> What about the rest of the patch?
>
> Thanks,
> Evgeny
>
> On Thu, Jun 5, 2014 at 3:54 PM, Ramana Radhakrishnan
>  wrote:
>> On 06/05/14 12:43, Evgeny Stupachenko wrote:
>>>
>>> New hook is related to vector instructions only. Vector instructions
>>> could be sequential in pipeline, but scalar - parallel. For x86
>>> architectures TARGET_SCHED_REASSOC_WIDTH does not give required
>>> differentiation.
>>> General hooks could be potentially reused in other algorithms/by other
>>> architectures.
>>
>>
>> It already takes a "mode" argument. Couldn't you use a vector mode to work
>> this out ?
>>
>> If it is not enough then please be more specific about the documentation of
>> this hook about where it is useful so that it's easy for people reading the
>> documentation to understand at a glance what purpose it serves.
>>
>>
>> Ramana
>>
>>
>>>
>>> Thanks,
>>> Evgeny
>>>
>>> On Thu, Jun 5, 2014 at 2:04 PM, Ramana Radhakrishnan
>>>  wrote:

 On Wed, May 28, 2014 at 2:09 PM, Evgeny Stupachenko 
 wrote:
>
> Hi,
>
> The patch introduces alternative way of permutations for load groups
> of size 2 and 3 which should be faster on architectures with low
> parallelism.
> The patch gives 2 times gain on Silvermont to the test from PR52252
> (in addition to already committed 3 times gain).
>
> Patch passes bootstrap on x86. Make check is in progress.


 Why do we need a new hook ? Can't you derive this information from
 something which is equally badly named TARGET_SCHED_REASSOC_WIDTH
 though used in the reassociation logic but also serves a similar
 purpose ?

 Also the documentation of this hook is incomplete at best and wrong at
 worst as this is not applied everywhere in the vectorizer but just for
 this special case for load store permuting. Implying this is useful
 everywhere in the vectorizer does not appear to be correct.

 regards
 Ramana




>
> ChangeLog:
>
> 2014-05-28  Evgeny Stupachenko  
>
>  * config/i386/i386.c (ix86_have_vector_parallel_execution):
> New.
>  (TARGET_VECTORIZE_HAVE_VECTOR_PARALLEL_EXECUTION): New.
>  * config/i386/i386.h (TARGET_VECTOR_PARALLEL_EXECUTION): New.
>  * config/i386/x86-tune.def
> (X86_TUNE_VECTOR_PARALLEL_EXECUTION): New.
>  * target.def (have_vector_parallel_execution): New.
>  * doc/tm.texi.in (have_vector_parallel_execution)): New.
>  * doc/tm.texi: Regenerate.
>  * targhooks.c (default_have_vector_parallel_execution): New.
>  * tree-vect-data-refs.c (vect_shift_permute_load_chain): New.
>  Introduces alternative way of loads group permutaions.
>  (vect_transform_grouped_load): Try alternative way of
> permutaions.
>
> Evgeny
>>>
>>>
>>


vect_groups1.patch
Description: Binary data


Re: [Patch ARM/testsuite 00/22] Neon intrinsics executable tests

2014-06-11 Thread Mike Stump
On Jun 10, 2014, at 3:03 PM, Ramana Radhakrishnan  
wrote:
> I am a bit ambivalent between getting folks to add scan-assembler
> tests here and worrying between this and getting the behaviour
> correct. Additionally if you add the complexity of scanning for
> aarch64 as well this starts getting messy.
> 
> At this point I'm going to wait to see if any of the testsuite
> maintainers step in and comment and if not I'll start looking at this
> properly early next week.

[ ducks ] So, I wasn’t going to comment…  If you guys do something really 
stupid, I’ll scream, as hopefully will others.  Doing something a little 
misguided I don’t think hurts much.  The worst case if you figure out in a year 
or two why it was a bad idea and then fix it, not the end of the world.

Re: [C++ Patch] PR 19200 follow up

2014-06-11 Thread Jason Merrill

OK.

Jason


Re: [patch] libstdc++/29988 Rb_Tree reuse allocated nodes

2014-06-11 Thread Jonathan Wakely

On 11/06/14 21:56 +0200, François Dumont wrote:
   For the testsuite allocator I though that for an internal 
allocator used in our tests it was ok. But alright, I will make it 
better and compatible with SimpleAllocator.



I suppose it's OK for now, and we can change it later if we need it to
work with other  allocators.



Is there a reason to define this and _Rb_tree_alloc_node as
namespace-scope class templates, rather than non-template members of
_Rb_tree?
   Just to limit amount of code within _Rb_tree. I wanted to do 
something like in _Hashtable where many code is isolated in different 
types aggregated to build the final _Hashtable type. But it looks like 
you prefer it nested so I will do so.


Yes, I think it's better to define them inside _Rb_tree rather than
having separate templates in namespace std which are not general
purpose or useful anywhere except _Rb_tree.

(I find the fragmented _Hashtable design quite confusing!)


This type needs to be non-copyable, or unintentional copies would
erase all the nodes and leave nothing to be reused (which might be
difficult to detect as it would only affect performance, not
correctness).
   Yes, sure, like in the equivalent _Hashtable types. I guess I 
didn't do so here because we might not be in c++11 so it is not as 
convenient to forbid its usage.


You could delete the functions for C++11 only - that would probably be
good enough to catch any accidental misuse.




+  template
+__node_type*
+#if __cplusplus < 201103L
+operator()(const _Arg& __arg) const
+#else
+operator()(_Arg&& __arg) const
+#endif


Does this need to be const?

I don't think it does (if you change the function templates taking a
const _NodeGen& to take _NodeGen& instead).


Sometimes I used lambdas, I am not sure but I think it forced me to 
take functors as const lvalue reference and so the const qualification 
on the operator.


If you declare the lambda 'mutable' then it's allowed to modify its
captures.



What's the purpose of this change?
Although it can be 'const' it is consistent with the usual
begin()/end() functions that the functions returning a mutable iterator
are non-const and the functions returning a constant iterator are const.


 _Const_Link_type
-  _M_begin() const _GLIBCXX_NOEXCEPT
+  _M_cbegin() const _GLIBCXX_NOEXCEPT
 {
   return static_cast<_Const_Link_type>
 (this->_M_impl._M_header._M_parent);
@@ -529,7 +666,7 @@
 { return reinterpret_cast<_Link_type>(&this->_M_impl._M_header); }

 _Const_Link_type
-  _M_end() const _GLIBCXX_NOEXCEPT
+  _M_cend() const _GLIBCXX_NOEXCEPT
 { return 
reinterpret_cast<_Const_Link_type>(&this->_M_impl._M_header); }


 static const_reference


I'm not very comfortable with this renaming.

Having consistent _M_begin() functions allows using them in template
code that doesn't care if it's using the const or non-const version.



I will try to remember why I did those :-)


OK thanks :-)

I went through the rest of the patch and it is fine - I like the
overall change very much, it's a good improvement, so we definitely
want to apply a revised patch. Thanks for working on it.



Re: [PING][PATCH, trunk, 4.9, 4.8] Fix PR57653, filename information discarded when using -imacros

2014-06-11 Thread Peter Bergner
On Wed, 2014-06-11 at 23:07 +, Joseph S. Myers wrote:
> On Wed, 11 Jun 2014, Peter Bergner wrote:
> 
> > I'd like to ping the following patch that fixes PR57653.  This did
> > bootstrap and regtest with no regressions on powerpc64-linux.
> > 
> > https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01571.html
> > 
> > Is this ok for trunk, 4.9 and 4.8?
> 
> I think the code change is correct, but the comment added needs expanding 
> to explain better what's going on (i.e. the circumstances in which the 
> condition include_cursor > deferred_count may hold, and why, in those 
> circumstances, returning early is the correct thing to do).

Manuel, can you offer an updated comment?  Being just the patch
tester and not knowing this code at all, I'm not going to be of
much use at expanding the Manuel's original comment.

Peter





Re: [PING][PATCH, trunk, 4.9, 4.8] Fix PR57653, filename information discarded when using -imacros

2014-06-11 Thread Joseph S. Myers
On Wed, 11 Jun 2014, Peter Bergner wrote:

> I'd like to ping the following patch that fixes PR57653.  This did
> bootstrap and regtest with no regressions on powerpc64-linux.
> 
> https://gcc.gnu.org/ml/gcc-patches/2014-04/msg01571.html
> 
> Is this ok for trunk, 4.9 and 4.8?

I think the code change is correct, but the comment added needs expanding 
to explain better what's going on (i.e. the circumstances in which the 
condition include_cursor > deferred_count may hold, and why, in those 
circumstances, returning early is the correct thing to do).

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


[PATCH] PR rtl-optimization/61047

2014-06-11 Thread Bernd Edlinger
Hi,

this patch fixes PR 61047, where rtx_addr_can_trap_p_1
incorrectly assumes, that all SP-relative offsets can be safely
read witout causing any traps. And therefore such references
are safe to be moved out of an if-block.

This patch tries to get safe lower and upper bounds where accesses
are always guaranteed to work.  The goal is not to penalize
reasonable written code:  When boot-strapping the whole GCC
only a few places were found, where this new check triggers.

Boot-strapped and regression-tested on x86_64-linux-gnu.
Additionally built a cross compiler for a stack-grows-upward-target 
(xstormy16-elf).

Ok for trunk?


Thanks
Bernd.
  

changelog-pr60147.diff
Description: Binary data


patch-pr61047.diff
Description: Binary data


Re: [PATCH, PR 61186]

2014-06-11 Thread Jan Hubicka
> Hi,
> 
> in PR 61186 valgrind reports use of uninitialized value.  The reason
> is that walk_polymorphic_call_targets uses cache_token before it
> checks return value of possible_polymorphic_call_targets which however
> does not produce a cache token if it fails early.  This is not the
> only place where we make this mistake so I decided to store NULL to
> cache_token in these cases instead.  I understand this slightly
> controversial as it means that the callers making this error will now
> end up with a NULL pointer in their pointer_sets (which they use in
> order not to process the same results multiple times).  It just seemed
> quite a lot easier and also avoids making the same mistake elsewhere
> in future.
> 
> Bootstrapped and tested on x86_64-linux, I have of course also
> verified it fixes the bug.  OK for trunk?  And perhaps also the 4.9
> branch?

OK for mainline and branch.
Honza


Re: [PATCH, PR61446] Fix mode for register copy in REE pass

2014-06-11 Thread Ilya Enkovich
On 11 Jun 22:47, Uros Bizjak wrote:
> 
> This should read:
> 
> /* { dg-do compile { target { ia32 } } } */
> /* { dg-options "-O2 -march=corei7 -mfpmath=387" } */
> 
> The x86 part is OK with this change.
> 
> Uros.

Thanks for comment!  Here is a fixed version.

Ilya
--
gcc/

2014-06-11  Ilya Enkovich  

PR 61446
* ree.c (find_and_remove_re): Narrow mode for register copy
if required.

gcc/testsuite/

2014-06-11  Ilya Enkovich  

 * gcc.target/i386/pr61446.c : New.


diff --git a/gcc/ree.c b/gcc/ree.c
index ade413e..6d34764 100644
--- a/gcc/ree.c
+++ b/gcc/ree.c
@@ -1088,14 +1088,24 @@ find_and_remove_re (void)
   /* Use the mode of the destination of the defining insn
 for the mode of the copy.  This is necessary if the
 defining insn was used to eliminate a second extension
-that was wider than the first.  */
+that was wider than the first.  Truncate mode if it is
+too wide for destination reg.  */
   rtx sub_rtx = *get_sub_rtx (def_insn);
   rtx pat = PATTERN (curr_insn);
-  rtx new_dst = gen_rtx_REG (GET_MODE (SET_DEST (sub_rtx)),
-REGNO (XEXP (SET_SRC (pat), 0)));
-  rtx new_src = gen_rtx_REG (GET_MODE (SET_DEST (sub_rtx)),
-REGNO (SET_DEST (pat)));
-  rtx set = gen_rtx_SET (VOIDmode, new_dst, new_src);
+  unsigned int regno = REGNO (XEXP (SET_SRC (pat), 0));
+  enum machine_mode mode = GET_MODE (SET_DEST (sub_rtx));
+  rtx new_dst, new_src, set;
+
+  if (HARD_REGNO_NREGS (regno, mode) != 1)
+   {
+ mode = GET_CLASS_NARROWEST_MODE (GET_MODE_CLASS (mode));
+ while (HARD_REGNO_NREGS (regno, GET_MODE_WIDER_MODE (mode)) == 1)
+   mode = GET_MODE_WIDER_MODE (mode);
+   }
+
+  new_dst = gen_rtx_REG (mode, REGNO (XEXP (SET_SRC (pat), 0)));
+  new_src = gen_rtx_REG (mode, REGNO (SET_DEST (pat)));
+  set = gen_rtx_SET (VOIDmode, new_dst, new_src);
   emit_insn_after (set, def_insn);
 }
 
diff --git a/gcc/testsuite/gcc.target/i386/pr61446.c 
b/gcc/testsuite/gcc.target/i386/pr61446.c
new file mode 100644
index 000..fc32f63
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr61446.c
@@ -0,0 +1,14 @@
+/* PR rtl-optimization/61446 */
+
+/* { dg-do compile { target { ia32 } } } */
+/* { dg-options "-O2 -march=corei7 -mfpmath=387" } */
+
+unsigned long long
+foo (float a)
+{
+  const double dfa = a;
+  const unsigned int hi = dfa / 0x1p32f;
+  const unsigned int lo = dfa - (double) hi * 0x1p32f;
+
+  return ((unsigned long long) hi << (4 * (8))) | lo;
+}


fix math wrt volatile-bitfields vs C++ model

2014-06-11 Thread DJ Delorie

If the combined bitfields are exactly the size of the mode, the logic
for detecting range overflow is flawed - it calculates an ending
"position" that's the position of the first bit in the next field.

In the case of "short" for example, you get "16 > 15" without this
patch (comparing size to position), and "15 > 15" with (comparing
position to position).

Ok to apply?

* expmed.c (strict_volatile_bitfield_p): Fix off-by-one error.

Index: expmed.c
===
--- expmed.c(revision 211479)
+++ expmed.c(working copy)
@@ -472,13 +472,13 @@ strict_volatile_bitfield_p (rtx op0, uns
  && bitnum % GET_MODE_ALIGNMENT (fieldmode) + bitsize > modesize))
 return false;
 
   /* Check for cases where the C++ memory model applies.  */
   if (bitregion_end != 0
   && (bitnum - bitnum % modesize < bitregion_start
- || bitnum - bitnum % modesize + modesize > bitregion_end))
+ || bitnum - bitnum % modesize + modesize - 1 > bitregion_end))
 return false;
 
   return true;
 }
 
 /* Return true if OP is a memory and if a bitfield of size BITSIZE at


Re: [PING*2][PATCH] Extend mode-switching to support toggle (1/2)

2014-06-11 Thread Oleg Endo

On 11 Jun 2014, at 14:40, Christian Bruel  wrote:

> 
> On 06/10/2014 04:03 PM, Joern Rennecke wrote:
>> On 13 May 2014 22:41, Oleg Endo  wrote:
>> 
>>> Right.  I was thinking to add FPSCR.SZ mode switching to SH, in order to
>>> do float vector moves.  For that SZ and PR need to be switched both at
>>> the same time (only SH4A has both, fpchg and fschg).  So basically I'd
>>> add another mode entity, which would emit SZ mode changes in addition to
>>> the PR mode changes.  But then adjacent FPSCR-changing insns could be
>>> combined ... any idea/suggestion how to accomplish that?
>> If they are sufficiently adjacent, you can use a peephole2 pattern for this.
>> 
>> I see Cristian's patch addresses this in a different way - keeping size and
>> precision in the same entity, and emitting toggles as appropriate.
> 
> yes, I was only interested to optimize the SH4a case when PR=1 with a
> good enough implementation. To cover all the other possibilities a new
> entity would be better. But then as you say recombining them might be
> difficult.  An alternate hackish way could be to have a singe entity
> with 4 modes covering all PR*SZ combinations).
> 
> but I'm not sure that covering the case where PR=0 SZ=1 worth it, maybe
> code size only, ? as the 64 move would be implemented as 2*32 moves anyway,

I was thinking of using PR=0,SZ=1 mode (i.e. fmov.d) for float vector 
loads/stores.  But at the moment that's a pie in the sky.

Cheers,
Oleg

[PING][PATCH, trunk, 4.9, 4.8] Fix PR57653, filename information discarded when using -imacros

2014-06-11 Thread Peter Bergner
I'd like to ping the following patch that fixes PR57653.  This did
bootstrap and regtest with no regressions on powerpc64-linux.

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

Is this ok for trunk, 4.9 and 4.8?

Peter




[C++ Patch] PR 19200 follow up

2014-06-11 Thread Paolo Carlini

Hi,

just reminded the hard way that, for friend *template* declarations, 
cp_parser_init_declarator (vs cp_parser_member_declaration) has to pass 
the actual friend_p information. I'm finishing testing the below.


Thanks,
Paolo.

//
/cp
2014-06-11  Paolo Carlini  

PR c++/19200
* parser.c (cp_parser_init_declarator): Actually pass friend_p
to cp_parser_declarator.

/testsuite
2014-06-11  Paolo Carlini  

PR c++/19200
* g++.dg/parse/friend11.C: New.

Index: cp/parser.c
===
--- cp/parser.c (revision 211479)
+++ cp/parser.c (working copy)
@@ -16545,7 +16545,7 @@ cp_parser_init_declarator (cp_parser* parser,
   bool is_direct_init = false;
   bool is_non_constant_init;
   int ctor_dtor_or_conv_p;
-  bool friend_p;
+  bool friend_p = cp_parser_friend_p (decl_specifiers);
   tree pushed_scope = NULL_TREE;
   bool range_for_decl_p = false;
   bool saved_default_arg_ok_p = parser->default_arg_ok_p;
@@ -16574,7 +16574,7 @@ cp_parser_init_declarator (cp_parser* parser,
 = cp_parser_declarator (parser, CP_PARSER_DECLARATOR_NAMED,
&ctor_dtor_or_conv_p,
/*parenthesized_p=*/NULL,
-   member_p, /*friend_p=*/false);
+   member_p, friend_p);
   /* Gather up the deferred checks.  */
   stop_deferring_access_checks ();
 
@@ -16746,9 +16746,6 @@ cp_parser_init_declarator (cp_parser* parser,
   decl_specifiers->type = integer_type_node;
 }
 
-  /* Check to see whether or not this declaration is a friend.  */
-  friend_p = cp_parser_friend_p (decl_specifiers);
-
   /* Enter the newly declared entry in the symbol table.  If we're
  processing a declaration in a class-specifier, we wait until
  after processing the initializer.  */
Index: testsuite/g++.dg/parse/friend11.C
===
--- testsuite/g++.dg/parse/friend11.C   (revision 0)
+++ testsuite/g++.dg/parse/friend11.C   (working copy)
@@ -0,0 +1,6 @@
+// PR c++/19200
+
+struct S {
+  struct T{};
+  template friend void S(T);
+};


[rx] adjust alignments for RX100/200 families

2014-06-11 Thread DJ Delorie

The RX100/200 families have 4 byte cache lines, vs 8 bytes for the
RX600 family.  Applied.

* config/rx/rx.h (FUNCTION_BOUNDARY): Adjust for RX100/200 4-byte
cache lines.
* config/rx/rx.c (rx_option_override): Likewise.
(rx_align_for_label): Likewise.

Index: config/rx/rx.h
===
--- config/rx/rx.h  (revision 211479)
+++ config/rx/rx.h  (working copy)
@@ -139,13 +139,13 @@
 #endif
 
 #define DEFAULT_SIGNED_CHAR0
 
 /* RX load/store instructions can handle unaligned addresses.  */
 #define STRICT_ALIGNMENT   0
-#define FUNCTION_BOUNDARY  8
+#define FUNCTION_BOUNDARY  ((rx_cpu_type == RX100 || rx_cpu_type 
== RX200) ? 4 : 8)
 #define BIGGEST_ALIGNMENT  32
 #define STACK_BOUNDARY 32
 #define PARM_BOUNDARY  8
 
 #define STACK_GROWS_DOWNWARD   1
 #define FRAME_GROWS_DOWNWARD   0
Index: config/rx/rx.c
===
--- config/rx/rx.c  (revision 211480)
+++ config/rx/rx.c  (working copy)
@@ -2789,17 +2789,17 @@ rx_option_override (void)
   if (flag_strict_volatile_bitfields < 0 && abi_version_at_least(2))
 flag_strict_volatile_bitfields = 1;
 
   rx_override_options_after_change ();
 
   if (align_jumps == 0 && ! optimize_size)
-align_jumps = 3;
+align_jumps = ((rx_cpu_type == RX100 || rx_cpu_type == RX200) ? 2 : 3);
   if (align_loops == 0 && ! optimize_size)
-align_loops = 3;
+align_loops = ((rx_cpu_type == RX100 || rx_cpu_type == RX200) ? 2 : 3);
   if (align_labels == 0 && ! optimize_size)
-align_labels = 3;
+align_labels = ((rx_cpu_type == RX100 || rx_cpu_type == RX200) ? 2 : 3);
 }
 
 
 static bool
 rx_allocate_stack_slots_for_args (void)
 {
@@ -3198,13 +3198,17 @@ rx_align_for_label (rtx lab, int uses_th
  because the delay due to the inserted NOPs would be greater than the delay
  due to the misaligned branch.  If uses_threshold is zero then the 
alignment
  is always useful.  */
   if (LABEL_P (lab) && LABEL_NUSES (lab) < uses_threshold)
 return 0;
 
-  return optimize_size ? 1 : 3;
+  if (optimize_size)
+return 0;
+  if (rx_cpu_type == RX100 || rx_cpu_type == RX200)
+return 2;
+  return 2;
 }
 
 static int
 rx_max_skip_for_label (rtx lab)
 {
   int opsize;


Re: [PATCH, rs6000][trunk, 4.9, 4.8] Fix PR target/61415, long double 128 issues

2014-06-11 Thread Peter Bergner
On Fri, 2014-06-06 at 11:37 -0400, David Edelsohn wrote:
> On Thu, Jun 5, 2014 at 3:57 PM, Peter Bergner  wrote:
> > Is this also ok for the FSF 4.9 and FSF 4.8 branches?  Without the gcc/
> > changes, we hit an ICE whenever we call __builtin_pack_longdouble and
> > __builtin_unpack_longdouble when -mlong-double-64 is in effect.
[snip]
> > gcc/
> > PR target/61415
> > * config/rs6000/rs6000-builtin.def (BU_MISC_1): Delete.
> > (BU_MISC_2): Rename to ...
> > (BU_LDBL128_2): ... this.
> > * config/rs6000/rs6000.h (RS6000_BTM_LDBL128): New define.
> > (RS6000_BTM_COMMON): Add RS6000_BTM_LDBL128.
> > * config/rs6000/rs6000.c (rs6000_builtin_mask_calculate): Handle
> > RS6000_BTM_LDBL128.
> > (rs6000_invalid_builtin): Add long double 128-bit builtin support.
> > (rs6000_builtin_mask_names): Add RS6000_BTM_LDBL128.
> > * config/rs6000/rs6000.md (unpacktf_0): Remove define)expand.
> > (unpacktf_1): Likewise.
> > * doc/extend.texi (__builtin_longdouble_dw0): Remove documentation.
> > (__builtin_longdouble_dw1): Likewise.
> > * doc/sourcebuild.texi (longdouble128): Document.
> >
> > gcc/testsuite/
> > PR target/61415
> > * lib/target-supports.exp (check_effective_target_longdouble128): 
> > New.
> > * gcc.target/powerpc/pack02.c: Use it.
> > * gcc.target/powerpc/tfmode_off.c: Likewise.
> 
> This is okay with me, as long as there are no objections from RMs
> about removing the private APIs that should not have been added to FSF
> GCC.

...back from a short vacation.

Richard and/or Jakub, do either of you have an objection to the above
patch going into the FSF 4.9 and 4.8 branches?

Peter





Re: [PATCH, PR61446] Fix mode for register copy in REE pass

2014-06-11 Thread Uros Bizjak
On Wed, Jun 11, 2014 at 6:11 PM, Ilya Enkovich  wrote:
> On 11 Jun 14:59, Uros Bizjak wrote:
>> On Tue, Jun 10, 2014 at 3:45 PM, Dominique Dhumieres  
>> wrote:
>> >> This patch fixes PR61446. ...
>> >
>> > Confirmed, it also allows to bootstrap Core* targets.
>> > Could it be reviewed and committed ASAP?
>>
>> > 2014-06-09  Ilya Enkovich  
>> >
>> > PR 61446
>> > * ree.c (find_and_remove_re): Narrow mode for register copy
>> > if required.
>>
>> Please also add the testcase form the PR.
>>
>> (I am not RTL reviewer, so I can't approve the patch).
>>
>> Uros.
>
> Hi,
>
> rgis one is the same but with testcase added.
>
> Bootstrapped and tested on linux-x86_64.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-06-11  Ilya Enkovich  
>
> PR 61446
> * ree.c (find_and_remove_re): Narrow mode for register copy
> if required.
>
> gcc/testsuite/
>
> 2014-06-11  Ilya Enkovich  
>
>  * gcc.target/i386/pr61446.c : New.
>
>
> diff --git a/gcc/ree.c b/gcc/ree.c
> index ade413e..6d34764 100644
> --- a/gcc/ree.c
> +++ b/gcc/ree.c
> @@ -1088,14 +1088,24 @@ find_and_remove_re (void)
>/* Use the mode of the destination of the defining insn
>  for the mode of the copy.  This is necessary if the
>  defining insn was used to eliminate a second extension
> -that was wider than the first.  */
> +that was wider than the first.  Truncate mode if it is
> +too wide for destination reg.  */
>rtx sub_rtx = *get_sub_rtx (def_insn);
>rtx pat = PATTERN (curr_insn);
> -  rtx new_dst = gen_rtx_REG (GET_MODE (SET_DEST (sub_rtx)),
> -REGNO (XEXP (SET_SRC (pat), 0)));
> -  rtx new_src = gen_rtx_REG (GET_MODE (SET_DEST (sub_rtx)),
> -REGNO (SET_DEST (pat)));
> -  rtx set = gen_rtx_SET (VOIDmode, new_dst, new_src);
> +  unsigned int regno = REGNO (XEXP (SET_SRC (pat), 0));
> +  enum machine_mode mode = GET_MODE (SET_DEST (sub_rtx));
> +  rtx new_dst, new_src, set;
> +
> +  if (HARD_REGNO_NREGS (regno, mode) != 1)
> +   {
> + mode = GET_CLASS_NARROWEST_MODE (GET_MODE_CLASS (mode));
> + while (HARD_REGNO_NREGS (regno, GET_MODE_WIDER_MODE (mode)) == 1)
> +   mode = GET_MODE_WIDER_MODE (mode);
> +   }
> +
> +  new_dst = gen_rtx_REG (mode, REGNO (XEXP (SET_SRC (pat), 0)));
> +  new_src = gen_rtx_REG (mode, REGNO (SET_DEST (pat)));
> +  set = gen_rtx_SET (VOIDmode, new_dst, new_src);
>emit_insn_after (set, def_insn);
>  }
>
> diff --git a/gcc/testsuite/gcc.target/i386/pr61446.c 
> b/gcc/testsuite/gcc.target/i386/pr61446.c
> new file mode 100644
> index 000..8537cdb
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/pr61446.c
> @@ -0,0 +1,14 @@
> +/* PR rtl-optimization/61446 */
> +
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -m32 -march=corei7" } */

This should read:

/* { dg-do compile { target { ia32 } } } */
/* { dg-options "-O2 -march=corei7 -mfpmath=387" } */

The x86 part is OK with this change.

Uros.


Re: [PATCH] PR 61642

2014-06-11 Thread Martin Liška


On 06/11/2014 02:01 PM, Richard Biener wrote:

On Wed, Jun 11, 2014 at 1:58 PM, Martin Liška  wrote:

Hello,
I send patch for PR61642.

61462?


Hello,
   that's bogus, I am not a visionary that creates a patch for a future 
bug :)


Thanks,
Martin




Changelog:
2014-06-11  Martin Liska  


PR ipa/61462

 * ipa-prop.c (ipa_make_edge_direct_to_target): Check that gimple call
 statement is reachable.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.

Ready for trunk?

Ok with those adjustments.

Richard.


Martin




[PATCH, PR 61186]

2014-06-11 Thread Martin Jambor
Hi,

in PR 61186 valgrind reports use of uninitialized value.  The reason
is that walk_polymorphic_call_targets uses cache_token before it
checks return value of possible_polymorphic_call_targets which however
does not produce a cache token if it fails early.  This is not the
only place where we make this mistake so I decided to store NULL to
cache_token in these cases instead.  I understand this slightly
controversial as it means that the callers making this error will now
end up with a NULL pointer in their pointer_sets (which they use in
order not to process the same results multiple times).  It just seemed
quite a lot easier and also avoids making the same mistake elsewhere
in future.

Bootstrapped and tested on x86_64-linux, I have of course also
verified it fixes the bug.  OK for trunk?  And perhaps also the 4.9
branch?

Thanks,

Martin


2014-06-11  Martin Jambor  

PR ipa/61186
* ipa-devirt.c (possible_polymorphic_call_targets): Store NULL to
cache_token if returning early.

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index d733461..a90d1dc 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1603,6 +1603,8 @@ possible_polymorphic_call_targets (tree otr_type,
 {
   if (completep)
*completep = false;
+  if (cache_token)
+   *cache_token = NULL;
   if (nonconstruction_targetsp)
*nonconstruction_targetsp = 0;
   return nodes;
@@ -1613,6 +1615,8 @@ possible_polymorphic_call_targets (tree otr_type,
 {
   if (completep)
*completep = true;
+  if (cache_token)
+   *cache_token = NULL;
   if (nonconstruction_targetsp)
*nonconstruction_targetsp = 0;
   return nodes;
@@ -1626,6 +1630,8 @@ possible_polymorphic_call_targets (tree otr_type,
 {
   if (completep)
*completep = false;
+  if (cache_token)
+   *cache_token = NULL;
   if (nonconstruction_targetsp)
*nonconstruction_targetsp = 0;
   return nodes;


Re: [patch] libstdc++/29988 Rb_Tree reuse allocated nodes

2014-06-11 Thread François Dumont
For the testsuite allocator I though that for an internal allocator 
used in our tests it was ok. But alright, I will make it better and 
compatible with SimpleAllocator.



On 11/06/2014 14:02, Jonathan Wakely wrote:

Index: include/bits/stl_tree.h
===
--- include/bits/stl_tree.h(revision 211388)
+++ include/bits/stl_tree.h(working copy)
@@ -330,6 +330,111 @@
   const _Rb_tree_const_iterator<_Val>& __y) 
_GLIBCXX_NOEXCEPT

{ return __x._M_node != __y._M_node; }

+  // Functor recycling a pool of nodes and using allocation once the 
pool is

+  // empty.
+  template
+struct _Rb_tree_reuse_or_alloc_node
+{


Is there a reason to define this and _Rb_tree_alloc_node as
namespace-scope class templates, rather than non-template members of
_Rb_tree?
Just to limit amount of code within _Rb_tree. I wanted to do 
something like in _Hashtable where many code is isolated in different 
types aggregated to build the final _Hashtable type. But it looks like 
you prefer it nested so I will do so.


They wouldn't need to be friends if they were members, and you
wouldn't need a typedef for _Rb_tree_alloc_node<_Rb_tree> because it
would just be called _Rb_tree_alloc_node.


+private:
+  typedef _RbTree __rb_tree;


This typedef doesn't seem useful, it's only used once and is more
characters than "_RbTree". If the class was a member of _Rb_tree it
could just use that name.


+  typedef _Rb_tree_node __node_type;


If it was a member the value_type name would be in scope.


+public:
+  _Rb_tree_reuse_or_alloc_node(const _Rb_tree_node_base& __header,
+   __rb_tree& __t)
+: _M_root(__header._M_parent), _M_nodes(__header._M_right), 
_M_t(__t)

+  {
+if (_M_root)
+  _M_root->_M_parent = 0;
+else
+  _M_nodes = 0;
+  }
+
+  ~_Rb_tree_reuse_or_alloc_node()
+  { _M_t._M_erase(static_cast<__node_type*>(_M_root)); }


This type needs to be non-copyable, or unintentional copies would
erase all the nodes and leave nothing to be reused (which might be
difficult to detect as it would only affect performance, not
correctness).
Yes, sure, like in the equivalent _Hashtable types. I guess I 
didn't do so here because we might not be in c++11 so it is not as 
convenient to forbid its usage.




+  template
+__node_type*
+#if __cplusplus < 201103L
+operator()(const _Arg& __arg) const
+#else
+operator()(_Arg&& __arg) const
+#endif


Does this need to be const?

I don't think it does (if you change the function templates taking a
const _NodeGen& to take _NodeGen& instead).


Sometimes I used lambdas, I am not sure but I think it forced me to take 
functors as const lvalue reference and so the const qualification on the 
operator.




That means the members of this type don't need to be 'mutable'.



+  typedef _Rb_tree_node_base __node_base;


I'm not sure this typedef is useful either, it just means an extra
name to remember when reading the code, when _Rb_tree_node_base is
already in scope and probably understood by readers of the code.


+  mutable __node_base* _M_root;
+  mutable __node_base* _M_nodes;


These members should be of type _Rb_tree::_Base_ptr, not __node_base*,
because that's the type _Rb_tree::_M_right is declared as.

I have a work-in-progress patch to make _Rb_tree use
allocator_traits<_Node_allocator>::pointer for _Link_type, which
might not be the same type as _Rb_tree_node*, so it is important
to consistently use the _Base_ptr and _Link_type typedefs not the
underlying types they refer to (because those underlying types are
going to change soon).


+  _RbTree& _M_t;
+};
+
+  // Functor similar to the previous one but without any pool of 
node to recycle.

+  template
+struct _Rb_tree_alloc_node


Again, I think this should be a member of _Rb_tree.


+{
+private:
+  typedef _Rb_tree_node __node_type;


This typedef should be removed.


+
+public:
+  _Rb_tree_alloc_node(_RbTree& __t)
+: _M_t(__t) { }
+
+  template
+__node_type*


This function should return _Rb_tree::_Link_type because that's what
_M_create_node returns.


+#if __cplusplus < 201103L
+operator()(const _Arg& __arg) const
+#else
+operator()(_Arg&& __arg) const
+#endif
+{ return _M_t._M_create_node(_GLIBCXX_FORWARD(_Arg, __arg)); }
@@ -349,6 +454,12 @@
rebind<_Rb_tree_node<_Val> >::other _Node_allocator;

  typedef __gnu_cxx::__alloc_traits<_Node_allocator> _Alloc_traits;
+  template
+friend struct _Rb_tree_alloc_node;
+  typedef _Rb_tree_alloc_node<_Rb_tree> __alloc_node_t;
+  template
+friend struct _Rb_tree_reuse_or_alloc_node;
+  typedef _Rb_tree_reuse_or_alloc_node<_Rb_tree> 
__reuse_or_alloc_node_t;


These friend declarations and typedefs become unnecessary.


@@ -389,44 +500,55 @@
  { _Alloc_traits::deallocate(_M_get_Node_allocator(), __p, 1); }

#if __cplus

Re: [PATCH] Trust TREE_ADDRESSABLE

2014-06-11 Thread Jan Hubicka
> 
> Why not just make the change to may_be_aliased in LTO mode, with a comment 
> saying that TREE_PUBLIC and DECL_EXTERNAL aren't fully correct any longer?

They are fully correct to the partition being compiled BTW.

Honza


Re: [PATCH] Trust TREE_ADDRESSABLE

2014-06-11 Thread Jan Hubicka
> > Sure.  Still currently TREE_ADDRESSABLE on TREE_PUBLIC/DECL_EXTERNAL
> > VAR_DECLs carries no useful information, so I consider the bit unused.
> 
> I guess that's true for the middle-end in non-LTO mode at this point.
> But then the new approach shouldn't be make correctness depend on its setting 
> in the front-ends, that's too error-prone IMO.
> 
> > I propose to add semantics for it.
> 
> Fine with me, as long as it's centralized somewhere in the middle-end.

If we want to give frontends a way to pass information that address of a given
global object is not taken (apparently useful for Ada and its alias attribute),
then I do not think we are looking for middle-end only solution.

If we really do not want to revisit TREE_ADDRESSABLE in frontends, we can do
the following:
 1) change semantics of addressable flag on global variables in a way Richard
did, document it is initialized only after symbol table is built
 2) add code to cgraph construction to set TREE_ADDRESSABLE on every global
variable it sees.
IPA visibility is run before early optimizations. I suppose we can set it
there.  I.e. in function_and_variable_visibility whenever we set
externally_visible and we have !in_lto_p
It is bit of hack.
 3) perhaps add some way to avoid 2) on objects we want - apparenlty we now
have DECL_NONALIASED that may be useful for this.

Honza


[rx] further optimize alignment with -Os

2014-06-11 Thread DJ Delorie

Minor tweak to space optimization.  Committed.

* config/rx/rx.c (rx_max_skip_for_label): Don't skip anything if -Os.

Index: config/rx/rx.c
===
--- config/rx/rx.c  (revision 211479)
+++ config/rx/rx.c  (working copy)
@@ -3207,12 +3207,15 @@ rx_align_for_label (rtx lab, int uses_th
 static int
 rx_max_skip_for_label (rtx lab)
 {
   int opsize;
   rtx op;
 
+  if (optimize_size)
+return 0;
+
   if (lab == NULL_RTX)
 return 0;
 
   op = lab;
   do
 {


Re: [PATCH][RX] Patch to correct the functionality of compiler option -falign-labels=n

2014-06-11 Thread DJ Delorie

> Please review the patch and let me know if there should be any modifications
> in it?

Have you checked the other alignment macros to see if they need to be
fixed too?

* config/rx/rx.h (Corrected macro LABEL_ALIGN).

This should be :

* config/rx/rx.h (LABEL_ALIGN): 

It's always:

* file (function/macro): Description.

Otherwise OK.


RFC: PR target/61296: Excessive alignment in ix86_data_alignment

2014-06-11 Thread H.J. Lu
ix86_data_alignment returns 32 bytes or the cache line size when getting
the optimized alignment for a static aggregate variable bigger than 32
bytes or the cache line size.  The increased alignment only applies to
the static variable in the same compilation unit while not optimizing for
space.  If excessive alignment over natural alignment provides very
little performance improvements, we should avoid it to reduce memory
size. This patch does 2 things:

1. Remove the cache line size alignment introduced in GCC 4.9.
2. Limit the alignment increase to word size like -Os.

Kirill, can you measure its performance impact on SPEC CPU 2006 with
-O2 and -O3?

Thanks.

H.J.
---
2014-06-11  H.J. Lu  

PR target/61296
* config/i386/i386.c (ix86_data_alignment): Only increase
alignment to word size for optimization.
* config/i386/i386.h (DATA_ALIGNMENT): Update comments.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 2050aaf..3a571bf 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -26617,42 +26617,27 @@ ix86_data_alignment (tree type, int align, bool opt)
 {
   /* GCC 4.8 and earlier used to incorrectly assume this alignment even
  for symbols from other compilation units or symbols that don't need
- to bind locally.  In order to preserve some ABI compatibility with
- those compilers, ensure we don't decrease alignment from what we
- used to assume.  */
+ to bind locally.  When aligning for optimization, we align static
+ variable to the word size.  GCC 4.9 and earlier align static
+ aggregate variables to 32 bytes or the cache line size.  But it
+ creates data size without very little performance improvements
+ over natural data alignments.  */
 
-  int max_align_compat
-= optimize_size ? BITS_PER_WORD : MIN (256, MAX_OFILE_ALIGNMENT);
-
-  /* A data structure, equal or greater than the size of a cache line
- (64 bytes in the Pentium 4 and other recent Intel processors, including
- processors based on Intel Core microarchitecture) should be aligned
- so that its base address is a multiple of a cache line size.  */
-
-  int max_align
-= MIN ((unsigned) ix86_tune_cost->prefetch_block * 8, MAX_OFILE_ALIGNMENT);
-
-  if (max_align < BITS_PER_WORD)
-max_align = BITS_PER_WORD;
+  int max_align = BITS_PER_WORD;
 
   if (opt
   && AGGREGATE_TYPE_P (type)
   && TYPE_SIZE (type)
-  && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST)
-{
-  if (wi::geu_p (TYPE_SIZE (type), max_align_compat)
- && align < max_align_compat)
-   align = max_align_compat;
-   if (wi::geu_p (TYPE_SIZE (type), max_align)
-  && align < max_align)
-align = max_align;
-}
+  && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
+  && wi::geu_p (TYPE_SIZE (type), max_align)
+  && align < max_align)
+align = max_align;
 
   /* x86-64 ABI requires arrays greater than 16 bytes to be aligned
  to 16byte boundary.  */
   if (TARGET_64BIT)
 {
-  if ((opt ? AGGREGATE_TYPE_P (type) : TREE_CODE (type) == ARRAY_TYPE)
+  if (TREE_CODE (type) == ARRAY_TYPE
  && TYPE_SIZE (type)
  && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
  && wi::geu_p (TYPE_SIZE (type), 128)
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index a4009d3..22af036 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -837,12 +837,7 @@ extern const char *host_detect_local_cpu (int argc, const 
char **argv);
the object would ordinarily have.  The value of this macro is used
instead of that alignment to align the object.
 
-   If this macro is not defined, then ALIGN is used.
-
-   One use of this macro is to increase alignment of medium-size
-   data to make it all fit in fewer cache lines.  Another is to
-   cause character arrays to be word-aligned so that `strcpy' calls
-   that copy constants to character arrays can be done inline.  */
+   If this macro is not defined, then ALIGN is used.  */
 
 #define DATA_ALIGNMENT(TYPE, ALIGN) \
   ix86_data_alignment ((TYPE), (ALIGN), true)


[wwwdocs, patch, committed] Changed some http://gcc.gnu.org to https

2014-06-11 Thread Tobias Burnus

Dear all,

given that the webserver now redirects http accesses to https, it makes 
sense that all references already use https.


Committed as obvious for the most important files.

Tobias
Index: style.mhtml
===
RCS file: /cvs/gcc/wwwdocs/htdocs/style.mhtml,v
retrieving revision 1.123
diff -u -r1.123 style.mhtml
--- style.mhtml	24 Nov 2013 17:17:08 -	1.123
+++ style.mhtml	11 Jun 2014 17:45:01 -
@@ -67,13 +67,13 @@
   
 
-http://gcc.gnu.org/favicon.ico"; />
-http://gcc.gnu.org/gcc.css"; />
+https://gcc.gnu.org/favicon.ico"; />
+https://gcc.gnu.org/gcc.css"; />
   >
   
 
-http://gcc.gnu.org/favicon.ico";>
+https://gcc.gnu.org/favicon.ico";>
 
   >
  >
@@ -142,8 +142,8 @@
  >
 libstdc++ Home
 GCC Home
-http://gcc.gnu.org/onlinedocs/libstdc++/faq.html";>FAQ
-http://gcc.gnu.org/onlinedocs/libstdc++/";>Documentation
+https://gcc.gnu.org/onlinedocs/libstdc++/faq.html";>FAQ
+https://gcc.gnu.org/onlinedocs/libstdc++/";>Documentation
 
 
>
@@ -156,7 +156,7 @@
   Releases
   Snapshots
   Mailing lists
-  http://gcc.gnu.org/onlinedocs/gcc/Contributors.html";>Contributors
+  https://gcc.gnu.org/onlinedocs/gcc/Contributors.html";>Contributors
   Steering Committee
   https://twitter.com/gnutools";>
 
>Documentation
>
-  http://gcc.gnu.org/install/";>Installation
-  · http://gcc.gnu.org/install/specific.html";>Platforms
-  · http://gcc.gnu.org/install/test.html";>Testing
+  https://gcc.gnu.org/install/";>Installation
+  · https://gcc.gnu.org/install/specific.html";>Platforms
+  · https://gcc.gnu.org/install/test.html";>Testing
   Manual
   FAQ
-  http://gcc.gnu.org/wiki";>Wiki
+  https://gcc.gnu.org/wiki";>Wiki
   Further Readings
   
   
@@ -188,7 +188,7 @@
>Download
>
   Mirror sites
-  http://gcc.gnu.org/install/binaries.html";>Binaries
+  https://gcc.gnu.org/install/binaries.html";>Binaries
   
   
 
@@ -196,7 +196,7 @@
>"Live" Sources
>
   SVN read access
-  http://gcc.gnu.org/wiki/GitMirror";>Git read access
+  https://gcc.gnu.org/wiki/GitMirror";>Git read access
   Rsync read access
   SVN write access
   
@@ -224,7 +224,7 @@
>
   Known bugs
   How to report
-  http://gcc.gnu.org/bugzilla/";>Bug database
+  https://gcc.gnu.org/bugzilla/";>Bug database
   · Management
   
   
@@ -243,12 +243,12 @@
 
 For questions related to the use of GCC,
 please consult these web pages and the
-http://gcc.gnu.org/onlinedocs/";>GCC manuals. If that fails,
+https://gcc.gnu.org/onlinedocs/";>GCC manuals. If that fails,
 the gcc-h...@gcc.gnu.org
 mailing list might help.
 Comments on these web pages and the development of GCC are welcome on our
 developer list at g...@gcc.gnu.org.
-All of http://gcc.gnu.org/lists.html";>our lists
+All of https://gcc.gnu.org/lists.html";>our lists
 have public archives.
 
 
@@ -258,7 +258,7 @@
 permitted in any medium, provided this notice is preserved.
 
 These pages are
-http://gcc.gnu.org/about.html";>maintained by the GCC team.
+https://gcc.gnu.org/about.html";>maintained by the GCC team.
 Last modified http://validator.w3.org/check/referer";>.
 
Index: index.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/index.html,v
retrieving revision 1.921
diff -u -r1.921 index.html
--- index.html	11 Jun 2014 14:40:49 -	1.921
+++ index.html	11 Jun 2014 17:45:01 -
@@ -114,7 +114,7 @@
 
 
 
-http://gcc.gnu.org/news.html";>Older news |
+https://gcc.gnu.org/news.html";>Older news |
 
 Any additions?  Don't be shy, send them to ger...@pfeifer.com!
 
@@ -135,16 +135,16 @@
 
   Status:
   
-  http://gcc.gnu.org/ml/gcc/2014-04/msg00196.html";>2014-04-22
+  https://gcc.gnu.org/ml/gcc/2014-04/msg00196.html";>2014-04-22
   
   (regression fixes and docs only).
   
   
   http://gcc.gnu.org/bugzilla/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=4.9&target_milestone=4.7.4&target_milestone=4.8.4&target_milestone=4.9.1&known_to_fail_type=allwordssubstr&known_to_work_type=allwordssubstr&long_desc_type=allwordssubstr&long_desc=&bug_file_loc_type=allwordssubstr&bug_file_loc=&gcchost_type=allwordssubstr&gcchost=&gcctarget_type=allwordssubstr&gcctarget=&gccbuild_type=allwordssubstr&gccbuild=&keywords_type=allwords&keywords=&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=SUSPENDED&bug_status=WAITING&bug_status=REOPENED&priority=P1&priority=P2&priority=P3&emailtype1=substring&email1=&emailtype2=substring&email2=&bugidtype=include&bug_id=&votes=&chfieldfrom=&chfieldto=Now&chfieldvalue=&cmdtype=doit&order=Reuse+same+sort+as+last+time&field0-0-0=noop&type0-0-0=noop&value0-0-0=";>Serious
+  href="https://gcc.gnu.org/bugzilla/buglist.cgi?query_format=advanced&short_desc_type=allwordssubstr&short_desc=4.9&target_milestone=4.7.4&target_milestone=4.8.4&target_milestone=4.9.1&known_to_fail_type=allwordssubstr&known_to_work_type=allwordssubstr

Re: [GOOGLE] Emit linkage_name when built with -gmlt and for abstract decls

2014-06-11 Thread Dehao Chen
On Wed, Jun 11, 2014 at 10:38 AM, Cary Coutant  wrote:
>> This will increase c++ g1/g2 binary size a little. For all spec
>> cint2006 benchmarks, the binary size change is shown below.
>>
>> 400 0.00% 0.00% 0.00% 0.00%
>> 401 0.00% 0.00% 0.00% 0.00%
>> 403 0.00% 0.00% 0.00% 0.00%
>> 429 0.00% 0.00% 0.00% 0.00%
>> 445 0.00% 0.00% 0.00% 0.00%
>> 456 0.00% 0.00% 0.00% 0.00%
>> 458 0.00% 0.00% 0.00% 0.00%
>> 462 0.00% 0.00% 0.00% 0.00%
>> 464 0.00% 0.00% 0.00% 0.00%
>> 471 1.28% 0.20% 1.23% 0.15%
>> 473 0.36% 0.00% 0.35% 0.01%
>> 483 12.79% 1.73% 13.65% 2.12%
>> geomean 1.14% 0.16% 1.20% 0.19%
>>
>> The 4 columns are:
>>
>> o0 -g1
>> o0 -g2
>> o2 -g1
>> o2 -g2
>
> We expect this to affect C++ code, so only the last three of those
> benchmarks are really meaningful -- if you omit the C benchmarks, the
> geomean will be a bit higher. Why, I wonder, is 483 affected so much
> more than 471 and 473?

483 is heavily templated code with very deep inline stacks. And the
function name for 483 is also much longer than 471 and 473.

Dehao

>
> At any rate, -g2 doesn't seem to be affected too much. I wish the -g1
> numbers for 483 weren't quite so high, but I understand the importance
> for FDO, and there isn't a lot of current usage of -g1, so it's OK
> with me for trunk. I hope we can fine-tune this a bit in the future,
> though.
>
> -cary


Re: [GOOGLE] Emit linkage_name when built with -gmlt and for abstract decls

2014-06-11 Thread Cary Coutant
> This will increase c++ g1/g2 binary size a little. For all spec
> cint2006 benchmarks, the binary size change is shown below.
>
> 400 0.00% 0.00% 0.00% 0.00%
> 401 0.00% 0.00% 0.00% 0.00%
> 403 0.00% 0.00% 0.00% 0.00%
> 429 0.00% 0.00% 0.00% 0.00%
> 445 0.00% 0.00% 0.00% 0.00%
> 456 0.00% 0.00% 0.00% 0.00%
> 458 0.00% 0.00% 0.00% 0.00%
> 462 0.00% 0.00% 0.00% 0.00%
> 464 0.00% 0.00% 0.00% 0.00%
> 471 1.28% 0.20% 1.23% 0.15%
> 473 0.36% 0.00% 0.35% 0.01%
> 483 12.79% 1.73% 13.65% 2.12%
> geomean 1.14% 0.16% 1.20% 0.19%
>
> The 4 columns are:
>
> o0 -g1
> o0 -g2
> o2 -g1
> o2 -g2

We expect this to affect C++ code, so only the last three of those
benchmarks are really meaningful -- if you omit the C benchmarks, the
geomean will be a bit higher. Why, I wonder, is 483 affected so much
more than 471 and 473?

At any rate, -g2 doesn't seem to be affected too much. I wish the -g1
numbers for 483 weren't quite so high, but I understand the importance
for FDO, and there isn't a lot of current usage of -g1, so it's OK
with me for trunk. I hope we can fine-tune this a bit in the future,
though.

-cary


Re: [GOOGLE] Emit linkage_name when built with -gmlt and for abstract decls

2014-06-11 Thread Dehao Chen
ping...

Dehao


On Fri, May 30, 2014 at 4:13 PM, Dehao Chen  wrote:
> This will increase c++ g1/g2 binary size a little. For all spec
> cint2006 benchmarks, the binary size change is shown below.
>
> 400 0.00% 0.00% 0.00% 0.00%
> 401 0.00% 0.00% 0.00% 0.00%
> 403 0.00% 0.00% 0.00% 0.00%
> 429 0.00% 0.00% 0.00% 0.00%
> 445 0.00% 0.00% 0.00% 0.00%
> 456 0.00% 0.00% 0.00% 0.00%
> 458 0.00% 0.00% 0.00% 0.00%
> 462 0.00% 0.00% 0.00% 0.00%
> 464 0.00% 0.00% 0.00% 0.00%
> 471 1.28% 0.20% 1.23% 0.15%
> 473 0.36% 0.00% 0.35% 0.01%
> 483 12.79% 1.73% 13.65% 2.12%
> geomean 1.14% 0.16% 1.20% 0.19%
>
> The 4 columns are:
>
> o0 -g1
> o0 -g2
> o2 -g1
> o2 -g2
>
> Thanks,
> Dehao
>
> On Fri, May 30, 2014 at 3:23 PM, Dehao Chen  wrote:
>> As we are pushing AutoFDO patch upstream, is this patch OK for trunk?
>>
>> Thanks,
>> Dehao
>>
>> On Mon, Aug 19, 2013 at 1:32 PM, Dehao Chen  wrote:
>>> After rerunning test, this will fail one gcc regression test. So I
>>> updated the patch to make sure all test will pass:
>>>
>>> Index: gcc/dwarf2out.c
>>> ===
>>> --- gcc/dwarf2out.c (revision 201850)
>>> +++ gcc/dwarf2out.c (working copy)
>>> @@ -16545,10 +16545,9 @@ add_src_coords_attributes (dw_die_ref die, tree de
>>>  static void
>>>  add_linkage_name (dw_die_ref die, tree decl)
>>>  {
>>> -  if (debug_info_level > DINFO_LEVEL_TERSE
>>> +  if (debug_info_level > DINFO_LEVEL_NONE
>>>&& (TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == 
>>> VAR_DECL)
>>>&& TREE_PUBLIC (decl)
>>> -  && !DECL_ABSTRACT (decl)
>>>&& !(TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
>>>&& die->die_tag != DW_TAG_member)
>>>  {
>>> Index: gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C
>>> ===
>>> --- gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C (revision 201850)
>>> +++ gcc/testsuite/g++.dg/debug/dwarf2/cdtor-1.C (working copy)
>>> @@ -14,4 +14,4 @@ main()
>>>K k;
>>>  }
>>>
>>> -// { dg-final {scan-assembler-times " DW_AT_\[MIPS_\]*linkage_name" 2 } }
>>> +// { dg-final {scan-assembler-times " DW_AT_\[MIPS_\]*linkage_name" 4 } }
>>>
>>> On Mon, Aug 19, 2013 at 9:22 AM, Cary Coutant  wrote:
> This patch emits linkage_name at -gmlt. It also make sure abstract
> decls' linkage_names are emitted so that inlined functions can also
> find linkage name.
>
> Bootstrapped and passed regression test.
>
> OK for google branches?

 OK.

 -cary


[c++-concepts] Terse notation

2014-06-11 Thread Andrew Sutton
Sorry if you receive multiple versions of this. The original message
bounced (formatting).

Attached is a patch that greatly improves terse notation support for
generic functions and the use of concept names in
constrained-type-specifiers. There are actually 2 patches. The second
includes unit tests. Mostly, this is just cleaning up a previous
(hacky) commit. Most of the work is done in the parser, since terse
notation is largely syntactic.

Generic functions can be declared with auto and concept names in
namespace and class scope. Definitions can be matched to declarations,
and overloading is supported.

Various restrictions are put in place to prevent things like this:

  template // C constrains a type argument!

That holds when C constrains a template template argument also.

The patch also includes the initial parsing and semantic hooks for
handling constrained-type-specifiers in compound requirements:

  {expr} -> const auto&; // unnamed result type must form a valid type
  {expr} -> C; // unnamed result type satisfies the concept C

Semantics will come later.

Changelog:

2014-06-11  Andrew Sutton  
* gcc/cp/cp-tree.h (build_constrained_parameter): Renamed fro
describe_tempalte_parm.
* gcc/cp/parser.c (cp_check_constrained_type_parm): New. Prevent
declaration of cv-qualifed or non-id types.
(cp_constrained_type_template_parm): Renamed, check for invalid
specifiers.
(cp_constrained_template_template_parm): Renamed, check for invalid
specifiers.
(cp_constrained_non_type_tmeplate_parm): Renamed.
(cp_finish_constrained-parameter): Support checking of decarlarations.
(cp_check_concept_name): Renamed. Add initial support for auto
and constrained-type-specifiers in compound requirements.
(cp_parser_nonclass_name): Only check for concept names if -fconcepts
is on.
(cp_manage_requirements): New RAII guard for managinging the
current_template_reqs variable during declaration parsing.
(cp_paresr_trailing_requirements): Refactored common parsing
requirements from cp_parser_init_declarator and
cp_parser_member_declarator. Take terse constraints from implicit
parameter declarations.
(cp_parser_init_declarator): Cleanup, refactor requirement logic.
(cp_parser_type_id_1): Allow auto in compound requirements.
(cp_parser_member_declaration): Cleanup, refactor requirement logic.
(cp_parser_compound_requirement): Note parsing state for the
trailing-type-id so we can get auto and constrained-type-specifiers.
(cp_parser_function_definition_after_decl): Remove broken constraint
association.
* gcc/cp/parser.h (cp_parser): New member.
* gcc/cp/constraint.cc (finish_validtype_expr): Initial (non-)handling
of auto in type requirements.
(finish_concept_name): Moved to cp_check_concept_name.
* gcc/testuite/g++.dg/concepts/constrained-parm.C: New test.
* gcc/testuite/g++.dg/concepts/generic-fn.C: New test.

Andrew Sutton
Index: constrained-parm.C
===
--- constrained-parm.C	(revision 0)
+++ constrained-parm.C	(revision 0)
@@ -0,0 +1,13 @@
+// { dg-options "-std=c++1y" }
+
+template
+  concept bool C() { return __is_class(T); }
+
+template struct S1 { };// { dg-error "cv-qualified" }
+template struct S2 { }; // { dg-error "cv-qualified" }
+template struct S3 { }; // { dg-error "invalid" }
+template struct S3a { };  // { dg-error "invalid" }
+template struct S3b { };  // { dg-error "invalid" }
+template struct S4 { }; // { dg-error "invalid" }
+template struct S4 { };   // { dg-error "invalid|expected" } 
+template struct S5 { };  // { dg-error "invalid" }
Index: generic-fn.C
===
--- generic-fn.C	(revision 0)
+++ generic-fn.C	(revision 0)
@@ -0,0 +1,108 @@
+// { dg-options "-std=c++1y" }
+
+#include 
+
+template
+  concept bool C() { return __is_class(T); }
+
+struct S { } s;
+
+int called;
+
+// Basic terse notation
+void f(auto x) { called = 1; }
+void g(C x) { called = 2; }
+
+// Overloading generic functions
+void h(auto x) { called = 1; }
+void h(C x) { called = 2; }
+
+void p(auto x);
+void p(C x);
+
+struct S1 {
+  void f1(auto x) { called = 1; }
+  void f2(C x) { called = 2; }
+
+  void f3(auto x) { called = 1; }
+  void f3(C x) { called = 2; }
+};
+
+template
+  struct S2 {
+void f1(auto x) { called = 1; }
+void f2(C x) { called = 2; }
+
+void f3(auto x) { called = 1; }
+void f3(C x) { called = 2; }
+
+void h1(auto x);
+void h2(C x);
+
+void h3(auto x);
+void h3(C x);
+
+template
+  void g1(T t, U u) { called = 1; }
+
+template
+  void g2(T t, U u);
+  };
+
+
+int main() {
+  f(0); assert(called == 1);
+  g(s); assert(called == 2);
+
+  h(0); assert(called == 1);

Re: [PATCH] GCC/MMIX: Remove orphan mmix_asm_output_source_line prototype

2014-06-11 Thread Maciej W. Rozycki
On Wed, 11 Jun 2014, Hans-Peter Nilsson wrote:

> >  I've noticed mmix_asm_output_source_line is declared, but nowhere
> > defined.  OK to remove the prototype?
> 
> Sure; in fact, obvious.

 Applied, thanks.

  Maciej


Re: [ARM] Fix build failure due to movsi_compare0 (PR 61430)

2014-06-11 Thread Chung-Lin Tang
On 2014/6/11 下午 06:32, James Greenhalgh wrote:
> 
> Hi,
> 
> A recent change somewhere exposed a latent bug between LRA and the definition
> of the movsi_compare0 pattern.
> 
> This pattern ties the source and destination register of a set together
> a (match_dup) and register constraints:
> 
>[(set (reg:CC CC_REGNUM)
>   (compare:CC (match_operand:SI 1 "s_register_operand" "0,r")
>   (const_int 0)))
> (set (match_operand:SI 0 "s_register_operand" "=r,r")
>   (match_dup 1))]
> 
> This confuses LRA which expects the source and destination register of
> a set to be different.
> 
> reduced.c: In function '_IO_vfscanf_internal':
> reduced.c:104:1: internal compiler error: in lra_create_copy, at lra.c:1512
>  }
>  ^
> 0x8c3f9a lra_create_copy(int, int, int)
>   /work/gcc-dev/src/gcc/gcc/lra.c:1512
> 0x8e4ab0 process_bb_lives
>   /work/gcc-dev/src/gcc/gcc/lra-lives.c:568
> 0x8e4ab0 lra_create_live_ranges(bool)
>   /work/gcc-dev/src/gcc/gcc/lra-lives.c:1019
> 0x8c5a39 lra(_IO_FILE*)
>   /work/gcc-dev/src/gcc/gcc/lra.c:2356
> 0x873a96 do_reload
>   /work/gcc-dev/src/gcc/gcc/ira.c:5415
> 0x873a96 execute
>   /work/gcc-dev/src/gcc/gcc/ira.c:5576
> Please submit a full bug report,
> 
> We can fix the pattern by moving away from match_dup and using register
> tying with constraints consistently.
> 
> I'm not entirely convinced that this is legitimate (my vague recollection is
> that register tying should only be used to tie inputs to outputs).
> 
> This has passed testing on a bunch of ARM targets, and fixes the build
> issues I've been seeing.

Looking at this too, as an LRA exercise. I don't really think the
pattern is wrong, rather LRA should just avoid creating the copy in this
case; it's a result of operand constraining, after all.

Attached is the small LRA patch, pending testing. Vladimir should weight
in on this.

Thanks,
Chung-Lin

* ira-lives.c (process_bb_lives): Skip creating copy during
insn sca when src/dest has constrained to same regno.

Index: lra-lives.c
===
--- lra-lives.c (revision 211398)
+++ lra-lives.c (working copy)
@@ -558,7 +558,11 @@ process_bb_lives (basic_block bb, int &curr_point)
  /* It might be 'inheritance pseudo <- reload pseudo'.  */
  || (src_regno >= lra_constraint_new_regno_start
  && ((int) REGNO (SET_DEST (set))
- >= lra_constraint_new_regno_start
+ >= lra_constraint_new_regno_start)
+ /* Remember to skip special cases where src/dest regnos are
+the same, e.g. insn SET pattern has matching constraints
+like =r,0.  */
+ && src_regno != (int) REGNO (SET_DEST (set)
{
  int hard_regno = -1, regno = -1;
 


Re: ipa-visibility TLC 2/n

2014-06-11 Thread Jan Hubicka
> 
> Unfortunately, AIX isn't the only target massively affected by your
> recent patches.  This all started with r210597
> 
> 2014-05-17  Jan Hubicka  
> 
>   * 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.
> 
> At that time, only Solaris 11 with gas/Solaris ld was affected: many Go
> tests started failing like this:
> 
> runtime.SetFinalizer: cannot pass * os  os.file to finalizer func(*   
>   os  os.file) error
> fatal error: runtime.SetFinalizer

Thanks for letting me know.  THis is different transformation than one causing 
trouble
on AIX (AIX has no comdats, so this pass does nothing).  Go seems tobe quite 
heavy user
of comdat locals produced by that patch, so I suppose they somehow break with 
Solaris.

Comdat locals are now used by ipa-comdats, for thunks and for decloned ctors.
We probably need to figure out bit more precise limitation of Solaris and either
fix or add way for target to say what kind of comdat locals are not supported.

Can I reproduce your setup on the compile farm?

Honza
> 
> Neither Solaris 10 (which doesn't enable comdat group due to missing ld
> support for what gas emits) nor Solaris 11 with /bin/as (which has
> different comdat syntax, thus emitting groups differently) were
> affected.
> 
> I didn't file a PR at that time since I had started to work with the
> Solaris linker engineers to see what could be done about this on the ld
> side.  Unfortunately, even if this worked, it won't change the installed
> base.
> 
> Since then, the number of Go testsuite failures seems to increase daily,
> now Solaris 10 is also affected.  Given that sparc-sun-solaris2.10 is a
> primary platform, we need to do something about this.
> 
>   Rainer
> 
> -- 
> -
> Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH 8/8] Add a common .md file and define standard constraints there

2014-06-11 Thread Richard Sandiford
Thanks for the reviews.

Jeff Law  writes:
> Does the comment before indep_constraints in genoutput need updating? 
> The constraints in common.md are machine independent, but aren't listed 
> in indep_constraints in genoutput.c

Yeah, good catch.  I changed it to:

/* All machine-independent constraint characters (except digits) that
   are handled outside the define*_constraint mechanism.  */
static const char indep_constraints[] = ",=+%*?!#&g";

Also in genpreds.c:

/* Contraint letters that have a special meaning and that cannot be used
   in define*_constraints.  */
static const char generic_constraint_letters[] = "g";

Richard


Re: [C++ Path/RFC] PR 60265

2014-06-11 Thread Jason Merrill

On 06/11/2014 12:49 PM, Paolo Carlini wrote:

.. Core/1742 seems relevant to the difference scoped/unscoped. It's
still open, though.


And priority 2, so unlikely to be resolved any time soon.  The patch is OK.

Jason




Re: [C++ Path/RFC] PR 60265

2014-06-11 Thread Paolo Carlini
.. Core/1742 seems relevant to the difference scoped/unscoped. It's 
still open, though.


Thanks,
Paolo.


[C++ Path/RFC] PR 60265

2014-06-11 Thread Paolo Carlini

Hi,

this issue is probably easy to resolve, one way or another, but I find 
it rather curious: as the submitted testcase explains, we reject the 
trivial:


enum E { V };

using E::V;

because "'E' is not a namespace", but I don't see anything in C++11 
explicitly outlawing enums. In fact, current clang accept the whole 
using-enum-1.C attached below. Then there is the case of *scoped enums*, 
which are mentioned in negative in C++11 (7.3.3/7), and current clang 
accepts, the whole using-enum-2.C attached below. Anyay, patchlet passes 
testing on x86_64-linux.


Thanks,
Paolo.

/
Index: cp/name-lookup.c
===
--- cp/name-lookup.c(revision 211466)
+++ cp/name-lookup.c(working copy)
@@ -2487,7 +2487,7 @@ validate_nonmember_using_decl (tree decl, tree sco
member-declaration.  */
   if (TYPE_P (scope))
 {
-  error ("%qT is not a namespace", scope);
+  error ("%qT is not a namespace or unscoped enum", scope);
   return NULL_TREE;
 }
   else if (scope == error_mark_node)
Index: cp/parser.c
===
--- cp/parser.c (revision 211467)
+++ cp/parser.c (working copy)
@@ -16022,6 +16022,8 @@ cp_parser_using_declaration (cp_parser* parser,
  /*is_declaration=*/true);
   if (!qscope)
 qscope = global_namespace;
+  else if (UNSCOPED_ENUM_P (qscope))
+qscope = CP_TYPE_CONTEXT (qscope);
 
   if (access_declaration_p && cp_parser_error_occurred (parser))
 /* Something has already gone wrong; there's no need to parse
Index: testsuite/g++.dg/cpp0x/using-enum-1.C
===
--- testsuite/g++.dg/cpp0x/using-enum-1.C   (revision 0)
+++ testsuite/g++.dg/cpp0x/using-enum-1.C   (working copy)
@@ -0,0 +1,20 @@
+// PR c++/60265
+// { dg-do compile { target c++11 } }
+
+namespace A
+{
+  enum E { V };
+
+  using E::V;
+}
+
+void foo()
+{
+  using A::E::V;
+}
+
+using A::E::V;
+
+enum F { U };
+
+using F::U;
Index: testsuite/g++.dg/cpp0x/using-enum-2.C
===
--- testsuite/g++.dg/cpp0x/using-enum-2.C   (revision 0)
+++ testsuite/g++.dg/cpp0x/using-enum-2.C   (working copy)
@@ -0,0 +1,20 @@
+// PR c++/60265
+// { dg-do compile { target c++11 } }
+
+namespace A
+{
+  enum class E { V };
+
+  using E::V;// { dg-error "not a namespace or unscoped enum" }
+}
+
+void foo()
+{
+  using A::E::V; // { dg-error "not a namespace or unscoped enum" }
+}
+
+using A::E::V;   // { dg-error "not a namespace or unscoped enum" }
+
+enum class F { U };
+
+using F::U;  // { dg-error "not a namespace or unscoped enum" }


Re: [patch,avr] Fix ICE PR61443

2014-06-11 Thread Denis Chertykov
2014-06-11 13:05 GMT+04:00 Georg-Johann Lay :
> This is a fix for unrecognizable insn ICE where the push expander generated
> (subreg(mem)) for non-generic address-space locations.
>
> Instead of loading byte-wise and legitimizing such expressions, it's easier
> and results in better code when we load such MEMs in one chunk.
>
> Ok to apply?
>
> Johann
>
>
> gcc/
> PR target/61443
> * config/avr/avr.md (push1): Avoid (subreg(mem)) when
> loading from address spaces.
> gcc/testsuite/
> PR target/61443
> * gcc.target/avr/torture/pr61443.c: New test.

Approved. Please apply.

Denis.


Re: [patch] don't link shared RTPs with libc_internal.a on VxWorks

2014-06-11 Thread Olivier Hainque

On Jun 11, 2014, at 17:49 , Olivier Hainque  wrote:

>   * config/vxworks.h (VXWORKS_LIBGCC_SPEC): Don't link shared RTPs with
>   libc_internal.

 Oops. I think I sent a bogus version of the patch, as the system libc.so
 embeds libgcc as well. Let me revisit.

 Olivier




Re: [PATCH, PR61446] Fix mode for register copy in REE pass

2014-06-11 Thread Ilya Enkovich
On 11 Jun 14:59, Uros Bizjak wrote:
> On Tue, Jun 10, 2014 at 3:45 PM, Dominique Dhumieres  
> wrote:
> >> This patch fixes PR61446. ...
> >
> > Confirmed, it also allows to bootstrap Core* targets.
> > Could it be reviewed and committed ASAP?
> 
> > 2014-06-09  Ilya Enkovich  
> >
> > PR 61446
> > * ree.c (find_and_remove_re): Narrow mode for register copy
> > if required.
> 
> Please also add the testcase form the PR.
> 
> (I am not RTL reviewer, so I can't approve the patch).
> 
> Uros.

Hi,

rgis one is the same but with testcase added.

Bootstrapped and tested on linux-x86_64.

Thanks,
Ilya
--
gcc/

2014-06-11  Ilya Enkovich  

PR 61446
* ree.c (find_and_remove_re): Narrow mode for register copy
if required.

gcc/testsuite/

2014-06-11  Ilya Enkovich  

 * gcc.target/i386/pr61446.c : New.


diff --git a/gcc/ree.c b/gcc/ree.c
index ade413e..6d34764 100644
--- a/gcc/ree.c
+++ b/gcc/ree.c
@@ -1088,14 +1088,24 @@ find_and_remove_re (void)
   /* Use the mode of the destination of the defining insn
 for the mode of the copy.  This is necessary if the
 defining insn was used to eliminate a second extension
-that was wider than the first.  */
+that was wider than the first.  Truncate mode if it is
+too wide for destination reg.  */
   rtx sub_rtx = *get_sub_rtx (def_insn);
   rtx pat = PATTERN (curr_insn);
-  rtx new_dst = gen_rtx_REG (GET_MODE (SET_DEST (sub_rtx)),
-REGNO (XEXP (SET_SRC (pat), 0)));
-  rtx new_src = gen_rtx_REG (GET_MODE (SET_DEST (sub_rtx)),
-REGNO (SET_DEST (pat)));
-  rtx set = gen_rtx_SET (VOIDmode, new_dst, new_src);
+  unsigned int regno = REGNO (XEXP (SET_SRC (pat), 0));
+  enum machine_mode mode = GET_MODE (SET_DEST (sub_rtx));
+  rtx new_dst, new_src, set;
+
+  if (HARD_REGNO_NREGS (regno, mode) != 1)
+   {
+ mode = GET_CLASS_NARROWEST_MODE (GET_MODE_CLASS (mode));
+ while (HARD_REGNO_NREGS (regno, GET_MODE_WIDER_MODE (mode)) == 1)
+   mode = GET_MODE_WIDER_MODE (mode);
+   }
+
+  new_dst = gen_rtx_REG (mode, REGNO (XEXP (SET_SRC (pat), 0)));
+  new_src = gen_rtx_REG (mode, REGNO (SET_DEST (pat)));
+  set = gen_rtx_SET (VOIDmode, new_dst, new_src);
   emit_insn_after (set, def_insn);
 }
 
diff --git a/gcc/testsuite/gcc.target/i386/pr61446.c 
b/gcc/testsuite/gcc.target/i386/pr61446.c
new file mode 100644
index 000..8537cdb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr61446.c
@@ -0,0 +1,14 @@
+/* PR rtl-optimization/61446 */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -m32 -march=corei7" } */
+
+unsigned long long
+foo (float a)
+{
+  const double dfa = a;
+  const unsigned int hi = dfa / 0x1p32f;
+  const unsigned int lo = dfa - (double) hi * 0x1p32f;
+
+  return ((unsigned long long) hi << (4 * (8))) | lo;
+}


[PATCH, Pointer Bounds Checker 35/x] Fix object size emitted for structures with flexible arrays

2014-06-11 Thread Ilya Enkovich
Hi,

This patch fixes problem with size emitted for static structures with flexible 
array.  I found a couple of trackers in guzilla for this problem but all of 
them are marked as fixed and problem still exists.

For a simple testcase

struct S { int a; int b[0]; } s = { 1, { 0, 0} };

current trunk produces (no flags):

.globl  s
.data
.align 4
.type   s, @object
.size   s, 4
s:
.long   1
.long   0
.long   0

which has wrong size for object s.

This problem is important for checker because wrong size leads to wrong bounds 
and false bounds violations.  Following patch uses DECL_SIZE_UNIT instead of 
type size and works well for me.  Does it look OK?

Bootstrapped and tested on linux-x86_64.

Thanks,
Ilya
--
gcc/

2014-06-11  Ilya Enkovich  

* config/elfos.h (ASM_DECLARE_OBJECT_NAME): Use decl size
instead of type size.
(ASM_FINISH_DECLARE_OBJECT): Likewise.


diff --git a/gcc/config/elfos.h b/gcc/config/elfos.h
index c1d5553..7929708 100644
--- a/gcc/config/elfos.h
+++ b/gcc/config/elfos.h
@@ -313,7 +313,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
  && (DECL) && DECL_SIZE (DECL))\
{   \
  size_directive_output = 1;\
- size = int_size_in_bytes (TREE_TYPE (DECL));  \
+ size = tree_to_uhwi (DECL_SIZE_UNIT (DECL));  \
  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, NAME, size); \
}   \
\
@@ -341,7 +341,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
  && !size_directive_output)\
{   \
  size_directive_output = 1;\
- size = int_size_in_bytes (TREE_TYPE (DECL));  \
+ size = tree_to_uhwi (DECL_SIZE_UNIT (DECL));  \
  ASM_OUTPUT_SIZE_DIRECTIVE (FILE, name, size); \
}   \
 }  \


[patch] don't link shared RTPs with libc_internal.a on VxWorks

2014-06-11 Thread Olivier Hainque
Hello,

For VxWorks RTPs, the config/vxworks.h has:

 /* For VxWorks, the system provides libc_internal.a.  This is a superset
of libgcc.a; we want to use it.  Make sure not to dynamically export
any of its symbols, though.  Always look for libgcc.a first so that
we get the latest versions of the GNU intrinsics during our builds.  */
 #undef VXWORKS_LIBGCC_SPEC
 #define VXWORKS_LIBGCC_SPEC \
   "-lgcc %{mrtp:--exclude-libs=libc_internal,libgcc -lc_internal}"

This is not quite appropriate for shared RTPs, as there is no shared
version of libc_internal. The corresponding entry points are provided by
the system libc.so instead.

The attached patch is a suggestion to address this by guarding the
inclusion with !shared.

Tested by verifying that we can produce functional static and dynamic
RTPs with the change on VxWorks 6.X.

OK to commit ?

Thanks in advance for your feedback,

Olivier

2014-06-11  Olivier Hainque  

* config/vxworks.h (VXWORKS_LIBGCC_SPEC): Don't link shared RTPs with
libc_internal.



vxworks_libc_internal.diff
Description: Binary data


Re: libgo patch committed: Merge from revision 18783 of master

2014-06-11 Thread Rainer Orth
Ian Lance Taylor  writes:

> On Wed, Jun 11, 2014 at 6:57 AM, Rainer Orth
>  wrote:
>>
>> Ok, I'll have a look unless some other solution can be found.
>
> There are other, less efficient, ways that this could be compiled, but
> a common symbol seems like the right solution.
>
> Basically, every type descriptor now points to a zero value for the
> type.  The zero value in Go is always the all-bytes-zero value.  So
> we can have every type descriptor point to the same block of memory,
> as long as we can ensure that that memory is large enough.  Using a
> common symbol does exactly what we want: the linker sees all the
> go$zerovalue symbols, and sets the final one to the largest
> go$zerovalue that it sees.
>
> I can't think of any other solution that doesn't involve some sort of
> runtime initialization.
>
> I do wonder what gfortran does on Solaris.

This case only occurs in a few LTO testcases, where they are pruned by
lto.exp (lto_prune_warns).

Apart from that, the only testcase I could find is
gfortran.dg/bind_c_coms.f90 with gfortran.dg/bind_c_coms_driver.c, and
there all common symbols are the same size in the C and F90 cases.

Rainer

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


[patch] improve sloc assignment on bind_expr entry/exit code

2014-06-11 Thread Olivier Hainque
Hello,

For blocks requiring it, the gimplifier generates stack pointer
save/restore operations on entry/exit, per:

 gimplify_bind_expr (...)

  if (gimplify_ctxp->save_stack)
{
  gimple stack_restore;

  /* Save stack on entry and restore it on exit.  Add a try_finally
 block to achieve this.  */
  build_stack_save_restore (&stack_save, &stack_restore);

  gimplify_seq_add_stmt (&cleanup, stack_restore);
}

  /* Add clobbers for all variables that go out of scope.  */
  ...

There is no specific location assigned to these entry/exit statements
so they eventually inherits slocs coming from preceding statements.

This is problematic for tools relying on debug info to infer
which statements were executed out of execution traces (allowing
coverage analysis without code instrumentation).

An example of problematic scenario is provided below.

The attached patch is a proposal to improve this by propagating
start and end of block locations from the block structure to the
few gimple statements we generate. It adds an "end_locus" to the
block structure for this purpose, which the Ada front-end knows
how to fill already.

I verified that it does inserts proper .loc directives before the
entry/exit code on the example. The patch also bootstraps and regtests
fine for languages=all,ada on x86_64-pc-linux-gnu.

OK to commit ?

Thanks in advance for your feedback,

With Kind Regards,

Olivier

--

2014-06-11  Olivier Hainque  

* tree-core.h (tree_block): Add an "end_locus" field, allowing
memorization of the end of block source location.
* tree.h (BLOCK_SOURCE_END_LOCATION): New accessor.
* gimplify.c (gimplify_bind_expr): Propagate the block start and
end source location info we have on the block entry/exit code we
generate.

--

Here is an Ada example to illustrate:

-- p.adb
 1  procedure P (Choice : Integer; N : in out Integer) is
 2  begin
 3 if Choice > 0 then
 4declare
 5   S : String (1 .. N * 2);
 6   pragma Volatile (S);
 7begin
 8   S := (others => 'B');
 9end;
10 else
11declare
12   S : String (1 .. N );
13   pragma Volatile (S);
14begin
15   S := (others => '1');
16end;
17 end if;
18  end;

The two if/else blocks allocate a local string of dynamic size and call for
stack save/restore operations. A very recent mainline on x86_64-linux produces
the following code (gcc -c -g -save-temps -fverbose-asm p.adb):

 .loc 1 3 0
 cmpl$0, -84(%rbp)   #, choice
 jle .L2 < branch to the else block if choice <= 0
 [...]
 [code for the if block here]
 ...
 .loc 1 8 0 discriminator 3
 addl$1, %eax#, D.3124
 jmp .L5 #
 ...
   .L2:  <--- branch lands here
   .LBB4:
 movq%rsp, %rax  #, tmp136 <--- stack save on entry of the
 movq%rax, %rdi  # tmp136, D.3125  <--- else block.
 .loc 1 12 0 is_stmt 1
 movl-88(%rbp), %ecx # n, D.3129


The stack save code has no specific sloc assigned, so inherits
what happens to be current at this point, here the .loc 1 8 corresponding
to the code last emitted for the string assignment on line 8.

This is inaccurate because the stack save code really has nothing to do with
the statement on line 8. And this is problematic when infering coverage
information from execution traces, as it incorrectly appears as if part of
line 8 was executed as soon as we reach here.

The proposed change ends up inserting a .loc 1 11 0 just before the first move
insn, curing the problem, as well as a .loc 1 4, a .loc 1 9 and a .loc 1 16
before the other start and end of blocks for similar reasons.



bind_expr_locus.diff
Description: Binary data



Re: [C++ Patch] PR 19200

2014-06-11 Thread Jason Merrill

OK.

Jason


Re: libgo patch committed: Merge from revision 18783 of master

2014-06-11 Thread Ian Lance Taylor
On Wed, Jun 11, 2014 at 6:57 AM, Rainer Orth
 wrote:
>
> Ok, I'll have a look unless some other solution can be found.

There are other, less efficient, ways that this could be compiled, but
a common symbol seems like the right solution.

Basically, every type descriptor now points to a zero value for the
type.  The zero value in Go is always the all-bytes-zero value.  So
we can have every type descriptor point to the same block of memory,
as long as we can ensure that that memory is large enough.  Using a
common symbol does exactly what we want: the linker sees all the
go$zerovalue symbols, and sets the final one to the largest
go$zerovalue that it sees.

I can't think of any other solution that doesn't involve some sort of
runtime initialization.

I do wonder what gfortran does on Solaris.

Ian


Re: ipa-visibility TLC 2/n

2014-06-11 Thread Rainer Orth
Jan Hubicka  writes:

>> Honza,
>> 
>> I am not sure that the problem is caused only by aliases and thunks.
>> The large increase in AIX linker warnings about branches not followed
>> by nop also worry me.
>> 
>> Your patch was about visibility. How does the more aggressive
>
> ipa-visibility is a pass that basically bring external symbols local whenever
> it can (i.e. does privatizatoin), it is not that much about ELF visibilities.
>
>> algorithm behave on a platform that does not support visibility? Is it
>> defaulting to hidden? If the new algorithm is being too aggressive and
>> incorrectly converting calls from global to local, it could cause
>> serious problems for AIX because the GOT register will not be
>> restored.
>
> One of optimizations IPA visibility does is that it looks for global symbols
> that
>   1) are believed by target to be overwritable (interposed - I will probably
>  update name here) by linker to a different definition (we have
>  decl_binds_to_current_def_p that is target tweakable), and
>   2) the interposition may not change semantics of the symbol (i.e. function
>  body must be the same or variable initializer must match)
>
>  For some symbols (such as inline functions, virtual tables, readonly
>  variables with no address taken) we know it won't.
>   3) the symbol's definition can not be optimized away by linker
>  (by symtab_can_be_discarded)
> If all conditons match, it creates a static alias (not hidden, just local to
> the .o file) and redirects users of the symbol to the alias.  This should be
> always win: we know that the representation of symbol will survive to final
> binary (it is not discarded) and we replace expensive references through GOT 
> by
> cheap references to local symbol.
>
> We did, for longer time, redirect calls.  The troublesome patch makes us to
> redirect also references in virtual tables and newly we also consider virtual
> tables themselves for aliases.
>
> This should be a win, since virtual tables tends to be startup time hogs and
> it is common to have virtual tables in one DSO to refer to comdats that are
> shared with other DSO, but because they must be the same, we can just ignore
> the sharing.
>
> On AIX we observed interesting series of events.
>
>  1) First the output machinery was not quite able to declare local static
> alias for a symbol (this was about year ago when I introduced the first
> change).
>  2) AIX assembler seems to issue warning when jump happens to the local
> static alias confusing it with the global symbol it is aliasing.
> I do not know if the warning is just bogus or we output something
> incorrectly.  This is the reason for NOP warning as I understand.
>  3) Important difference we is that in AIX all COMDAT symbols are considered
> non-discardable. This makes us to produce a lot more aliases than on ELF
> system.
>
> I am not sure if this is acurate and AIX linker really has no means
> of removing duplicated bodies of COMDAT functions/initializers of 
> variables.
> If it has, we need to model it in symtab_can_be_discarded.
> Currently we test whether symbol is in comdat group and in the case of
> AIX it isn't. 
>
> As disucssed earlier, I am thinking about making symtab_can_be_discarded
> return true also for implicit sections (I have WIP patch for this to
> commit today). Earlier version of the patch however did not solve
> the warnings.
>
> I also tested libstdc++.so sizes with current mainline, with the
> local aliases disabled and with this change and current mainline
> wins. Suggesting that perhaps there is really no way to discard
> duplicated comdats or libstdc++ doesn't really have them.
> Insight here would be welcome - I am sure it is easy to test if 
> including and using inline __noinline__ function in two units
> leads to two copies of that beast or not. It would be nice to know
> how native toolchain handles it and if GCC does the same trick.
>  4) Before 4.9 we hit bug in inliner dealing with aliases that gave me
> a headache. It reproduced on AIX only because of 3)
>  5) We hit problem with aliases to anchored sections, hopefully solved now
>  6) We hit the problem that AIX assembler silently accepts but miscompile
> when alias is declared before its target.  THis is also hopefully
> fixed now.  We hit it twice - one for normal symbols about year ago
> and now again for thunks.
>  7) Given number of issues I ended up writting a verifier that checks
> sanity of sections, aliases and comdat groups.  I check
>   a) all symbols in comdat group have the same section
>   b) alias and its target have same comdat group & section characteristics
>  (obivously one can not place alias out of comdat)
>   c) I check sanity of IMPLICIT_SECTION flag.
> It turns out that C++ FE makes complete mess of those breaking all three
> rules due to complex i

[PATCH][Ping] Add patch for debugging compiler ICEs

2014-06-11 Thread Maxim Ostapenko

Ping.


 Original Message 
Subject:[PATCH] Add patch for debugging compiler ICEs
Date:   Mon, 02 Jun 2014 19:21:14 +0400
From:   Maxim Ostapenko 
To: GCC Patches 
CC: 	Yury Gribov , Slava Garbuzov 
, Jakub Jelinek , 
tsaund...@mozilla.com, chefm...@gmail.com




Hi,

A years ago there was a discussion 
(https://gcc.gnu.org/ml/gcc-patches/2004-01/msg02437.html) about debugging 
compiler ICEs that resulted in a patch from Jakub, which dumps
useful information into temporary file, but for some reasons this patch wasn't 
applied to trunk.

This is the resurrected patch with added GCC version information into generated 
repro file.

-Maxim

2014-06-02  Jakub Jelinek  
	Max Ostapenko  

	* diagnostic.c (diagnostic_action_after_output): Exit with
	ICE_EXIT_CODE instead of FATAL_EXIT_CODE.
	* gcc.c (execute): Don't free first string early, but at the end
	of the function.  Call retry_ice if compiler exited with
	ICE_EXIT_CODE.
	(main): Factor out common code.
	(print_configuration): New function.
	(try_fork): Likewise.
	(redirect_stdout_stderr): Likewise.
	(files_equal_p): Likewise.
	(check_repro): Likewise.
	(run_attempt): Likewise.
	(generate_preprocessed_code): Likewise.
	(append_text): Likewise.
	(try_generate_repro): Likewise.

diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c
index 0cc7593..67b8c5b 100644
--- a/gcc/diagnostic.c
+++ b/gcc/diagnostic.c
@@ -492,7 +492,7 @@ diagnostic_action_after_output (diagnostic_context *context,
 	real_abort ();
   diagnostic_finish (context);
   fnotice (stderr, "compilation terminated.\n");
-  exit (FATAL_EXIT_CODE);
+  exit (ICE_EXIT_CODE);
 
 default:
   gcc_unreachable ();
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 9ac18e6..86dce03 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -43,6 +43,13 @@ compilation is specified by a string called a "spec".  */
 #include "params.h"
 #include "vec.h"
 #include "filenames.h"
+#ifdef HAVE_UNISTD_H
+#include 
+#endif
+
+#if !(defined (__MSDOS__) || defined (OS2) || defined (VMS))
+#define RETRY_ICE_SUPPORTED
+#endif
 
 /* By default there is no special suffix for target executables.  */
 /* FIXME: when autoconf is fixed, remove the host check - dj */
@@ -253,6 +260,9 @@ static void init_gcc_specs (struct obstack *, const char *, const char *,
 static const char *convert_filename (const char *, int, int);
 #endif
 
+#ifdef RETRY_ICE_SUPPORTED
+static void try_generate_repro (const char *prog, const char **argv);
+#endif
 static const char *getenv_spec_function (int, const char **);
 static const char *if_exists_spec_function (int, const char **);
 static const char *if_exists_else_spec_function (int, const char **);
@@ -2797,7 +2807,7 @@ execute (void)
 	}
 	}
 
-  if (string != commands[i].prog)
+  if (i && string != commands[i].prog)
 	free (CONST_CAST (char *, string));
 }
 
@@ -2850,6 +2860,16 @@ execute (void)
 	else if (WIFEXITED (status)
 		 && WEXITSTATUS (status) >= MIN_FATAL_STATUS)
 	  {
+#ifdef RETRY_ICE_SUPPORTED
+	/* For ICEs in cc1, cc1obj, cc1plus see if it is
+	   reproducible or not.  */
+	const char *p;
+	if (WEXITSTATUS (status) == ICE_EXIT_CODE
+		&& i == 0
+		&& (p = strrchr (commands[0].argv[0], DIR_SEPARATOR))
+		&& ! strncmp (p + 1, "cc1", 3))
+	  try_generate_repro (commands[0].prog, commands[0].argv);
+#endif
 	if (WEXITSTATUS (status) > greatest_status)
 	  greatest_status = WEXITSTATUS (status);
 	ret_code = -1;
@@ -2907,6 +2927,9 @@ execute (void)
 	  }
   }
 
+   if (commands[0].argv[0] != commands[0].prog)
+ free (CONST_CAST (char *, commands[0].argv[0]));
+
 return ret_code;
   }
 }
@@ -6098,6 +6121,342 @@ give_switch (int switchnum, int omit_first_word)
   switches[switchnum].validated = true;
 }
 
+static void
+print_configuration (void)
+{
+  int n;
+  const char *thrmod;
+
+  fnotice (stderr, "Target: %s\n", spec_machine);
+  fnotice (stderr, "Configured with: %s\n", configuration_arguments);
+
+#ifdef THREAD_MODEL_SPEC
+  /* We could have defined THREAD_MODEL_SPEC to "%*" by default,
+  but there's no point in doing all this processing just to get
+  thread_model back.  */
+  obstack_init (&obstack);
+  do_spec_1 (THREAD_MODEL_SPEC, 0, thread_model);
+  obstack_1grow (&obstack, '\0');
+  thrmod = XOBFINISH (&obstack, const char *);
+#else
+  thrmod = thread_model;
+#endif
+
+  fnotice (stderr, "Thread model: %s\n", thrmod);
+
+  /* compiler_version is truncated at the first space when initialized
+  from version string, so truncate version_string at the first space
+  before comparing.  */
+  for (n = 0; version_string[n]; n++)
+if (version_string[n] == ' ')
+  break;
+
+  if (! strncmp (version_string, compiler_version, n)
+  && compiler_version[n] == 0)
+fnotice (stderr, "gcc version %s %s\n\n", version_string,
+ pkgversion_string);
+  else
+fnotice (stderr, "gcc driver version %s %sexecuting gcc version %s\n\n",
+ version_string, pkgversion_st

[PATCH, i386, Pointer Bounds Checker 34/x] Vararg functions support

2014-06-11 Thread Ilya Enkovich
Hi,

This patch introduces initialization of incoming bounds for vararg function on 
i386 target.

Bootstrapped and tested on linux-x86_64.

Thanks,
Ilya
--
gcc/

2014-06-11  Ilya Enkovich  

* config/i386/i386.c (ix86_setup_incoming_varargs): New.
(ix86_va_start): Initialize bounds for pointers in va_list.
(TARGET_SETUP_INCOMING_VARARG_BOUNDS): New.


diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a67e6e7..c520f26 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -8456,6 +8456,72 @@ ix86_setup_incoming_varargs (cumulative_args_t cum_v, 
enum machine_mode mode,
 setup_incoming_varargs_64 (&next_cum);
 }
 
+static void
+ix86_setup_incoming_vararg_bounds (cumulative_args_t cum_v,
+  enum machine_mode mode,
+  tree type,
+  int *pretend_size ATTRIBUTE_UNUSED,
+  int no_rtl)
+{
+  CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v);
+  CUMULATIVE_ARGS next_cum;
+  tree fntype;
+  rtx save_area;
+  int bnd_reg, i, max;
+
+  gcc_assert (!no_rtl);
+
+  if (!TARGET_64BIT)
+return;
+
+  fntype = TREE_TYPE (current_function_decl);
+
+  /* For varargs, we do not want to skip the dummy va_dcl argument.
+ For stdargs, we do want to skip the last named argument.  */
+  next_cum = *cum;
+  if (stdarg_p (fntype))
+ix86_function_arg_advance (pack_cumulative_args (&next_cum), mode, type,
+  true);
+  if (cum->call_abi == MS_ABI)
+return;
+
+  save_area = frame_pointer_rtx;
+
+  max = cum->regno + cfun->va_list_gpr_size / UNITS_PER_WORD;
+  if (max > X86_64_REGPARM_MAX)
+max = X86_64_REGPARM_MAX;
+
+  bnd_reg = cum->bnd_regno + cum->force_bnd_pass;
+  if (chkp_function_instrumented_p (current_function_decl))
+for (i = cum->regno; i < max; i++)
+  {
+   rtx addr = plus_constant (Pmode, save_area, i * UNITS_PER_WORD);
+   rtx reg = gen_rtx_REG (DImode,
+  x86_64_int_parameter_registers[i]);
+   rtx ptr = reg;
+   rtx bounds;
+
+   if (bnd_reg <= LAST_BND_REG)
+ bounds = gen_rtx_REG (BNDmode, bnd_reg);
+   else
+ {
+   rtx ldx_addr = plus_constant (Pmode, arg_pointer_rtx,
+ (LAST_BND_REG - bnd_reg) * 8);
+   bounds = gen_reg_rtx (BNDmode);
+   emit_insn (TARGET_64BIT
+  ? gen_bnd64_ldx (bounds, ldx_addr, ptr)
+  : gen_bnd32_ldx (bounds, ldx_addr, ptr));
+ }
+
+   emit_insn (TARGET_64BIT
+  ? gen_bnd64_stx (addr, ptr, bounds)
+  : gen_bnd32_stx (addr, ptr, bounds));
+
+   bnd_reg++;
+  }
+}
+
+
 /* Checks if TYPE is of kind va_list char *.  */
 
 static bool
@@ -8478,7 +8544,7 @@ ix86_va_start (tree valist, rtx nextarg)
 {
   HOST_WIDE_INT words, n_gpr, n_fpr;
   tree f_gpr, f_fpr, f_ovf, f_sav;
-  tree gpr, fpr, ovf, sav, t;
+  tree gpr, fpr, ovf, sav, t, t1;
   tree type;
   rtx ovf_rtx;
 
@@ -8529,6 +8595,13 @@ ix86_va_start (tree valist, rtx nextarg)
   crtl->args.arg_offset_rtx,
   NULL_RTX, 0, OPTAB_LIB_WIDEN);
  convert_move (va_r, next, 0);
+
+ /* Store zero bounds for va_list.  */
+ if (chkp_function_instrumented_p (current_function_decl))
+   chkp_expand_bounds_reset_for_mem (valist,
+ make_tree (TREE_TYPE (valist),
+next));
+
}
   return;
 }
@@ -8582,10 +8655,15 @@ ix86_va_start (tree valist, rtx nextarg)
   t = make_tree (type, ovf_rtx);
   if (words != 0)
 t = fold_build_pointer_plus_hwi (t, words * UNITS_PER_WORD);
+  t1 = t;
   t = build2 (MODIFY_EXPR, type, ovf, t);
   TREE_SIDE_EFFECTS (t) = 1;
   expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
 
+  /* Store zero bounds for overflow area pointer.  */
+  if (chkp_function_instrumented_p (current_function_decl))
+chkp_expand_bounds_reset_for_mem (ovf, t1);
+
   if (ix86_varargs_gpr_size || ix86_varargs_fpr_size)
 {
   /* Find the register save area.
@@ -8594,9 +8672,14 @@ ix86_va_start (tree valist, rtx nextarg)
   t = make_tree (type, frame_pointer_rtx);
   if (!ix86_varargs_gpr_size)
t = fold_build_pointer_plus_hwi (t, -8 * X86_64_REGPARM_MAX);
+  t1 = t;
   t = build2 (MODIFY_EXPR, type, sav, t);
   TREE_SIDE_EFFECTS (t) = 1;
   expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
+
+  /* Store zero bounds for save area pointer.  */
+  if (chkp_function_instrumented_p (current_function_decl))
+   chkp_expand_bounds_reset_for_mem (sav, t1);
 }
 }
 
@@ -48057,6 +48140,9 @@ ix86_initialize_bounds (tree var, tree lb, tree ub, 
tree *stmts)
 #undef TARGET_CHKP_INITIALIZE_BOUNDS
 #define TARGET_CHKP_INITIALIZE_BOUNDS ix86_initialize_

[PATCH, i386, Pointer Bounds Checker 31/x] Pointer Bounds Checker builtins for i386 target

2014-06-11 Thread Ilya Enkovich
Hi,

This patch adds i386 target builtins for Pointer Bounds Checker.

Bootstrapped and tested on linux-x86_64.

Thanks,
Ilya
--
gcc/

2014-06-11  Ilya Enkovich  

* config/i386/i386-builtin-types.def (BND): New.
(ULONG): New.
(BND_FTYPE_PCVOID_ULONG): New.
(VOID_FTYPE_BND_PCVOID): New.
(VOID_FTYPE_PCVOID_PCVOID_BND): New.
(BND_FTYPE_PCVOID_PCVOID): New.
(BND_FTYPE_PCVOID): New.
(BND_FTYPE_BND_BND): New.
(PVOID_FTYPE_PVOID_PVOID_ULONG): New.
(PVOID_FTYPE_PCVOID_BND_ULONG): New.
(ULONG_FTYPE_VOID): New.
(PVOID_FTYPE_BND): New.
* config/i386/i386.c: Include tree-chkp.h, rtl-chkp.h.
(ix86_builtins): Add
IX86_BUILTIN_BNDMK, IX86_BUILTIN_BNDSTX,
IX86_BUILTIN_BNDLDX, IX86_BUILTIN_BNDCL,
IX86_BUILTIN_BNDCU, IX86_BUILTIN_BNDRET,
IX86_BUILTIN_BNDNARROW, IX86_BUILTIN_BNDINT,
IX86_BUILTIN_SIZEOF, IX86_BUILTIN_BNDLOWER,
IX86_BUILTIN_BNDUPPER.
(builtin_isa): Add leaf_p and nothrow_p fields.
(def_builtin): Initialize leaf_p and nothrow_p.
(ix86_add_new_builtins): Handle leaf_p and nothrow_p
flags.
(bdesc_mpx): New.
(bdesc_mpx_const): New.
(ix86_init_mpx_builtins): New.
(ix86_init_builtins): Call ix86_init_mpx_builtins.
(ix86_emit_move_max): New.
(ix86_expand_builtin): Expand IX86_BUILTIN_BNDMK,
IX86_BUILTIN_BNDSTX, IX86_BUILTIN_BNDLDX,
IX86_BUILTIN_BNDCL, IX86_BUILTIN_BNDCU,
IX86_BUILTIN_BNDRET, IX86_BUILTIN_BNDNARROW,
IX86_BUILTIN_BNDINT, IX86_BUILTIN_SIZEOF,
IX86_BUILTIN_BNDLOWER, IX86_BUILTIN_BNDUPPER.


diff --git a/gcc/config/i386/i386-builtin-types.def 
b/gcc/config/i386/i386-builtin-types.def
index 822c5e5..169d40a 100644
--- a/gcc/config/i386/i386-builtin-types.def
+++ b/gcc/config/i386/i386-builtin-types.def
@@ -47,6 +47,7 @@ DEF_PRIMITIVE_TYPE (UCHAR, unsigned_char_type_node)
 DEF_PRIMITIVE_TYPE (QI, char_type_node)
 DEF_PRIMITIVE_TYPE (HI, intHI_type_node)
 DEF_PRIMITIVE_TYPE (SI, intSI_type_node)
+DEF_PRIMITIVE_TYPE (BND, pointer_bounds_type_node)
 # ??? Logically this should be intDI_type_node, but that maps to "long"
 # with 64-bit, and that's not how the emmintrin.h is written.  Again, 
 # changing this would change name mangling.
@@ -60,6 +61,7 @@ DEF_PRIMITIVE_TYPE (USHORT, short_unsigned_type_node)
 DEF_PRIMITIVE_TYPE (INT, integer_type_node)
 DEF_PRIMITIVE_TYPE (UINT, unsigned_type_node)
 DEF_PRIMITIVE_TYPE (UNSIGNED, unsigned_type_node)
+DEF_PRIMITIVE_TYPE (ULONG, long_unsigned_type_node)
 DEF_PRIMITIVE_TYPE (LONGLONG, long_long_integer_type_node)
 DEF_PRIMITIVE_TYPE (ULONGLONG, long_long_unsigned_type_node)
 DEF_PRIMITIVE_TYPE (UINT8, unsigned_char_type_node)
@@ -806,3 +808,15 @@ DEF_FUNCTION_TYPE_ALIAS (V2DI_FTYPE_V2DI_V2DI, TF)
 DEF_FUNCTION_TYPE_ALIAS (V4SF_FTYPE_V4SF_V4SF, TF)
 DEF_FUNCTION_TYPE_ALIAS (V4SI_FTYPE_V4SI_V4SI, TF)
 DEF_FUNCTION_TYPE_ALIAS (V8HI_FTYPE_V8HI_V8HI, TF)
+
+# MPX builtins
+DEF_FUNCTION_TYPE (BND, PCVOID, ULONG)
+DEF_FUNCTION_TYPE (VOID, PCVOID, BND)
+DEF_FUNCTION_TYPE (VOID, PCVOID, BND, PCVOID)
+DEF_FUNCTION_TYPE (BND, PCVOID, PCVOID)
+DEF_FUNCTION_TYPE (BND, PCVOID)
+DEF_FUNCTION_TYPE (BND, BND, BND)
+DEF_FUNCTION_TYPE (PVOID, PVOID, PVOID, ULONG)
+DEF_FUNCTION_TYPE (PVOID, PCVOID, BND, ULONG)
+DEF_FUNCTION_TYPE (ULONG, VOID)
+DEF_FUNCTION_TYPE (PVOID, BND)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 888f5ad..ac79231 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -81,6 +81,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "context.h"
 #include "pass_manager.h"
 #include "target-globals.h"
+#include "tree-chkp.h"
+#include "rtl-chkp.h"
 
 static rtx legitimize_dllimport_symbol (rtx, bool);
 static rtx legitimize_pe_coff_extern_decl (rtx, bool);
@@ -28723,6 +28725,19 @@ enum ix86_builtins
   IX86_BUILTIN_XABORT,
   IX86_BUILTIN_XTEST,
 
+  /* MPX */
+  IX86_BUILTIN_BNDMK,
+  IX86_BUILTIN_BNDSTX,
+  IX86_BUILTIN_BNDLDX,
+  IX86_BUILTIN_BNDCL,
+  IX86_BUILTIN_BNDCU,
+  IX86_BUILTIN_BNDRET,
+  IX86_BUILTIN_BNDNARROW,
+  IX86_BUILTIN_BNDINT,
+  IX86_BUILTIN_SIZEOF,
+  IX86_BUILTIN_BNDLOWER,
+  IX86_BUILTIN_BNDUPPER,
+
   /* BMI instructions.  */
   IX86_BUILTIN_BEXTR32,
   IX86_BUILTIN_BEXTR64,
@@ -28796,6 +28811,8 @@ struct builtin_isa {
   enum ix86_builtin_func_type tcode; /* type to use in the declaration */
   HOST_WIDE_INT isa;   /* isa_flags this builtin is defined for */
   bool const_p;/* true if the declaration is constant 
*/
+  bool leaf_p; /* true if the declaration has leaf attribute */
+  bool nothrow_p;  /* true if the declaration has nothrow 
attribute */
   bool set_and_not_built_p;
 };
 
@@ -28847,6 +28864,8 @@ def_builtin (HOST_WIDE_INT mask, const char *name,
  ix86_builtins[(int) code] = NULL_TREE;
  ix86_builtins_isa[(int) code].tcode = tcode;

Re: libgo patch committed: Merge from revision 18783 of master

2014-06-11 Thread Rainer Orth
Ian Lance Taylor  writes:

> On Wed, Jun 11, 2014 at 5:01 AM, Rainer Orth
>  wrote:
>> Ian Lance Taylor  writes:
>>
>>> On Fri, Jun 6, 2014 at 2:12 AM, Rainer Orth
>>>  wrote:
 Ian Lance Taylor  writes:

> I have committed a patch to libgo to merge from revision
> 18783:00cce3a34d7e of the master library.  This revision was committed
> January 7.  I picked this revision to merge to because the next revision
> deleted a file that is explicitly merged in by the libgo/merge.sh
> script.
>
> Among other things, this patch changes type descriptors to add a new
> pointer to a zero value.  In gccgo this is implemented as a common
> variable, and that requires some changes to the compiler and a small
> change to go-gcc.cc.

 This change introduced many failures on Solaris with /bin/ld, e.g.

 FAIL: go.test/test/bom.go -O (test for excess errors)

 ld: warning: symbol 'go$zerovalue' has differing sizes:
 (file bom.o value=0x8; file
 /var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/./libgo/.libs/libgo.so
 value=0x800);
 bom.o definition taken and updated with larger size
>>>
>>> Interesting.  This is working as intended, except for the warning.
>>>
>>> go$zerovalue is a common symbol, and the linker is supposed to use the
>>> larger version.  From the error message I'm guessing the Solaris
>>> linker supports this when linking object files, but not when linking
>>> an object file against a shared library.
>>>
>>> I wonder if we could avoid this warning by giving go$zerovalue hidden
>>> visibility.  That would mean something like this patch.
>>>
>>> Ian
>>>
>>> Index: go-gcc.cc
>>> ===
>>> --- go-gcc.cc (revision 211315)
>>> +++ go-gcc.cc (working copy)
>>> @@ -2521,6 +2521,8 @@ Gcc_backend::implicit_variable(const std
>>>DECL_COMMON(decl) = 1;
>>>TREE_PUBLIC(decl) = 1;
>>>gcc_assert(init_tree == NULL_TREE);
>>> +  DECL_VISIBILITY(decl) = VISIBILITY_HIDDEN;
>>> +  DECL_VISIBILITY_SPECIFIED(decl) = 1;
>>>  }
>>>else if (is_constant)
>>>  {
>>
>> Unfortunately, this doesn't make a difference.
>
> That is peculiar.  Can you verify that in libgo.so the symbol
> go$zerovalue is marked as hidden?  I don't understand why the linker
> would say anything about a symbol in a .o file not matching a hidden
> symbol in a .so file.  That seems like a linker bug, since the symbols
> are not being linked together.

It's not about libgo.so.  E.g. for the bug191 testcase, I get

ro@arenal 118 > 
/var/gcc/regression/trunk/11-gcc/build/gcc/testsuite/go1/../../gccgo 
-B/var/gcc/regression/trunk/11-gcc/build/gcc/testsuite/go1/../../ 
/vol/gcc/src/hg/trunk/local/gcc/testsuite/go.test/test/fixedbugs/bug191.dir/main.go
 -fno-diagnostics-show-caret -fdiagnostics-color=never 
-I/var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/./libgo -w -O2 -g 
a.o b.o -L/var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/./libgo 
-L/var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/./libgo/.libs -lm 
-o main.x -save-temps
ld: warning: symbol 'go$zerovalue' has differing sizes:
(file main.o value=0x8; file a.o value=0x4);
main.o definition taken
ld: warning: symbol 'go$zerovalue' has differing sizes:
(file main.o value=0x8; file b.o value=0x4);
main.o definition taken
ro@arenal 120 > elfdump -s main.o a.o b.o|egrep 'index|zerov'
  index  value size  type bind oth ver shndx  name
   [38]0x4  0x8  OBJT GLOB  H0 COMMON go$zerovalue
  index  value size  type bind oth ver shndx  name
   [27]0x4  0x4  OBJT GLOB  H0 COMMON go$zerovalue
  index  value size  type bind oth ver shndx  name
   [27]0x4  0x4  OBJT GLOB  H0 COMMON go$zerovalue

>> I've now found that ld
>> supports
>>
>>  -t
>>
>>  Turns off the  warning  for  multiply-defined  tentative
>>  (common block) data symbols that have different sizes or
>>  different  alignments.  This  option  is  equivalent  to
>>  specifying the -z relax=common option.
>>
>> But I'm reluctant to enable this globally.  Since Go uses no specs file,
>> support for target-specific (linker) options would have to go into gccgo
>> somehow.
>
> Does using that option fix the problem?

Yup, it does, I tried linking the testcase above with -Wl,-t added.

> The place to add a target-specific linker option is gcc/go/gospec.c.
> See, for example, the ways it adds -Wl,-u,pthread_create on some
> systems.

Ok, I'll have a look unless some other solution can be found.

Rainer

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


[PATCH, i386, Pointer Bounds Checker 33/x] MPX ABI

2014-06-11 Thread Ilya Enkovich
Hi,

This patch adds MPX ABI support for i386 target.

Bootstrapped and tested on linux-x86_64.

Thanks,
Ilya
--
gcc/

2014-06-11  Ilya Enkovich  

* config/i386/i386.c (ix86_option_override_internal): Do not
support x32 with MPX.
is not available.
(init_cumulative_args): Init stdarg, bnd_regno, bnds_in_bt
and force_bnd_pass.
(function_arg_advance_32): Return number of used integer
registers.
(function_arg_advance_64): Likewise.
(function_arg_advance_ms_64): Likewise.
(ix86_function_arg_advance): Handle pointer bounds.
(ix86_function_arg): Likewise.
(ix86_function_value_regno_p): Mark fisrt bounds registers as
possible function value.
(ix86_function_value_1): Handle pointer bounds type/mode
(ix86_return_in_memory): Likewise.
(ix86_print_operand): Analyse insn to decide abounf"bnd" prefix.
(ix86_expand_call): Generate returned bounds.
(ix86_bnd_prefixed_insn_p): Check if we have instrumented call
or function.
* config/i386/i386.h (ix86_args): Add bnd_regno, bnds_in_bt,
force_bnd_pass and stdarg fields.
* config/i386/i386.md (UNSPEC_BNDRET): New.
(*call_value): Add returned bounds.
(*sibcall_value): Likewise.
(*call_value_rex64_ms_sysv): Likewise.
(*call_value_pop): Likewise.
(*sibcall_value_pop): Likewise.
* config/i386/predicates.md (call_rex64_ms_sysv_operation): Adjust
to changed call patterns.


diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index dac83d0..a67e6e7 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3693,6 +3693,9 @@ ix86_option_override_internal (bool main_args_p,
   if (TARGET_X32 && (opts->x_ix86_isa_flags & OPTION_MASK_ISA_MPX))
 error ("Intel MPX does not support x32");
 
+  if (TARGET_X32 && (ix86_isa_flags & OPTION_MASK_ISA_MPX))
+error ("Intel MPX does not support x32");
+
   if (!strcmp (opts->x_ix86_arch_string, "generic"))
 error ("generic CPU can be used only for %stune=%s %s",
   prefix, suffix, sw);
@@ -6170,10 +6173,15 @@ init_cumulative_args (CUMULATIVE_ARGS *cum,  /* 
Argument info to initialize */
  FIXME: once typesytem is fixed, we won't need this code anymore.  */
   if (i && i->local && i->can_change_signature)
 fntype = TREE_TYPE (fndecl);
+  cum->stdarg = fntype ? stdarg_p (fntype) : false;
   cum->maybe_vaarg = (fntype
  ? (!prototype_p (fntype) || stdarg_p (fntype))
  : !libname);
 
+  cum->bnd_regno = FIRST_BND_REG;
+  cum->bnds_in_bt = 0;
+  cum->force_bnd_pass = 0;
+
   if (!TARGET_64BIT)
 {
   /* If there are variable arguments, then we won't pass anything
@@ -7108,11 +7116,13 @@ construct_container (enum machine_mode mode, enum 
machine_mode orig_mode,
and data type TYPE.  (TYPE is null for libcalls where that information
may not be available.)  */
 
-static void
+static int
 function_arg_advance_32 (CUMULATIVE_ARGS *cum, enum machine_mode mode,
 const_tree type, HOST_WIDE_INT bytes,
 HOST_WIDE_INT words)
 {
+  int res = 0;
+
   switch (mode)
 {
 default:
@@ -7130,7 +7140,8 @@ function_arg_advance_32 (CUMULATIVE_ARGS *cum, enum 
machine_mode mode,
   cum->words += words;
   cum->nregs -= words;
   cum->regno += words;
-
+  if (cum->nregs >= 0)
+   res = words;
   if (cum->nregs <= 0)
{
  cum->nregs = 0;
@@ -7201,36 +7212,42 @@ function_arg_advance_32 (CUMULATIVE_ARGS *cum, enum 
machine_mode mode,
}
   break;
 }
+
+  return res;
 }
 
-static void
+static int
 function_arg_advance_64 (CUMULATIVE_ARGS *cum, enum machine_mode mode,
 const_tree type, HOST_WIDE_INT words, bool named)
 {
-  int int_nregs, sse_nregs;
+  int int_nregs, sse_nregs, exam;
 
   /* Unnamed 512 and 256bit vector mode parameters are passed on stack.  */
   if (!named && (VALID_AVX512F_REG_MODE (mode)
 || VALID_AVX256_REG_MODE (mode)))
-return;
+return 0;
+
+  exam = examine_argument (mode, type, 0, &int_nregs, &sse_nregs);
 
-  if (examine_argument (mode, type, 0, &int_nregs, &sse_nregs)
+  if (exam
   && sse_nregs <= cum->sse_nregs && int_nregs <= cum->nregs)
 {
   cum->nregs -= int_nregs;
   cum->sse_nregs -= sse_nregs;
   cum->regno += int_nregs;
   cum->sse_regno += sse_nregs;
+  return int_nregs;
 }
   else
 {
   int align = ix86_function_arg_boundary (mode, type) / BITS_PER_WORD;
   cum->words = (cum->words + align - 1) & ~(align - 1);
   cum->words += words;
+  return 0;
 }
 }
 
-static void
+static int
 function_arg_advance_ms_64 (CUMULATIVE_ARGS *cum, HOST_WIDE_INT bytes,
HOST_WIDE_INT words)
 {
@@ -7242,7 +7259,9 @@ function_arg_advance_ms_64 (CUMULATIVE_ARGS *cum, 
HOST_WIDE_INT bytes,
 {
 

[PATCH, i386, Pointer Bounds Checker 32/x] Pointer Bounds Checker hooks for i386 target

2014-06-11 Thread Ilya Enkovich
Hi,

This patch adds i386 target hooks for Pointer Bounds Checker.

Bootstrapped and tested on linux-x86_64.

Thanks,
Ilya
--
gcc/

2014-06-11  Ilya Enkovich  

* config/i386/i386.c: Include tree-iterator.h.
(ix86_function_value_bounds): New.
(ix86_builtin_mpx_function): New.
(ix86_load_bounds): New.
(ix86_store_bounds): New.
(ix86_load_returned_bounds): New.
(ix86_store_returned_bounds): New.
(ix86_fn_abi_va_list_bounds_size): New.
(ix86_mpx_bound_mode): New.
(ix86_make_bounds_constant): New.
(ix86_initialize_bounds):
(TARGET_LOAD_BOUNDS_FOR_ARG): New.
(TARGET_STORE_BOUNDS_FOR_ARG): New.
(TARGET_LOAD_RETURNED_BOUNDS): New.
(TARGET_STORE_RETURNED_BOUNDS): New.
(TARGET_CHKP_BOUND_MODE): New.
(TARGET_BUILTIN_CHKP_FUNCTION): New.
(TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE): New.
(TARGET_CHKP_FUNCTION_VALUE_BOUNDS): New.
(TARGET_CHKP_MAKE_BOUNDS_CONSTANT): New.
(TARGET_CHKP_INITIALIZE_BOUNDS): New.


diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index ac79231..dac83d0 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -81,6 +81,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "context.h"
 #include "pass_manager.h"
 #include "target-globals.h"
+#include "tree-iterator.h"
 #include "tree-chkp.h"
 #include "rtl-chkp.h"
 
@@ -7971,6 +7972,39 @@ ix86_function_value (const_tree valtype, const_tree 
fntype_or_decl,
   return ix86_function_value_1 (valtype, fntype_or_decl, orig_mode, mode);
 }
 
+static rtx
+ix86_function_value_bounds (const_tree valtype,
+   const_tree fntype_or_decl ATTRIBUTE_UNUSED,
+   bool outgoing ATTRIBUTE_UNUSED)
+{
+  rtx res = NULL_RTX;
+
+  if (BOUNDED_TYPE_P (valtype))
+res = gen_rtx_REG (BNDmode, FIRST_BND_REG);
+  else if (chkp_type_has_pointer (valtype))
+{
+  bitmap slots = chkp_find_bound_slots (valtype);
+  rtx bounds[2];
+  bitmap_iterator bi;
+  unsigned i, bnd_no = 0;
+
+  EXECUTE_IF_SET_IN_BITMAP (slots, 0, i, bi)
+   {
+ rtx reg = gen_rtx_REG (BNDmode, FIRST_BND_REG + bnd_no);
+ rtx offs = GEN_INT (i * POINTER_SIZE / BITS_PER_UNIT);
+ gcc_assert (bnd_no < 2);
+ bounds[bnd_no++] = gen_rtx_EXPR_LIST (VOIDmode, reg, offs);
+   }
+
+  res = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (bnd_no, bounds));
+  BITMAP_FREE (slots);
+}
+  else
+res = NULL_RTX;
+
+  return res;
+}
+
 /* Pointer function arguments and return values are promoted to
word_mode.  */
 
@@ -36620,6 +36654,173 @@ static tree ix86_get_builtin (enum ix86_builtins code)
 return NULL_TREE;
 }
 
+/* Return function decl for target specific builtin
+   for given MPX builtin passed i FCODE.  */
+static tree
+ix86_builtin_mpx_function (unsigned fcode)
+{
+  switch (fcode)
+{
+case BUILT_IN_CHKP_BNDMK:
+  return ix86_builtins[IX86_BUILTIN_BNDMK];
+
+case BUILT_IN_CHKP_BNDSTX:
+  return ix86_builtins[IX86_BUILTIN_BNDSTX];
+
+case BUILT_IN_CHKP_BNDLDX:
+  return ix86_builtins[IX86_BUILTIN_BNDLDX];
+
+case BUILT_IN_CHKP_BNDCL:
+  return ix86_builtins[IX86_BUILTIN_BNDCL];
+
+case BUILT_IN_CHKP_BNDCU:
+  return ix86_builtins[IX86_BUILTIN_BNDCU];
+
+case BUILT_IN_CHKP_BNDRET:
+  return ix86_builtins[IX86_BUILTIN_BNDRET];
+
+case BUILT_IN_CHKP_INTERSECT:
+  return ix86_builtins[IX86_BUILTIN_BNDINT];
+
+case BUILT_IN_CHKP_NARROW:
+  return ix86_builtins[IX86_BUILTIN_BNDNARROW];
+
+case BUILT_IN_CHKP_SIZEOF:
+  return ix86_builtins[IX86_BUILTIN_SIZEOF];
+
+case BUILT_IN_CHKP_EXTRACT_LOWER:
+  return ix86_builtins[IX86_BUILTIN_BNDLOWER];
+
+case BUILT_IN_CHKP_EXTRACT_UPPER:
+  return ix86_builtins[IX86_BUILTIN_BNDUPPER];
+
+default:
+  return NULL_TREE;
+}
+
+  gcc_unreachable ();
+}
+
+/* Load bounds PTR pointer value loaded from SLOT.
+   if SLOT is a register then load bounds associated
+   with special address identified by BND.
+
+   Return loaded bounds.  */
+static rtx
+ix86_load_bounds (rtx slot, rtx ptr, rtx bnd)
+{
+  rtx addr = NULL;
+  rtx reg;
+
+  if (!ptr)
+{
+  gcc_assert (MEM_P (slot));
+  ptr = copy_to_mode_reg (Pmode, slot);
+}
+
+  if (!slot || REG_P (slot))
+{
+  if (slot)
+   ptr = slot;
+
+  gcc_assert (CONST_INT_P (bnd));
+
+  /* Here we have the case when more than four pointers are
+passed in registers.  In this case we are out of bound
+registers and have to use bndldx to load bound.  RA,
+RA - 8, etc. are used for address translation in bndldx.  */
+  addr = plus_constant (Pmode, arg_pointer_rtx, -(INTVAL (bnd) + 1) * 8);
+}
+  else if (MEM_P (slot))
+{
+  addr = XEXP (slot, 0);
+  addr = force_reg (Pmode, addr);
+}
+  else
+gcc_unreachable ();
+
+  ptr = force_reg (Pmode, ptr);

Re: [PATCH, Pointer Bounds Checker 28/x] IPA CP

2014-06-11 Thread Ilya Enkovich
On 11 Jun 15:07, Ilya Enkovich wrote:
> 2014-06-11 13:45 GMT+04:00 Martin Jambor :
> > Hi,
> >
> > On Wed, Jun 11, 2014 at 12:24:57PM +0400, Ilya Enkovich wrote:
> >> Hi,
> >>
> >> This patch fixes IPA CP pass to handle instrumented code correctly.
> >>
> >> Bootstrapped and tested on linux-x86_64.
> >>
> >> Thanks,
> >> Ilya
> >> --
> >> gcc/
> >>
> >> 2014-06-11  Ilya Enkovich  
> >>
> >>   * ipa-cp.c (initialize_node_lattices): Check original
> >>   version locality for instrumentation clones.
> >>   (propagate_constants_accross_call): Do not propagate
> >>   through instrumentation thunks.
> >>
> >>
> >> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
> >> index 689378a..683b9f0 100644
> >> --- a/gcc/ipa-cp.c
> >> +++ b/gcc/ipa-cp.c
> >> @@ -699,7 +699,10 @@ initialize_node_lattices (struct cgraph_node *node)
> >>int i;
> >>
> >>gcc_checking_assert (cgraph_function_with_gimple_body_p (node));
> >> -  if (!node->local.local)
> >> +  if (!node->local.local
> >> +  || (node->instrumentation_clone
> >> +   && node->instrumented_version
> >> +   && !node->instrumented_version->local.local))
> >
> > This looks quite convoluted, can you please put the test into a new
> > predicate in cgraph.c?  I assume you had to change other tests of the
> > local flag in a similar fashion anyway.
> 
> You are right. Would cgraph_node_local_p be OK?
> 
> >
> >>  {
> >>/* When cloning is allowed, we can assume that externally visible
> >>functions are not called.  We will compensate this by cloning
> >> @@ -1440,7 +1443,8 @@ propagate_constants_accross_call (struct cgraph_edge 
> >> *cs)
> >>alias_or_thunk = cs->callee;
> >>while (alias_or_thunk->alias)
> >>  alias_or_thunk = cgraph_alias_target (alias_or_thunk);
> >> -  if (alias_or_thunk->thunk.thunk_p)
> >> +  if (alias_or_thunk->thunk.thunk_p
> >> +  && !alias_or_thunk->thunk.add_pointer_bounds_args)
> >
> > so there are thunks that do not change the first argument and so we do
> > want to propagate to/through it?
> 
> Yes. Thunks marked as add_pointer_bounds_args do not change arguments,
> but add default pointer bounds for all pointer arguments.
> 
> >>  {
> >>ret |= set_all_contains_variable (ipa_get_parm_lattices 
> >> (callee_info,
> >>  0));
> >> @@ -1449,6 +1453,20 @@ propagate_constants_accross_call (struct 
> >> cgraph_edge *cs)
> >>else
> >>  i = 0;
> >>
> >> +  /* No propagation through instrumentation thunks is available yet.
> >> + It should be possible with proper mapping of call args and
> >> + instrumented callee params in the propagation loop below.  But
> >> + this case mostly occurs when legacy code calls instrumented code
> >> + and it is not a primary target for optimizations.  */
> >> +  if (!alias_or_thunk->instrumentation_clone
> >> +  && callee->instrumentation_clone)
> >> +{
> >> +  for (; i < parms_count; i++)
> >> + ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info,
> >> +  i));
> >> +  return ret;
> >> +}
> >> +
> >
> > and these thunks are different from those marked as
> > thunk.add_pointer_bounds_args?  If they are not, the previous hunk is
> > redundant.
> 
> This check covers more cases. It catches all chains of aliases and
> thunks where thunk.add_pointer_bounds_args is met. It does not mean
> the first met thunk has thunk.add_pointer_bounds_args (as is in
> previous check).  I suppose you are right about previous hunk. It
> would be better to make wider check first and make exit earlier. Will
> fix it.
> 
> >
> > My apologies for not looking at the patches introducing all the new
> > cgraph_node fields but it is quite difficult to figure out what the
> > new tests actually mean (that is why I'd really prefer predicates with
> > more explanatory names).
> 
> New predicates are good but do we need them for single usage? Locality
> check are used during output and new predicate would be nice for it.
> But there is no another thunk.add_pointer_bounds_args chain check used
> somewhere else. Will try to make more explanatory comment for it for
> now.
> 
> Thanks,
> Ilya
> 
> >
> > Thanks,
> >
> > Martin

Here is fixed verison.

Thanks,
Ilya
--
gcc/

2014-06-11  Ilya Enkovich  

* cgraph.h (cgraph_local_p): New.
* ipa-cp.c (initialize_node_lattices): Use cgraph_local_p
to handle instrumentation clones properly.
(propagate_constants_accross_call): Do not propagate
through instrumentation thunks.


diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 5e702a7..b225ebe 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -1556,4 +1556,17 @@ symtab_in_same_comdat_p (symtab_node *one, symtab_node 
*two)
 {
   return DECL_COMDAT_GROUP (one->decl) == DECL_COMDAT_GROUP (two->decl);
 }
+
+/* Return true if NODE is local.  Instrumentation clones are counted as local

Re: [PATCH, PR61446] Fix mode for register copy in REE pass

2014-06-11 Thread Dominique Dhumieres
> Yes, these are bootstraps with non-default configurations.

Core2 is the default for darwin and bootstrap is also broken for it
without the patch.

Dominique


Re: [Patch ARM/testsuite 00/22] Neon intrinsics executable tests

2014-06-11 Thread Christophe Lyon
On 11 June 2014 00:03, Ramana Radhakrishnan  wrote:
> On Thu, Jun 5, 2014 at 11:04 PM, Christophe Lyon
>  wrote:
>> This is patch series is a more complete version of the patch I sent
>> some time ago:
>> https://gcc.gnu.org/ml/gcc-patches/2013-10/msg00624.html
>>
>> I have created a series of patches to help review.  The 1st one adds
>> some documentation, the common .h files defining helpers used in the
>> actual tests, and two real tests (vaba and vld1) to show how the
>> various macros are used.
>>
>> The next patches add other tests (grouped when they use a common
>> framework).
>>
>> Looking at the .exp file, you'll notice that the tests are performed twice:
>> * once using c-torture-execute to make sure they execute correctly
>>   under various levels of optimization. In this case dejagnu
>>   directives embedded in each .c test file are ignored.
>>
>> * once using gcc-dg-runtest, which enables compiling with various
>>   optimization levels and scanning the generated assembly for some
>>   code sequences. Currently, only the vadd test contains some
>>   scan-assembler-times directives, as an example. We can add such
>>   directives to other tests later.
>
>>
>> Regarding the results of these tests on target
>> arm-none-linux-gnueabihf, note that:
>> * vclz tests currently fail at optimization levels starting with -O1
>> * vqadd test fails when compiled with -Os
>> * vadd scan-assembler fails for vadd.i64 (because the compiler uses
>>   core registers instead of Neon ones. Not sure if this should be
>>   considered as a bug or if the test should be changed)
>> * this gives 1164 PASS and 18 FAIL
>>
>
> I am a bit ambivalent between getting folks to add scan-assembler
> tests here and worrying between this and getting the behaviour
> correct. Additionally if you add the complexity of scanning for
> aarch64 as well this starts getting messy.
>

This feature wasn't in my testsuite originally, I added it recently
after your suggestion.
Indeed it's getting messy, not sure what the best way to proceed (and
that's why I only added the scan-assembler as an example in one test
:-)


> At this point I'm going to wait to see if any of the testsuite
> maintainers step in and comment and if not I'll start looking at this
> properly early next week.
>
OK thanks.

Christophe.


Re: [Patch ARM/testsuite 00/22] Neon intrinsics executable tests

2014-06-11 Thread Christophe Lyon
On 6 June 2014 22:15, Christophe Lyon  wrote:
> On 6 June 2014 17:57, Ramana Radhakrishnan  
> wrote:
>> On 06/06/14 15:40, Christophe Lyon wrote:
>>>
>>> On 6 June 2014 01:32, Joseph S. Myers  wrote:

 Have these been tested for both big and little endian (especially for
 tests where memory layout matters - load / store / lane number tests -
 remembering that GNU C vector initializers always use array ordering,
 which is not the same as the architecture-defined lane numbering for big
 endian)?

>>>
>>> I did run the tests on armeb-none-linux-gnueabihf (with qemu), and in
>>> addition to the FAILs I already mentionned I can see errors in the
>>> vzip and vuzp tests.
>>> At this stage I don't know if it's a bug in my tests or a compiler bug.
>>
>>
>> Didn't Alan recently fix a bug for big-endian in vzip / vuzp ?
>>
>> PR target/61062
>>
>> Ramana
>>
> Maybe, but this hasn't been committed yet, so I didn't test with this fix.
>
> Christophe.

After running my tests on an updated tree, here is what I have noted:
- I need to adjust vadd's target in scan-assembler directives:
arm*-*-* instead of arm*-*-* otherwise the tests are not executed for
targets such as arm-none-eabi.
- vzip/vuzp tests now PASS after Alan's fix.

I have run the following targets:
arm-none-linux-gnueabihf
arm-none-linux-gnueabi
arm-none-eabi
armeb-none-linux-gnueabihf
armeb-none-linux-gnueabi
aarch64-none-elf
aarch64_be-none-elf
aarch64-none-linux-gnu

All the arm* configs have the same 1164 PASS / 18 FAIL
- vadd's scan-assembler for vadd.i64 (as already discussed)
- vclz tests currently fail at optimization levels starting with -O1
- vqadd test fails when compiled with -Os

For aarch64, aarch64-none-elf and aarch64-none-linux-gnu have
hopefully the same results (1152 PASS, 30 FAIL, 2 UNRESOLVED):
- vadd's scan-assembler FAIL when optimizing: vadd of vectors of 1
64-bits element, and use of fadd for vectors of FP values. These tests
pass at -O0
- vqadd and vqsub -Og -g: ICE

In addtion, for aarch64_be (1108 PASS, 74 FAIL, 6 UNRESOLVED):
- vldX, vldX_lane, vzip and vuzp: ICE at any optim level (incl -O0)

Christophe.


Re: libgo patch committed: Merge from revision 18783 of master

2014-06-11 Thread Ian Lance Taylor
On Wed, Jun 11, 2014 at 5:01 AM, Rainer Orth
 wrote:
> Ian Lance Taylor  writes:
>
>> On Fri, Jun 6, 2014 at 2:12 AM, Rainer Orth  
>> wrote:
>>> Ian Lance Taylor  writes:
>>>
 I have committed a patch to libgo to merge from revision
 18783:00cce3a34d7e of the master library.  This revision was committed
 January 7.  I picked this revision to merge to because the next revision
 deleted a file that is explicitly merged in by the libgo/merge.sh
 script.

 Among other things, this patch changes type descriptors to add a new
 pointer to a zero value.  In gccgo this is implemented as a common
 variable, and that requires some changes to the compiler and a small
 change to go-gcc.cc.
>>>
>>> This change introduced many failures on Solaris with /bin/ld, e.g.
>>>
>>> FAIL: go.test/test/bom.go -O (test for excess errors)
>>>
>>> ld: warning: symbol 'go$zerovalue' has differing sizes:
>>> (file bom.o value=0x8; file
>>> /var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/./libgo/.libs/libgo.so
>>> value=0x800);
>>> bom.o definition taken and updated with larger size
>>
>> Interesting.  This is working as intended, except for the warning.
>>
>> go$zerovalue is a common symbol, and the linker is supposed to use the
>> larger version.  From the error message I'm guessing the Solaris
>> linker supports this when linking object files, but not when linking
>> an object file against a shared library.
>>
>> I wonder if we could avoid this warning by giving go$zerovalue hidden
>> visibility.  That would mean something like this patch.
>>
>> Ian
>>
>> Index: go-gcc.cc
>> ===
>> --- go-gcc.cc (revision 211315)
>> +++ go-gcc.cc (working copy)
>> @@ -2521,6 +2521,8 @@ Gcc_backend::implicit_variable(const std
>>DECL_COMMON(decl) = 1;
>>TREE_PUBLIC(decl) = 1;
>>gcc_assert(init_tree == NULL_TREE);
>> +  DECL_VISIBILITY(decl) = VISIBILITY_HIDDEN;
>> +  DECL_VISIBILITY_SPECIFIED(decl) = 1;
>>  }
>>else if (is_constant)
>>  {
>
> Unfortunately, this doesn't make a difference.

That is peculiar.  Can you verify that in libgo.so the symbol
go$zerovalue is marked as hidden?  I don't understand why the linker
would say anything about a symbol in a .o file not matching a hidden
symbol in a .so file.  That seems like a linker bug, since the symbols
are not being linked together.


> I've now found that ld
> supports
>
>  -t
>
>  Turns off the  warning  for  multiply-defined  tentative
>  (common block) data symbols that have different sizes or
>  different  alignments.  This  option  is  equivalent  to
>  specifying the -z relax=common option.
>
> But I'm reluctant to enable this globally.  Since Go uses no specs file,
> support for target-specific (linker) options would have to go into gccgo
> somehow.

Does using that option fix the problem?

The place to add a target-specific linker option is gcc/go/gospec.c.
See, for example, the ways it adds -Wl,-u,pthread_create on some
systems.

Ian


Re: [PATCH, PR61446] Fix mode for register copy in REE pass

2014-06-11 Thread Uros Bizjak
On Wed, Jun 11, 2014 at 3:19 PM, Dominique Dhumieres  wrote:
>> (I am not RTL reviewer, so I can't approve the patch).
>
> Is https://gcc.gnu.org/ml/gcc-regression/2014-06/ accepatble?

Yes, these are bootstraps with non-default configurations.

Uros.


Re: [PATCH, PR61446] Fix mode for register copy in REE pass

2014-06-11 Thread Dominique Dhumieres
> (I am not RTL reviewer, so I can't approve the patch).

Is https://gcc.gnu.org/ml/gcc-regression/2014-06/ accepatble?

Dominique


Re: [PATCH, PR61446] Fix mode for register copy in REE pass

2014-06-11 Thread Uros Bizjak
On Tue, Jun 10, 2014 at 3:45 PM, Dominique Dhumieres  wrote:
>> This patch fixes PR61446. ...
>
> Confirmed, it also allows to bootstrap Core* targets.
> Could it be reviewed and committed ASAP?

> 2014-06-09  Ilya Enkovich  
>
> PR 61446
> * ree.c (find_and_remove_re): Narrow mode for register copy
> if required.

Please also add the testcase form the PR.

(I am not RTL reviewer, so I can't approve the patch).

Uros.


Re: [PATCH 2/9] Add comments

2014-06-11 Thread Richard Earnshaw
On 11/06/14 11:19, Charles Baylis wrote:
> 2014-05-22  Charles Baylis  
> 
>   * config/arm/bpabi.S (__aeabi_uldivmod, __aeabi_ldivmod): Add comment
>   describing register usage on function entry and exit.


OK.

R.
> ---
>  libgcc/config/arm/bpabi.S | 16 
>  1 file changed, 16 insertions(+)
> 
> diff --git a/libgcc/config/arm/bpabi.S b/libgcc/config/arm/bpabi.S
> index f47d715..ae76cd3 100644
> --- a/libgcc/config/arm/bpabi.S
> +++ b/libgcc/config/arm/bpabi.S
> @@ -122,6 +122,14 @@ ARM_FUNC_START aeabi_ulcmp
>  
>  #ifdef L_aeabi_ldivmod
>  
> +/* Perform 64 bit signed division.
> +   Inputs:
> + r0:r1   numerator
> + r2:r3   denominator
> +   Outputs:
> + r0:r1   quotient
> + r2:r3   remainder
> + */
>  ARM_FUNC_START aeabi_ldivmod
>   cfi_start   __aeabi_ldivmod, LSYM(Lend_aeabi_ldivmod)
>   test_div_by_zerosigned
> @@ -145,6 +153,14 @@ ARM_FUNC_START aeabi_ldivmod
>  
>  #ifdef L_aeabi_uldivmod
>  
> +/* Perform 64 bit signed division.
> +   Inputs:
> + r0:r1   numerator
> + r2:r3   denominator
> +   Outputs:
> + r0:r1   quotient
> + r2:r3   remainder
> + */
>  ARM_FUNC_START aeabi_uldivmod
>   cfi_start   __aeabi_uldivmod, LSYM(Lend_aeabi_uldivmod)
>   test_div_by_zerounsigned
> 




Re: [PATCH 1/9] Whitespace

2014-06-11 Thread Richard Earnshaw
On 11/06/14 11:19, Charles Baylis wrote:
> 2014-05-22  Charles Baylis  
> 
>   * config/arm/bpabi.S (__aeabi_uldivmod): Fix whitespace.
>   (__aeabi_ldivmod): Fix whitespace.

This is OK, but please wait until the others are ready to go in.

R.

> ---
>  libgcc/config/arm/bpabi.S | 36 ++--
>  1 file changed, 18 insertions(+), 18 deletions(-)
> 
> diff --git a/libgcc/config/arm/bpabi.S b/libgcc/config/arm/bpabi.S
> index 7772301..f47d715 100644
> --- a/libgcc/config/arm/bpabi.S
> +++ b/libgcc/config/arm/bpabi.S
> @@ -124,20 +124,20 @@ ARM_FUNC_START aeabi_ulcmp
>  
>  ARM_FUNC_START aeabi_ldivmod
>   cfi_start   __aeabi_ldivmod, LSYM(Lend_aeabi_ldivmod)
> - test_div_by_zero signed
> + test_div_by_zerosigned
>  
> - sub sp, sp, #8
> + sub sp, sp, #8
>  #if defined(__thumb2__)
> - mov ip, sp
> - push {ip, lr}
> + mov ip, sp
> + push{ip, lr}
>  #else
> - do_push {sp, lr}
> + do_push {sp, lr}
>  #endif
>  98:  cfi_push 98b - __aeabi_ldivmod, 0xe, -0xc, 0x10
> - bl SYM(__gnu_ldivmod_helper) __PLT__
> - ldr lr, [sp, #4]
> - add sp, sp, #8
> - do_pop {r2, r3}
> + bl  SYM(__gnu_ldivmod_helper) __PLT__
> + ldr lr, [sp, #4]
> + add sp, sp, #8
> + do_pop  {r2, r3}
>   RET
>   cfi_end LSYM(Lend_aeabi_ldivmod)
>   
> @@ -147,20 +147,20 @@ ARM_FUNC_START aeabi_ldivmod
>  
>  ARM_FUNC_START aeabi_uldivmod
>   cfi_start   __aeabi_uldivmod, LSYM(Lend_aeabi_uldivmod)
> - test_div_by_zero unsigned
> + test_div_by_zerounsigned
>  
> - sub sp, sp, #8
> + sub sp, sp, #8
>  #if defined(__thumb2__)
> - mov ip, sp
> - push {ip, lr}
> + mov ip, sp
> + push{ip, lr}
>  #else
> - do_push {sp, lr}
> + do_push {sp, lr}
>  #endif
>  98:  cfi_push 98b - __aeabi_uldivmod, 0xe, -0xc, 0x10
> - bl SYM(__gnu_uldivmod_helper) __PLT__
> - ldr lr, [sp, #4]
> - add sp, sp, #8
> - do_pop {r2, r3}
> + bl  SYM(__gnu_uldivmod_helper) __PLT__
> + ldr lr, [sp, #4]
> + add sp, sp, #8
> + do_pop  {r2, r3}
>   RET
>   cfi_end LSYM(Lend_aeabi_uldivmod)
>  
> 




Re: [PATCH] Support asan-instrumentation-with-call-threshold in GCC (second try)

2014-06-11 Thread Yury Gribov

On 06/11/2014 01:31 PM, Jakub Jelinek wrote:

The plan (we had already for 4.9, but didn't get to that yet) is in the end
not to lower the checks in asan pass that much, and lower it in sanopt
pass later on after performing some inter-bb optimizations.
...
The reason for the plan is that it will be easier in the sanopt pass to
try to remove redundant instrumentation, e.g. when dominator bb already
checks a particular address/length and no calls that could change the
validity of the checks happen between the dominator bb and the dominated
__asan_load/storeX.


Sounds great, should help get rid of many useless checks.
Do you guys need a hand with this?


3) strlen instrumentation is still using two separate calls to
build_check_stmt (due to reasons I mentioned above).


If for strlen we check before the call the first byte and after the
call the last byte, then indeed we want two calls.  Or we could check
everything after the call and use one call after it.


Well, on one hand delaying the check risks accessing invalid memory.
But this would cause memory protection error worst case so may be fine.


Whitespace.  Please use tabs instead of spaces,
and align the lines below location_t.


Right, I didn't bother when sending the patch because I mostly worried 
about general correctness.

Attached version should have proper formatting.


Also, when it is one call or two minor checks in one
build_check_stmt call, we shouldn't record in the hash table start and end,
just the start, plus for NULL len also size_in_bytes, for non-NULL len
probably nothing, we don't know if len isn't zero.


Like this?

-Y
2014-06-11  Yury Gribov  
	
	New asan-instrumentation-with-call-threshold parameter.
	
	gcc/
	* asan.c (check_func): New function.
	(maybe_create_ssa_name): Likewise.
	(build_check_stmt_with_calls): Likewise.
	(use_calls_p): Likewise.
	(report_error_func): Change interface.
	(build_check_stmt): Allow non-integer lengths; add support
	for new parameter.
	(asan_instrument): Likewise.
	(instrument_mem_region_access): Moved code to
	build_check_stmt.
	(instrument_derefs): Likewise.
	(instrument_strlen_call): Likewise.
	* cfgcleanup.c (old_insns_match_p): Add support for new
	functions.
	* doc/invoke.texi: Describe new parameter.
	* params.def: Define new parameter.
	* params.h: Likewise.
	* sanitizer.def: Describe new builtins.
	
	gcc/testsuite/
	* c-c++-common/asan/instrument-with-calls-1.c: New test.
	* c-c++-common/asan/instrument-with-calls-2.c: Likewise.
	* c-c++-common/asan/instrument-with-calls-3.c: Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-1.c: Update
	test patterns.
	* c-c++-common/asan/no-redundant-instrumentation-2.c:
	Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-4.c:
	Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-5.c:
	Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-6.c:
	Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-7.c:
	Likewise.
	* c-c++-common/asan/no-redundant-instrumentation-8.c:
	Likewise.

diff --git a/gcc/asan.c b/gcc/asan.c
index 3397655..5f0a2de 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -242,6 +242,19 @@ static GTY(()) tree shadow_ptr_types[2];
 /* Decl for __asan_option_detect_stack_use_after_return.  */
 static GTY(()) tree asan_detect_stack_use_after_return;
 
+/* Number of instrumentations in current function so far.  */
+
+static int asan_num_accesses;
+
+/* Check whether we should replace inline instrumentation with calls.  */
+
+static inline bool
+use_calls_p ()
+{
+  return ASAN_INSTRUMENTATION_WITH_CALL_THRESHOLD < INT_MAX
+&& asan_num_accesses >= ASAN_INSTRUMENTATION_WITH_CALL_THRESHOLD;
+}
+
 /* Hashtable support for memory references used by gimple
statements.  */
 
@@ -1319,7 +1332,7 @@ asan_protect_global (tree decl)
IS_STORE is either 1 (for a store) or 0 (for a load).  */
 
 static tree
-report_error_func (bool is_store, HOST_WIDE_INT size_in_bytes, bool slow_p)
+report_error_func (bool is_store, HOST_WIDE_INT size_in_bytes, int *nargs)
 {
   static enum built_in_function report[2][6]
 = { { BUILT_IN_ASAN_REPORT_LOAD1, BUILT_IN_ASAN_REPORT_LOAD2,
@@ -1328,13 +1341,37 @@ report_error_func (bool is_store, HOST_WIDE_INT size_in_bytes, bool slow_p)
 	{ BUILT_IN_ASAN_REPORT_STORE1, BUILT_IN_ASAN_REPORT_STORE2,
 	  BUILT_IN_ASAN_REPORT_STORE4, BUILT_IN_ASAN_REPORT_STORE8,
 	  BUILT_IN_ASAN_REPORT_STORE16, BUILT_IN_ASAN_REPORT_STORE_N } };
-  if ((size_in_bytes & (size_in_bytes - 1)) != 0
-  || size_in_bytes > 16
-  || slow_p)
-return builtin_decl_implicit (report[is_store][5]);
+  if (size_in_bytes == -1)
+{
+  *nargs = 2;
+  return builtin_decl_implicit (report[is_store][5]);
+}
+  *nargs = 1;
   return builtin_decl_implicit (report[is_store][exact_log2 (size_in_bytes)]);
 }
 
+/* Construct a function tree for __asan_{load,store}{1,2,4,8,16,_n}.
+   IS_STORE is either 1 (for a store) or 0 (for a load).  */
+
+static tree
+check_func (bool is_store, int size_in_bytes, 

[PATCH][RX] Patch to correct the functionality of compiler option -falign-labels=n

2014-06-11 Thread Sandeep Kumar Singh
Hi,

The RX compiler align wrong labels with option falign-labels=n, where n is 
number 
of bytes. The relationship between -falign-labels and expected .balign output 
supposed to be:
-falign-labels=4 --> .balign 4
-falign-labels=8 --> .balign 8
-falign-labels=16 --> .balign 16

However, listed pseudo code was the like (without any optimization):
-falign-labels=1 --> .balign 2
-falign-labels=4 --> .balign 16
-falign-labels=8 --> .balign 256
-falign-labels=16 --> .balign 65536

No regression found with this patch.

Please review the patch and let me know if there should be any modifications
in it?

Regards,
Sandeep Kumar Singh,
KPIT Cummins InfoSystems Ltd.
Pune, India

gcc/ChangeLog
2014-06-11  Sandeep Kumar Singh  

* config/rx/rx.h (Corrected macro LABEL_ALIGN).




rx_align_labels.patch
Description: rx_align_labels.patch


Re: [PING*2][PATCH] Extend mode-switching to support toggle (1/2)

2014-06-11 Thread Christian Bruel

On 06/10/2014 04:03 PM, Joern Rennecke wrote:
> On 13 May 2014 22:41, Oleg Endo  wrote:
>
>> Right.  I was thinking to add FPSCR.SZ mode switching to SH, in order to
>> do float vector moves.  For that SZ and PR need to be switched both at
>> the same time (only SH4A has both, fpchg and fschg).  So basically I'd
>> add another mode entity, which would emit SZ mode changes in addition to
>> the PR mode changes.  But then adjacent FPSCR-changing insns could be
>> combined ... any idea/suggestion how to accomplish that?
> If they are sufficiently adjacent, you can use a peephole2 pattern for this.
>
> I see Cristian's patch addresses this in a different way - keeping size and
> precision in the same entity, and emitting toggles as appropriate.

yes, I was only interested to optimize the SH4a case when PR=1 with a
good enough implementation. To cover all the other possibilities a new
entity would be better. But then as you say recombining them might be
difficult.  An alternate hackish way could be to have a singe entity
with 4 modes covering all PR*SZ combinations).

but I'm not sure that covering the case where PR=0 SZ=1 worth it, maybe
code size only, ? as the 64 move would be implemented as 2*32 moves anyway,

>
> The problem get's a bit more interesting if you have some instruction patterns
> that care about one setting but not the other.
> Describing this exactly allows lazy code motion to be a bit more lazy, but 
> OTOH
> it can make it harder to combine mode switching instructions if you
> still want to
> do that.



[Ada] Fix handling of pragma/aspect Independent[_Components]

2014-06-11 Thread Arnaud Charlet
This fixes several errors in the handling of the pragmas Independent
and Independent_Components. The implementation now matches the RM
definition 100%. The following compiles without errors:

 1. package Independ is
 2.type A1 is array (1 .. 10) of Integer;
 3.pragma Independent_Components (A1);
 4.
 5.type A2 is array (1 .. 10) of Integer
 6.  with Independent_Components;
 7.
 8.A3 : array (1 .. 10) of Integer;
 9.pragma Independent_Components (A3);
10.
11.A4 : array (1 .. 10) of Integer
12.  with Independent_Components;
13.
14.type R1 is record
15.   X, Y : Integer;
16.end record;
17.pragma Independent_Components (R1);
18.
19.type R2 is record
20.   X, Y : Integer;
21.end record
22.  with Independent_Components;
23.
24.type R3 is record
25.   X, Y : Integer;
26.   pragma Independent (X);
27.end record;
28.
29.type R4 is record
30.   X : Integer with Independent;
31.   Y : Integer;
32.end record;
33. end;

The following test compiles with the errors shown

 1. package Independ2 is
 2.type A1 is array (1 .. 10) of Boolean;
 3.for A1'Component_Size use 1;
 4.pragma Independent_Components (A1);
   |
>>> independent components cannot be guaranteed for "A1"

 5.
 6.type A2 is array (1 .. 10) of Boolean
 7.  with Independent_Components,
  |
>>> independent components cannot be guaranteed for "A2"

 8.   Component_Size => 1;
 9.
10.type R1 is record
11.   X, Y : Boolean;
12.end record;
13.pragma Independent_Components (R1);
   |
>>> independent components cannot be guaranteed for "R1"
>>> because of Component_Clause at line 15

14.for R1 use record
15.   X at 0 range 0 .. 0;
16.   Y at 0 range 1 .. 1;
17.end record;
18.
19.type R2 is record
20.   X, Y : Boolean;
21.end record
22.  with Independent_Components;
  |
>>> independent components cannot be guaranteed for "R2"
>>> because of Component_Clause at line 24

23.for R2 use record
24.   X at 0 range 0 .. 0;
25.   Y at 0 range 1 .. 1;
26.end record;
27.
28.type R3 is record
29.   X, Y : Boolean;
30.   pragma Independent (X);
  |
>>> independence cannot be guaranteed for "X"
>>> because of Component_Clause at line 33

31.end record;
32.for R3 use record
33.   X at 0 range 0 .. 0;
34.   Y at 0 range 1 .. 1;
35.end record;
36.
37.type R4 is record
38.   X : Boolean with Independent;
   |
>>> independence cannot be guaranteed for "X"
>>> because of Component_Clause at line 42

39.   Y : Boolean;
40.end record;
41.for R4 use record
42.   X at 0 range 0 .. 0;
43.   Y at 0 range 1 .. 1;
44.end record;
45. end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-06-11  Robert Dewar  

* einfo.adb (Is_Independent): New flag.
* einfo.ads (Is_Independent): New flag.
(Has_Independent_Components): Clean up and fix comments.
* sem_prag.adb (Fix_Error): Deal with changing argument
[of] to entity [for].
(Analyze_Pragma, case Independent): Set Is_Independent flag
(Analyze_Pragma, case Independent_Components): Set Is_Independent flag
in all components of specified record.

Index: einfo.adb
===
--- einfo.adb   (revision 211445)
+++ einfo.adb   (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2013, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2014, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -558,12 +558,12 @@
--SPARK_Pragma_Inherited  Flag265
--SPARK_Aux_Pragma_Inherited  Flag266
--Has_Shift_Operator  Flag267
+   --Is_Independent  Flag268
 
--(unused)Flag1
--(unused)Flag2
--(unused)Flag3
 
-   --(unused)Flag268
--(unused)

[Ada] Consistent processing of preelaborated units across language versions

2014-06-11 Thread Arnaud Charlet
The processing of pragma Preelaborate_05 might cause inconsistent compiler
behaviour when a given unit having the pragma appears in the dependencies
of both an Ada 95 and and Ada 2005 unit in the same closure. This is
addressed by making runtime units Preelaborate in all cases.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-06-11  Thomas Quinot  

* a-astaco.ads, a-tags.ads, s-excdeb.ads, a-tgdico.ads, a-stmaco.ads,
a-except-2005.ads, s-except.ads, a-taside.ads, a-dynpri.ads,
a-chahan.ads, a-sytaco.ads, s-stalib.ads, a-strmap.ads: Change pragmas
Preelaborate_05 to just Preelaborate in runtime units, and similarly
change Pure_05 to just Pure.

Index: a-astaco.ads
===
--- a-astaco.ads(revision 211445)
+++ a-astaco.ads(working copy)
@@ -27,7 +27,7 @@
 with Ada.Task_Identification;
 
 package Ada.Asynchronous_Task_Control is
-   pragma Preelaborate_05;
+   pragma Preelaborate;
--  In accordance with Ada 2005 AI-362
 
pragma Unimplemented_Unit;
Index: a-tags.ads
===
--- a-tags.ads  (revision 211445)
+++ a-tags.ads  (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2014, Free Software Foundation, Inc. --
 --  --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -37,7 +37,7 @@
 with System.Storage_Elements;
 
 package Ada.Tags is
-   pragma Preelaborate_05;
+   pragma Preelaborate;
--  In accordance with Ada 2005 AI-362
 
type Tag is private;
Index: s-excdeb.ads
===
--- s-excdeb.ads(revision 211445)
+++ s-excdeb.ads(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 2006-2013, Free Software Foundation, Inc. --
+--  Copyright (C) 2006-2014, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -39,7 +39,7 @@
 
 package System.Exceptions_Debug is
 
-   pragma Preelaborate_05;
+   pragma Preelaborate;
--  To let Ada.Exceptions "with" us and let us "with" Standard_Library
 
package SSL renames System.Standard_Library;
Index: a-tgdico.ads
===
--- a-tgdico.ads(revision 211445)
+++ a-tgdico.ads(working copy)
@@ -25,7 +25,7 @@
 function Ada.Tags.Generic_Dispatching_Constructor
   (The_Tag : Tag;
Params  : not null access Parameters) return T'Class;
-pragma Preelaborate_05 (Generic_Dispatching_Constructor);
+pragma Preelaborate (Generic_Dispatching_Constructor);
 pragma Import (Intrinsic, Generic_Dispatching_Constructor);
 --  Note: the reason that we use Preelaborate_05 here is so that this will
 --  compile fine during the normal build procedures. In Ada 2005 mode (which
Index: a-stmaco.ads
===
--- a-stmaco.ads(revision 211445)
+++ a-stmaco.ads(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 1992-2009, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2014, Free Software Foundation, Inc. --
 --  --
 -- This specification is derived from the Ada Reference Manual for use with --
 -- GNAT. The copyright notice above, and the license provisions that follow --
@@ -36,8 +36,7 @@
 with Ada.Characters.Latin_1;
 
 package Ada.Strings.Maps.Constants is
-   pragma Preelaborate;
-   pragma Pure_05;
+   pragma Pure;
--  In accordance with Ada 2005 AI-362
 
Control_Set   : constant Character_Set;
Index: a-except-2005.ads
===
--- a-except-2005.ads   (revisio

[Ada] Better handling of variant records with No_Implicit_Conditionals

2014-06-11 Thread Arnaud Charlet
Previously, an attempt to declare a variant record type was rejected if
restriction No_Implicit_Conditionals was active, since the resulting
generated equality and initialization routines contained implicit tests.
Now such declarations are allowed, but these routines are not generated
if the restriction is active. Furthermore, if the restriction is active,
then any attempt to do a comparison of variant records, or to default
initialize such a record, will be considered a violation. The following
test is compiled with -gnatl -gnatj65 in the presence of a gnat.adc
file containing pragma Restrictions (No_Implicit_Conditionals).

 1. package NICDisc is
 2. type Enum is (One, Two, Three, Four);
 3. type Variant (En : Enum) is record
 4.E : Enum := En;
 5.case En is
 6.   when One =>
 7.  I : Integer := 0;
 8.   when Two =>
 9.  B  : Boolean := True;
10.  I2 : Integer;
11.   when Three | Four =>
12.  null;
13.end case;
14. end record;
15. end NICDisc;

 1. with NICDisc; use NICDisc;
 2. package NICDiscr is
 3.W : Variant (Two);
   |
>>> violation of restriction "No_Implicit_Conditionals"
at gnat.adc:1, initialization of variant record
tests discriminants

 4.X : Variant := (One, Two, 23);
 5.Y : Variant := (Two, Two, True, 24);
 6.M : Boolean := X = Y;
|
>>> violation of restriction "No_Implicit_Conditionals"
at gnat.adc:1, comparison of variant records tests
discriminants

 7. end;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-06-11  Robert Dewar  

* exp_ch3.adb (Build_Record_Init_Proc): Don't build for variant
record type if restriction No_Implicit_Conditionals is active.
(Expand_N_Object_Declaration): Don't allow default initialization
for variant record type if restriction No_Implicit_Condition is active.
(Build_Variant_Record_Equality): Don't build for variant
record type if restriction No_Implicit_Conditionals is active.
* exp_ch4.adb (Expand_N_Op_Eq): Error if variant records with
No_Implicit_Conditionals.
* sem_aux.ads, sem_aux.adb (Has_Variant_Part): New function.

Index: sem_aux.adb
===
--- sem_aux.adb (revision 211445)
+++ sem_aux.adb (working copy)
@@ -666,6 +666,51 @@
   end if;
end Has_Unconstrained_Elements;
 
+   --
+   -- Has_Variant_Part --
+   --
+
+   function Has_Variant_Part (Typ : Entity_Id) return Boolean is
+  FSTyp : Entity_Id;
+  Decl  : Node_Id;
+  TDef  : Node_Id;
+  CList : Node_Id;
+
+   begin
+  if not Is_Type (Typ) then
+ return False;
+  end if;
+
+  FSTyp := First_Subtype (Typ);
+
+  if not Has_Discriminants (FSTyp) then
+ return False;
+  end if;
+
+  --  Proceed with cautious checks here, return False if tree is not
+  --  as expected (may be caused by prior errors).
+
+  Decl := Declaration_Node (FSTyp);
+
+  if Nkind (Decl) /= N_Full_Type_Declaration then
+ return False;
+  end if;
+
+  TDef := Type_Definition (Decl);
+
+  if Nkind (TDef) /= N_Record_Definition then
+ return False;
+  end if;
+
+  CList := Component_List (TDef);
+
+  if Nkind (CList) /= N_Component_List then
+ return False;
+  else
+ return Present (Variant_Part (CList));
+  end if;
+   end Has_Variant_Part;
+
-
-- In_Generic_Body --
-
Index: sem_aux.ads
===
--- sem_aux.ads (revision 211445)
+++ sem_aux.ads (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 1992-2013, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2014, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -255,6 +255,10 @@
--  True if T has discriminants and is unconstrained, or is an array type
--  whose element type Has_Unconstrained_Elements.
 
+   function Has_Variant_Part (Typ : Entity_Id) return Boolean;
+   --  Return True if the first subtype of Typ is a discriminated record type
+   --  which has a variant part. False otherwise.
+
function In_Generic_Body (Id : Entity_Id) return

[Ada] Error not detected in illegal selected component

2014-06-11 Thread Arnaud Charlet
This patch corrects an error in the resolution of selected components when the
prefix is overloaded and none of the interpretations matches the context.

Compiling resolve_func_deref_comp.adb must yield:

resolve_func_deref_comp.adb:14:18:
  no interpretation matches type access to "T" defined at line 12
resolve_func_deref_comp.adb:14:18:
  expected type must be a general access type

--
procedure Resolve_Func_Deref_Comp is
   type T is null record;
   type Acc_T is access T;
   type Rec is record
  T_Comp : Acc_T;
   end record;
   type Acc_Rec is access all Rec;
   function F return Integer is (0);
   function F return Acc_Rec is (null);
begin
   declare
  Some_T : access T;
   begin
  Some_T := F.T_Comp;
   end;
end Resolve_Func_Deref_Comp;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-06-11  Ed Schonberg  

* sem_res.adb (Resolve_Selected_Component): Handle properly a
selected component whose prefix is overloaded, when none of the
interpretations matches the expected type.

Index: sem_res.adb
===
--- sem_res.adb (revision 211445)
+++ sem_res.adb (working copy)
@@ -9159,7 +9159,7 @@
Comp := First_Entity (T);
while Present (Comp) loop
   if Chars (Comp) = Chars (S)
-and then Covers (Etype (Comp), Typ)
+and then Covers (Typ, Etype (Comp))
   then
  if not Found then
 Found := True;
@@ -9213,6 +9213,9 @@
 Get_Next_Interp (I, It);
  end loop Search;
 
+ --  There must be a legal interpreations at this point.
+
+ pragma Assert (Found);
  Resolve (P, It1.Typ);
  Set_Etype (N, Typ);
  Set_Entity_With_Checks (S, Comp1);
@@ -9240,6 +9243,7 @@
   if Is_Access_Type (Etype (P)) then
  T := Designated_Type (Etype (P));
  Check_Fully_Declared_Prefix (T, P);
+
   else
  T := Etype (P);
   end if;


Ping x 6: [PATCH] [libgomp] make it possible to use OMP on both sides of a fork

2014-06-11 Thread Nathaniel Smith
Hi all,

Ping. Again, this patch fixes a limitation in GOMP which makes it
impossible for programmers who care about gcc compatibility to safely
use OpenMP in libraries; GOMP is the last OpenMP implementation with
this limitation.

-n

On Wed, May 14, 2014 at 3:47 PM, Nathaniel Smith  wrote:
> Hi all,
>
> Pinging again about the patch below. The lack of this patch is
> essentially a blocker to using gcc+python+openmp together, which is a
> shame, since python is increasingly important in numerical computing,
> openmp is pretty useful, and gcc is the only openmp implementation
> that does not support this functionality.
>
> -n
>
> On Tue, Apr 15, 2014 at 1:19 PM, Nathaniel Smith  wrote:
>> On Tue, Mar 4, 2014 at 11:37 PM, Nathaniel Smith  wrote:
>>> On Tue, Feb 18, 2014 at 8:58 PM, Richard Henderson  wrote:
 On 02/16/2014 03:59 PM, Nathaniel Smith wrote:
> Yes, but the problem is that depending on what the user intends to do
> after forking, our pthread_atfork handler might help or it might hurt,
> and we don't know which. Consider these two cases:
>   - fork+exec
>   - fork+continue to use OMP in child
> The former case is totally POSIX-legal, even when performed at
> arbitrary places, even when another thread is, say, in the middle of
> calling malloc().

 Point well taken.
>>>
>>> Hi all,
>>>
>>> I guess this patch has gotten all the feedback that it's getting. Any
>>> interest in committing it? :-) I don't have commit access.
>>>
>>> 2014-02-12  Nathaniel J. Smith  
>>>
>>> * team.c (gomp_free_pool_helper): Move per-thread cleanup to main
>>> thread.
>>> (gomp_free_thread): Delegate implementation to...
>>> (gomp_free_thread_pool): ...this new function. Like old
>>> gomp_free_thread, but does per-thread cleanup, and has option to
>>> skip everything that involves interacting with actual threads,
>>> which is useful when called after fork.
>>> (gomp_after_fork_callback): New function.
>>> (gomp_team_start): Register atfork handler, and check for fork on
>>> entry.
>>
>> Pinging this again now that trunk has re-opened. For compliant code
>> this patch has essentially no impact (OMP-using code acquires a
>> single-line post-fork callback which sets a flag; everything else
>> works the same as now). For technically non-compliant "mostly serial"
>> code that uses OMP in some places, and forks children in other places,
>> it makes a best effort attempt to clean up the thread pool detritus
>> left by a fork, instead of simply deadlocking as currently, so as to
>> allow children to use OMP as well. This makes GOMP match the behaviour
>> of all other OMP implementations I'm aware of.
>>
>> Previous discussion:
>>   http://gcc.gnu.org/ml/gcc-patches/2014-02/msg00813.html
>> Bug:
>>http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60035
>>
>> I don't have a commit bit -- please commit if acceptable.
>>
>> Cheers,
>> -n
>>
>> --
>> Nathaniel J. Smith
>> Postdoctoral researcher - Informatics - University of Edinburgh
>> http://vorpus.org
>
> --
> Nathaniel J. Smith
> Postdoctoral researcher - Informatics - University of Edinburgh
> http://vorpus.org



-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org
Index: team.c
===
--- team.c  (revision 207398)
+++ team.c  (working copy)
@@ -28,6 +28,7 @@
 #include "libgomp.h"
 #include 
 #include 
+#include 
 
 /* This attribute contains PTHREAD_CREATE_DETACHED.  */
 pthread_attr_t gomp_thread_attr;
@@ -43,6 +44,8 @@ __thread struct gomp_thread gomp_tls_data;
 pthread_key_t gomp_tls_key;
 #endif
 
+/* This is to enable best-effort cleanup after fork.  */
+static bool gomp_we_are_forked;
 
 /* This structure is used to communicate across pthread_create.  */
 
@@ -204,42 +207,41 @@ static struct gomp_thread_pool *gomp_new_thread_po
   return pool;
 }
 
+/* Free a thread pool and release its threads. */
+
 static void
 gomp_free_pool_helper (void *thread_pool)
 {
-  struct gomp_thread *thr = gomp_thread ();
   struct gomp_thread_pool *pool
 = (struct gomp_thread_pool *) thread_pool;
   gomp_barrier_wait_last (&pool->threads_dock);
-  gomp_sem_destroy (&thr->release);
-  thr->thread_pool = NULL;
-  thr->task = NULL;
   pthread_exit (NULL);
 }
 
-/* Free a thread pool and release its threads. */
-
-void
-gomp_free_thread (void *arg __attribute__((unused)))
+static void
+gomp_free_thread_pool (bool threads_are_running)
 {
   struct gomp_thread *thr = gomp_thread ();
   struct gomp_thread_pool *pool = thr->thread_pool;
   if (pool)
 {
+  int i;
   if (pool->threads_used > 0)
{
- int i;
- for (i = 1; i < pool->threads_used; i++)
+ if (threads_are_running)
{
- struct gomp_thread *nthr = pool->threads[i];
- nthr->fn = gomp_free_pool_helper;
- nthr->

[Ada] gnat link and shared libraries

2014-06-11 Thread Arnaud Charlet
When "gnat link" is invoked and there are shared libraries, the link may
be incorrect on some platforms, such as Windows. This is fixed by this patch.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-06-11  Vincent Celier  

* gnatcmd.adb (Process_Link): Do not invoke gnatlink with
-lgnarl or -lgnat.

Index: gnatcmd.adb
===
--- gnatcmd.adb (revision 211445)
+++ gnatcmd.adb (working copy)
@@ -1075,18 +1075,8 @@
 
   if Libraries_Present then
 
- --  Add -L -lgnarl -lgnat -Wl,-rpath,
+ --  Add -Wl,-rpath,
 
- Last_Switches.Increment_Last;
- Last_Switches.Table (Last_Switches.Last) :=
-   new String'("-L" & MLib.Utl.Lib_Directory);
- Last_Switches.Increment_Last;
- Last_Switches.Table (Last_Switches.Last) :=
-   new String'("-lgnarl");
- Last_Switches.Increment_Last;
- Last_Switches.Table (Last_Switches.Last) :=
-   new String'("-lgnat");
-
  --  If Path_Option is not null, create the switch ("-Wl,-rpath," or
  --  equivalent) with all the library dirs plus the standard GNAT
  --  library dir.


[Ada] Analyze contracts of subprogram body stubs

2014-06-11 Thread Arnaud Charlet
This patch ensures that contract of subprogram body stubs are analyzed in
timely fashion.


-- Source --


--  pack.ads

package Pack
  with SPARK_Mode,
   Abstract_State => State,
   Initializes=> (Var_1, State)
is
   Var_1 : Integer := 0;

   procedure Double
 with Global => (In_Out => (State, Var_1));

   procedure Error_1
 with Global => (In_Out => State);
end Pack;

--  pack-double.adb

separate (Pack)

procedure Double with SPARK_Mode is
begin
   Var_1 := Var_1 * 2;
end Double;

--  pack-double_a.adb

separate (Pack)

procedure Double_A with SPARK_Mode is
begin
   Var_2 := Var_2 * 2;
end Double_A;

--  pack-error_1.adb

separate (Pack)

procedure Error_1 with SPARK_Mode is
begin
   null;
end Error_1;

--  pack-error_2.adb

separate (Pack)

procedure Error_2 with SPARK_Mode is
begin
   null;
end Error_2;

--  pack.adb

package body Pack
  with SPARK_Mode,
   Refined_State => (State => Var_2)
is
   Var_2 : Integer := 0;

   procedure Double is separate
 with Refined_Global => (In_Out => (Var_1, Var_2));

   procedure Double_A is separate
 with Global => (In_Out => Var_2);

   procedure Error_1 is separate
 with Refined_Global => (In_Out => Junk_1);

   procedure Error_2 is separate
 with Global => (In_Out => Junk_2);
end Pack;


-- Compilation and output --


$ gcc -c pack.adb
pack.adb:14:40: "Junk_1" is undefined
pack.adb:17:32: "Junk_2" is undefined

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-06-11  Hristian Kirtchev  

* sem_ch3.adb Add with and use clause for Sem_Ch10.
(Analyze_Declarations): Code reformatting. Analyze the contract
of a subprogram body stub at the end of the declarative region.
* sem_ch6.adb (Analyze_Subprogram_Body_Contract): Spec_Id is
now a variable. Do not process the body if its contract is not
available. Account for subprogram body stubs when extracting
the corresponding spec.
* sem_ch6.ads (Analyze_Subprogram_Contract): Update the comment
on usage.
* sem_ch10.ads, sem_ch10.adb (Analyze_Subprogram_Body_Stub_Contract):
New routine.
* sem_prag.adb (Analyze_Depends_In_Decl_Part):
Account for subprogram body stubs when extracting the
corresponding spec.
(Analyze_Global_In_Decl_List):
Account for subprogram body stubs when extracting the
corresponding spec.
(Analyze_Refined_Depends_In_Decl_Part):
Use Find_Related_Subprogram_Or_Body to retrieve the declaration
of the related body. Spec_Is now a variable. Account for
subprogram body stubs when extracting the corresponding spec.
(Analyze_Refined_Global_In_Decl_Part): Use
Find_Related_Subprogram_Or_Body to retrieve the declaration
of the related body. Spec_Is now a variable. Account for
subprogram body stubs when extracting the corresponding spec.
(Collect_Subprogram_Inputs_Output): Account for subprogram body
stubs when extracting the corresponding spec.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 211448)
+++ sem_ch3.adb (working copy)
@@ -57,6 +57,7 @@
 with Sem_Ch6;  use Sem_Ch6;
 with Sem_Ch7;  use Sem_Ch7;
 with Sem_Ch8;  use Sem_Ch8;
+with Sem_Ch10; use Sem_Ch10;
 with Sem_Ch13; use Sem_Ch13;
 with Sem_Dim;  use Sem_Dim;
 with Sem_Disp; use Sem_Disp;
@@ -2371,13 +2372,16 @@
  if Nkind (Decl) = N_Object_Declaration then
 Analyze_Object_Contract (Defining_Entity (Decl));
 
+ elsif Nkind_In (Decl, N_Abstract_Subprogram_Declaration,
+   N_Subprogram_Declaration)
+ then
+Analyze_Subprogram_Contract (Defining_Entity (Decl));
+
  elsif Nkind (Decl) = N_Subprogram_Body then
 Analyze_Subprogram_Body_Contract (Defining_Entity (Decl));
 
- elsif Nkind_In (Decl, N_Subprogram_Declaration,
-   N_Abstract_Subprogram_Declaration)
- then
-Analyze_Subprogram_Contract (Defining_Entity (Decl));
+ elsif Nkind (Decl) = N_Subprogram_Body_Stub then
+Analyze_Subprogram_Body_Stub_Contract (Defining_Entity (Decl));
  end if;
 
  Next (Decl);
Index: sem_ch10.adb
===
--- sem_ch10.adb(revision 211445)
+++ sem_ch10.adb(working copy)
@@ -1879,6 +1879,39 @@
   end if;
end Analyze_Protected_Body_Stub;
 
+   ---
+   -- Analyze_Subprogram_Body_Stub_Contract --
+   ---
+
+   procedure Analyze_Subprogram_Body_Stub_Contract (Stub_Id : Entity_Id) is
+  Stub_Decl : constant Node_Id   := Parent (Parent (Stub_Id));
+  Spec_Id   : constant Entity_Id := Corresponding_Spec_Of_Stub (Stub_Decl);
+
+   begin

Re: [patch] libstdc++/29988 Rb_Tree reuse allocated nodes

2014-06-11 Thread Jonathan Wakely

Index: include/bits/stl_tree.h
===
--- include/bits/stl_tree.h (revision 211388)
+++ include/bits/stl_tree.h (working copy)
@@ -330,6 +330,111 @@
   const _Rb_tree_const_iterator<_Val>& __y) _GLIBCXX_NOEXCEPT
{ return __x._M_node != __y._M_node; }

+  // Functor recycling a pool of nodes and using allocation once the pool is
+  // empty.
+  template
+struct _Rb_tree_reuse_or_alloc_node
+{


Is there a reason to define this and _Rb_tree_alloc_node as
namespace-scope class templates, rather than non-template members of
_Rb_tree?

They wouldn't need to be friends if they were members, and you
wouldn't need a typedef for _Rb_tree_alloc_node<_Rb_tree> because it
would just be called _Rb_tree_alloc_node.


+private:
+  typedef _RbTree __rb_tree;


This typedef doesn't seem useful, it's only used once and is more
characters than "_RbTree". If the class was a member of _Rb_tree it
could just use that name.


+  typedef _Rb_tree_node __node_type;


If it was a member the value_type name would be in scope.


+public:
+  _Rb_tree_reuse_or_alloc_node(const _Rb_tree_node_base& __header,
+  __rb_tree& __t)
+   : _M_root(__header._M_parent), _M_nodes(__header._M_right), _M_t(__t)
+  {
+   if (_M_root)
+ _M_root->_M_parent = 0;
+   else
+ _M_nodes = 0;
+  }
+
+  ~_Rb_tree_reuse_or_alloc_node()
+  { _M_t._M_erase(static_cast<__node_type*>(_M_root)); }


This type needs to be non-copyable, or unintentional copies would
erase all the nodes and leave nothing to be reused (which might be
difficult to detect as it would only affect performance, not
correctness).



+  template
+   __node_type*
+#if __cplusplus < 201103L
+   operator()(const _Arg& __arg) const
+#else
+   operator()(_Arg&& __arg) const
+#endif


Does this need to be const?

I don't think it does (if you change the function templates taking a
const _NodeGen& to take _NodeGen& instead).

That means the members of this type don't need to be 'mutable'.



+  typedef _Rb_tree_node_base __node_base;


I'm not sure this typedef is useful either, it just means an extra
name to remember when reading the code, when _Rb_tree_node_base is
already in scope and probably understood by readers of the code.


+  mutable __node_base* _M_root;
+  mutable __node_base* _M_nodes;


These members should be of type _Rb_tree::_Base_ptr, not __node_base*,
because that's the type _Rb_tree::_M_right is declared as.

I have a work-in-progress patch to make _Rb_tree use
allocator_traits<_Node_allocator>::pointer for _Link_type, which
might not be the same type as _Rb_tree_node*, so it is important
to consistently use the _Base_ptr and _Link_type typedefs not the
underlying types they refer to (because those underlying types are
going to change soon).


+  _RbTree& _M_t;
+};
+
+  // Functor similar to the previous one but without any pool of node to 
recycle.
+  template
+struct _Rb_tree_alloc_node


Again, I think this should be a member of _Rb_tree.


+{
+private:
+  typedef _Rb_tree_node __node_type;


This typedef should be removed.


+
+public:
+  _Rb_tree_alloc_node(_RbTree& __t)
+   : _M_t(__t) { }
+
+  template
+   __node_type*


This function should return _Rb_tree::_Link_type because that's what
_M_create_node returns.


+#if __cplusplus < 201103L
+   operator()(const _Arg& __arg) const
+#else
+   operator()(_Arg&& __arg) const
+#endif
+   { return _M_t._M_create_node(_GLIBCXX_FORWARD(_Arg, __arg)); }
@@ -349,6 +454,12 @@
rebind<_Rb_tree_node<_Val> >::other _Node_allocator;

  typedef __gnu_cxx::__alloc_traits<_Node_allocator> _Alloc_traits;
+  template
+   friend struct _Rb_tree_alloc_node;
+  typedef _Rb_tree_alloc_node<_Rb_tree> __alloc_node_t;
+  template
+   friend struct _Rb_tree_reuse_or_alloc_node;
+  typedef _Rb_tree_reuse_or_alloc_node<_Rb_tree> __reuse_or_alloc_node_t;


These friend declarations and typedefs become unnecessary.


@@ -389,44 +500,55 @@
  { _Alloc_traits::deallocate(_M_get_Node_allocator(), __p, 1); }

#if __cplusplus < 201103L
-  _Link_type
-  _M_create_node(const value_type& __x)
+  void
+  _M_construct_node(_Link_type __node, const value_type& __x)
  {
-   _Link_type __tmp = _M_get_node();
__try
- { get_allocator().construct(__tmp->_M_valptr(), __x); }
+ { get_allocator().construct(__node->_M_valptr(), __x); }
__catch(...)
  {
-   _M_put_node(__tmp);
+   _M_put_node(__node);
__throw_exception_again;
  }
+  }
+
+  _Link_type
+  _M_create_node(const value_type& __x)
+  {
+   _Link_type __tmp = _M_get_node();
+   _M_construct_node(__tmp, __x);
return __tmp;
  }

  void
  _M_destroy_node(_Link_type __p)
- 

Re: [PATCH] PR 61642

2014-06-11 Thread Richard Biener
On Wed, Jun 11, 2014 at 1:58 PM, Martin Liška  wrote:
> Hello,
>I send patch for PR61642.

61462?

> Changelog:
> 2014-06-11  Martin Liska  
>

   PR ipa/61462
> * ipa-prop.c (ipa_make_edge_direct_to_target): Check that gimple call
> statement is reachable.
>
> Bootstrapped and regtested on x86_64-unknown-linux-gnu.
>
> Ready for trunk?

Ok with those adjustments.

Richard.

> Martin


Re: libgo patch committed: Merge from revision 18783 of master

2014-06-11 Thread Rainer Orth
Ian Lance Taylor  writes:

> On Fri, Jun 6, 2014 at 2:12 AM, Rainer Orth  
> wrote:
>> Ian Lance Taylor  writes:
>>
>>> I have committed a patch to libgo to merge from revision
>>> 18783:00cce3a34d7e of the master library.  This revision was committed
>>> January 7.  I picked this revision to merge to because the next revision
>>> deleted a file that is explicitly merged in by the libgo/merge.sh
>>> script.
>>>
>>> Among other things, this patch changes type descriptors to add a new
>>> pointer to a zero value.  In gccgo this is implemented as a common
>>> variable, and that requires some changes to the compiler and a small
>>> change to go-gcc.cc.
>>
>> This change introduced many failures on Solaris with /bin/ld, e.g.
>>
>> FAIL: go.test/test/bom.go -O (test for excess errors)
>>
>> ld: warning: symbol 'go$zerovalue' has differing sizes:
>> (file bom.o value=0x8; file
>> /var/gcc/regression/trunk/11-gcc/build/i386-pc-solaris2.11/./libgo/.libs/libgo.so
>> value=0x800);
>> bom.o definition taken and updated with larger size
>
> Interesting.  This is working as intended, except for the warning.
>
> go$zerovalue is a common symbol, and the linker is supposed to use the
> larger version.  From the error message I'm guessing the Solaris
> linker supports this when linking object files, but not when linking
> an object file against a shared library.
>
> I wonder if we could avoid this warning by giving go$zerovalue hidden
> visibility.  That would mean something like this patch.
>
> Ian
>
> Index: go-gcc.cc
> ===
> --- go-gcc.cc (revision 211315)
> +++ go-gcc.cc (working copy)
> @@ -2521,6 +2521,8 @@ Gcc_backend::implicit_variable(const std
>DECL_COMMON(decl) = 1;
>TREE_PUBLIC(decl) = 1;
>gcc_assert(init_tree == NULL_TREE);
> +  DECL_VISIBILITY(decl) = VISIBILITY_HIDDEN;
> +  DECL_VISIBILITY_SPECIFIED(decl) = 1;
>  }
>else if (is_constant)
>  {

Unfortunately, this doesn't make a difference.  I've now found that ld
supports

 -t

 Turns off the  warning  for  multiply-defined  tentative
 (common block) data symbols that have different sizes or
 different  alignments.  This  option  is  equivalent  to
 specifying the -z relax=common option.

But I'm reluctant to enable this globally.  Since Go uses no specs file,
support for target-specific (linker) options would have to go into gccgo
somehow.

Rainer

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


Re: [PING*2][PATCH] Extend mode-switching to support toggle (1/2)

2014-06-11 Thread Christian Bruel

On 06/11/2014 06:17 AM, Joern Rennecke wrote:
>
>>> Joern, is this new target macro interface OK with you ?
> Yes, this interface should allow me to do switches between rounding
> and truncating
> floating-point modes with an add/subtract immediate.
>
> However, the implentation, as posted, doesn't work - it causes memory
> corruption.
>
> It appears to work with the attached amendment patch.
>

Indeed,  thanks for pointing out the bad reusing of the aux field
between multiple entities.

In fact rereading this part of the implementation, I find the allocation
of aux*n_entities awkward. A simpler setting in the entity loop to carry
the mode directly into eg->aux is possible without array allocation
(which also fixes a memory leak by the way).

cheers,

Christian



[PATCH] PR 61642

2014-06-11 Thread Martin Liška

Hello,
   I send patch for PR61642.

Changelog:
2014-06-11  Martin Liska  

* ipa-prop.c (ipa_make_edge_direct_to_target): Check that gimple call
statement is reachable.

Bootstrapped and regtested on x86_64-unknown-linux-gnu.

Ready for trunk?

Martin
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index d02093a..1ffd173 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -2673,13 +2673,19 @@ ipa_make_edge_direct_to_target (struct cgraph_edge *ie, tree target)
 
   if (dump_enabled_p ())
 	{
-	  location_t loc = gimple_location (ie->call_stmt);
-	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
-			   "discovered direct call to non-function in %s/%i, "
-			   "making it __builtin_unreachable\n",
-   ie->caller->name (),
-   ie->caller->order);
+	  const char *fmt = "discovered direct call to non-function in %s/%i, "
+"making it __builtin_unreachable\n";
+
+	  if (ie->call_stmt)
+	{
+		  location_t loc = gimple_location (ie->call_stmt);
+		  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, fmt,
+   ie->caller->name (), ie->caller->order);
+		}
+	 else if (dump_file)
+	   fprintf (dump_file, fmt, ie->caller->name (), ie->caller->order);
 	}
+
 	  target = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
 	  callee = cgraph_get_create_node (target);
 	  unreachable = true;
@@ -2739,10 +2745,18 @@ ipa_make_edge_direct_to_target (struct cgraph_edge *ie, tree target)
  }
   if (dump_enabled_p ())
 {
-  location_t loc = gimple_location (ie->call_stmt);
-  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
-		   "converting indirect call in %s to direct call to %s\n",
-		   ie->caller->name (), callee->name ());
+  const char *fmt = "converting indirect call in %s to direct call to %s\n";
+
+  if (ie->call_stmt)
+{
+	  location_t loc = gimple_location (ie->call_stmt);
+
+	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc, fmt,
+			   ie->caller->name (), callee->name ());
+
+}
+  else if (dump_file)
+	fprintf (dump_file, fmt, ie->caller->name (), callee->name ());
 }
   ie = cgraph_make_edge_direct (ie, callee);
   es = inline_edge_summary (ie);


Re: [PATCH][libsanitizer] Cherry-pick r210012

2014-06-11 Thread Paolo Carlini

On 06/11/2014 01:33 PM, Richard Biener wrote:

Committed.

Thanks!

Paolo,



[PATCH][libsanitizer] Cherry-pick r210012

2014-06-11 Thread Richard Biener

Committed.

Richard.

Index: libsanitizer/ChangeLog
===
--- libsanitizer/ChangeLog  (revision 211449)
+++ libsanitizer/ChangeLog  (working copy)
@@ -1,3 +1,7 @@
+2014-06-11  Richard Biener  
+
+   * asan/asan_linux.cc: Cherry pick upstream r210012.
+
 2014-05-30  Jakub Jelinek  
 
* sanitizer_common/sanitizer_stacktrace.cc: Cherry pick upstream
Index: libsanitizer/asan/asan_linux.cc
===
--- libsanitizer/asan/asan_linux.cc (revision 211449)
+++ libsanitizer/asan/asan_linux.cc (working copy)
@@ -89,6 +89,10 @@ static int FindFirstDSOCallback(struct d
   if (!info->dlpi_name || info->dlpi_name[0] == 0)
 return 0;
 
+  // Ignore vDSO
+  if (internal_strncmp(info->dlpi_name, "linux-", sizeof("linux-") - 1) == 0)
+return 0;
+
   *(const char **)data = info->dlpi_name;
   return 1;
 }


Re: [PATCH] Trust TREE_ADDRESSABLE

2014-06-11 Thread Eric Botcazou
> Sure.  Still currently TREE_ADDRESSABLE on TREE_PUBLIC/DECL_EXTERNAL
> VAR_DECLs carries no useful information, so I consider the bit unused.

I guess that's true for the middle-end in non-LTO mode at this point.
But then the new approach shouldn't be make correctness depend on its setting 
in the front-ends, that's too error-prone IMO.

> I propose to add semantics for it.

Fine with me, as long as it's centralized somewhere in the middle-end.

-- 
Eric Botcazou


RE: RFA: Make LRA temporarily eliminate addresses before testing constraints

2014-06-11 Thread Robert Suchanek
Hi Richard,

>> Robert: you also had an LRA change, but is it still needed after this one?
>> If so, could you repost it and explain the case it handles?

For just turning the LRA for the MIPS backend is not needed but we have issues
with the code size for MIPS16. LRA inserted a lot of reloads and the code size
increased on average by about 10% IIRC. To fix this, a number of patterns 
have to accept the stack pointer and a new class, M16_SP_REGS with 
M16_REGS + $sp was added.

However, this triggered a reloading problem as the stack pointer was rejected
by the back end and LRA tried to insert base+disp with the displacement not
always present. It only affects $sp not directly accessible as in MIPS16 case.

Regards,
Robert
 
gcc/  
* lra-constraints.c (base_to_reg): New function.   
(process_address): Use new function.   

diff --git gcc/lra-constraints.c gcc/lra-constraints.c
index 08716fe..d5ed37f 100644
--- gcc/lra-constraints.c
+++ gcc/lra-constraints.c
@@ -2686,6 +2686,39 @@ process_alt_operands (int only_alternative)
   return ok_p;
 }
 
+/* Make reload base reg from address AD.  */
+static rtx
+base_to_reg (struct address_info *ad)
+{
+  enum reg_class cl;
+  int code = -1;
+  rtx new_inner = NULL_RTX;
+  rtx new_reg = NULL_RTX;
+  rtx insn;
+  rtx last_insn = get_last_insn();
+
+  lra_assert (ad->base == ad->base_term && ad->disp == ad->disp_term);
+  cl = base_reg_class (ad->mode, ad->as, ad->base_outer_code,
+   get_index_code (ad));
+  new_reg = lra_create_new_reg (GET_MODE (*ad->base_term), NULL_RTX,
+cl, "base");
+  new_inner = simplify_gen_binary (PLUS, GET_MODE (new_reg), new_reg,
+   ad->disp_term == NULL
+   ? gen_int_mode (0, ad->mode)
+   : *ad->disp_term);
+  if (!valid_address_p (ad->mode, new_inner, ad->as))
+return NULL_RTX;
+  insn = emit_insn (gen_rtx_SET (ad->mode, new_reg, *ad->base_term));
+  code = recog_memoized (insn);
+  if (code < 0)
+{
+  delete_insns_since (last_insn);
+  return NULL_RTX;
+}
+
+  return new_inner;
+}
+
 /* Make reload base reg + disp from address AD.  Return the new pseudo.  */
 static rtx
 base_plus_disp_to_reg (struct address_info *ad)
@@ -2908,6 +2941,8 @@ process_address_1 (int nop, rtx *before, rtx *after)
 
  3) the address is a frame address with an invalid offset.
 
+ 4) the address is a frame address with an invalid base.
+
  All these cases involve a non-autoinc address, so there is no
  point revalidating other types.  */
   if (ad.autoinc_p || valid_address_p (&ad))
@@ -2989,14 +3024,19 @@ process_address_1 (int nop, rtx *before, rtx *after)
   int regno;
   enum reg_class cl;
   rtx set, insns, last_insn;
+  /* Try to reload base into register only if the base is invalid
+ for the address but with valid offset, case (4) above.  */
+  start_sequence ();
+  new_reg = base_to_reg (&ad);
+
   /* base + disp => new base, cases (1) and (3) above.  */
   /* Another option would be to reload the displacement into an
 index register.  However, postreload has code to optimize
 address reloads that have the same base and different
 displacements, so reloading into an index register would
 not necessarily be a win.  */
-  start_sequence ();
-  new_reg = base_plus_disp_to_reg (&ad);
+  if (new_reg == NULL_RTX)
+new_reg = base_plus_disp_to_reg (&ad);
   insns = get_insns ();
   last_insn = get_last_insn ();
   /* If we generated at least two insns, try last insn source as


Re: [PATCH] [ARM] [RFC] Fix longstanding push_minipool_fix ICE (PR49423, lp1296601)

2014-06-11 Thread Charles Baylis
Ping?

On 6 May 2014 17:05, Charles Baylis  wrote:
> Ping?
>
> At this stage looking for general feedback on whether the define_split
> approach in this patch is appropriate. If it is, I'll do a clean patch
> for full review.
>
> Archive link: http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00078.html
>
> On 2 April 2014 14:29, Charles Baylis  wrote:
>> Hi
>>
>> This patch fixes the push_minipool_fix ICE, which occurs when the ARM
>> backend encounters a zero/sign extending load from a constant pool.
>>
>> I don't have a current test case for trunk, lp1296601 has a test case
>> which affects the linaro-4.8 branch. As far as I know, there has been
>> no fix for this on trunk.
>>
>> The approach taken in this patch is to extend each pattern where this
>> can occur,  so that it triggers a define_split to synthesise a
>> constant move instead. Some but not all extend patterns have
>> previously added pool_range attributes to work-around this problem,
>> this patch removes those, and also fixes the remaining patterns. Some
>> patterns have slightly more complex workarounds, which I have not yet
>> analysed, but it seems worth posting the patch at this stage to get
>> feedback on the general approach.
>>
>> Tested on arm-unknown-linux-gnueabihf (qemu), bootstrap in progress.
>>
>> If this looks good, I'll clean it up for a more detailed review.
>>
>> Thanks
>> Charles


[match-and-simplify] Merge from trunk r211444

2014-06-11 Thread Richard Biener

Bootstrapped on x86_64-unknown-linux-gnu.

Richard.

2014-06-11  Richard Biener  

Merge from trunk r208477 through r211444.



Re: [PATCH, Pointer Bounds Checker 28/x] IPA CP

2014-06-11 Thread Ilya Enkovich
2014-06-11 13:45 GMT+04:00 Martin Jambor :
> Hi,
>
> On Wed, Jun 11, 2014 at 12:24:57PM +0400, Ilya Enkovich wrote:
>> Hi,
>>
>> This patch fixes IPA CP pass to handle instrumented code correctly.
>>
>> Bootstrapped and tested on linux-x86_64.
>>
>> Thanks,
>> Ilya
>> --
>> gcc/
>>
>> 2014-06-11  Ilya Enkovich  
>>
>>   * ipa-cp.c (initialize_node_lattices): Check original
>>   version locality for instrumentation clones.
>>   (propagate_constants_accross_call): Do not propagate
>>   through instrumentation thunks.
>>
>>
>> diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
>> index 689378a..683b9f0 100644
>> --- a/gcc/ipa-cp.c
>> +++ b/gcc/ipa-cp.c
>> @@ -699,7 +699,10 @@ initialize_node_lattices (struct cgraph_node *node)
>>int i;
>>
>>gcc_checking_assert (cgraph_function_with_gimple_body_p (node));
>> -  if (!node->local.local)
>> +  if (!node->local.local
>> +  || (node->instrumentation_clone
>> +   && node->instrumented_version
>> +   && !node->instrumented_version->local.local))
>
> This looks quite convoluted, can you please put the test into a new
> predicate in cgraph.c?  I assume you had to change other tests of the
> local flag in a similar fashion anyway.

You are right. Would cgraph_node_local_p be OK?

>
>>  {
>>/* When cloning is allowed, we can assume that externally visible
>>functions are not called.  We will compensate this by cloning
>> @@ -1440,7 +1443,8 @@ propagate_constants_accross_call (struct cgraph_edge 
>> *cs)
>>alias_or_thunk = cs->callee;
>>while (alias_or_thunk->alias)
>>  alias_or_thunk = cgraph_alias_target (alias_or_thunk);
>> -  if (alias_or_thunk->thunk.thunk_p)
>> +  if (alias_or_thunk->thunk.thunk_p
>> +  && !alias_or_thunk->thunk.add_pointer_bounds_args)
>
> so there are thunks that do not change the first argument and so we do
> want to propagate to/through it?

Yes. Thunks marked as add_pointer_bounds_args do not change arguments,
but add default pointer bounds for all pointer arguments.

>>  {
>>ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info,
>>  0));
>> @@ -1449,6 +1453,20 @@ propagate_constants_accross_call (struct cgraph_edge 
>> *cs)
>>else
>>  i = 0;
>>
>> +  /* No propagation through instrumentation thunks is available yet.
>> + It should be possible with proper mapping of call args and
>> + instrumented callee params in the propagation loop below.  But
>> + this case mostly occurs when legacy code calls instrumented code
>> + and it is not a primary target for optimizations.  */
>> +  if (!alias_or_thunk->instrumentation_clone
>> +  && callee->instrumentation_clone)
>> +{
>> +  for (; i < parms_count; i++)
>> + ret |= set_all_contains_variable (ipa_get_parm_lattices (callee_info,
>> +  i));
>> +  return ret;
>> +}
>> +
>
> and these thunks are different from those marked as
> thunk.add_pointer_bounds_args?  If they are not, the previous hunk is
> redundant.

This check covers more cases. It catches all chains of aliases and
thunks where thunk.add_pointer_bounds_args is met. It does not mean
the first met thunk has thunk.add_pointer_bounds_args (as is in
previous check).  I suppose you are right about previous hunk. It
would be better to make wider check first and make exit earlier. Will
fix it.

>
> My apologies for not looking at the patches introducing all the new
> cgraph_node fields but it is quite difficult to figure out what the
> new tests actually mean (that is why I'd really prefer predicates with
> more explanatory names).

New predicates are good but do we need them for single usage? Locality
check are used during output and new predicate would be nice for it.
But there is no another thunk.add_pointer_bounds_args chain check used
somewhere else. Will try to make more explanatory comment for it for
now.

Thanks,
Ilya

>
> Thanks,
>
> Martin


Re: [PATCH] Delete temporary string within demangler even in failure cases.

2014-06-11 Thread Pedro Alves
On 06/10/2014 07:08 PM, Andrew Burgess wrote:

> I don't have gcc write permissions, would you (or any other interested
> maintainer) mind committing this for me please.

Done, and merged to binutils-gdb git repo.

Thanks,
-- 
Pedro Alves



[Ada] Cleanup handling of info and warning messages

2014-06-11 Thread Arnaud Charlet
This is a fairly major internal reorganization of how info and warning
messages are handled. Info messages for elaboration are now tagged
as [-gnatel] if warning tagging is activated (-gnatw.d), and info
messages coming from instantiations are consistently labeled as such
as shown by this example, compiled with -gnatw.e -gnatl

 1. generic
 2. package IWInfoD is
 3.   type Handle_Type is private;
 4.   function CH return Handle_Type;
   |
>>> info: "IWInfoD" requires body ("CH" requires completion)

 5. private
 6.   type Handle_Type is
 7.   record
 8. Initialised : Boolean;
 9.   end record;
10. end;

 1. package body IWInfoD is
 2.   function CH return Handle_Type is
 3.   begin
 4. return (Initialised => False);
 5.   end CH;
 6. end;

 1. with IWInfoD;
 2. generic
 3.   with package My_D is new IWInfoD;
  |
>>> info: in instantiation at iwinfod.ads:4
>>> info: "My_D" requires body ("CH" requires completion)

 4.   with procedure Method (Client : in out My_D.Handle_Type);
 5. package IWInfo is
 6. private
 7.   procedure C;
|
>>> info: "IWInfo" requires body ("C" requires completion)

 8. end;

 1. package body IWInfoD is
 2.   function CH return Handle_Type is
 3.   begin
 4. return (Initialised => False);
 5.   end CH;
 6. end;

prior to this fix the messages on line 3 of the IWinfo spec
were inconsistent with the first saying warning: and the
second saying info: which was confusing

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-06-11  Robert Dewar  

* errout.adb (Warn_Insertion): New function.
(Error_Msg): Use Warn_Insertion and Prescan_Message.
(Error_Msg_Internal): Set Info field of error object.
(Error_Msg_NEL): Use Prescan_Message.
(Set_Msg_Text): Don't store info: at start of message.
(Skip_Msg_Insertion_Warning): New name for Set_Msg_Insertion_Warning.
(Skip_Msg_Insertion_Warning): Now just skips warning insertion.
* errout.ads: Document new ?$? and >$> insertion sequences
Document use of "(style)" and "info: "
* erroutc.adb (dmsg): Print several missing fields
(Get_Warning_Tag): Handle -gnatel case (?$?)  (Output_Msg_Text):
Deal with new tagging of info messages
* erroutc.ads: Is_Info_Msg: New global (Error_Msg_Object):
Add field Info (Prescan_Message): New procedure, this procedure
replaces the old Test_Style_Warning_Serious_Unconditional_Msg
* errutil.adb, exp_util.adb, par-ch7.adb, sem_ch13.adb, sem_ch7.adb,
sem_elab.adb: Follow new rules for info message (info belongs
only at the start of a message, and only in the first message,
not in any of the continuations).

* gnat_ugn.texi: Document full set of warning tags.

Index: errout.adb
===
--- errout.adb  (revision 211445)
+++ errout.adb  (working copy)
@@ -197,6 +197,17 @@
--  spec for precise definition of the conversion that is performed by this
--  routine in OpenVMS mode.
 
+   function Warn_Insertion return String;
+   --  This is called for warning messages only (so Warning_Msg_Char is set)
+   --  and returns a corresponding string to use at the beginning of generated
+   --  auxiliary messages, such as "in instantiation at ...".
+   --'a' .. 'z'   returns "?x?"
+   --'A' .. 'Z'   returns "?X?"
+   --'*'  returns "?*?"
+   --'$'  returns "?$?info: "
+   --' '  returns " "
+   --  No other settings are valid
+
---
-- Change_Error_Text --
---
@@ -282,7 +293,7 @@
   --  Start of processing for new message
 
   Sindex := Get_Source_File_Index (Flag_Location);
-  Test_Style_Warning_Serious_Unconditional_Msg (Msg);
+  Prescan_Message (Msg);
   Orig_Loc := Original_Location (Flag_Location);
 
   --  If the current location is in an instantiation, the issue arises of
@@ -332,8 +343,7 @@
   --  that style checks are not considered warning messages for this
   --  purpose.
 
-  if Is_Warning_Msg
-and then Warnings_Suppressed (Orig_Loc) /= No_String
+  if Is_Warning_Msg and then Warnings_Suppressed (Orig_Loc) /= No_String
   then
  return;
 
@@ -438,9 +448,9 @@
--  Case of inlined body
 
if Inlined_Body (X) then
-  if Is_Warning_Msg or else Is_Style_Msg then
+  if Is_Warning_Msg or Is_Style_Msg then
  Error_Msg_Internal
-   ("?in inlined body #",
+   (Warn_Insertion & "in inlined body #",
 Actual_Error_Loc, Flag_Location, Msg_Cont_Status);
   else
  Error_Msg_Internal

Re: [patch i386]: Combine memory and indirect jump

2014-06-11 Thread Kai Tietz
2014-06-11 11:57 GMT+02:00 Steven Bosscher :
> On Wed, Jun 11, 2014 at 10:32 AM, Kai Tietz wrote:
>> this patch adds simple combining of indirect-jumps on memory-address.
>> This patch is pretty similar to sibcall-combing.
>> ChangeLog
>>
>> 2014-06-11  Kai Tietz  
>>
>> * config/i386/i386.md (peehole2): To combine
>> indirect jump with memory.
>
>
> Likely fixes part of PR39284, xf. https://gcc.gnu.org/PR39284#c12
>
> Ciao!
> Steven

Well, it fixes it just partial AFAICS.  Btw PR target/51840 is related
to the same issue too.

Latter problem shows much better the underlying issue of
jump-shortening. Issue is here that the jump to a jump (or better said
indirect jump) isn't shortened.

Regards,
Kai


[ARM] Fix build failure due to movsi_compare0

2014-06-11 Thread James Greenhalgh

Hi,

A recent change somewhere exposed a latent bug between LRA and the definition
of the movsi_compare0 pattern.

This pattern ties the source and destination register of a set together
a (match_dup) and register constraints:

   [(set (reg:CC CC_REGNUM)
(compare:CC (match_operand:SI 1 "s_register_operand" "0,r")
(const_int 0)))
(set (match_operand:SI 0 "s_register_operand" "=r,r")
(match_dup 1))]

This confuses LRA which expects the source and destination register of
a set to be different.

reduced.c: In function '_IO_vfscanf_internal':
reduced.c:104:1: internal compiler error: in lra_create_copy, at lra.c:1512
 }
 ^
0x8c3f9a lra_create_copy(int, int, int)
/work/gcc-dev/src/gcc/gcc/lra.c:1512
0x8e4ab0 process_bb_lives
/work/gcc-dev/src/gcc/gcc/lra-lives.c:568
0x8e4ab0 lra_create_live_ranges(bool)
/work/gcc-dev/src/gcc/gcc/lra-lives.c:1019
0x8c5a39 lra(_IO_FILE*)
/work/gcc-dev/src/gcc/gcc/lra.c:2356
0x873a96 do_reload
/work/gcc-dev/src/gcc/gcc/ira.c:5415
0x873a96 execute
/work/gcc-dev/src/gcc/gcc/ira.c:5576
Please submit a full bug report,

We can fix the pattern by moving away from match_dup and using register
tying with constraints consistently.

I'm not entirely convinced that this is legitimate (my vague recollection is
that register tying should only be used to tie inputs to outputs).

This has passed testing on a bunch of ARM targets, and fixes the build
issues I've been seeing.

OK for trunk?

Thanks,
James

---
gcc/

2014-06-11  James Greenhalgh  

* config/arm/arm.md (movsi_compare0): Clarify intentions using
register tying.
diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md
index f58a79b..a01333b 100644
--- a/gcc/config/arm/arm.md
+++ b/gcc/config/arm/arm.md
@@ -6582,10 +6582,10 @@
 
 (define_insn "*movsi_compare0"
   [(set (reg:CC CC_REGNUM)
-	(compare:CC (match_operand:SI 1 "s_register_operand" "0,r")
-		(const_int 0)))
+	(compare:CC (match_operand:SI 2 "s_register_operand" "0,1")
+	(const_int 0)))
(set (match_operand:SI 0 "s_register_operand" "=r,r")
-	(match_dup 1))]
+	(match_operand:SI 1 "s_register_operand" "0,r"))]
   "TARGET_32BIT"
   "@
cmp%?\\t%0, #0

Re: libsanitizer merge from upstream r208536

2014-06-11 Thread Paolo Carlini

Hi,

On 05/22/2014 09:02 PM, Jakub Jelinek wrote:

In file included from
../../../../trunk/libsanitizer/asan/asan_interceptors.cc:147:0:
../../../../trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:
In function ‘int __interceptor_accept4(int, void*, unsigned int*,
int)’:
../../../../trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:1821:12:
warning: ‘addrlen0’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
unsigned addrlen0;
^
../../../../trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:
In function ‘int __interceptor_accept(int, void*, unsigned int*)’:
../../../../trunk/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:1799:12:
warning: ‘addrlen0’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
unsigned addrlen0;
^
That sounds like a false positive warning:
   unsigned addrlen0;
   if (addrlen) {
 COMMON_INTERCEPTOR_READ_RANGE(ctx, addrlen, sizeof(*addrlen));
 addrlen0 = *addrlen;
   }
   int fd2 = REAL(accept4)(fd, addr, addrlen, f);
   if (fd2 >= 0) {
 if (fd >= 0) COMMON_INTERCEPTOR_FD_SOCKET_ACCEPT(ctx, fd, fd2);
 if (addr && addrlen)
   COMMON_INTERCEPTOR_WRITE_RANGE(ctx, addr, Min(*addrlen, addrlen0));
   }
(unless the COMMON_INTERCEPTOR* macros do too weird stuff), wonder why the
predicate aware uninit doesn't handle this.
By the way, I'm still seeing the above. Maybe a maintainer can have a 
look, double check it's just a false positive a shut it up somehow?


Thanks!
Paolo.


Re: [PATCH] Trust TREE_ADDRESSABLE

2014-06-11 Thread Richard Biener
On Wed, 11 Jun 2014, Eric Botcazou wrote:

> > Because that's not the point and because it feels like a hack ;)
> 
> Well, if we keep the current semantics of TREE_ADDRESSABLE and decide that 
> the 
> predicate for aliasing is may_be_aliased, the implementation for the latter 
> becomes a detail.  And it would seem better/simpler to have the knowledge 
> localized in this single predicate than spread over multiple files and FEs.

Sure.  Still currently TREE_ADDRESSABLE on TREE_PUBLIC/DECL_EXTERNAL
VAR_DECLs carries no useful information, so I consider the bit unused.
I propose to add semantics for it.

Btw, the optimization is not restricted to LTO but also applies
to -fwhole-program (poor-mans single-TU "LTO").  So it is a
property that could be computed (as Honza says) by the IPA
visibility pass (in the -fwhole-program non-LTO case it promotes
those decls to !TREE_PUBLIC && TREE_STATIC).

Richard.


[PATCH 9/9] Remove __gnu_uldivmod_helper

2014-06-11 Thread Charles Baylis
2014-05-22  Charles Baylis  

* config/arm/bpabi.c (__gnu_uldivmod_helper): Remove.
---
 libgcc/config/arm/bpabi.c | 14 --
 1 file changed, 14 deletions(-)

diff --git a/libgcc/config/arm/bpabi.c b/libgcc/config/arm/bpabi.c
index 7b155cc..e90d044 100644
--- a/libgcc/config/arm/bpabi.c
+++ b/libgcc/config/arm/bpabi.c
@@ -26,9 +26,6 @@ extern long long __divdi3 (long long, long long);
 extern unsigned long long __udivdi3 (unsigned long long, 
 unsigned long long);
 extern long long __gnu_ldivmod_helper (long long, long long, long long *);
-extern unsigned long long __gnu_uldivmod_helper (unsigned long long, 
-unsigned long long, 
-unsigned long long *);
 
 
 long long
@@ -43,14 +40,3 @@ __gnu_ldivmod_helper (long long a,
   return quotient;
 }
 
-unsigned long long
-__gnu_uldivmod_helper (unsigned long long a, 
-  unsigned long long b,
-  unsigned long long *remainder)
-{
-  unsigned long long quotient;
-
-  quotient = __udivdi3 (a, b);
-  *remainder = a - b * quotient;
-  return quotient;
-}
-- 
1.9.1



[PATCH 7/9] Fix cfi annotations

2014-06-11 Thread Charles Baylis
2014-05-22  Charles Baylis  

* config/arm/bpabi.S (__aeabi_ldivmod, __aeabi_uldivmod,
push_for_divide, pop_for_divide): Use .cfi_* directives for DWARF
annotations. Fix DWARF information.
---
 libgcc/config/arm/bpabi.S | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/libgcc/config/arm/bpabi.S b/libgcc/config/arm/bpabi.S
index c044167..959ecb1 100644
--- a/libgcc/config/arm/bpabi.S
+++ b/libgcc/config/arm/bpabi.S
@@ -22,6 +22,8 @@
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
.  */
 
+   .cfi_sections .debug_frame
+
 #ifdef __ARM_EABI__
 /* Some attributes that are common to all routines in this file.  */
/* Tag_ABI_align_needed: This code does not require 8-byte
@@ -145,7 +147,8 @@ ARM_FUNC_START aeabi_ulcmp
sub sp, sp, #8
do_push {sp, lr}
 #endif
-98:cfi_push98b - \fname, 0xe, -0xc, 0x10
+   .cfi_adjust_cfa_offset 16
+   .cfi_offset 14, -12
 .endm
 
 /* restore stack */
@@ -158,6 +161,8 @@ ARM_FUNC_START aeabi_ulcmp
add sp, sp, #8
do_pop  {r2, r3}
 #endif
+   .cfi_restore 14
+   .cfi_adjust_cfa_offset 0
 .endm
 
 #ifdef L_aeabi_ldivmod
@@ -171,7 +176,7 @@ ARM_FUNC_START aeabi_ulcmp
r2:r3   remainder
  */
 ARM_FUNC_START aeabi_ldivmod
-   cfi_start   __aeabi_ldivmod, LSYM(Lend_aeabi_ldivmod)
+   .cfi_startproc
test_div_by_zerosigned
 
push_for_divide __aeabi_ldivmod
@@ -181,16 +186,19 @@ ARM_FUNC_START aeabi_ldivmod
blt 2f
/* arguments in (r0:r1), (r2:r3) and *sp */
bl  SYM(__udivmoddi4) __PLT__
+   .cfi_remember_state
pop_for_divide
RET
 
 1: /* xxh:xxl is negative */
+   .cfi_restore_state
negsxxl, xxl
sbc xxh, xxh, xxh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
cmp yyh, #0
blt 3f
/* arguments in (r0:r1), (r2:r3) and *sp */
bl  SYM(__udivmoddi4) __PLT__
+   .cfi_remember_state
pop_for_divide
negsxxl, xxl
sbc xxh, xxh, xxh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
@@ -199,16 +207,19 @@ ARM_FUNC_START aeabi_ldivmod
RET
 
 2: /* only yyh:yyl is negative */
+   .cfi_restore_state
negsyyl, yyl
sbc yyh, yyh, yyh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
/* arguments in (r0:r1), (r2:r3) and *sp */
bl  SYM(__udivmoddi4) __PLT__
+   .cfi_remember_state
pop_for_divide
negsxxl, xxl
sbc xxh, xxh, xxh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
RET
 
 3: /* both xxh:xxl and yyh:yyl are negative */
+   .cfi_restore_state
negsyyl, yyl
sbc yyh, yyh, yyh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
/* arguments in (r0:r1), (r2:r3) and *sp */
@@ -218,7 +229,7 @@ ARM_FUNC_START aeabi_ldivmod
sbc yyh, yyh, yyh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
RET
 
-   cfi_end LSYM(Lend_aeabi_ldivmod)
+   .cfi_endproc

 #endif /* L_aeabi_ldivmod */
 
@@ -233,7 +244,7 @@ ARM_FUNC_START aeabi_ldivmod
r2:r3   remainder
  */
 ARM_FUNC_START aeabi_uldivmod
-   cfi_start   __aeabi_uldivmod, LSYM(Lend_aeabi_uldivmod)
+   .cfi_startproc
test_div_by_zerounsigned
 
push_for_divide __aeabi_uldivmod
@@ -241,7 +252,7 @@ ARM_FUNC_START aeabi_uldivmod
bl  SYM(__udivmoddi4) __PLT__
pop_for_divide
RET
-   cfi_end LSYM(Lend_aeabi_uldivmod)
+   .cfi_endproc
 
 #endif /* L_aeabi_divmod */

-- 
1.9.1



[PATCH 6/9] Optimise __aeabi_ldivmod

2014-06-11 Thread Charles Baylis
2014-05-22  Charles Baylis  

* config/arm/bpabi.S (__aeabi_ldivmod): Perform division using
__udivmoddi4, and fixups for negative operands.
---
 libgcc/config/arm/bpabi.S | 41 -
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/libgcc/config/arm/bpabi.S b/libgcc/config/arm/bpabi.S
index 3f9ece5..c044167 100644
--- a/libgcc/config/arm/bpabi.S
+++ b/libgcc/config/arm/bpabi.S
@@ -175,10 +175,49 @@ ARM_FUNC_START aeabi_ldivmod
test_div_by_zerosigned
 
push_for_divide __aeabi_ldivmod
+   cmp xxh, #0
+   blt 1f
+   cmp yyh, #0
+   blt 2f
+   /* arguments in (r0:r1), (r2:r3) and *sp */
+   bl  SYM(__udivmoddi4) __PLT__
+   pop_for_divide
+   RET
+
+1: /* xxh:xxl is negative */
+   negsxxl, xxl
+   sbc xxh, xxh, xxh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
+   cmp yyh, #0
+   blt 3f
+   /* arguments in (r0:r1), (r2:r3) and *sp */
+   bl  SYM(__udivmoddi4) __PLT__
+   pop_for_divide
+   negsxxl, xxl
+   sbc xxh, xxh, xxh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
+   negsyyl, yyl
+   sbc yyh, yyh, yyh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
+   RET
+
+2: /* only yyh:yyl is negative */
+   negsyyl, yyl
+   sbc yyh, yyh, yyh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
+   /* arguments in (r0:r1), (r2:r3) and *sp */
+   bl  SYM(__udivmoddi4) __PLT__
+   pop_for_divide
+   negsxxl, xxl
+   sbc xxh, xxh, xxh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
+   RET
+
+3: /* both xxh:xxl and yyh:yyl are negative */
+   negsyyl, yyl
+   sbc yyh, yyh, yyh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
/* arguments in (r0:r1), (r2:r3) and *sp */
-   bl  SYM(__gnu_ldivmod_helper) __PLT__
+   bl  SYM(__udivmoddi4) __PLT__
pop_for_divide
+   negsyyl, yyl
+   sbc yyh, yyh, yyh, lsl #1   /* Thumb-2 has no RSC, so use X - 2X */
RET
+
cfi_end LSYM(Lend_aeabi_ldivmod)

 #endif /* L_aeabi_ldivmod */
-- 
1.9.1



[PATCH 8/9] Use __udivmoddi4 for v6M aeabi_uldivmod

2014-06-11 Thread Charles Baylis
2014-05-22  Charles Baylis  

* config/arm/bpabi-v6m.S (__aeabi_uldivmod): Perform division using
__udivmoddi4.
---
 libgcc/config/arm/bpabi-v6m.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgcc/config/arm/bpabi-v6m.S b/libgcc/config/arm/bpabi-v6m.S
index 0bf2e55..d549fa6 100644
--- a/libgcc/config/arm/bpabi-v6m.S
+++ b/libgcc/config/arm/bpabi-v6m.S
@@ -148,7 +148,7 @@ FUNC_START aeabi_uldivmod
mov r0, sp
push {r0, lr}
ldr r0, [sp, #8]
-   bl SYM(__gnu_uldivmod_helper)
+   bl SYM(__udivmoddi4)
ldr r3, [sp, #4]
mov lr, r3
add sp, sp, #8
-- 
1.9.1



[PATCH 4/9] Optimise __aeabi_uldivmod

2014-06-11 Thread Charles Baylis
2014-05-22  Charles Baylis  

* config/arm/bpabi.S (__aeabi_uldivmod): Perform division using call
to __udivmoddi4.
---
 libgcc/config/arm/bpabi.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgcc/config/arm/bpabi.S b/libgcc/config/arm/bpabi.S
index 67246b0..927e37f 100644
--- a/libgcc/config/arm/bpabi.S
+++ b/libgcc/config/arm/bpabi.S
@@ -207,7 +207,7 @@ ARM_FUNC_START aeabi_uldivmod
 
push_for_divide __aeabi_uldivmod
/* arguments in (r0:r1), (r2:r3) and *sp */
-   bl  SYM(__gnu_uldivmod_helper) __PLT__
+   bl  SYM(__udivmoddi4) __PLT__
pop_for_divide
RET
cfi_end LSYM(Lend_aeabi_uldivmod)
-- 
1.9.1



[PATCH 5/9] Optimise __aeabi_ldivmod (stack manipulation)

2014-06-11 Thread Charles Baylis
2014-05-22  Charles Baylis  

* config/arm/bpabi.S (__aeabi_ldivmod): Optimise stack manipulation.
---
 libgcc/config/arm/bpabi.S | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/libgcc/config/arm/bpabi.S b/libgcc/config/arm/bpabi.S
index 927e37f..3f9ece5 100644
--- a/libgcc/config/arm/bpabi.S
+++ b/libgcc/config/arm/bpabi.S
@@ -174,18 +174,10 @@ ARM_FUNC_START aeabi_ldivmod
cfi_start   __aeabi_ldivmod, LSYM(Lend_aeabi_ldivmod)
test_div_by_zerosigned
 
-   sub sp, sp, #8
-#if defined(__thumb2__)
-   mov ip, sp
-   push{ip, lr}
-#else
-   do_push {sp, lr}
-#endif
-98:cfi_push 98b - __aeabi_ldivmod, 0xe, -0xc, 0x10
+   push_for_divide __aeabi_ldivmod
+   /* arguments in (r0:r1), (r2:r3) and *sp */
bl  SYM(__gnu_ldivmod_helper) __PLT__
-   ldr lr, [sp, #4]
-   add sp, sp, #8
-   do_pop  {r2, r3}
+   pop_for_divide
RET
cfi_end LSYM(Lend_aeabi_ldivmod)

-- 
1.9.1



[PATCH 2/9] Add comments

2014-06-11 Thread Charles Baylis
2014-05-22  Charles Baylis  

* config/arm/bpabi.S (__aeabi_uldivmod, __aeabi_ldivmod): Add comment
describing register usage on function entry and exit.
---
 libgcc/config/arm/bpabi.S | 16 
 1 file changed, 16 insertions(+)

diff --git a/libgcc/config/arm/bpabi.S b/libgcc/config/arm/bpabi.S
index f47d715..ae76cd3 100644
--- a/libgcc/config/arm/bpabi.S
+++ b/libgcc/config/arm/bpabi.S
@@ -122,6 +122,14 @@ ARM_FUNC_START aeabi_ulcmp
 
 #ifdef L_aeabi_ldivmod
 
+/* Perform 64 bit signed division.
+   Inputs:
+   r0:r1   numerator
+   r2:r3   denominator
+   Outputs:
+   r0:r1   quotient
+   r2:r3   remainder
+ */
 ARM_FUNC_START aeabi_ldivmod
cfi_start   __aeabi_ldivmod, LSYM(Lend_aeabi_ldivmod)
test_div_by_zerosigned
@@ -145,6 +153,14 @@ ARM_FUNC_START aeabi_ldivmod
 
 #ifdef L_aeabi_uldivmod
 
+/* Perform 64 bit signed division.
+   Inputs:
+   r0:r1   numerator
+   r2:r3   denominator
+   Outputs:
+   r0:r1   quotient
+   r2:r3   remainder
+ */
 ARM_FUNC_START aeabi_uldivmod
cfi_start   __aeabi_uldivmod, LSYM(Lend_aeabi_uldivmod)
test_div_by_zerounsigned
-- 
1.9.1



[PATCH 1/9] Whitespace

2014-06-11 Thread Charles Baylis
2014-05-22  Charles Baylis  

* config/arm/bpabi.S (__aeabi_uldivmod): Fix whitespace.
(__aeabi_ldivmod): Fix whitespace.
---
 libgcc/config/arm/bpabi.S | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/libgcc/config/arm/bpabi.S b/libgcc/config/arm/bpabi.S
index 7772301..f47d715 100644
--- a/libgcc/config/arm/bpabi.S
+++ b/libgcc/config/arm/bpabi.S
@@ -124,20 +124,20 @@ ARM_FUNC_START aeabi_ulcmp
 
 ARM_FUNC_START aeabi_ldivmod
cfi_start   __aeabi_ldivmod, LSYM(Lend_aeabi_ldivmod)
-   test_div_by_zero signed
+   test_div_by_zerosigned
 
-   sub sp, sp, #8
+   sub sp, sp, #8
 #if defined(__thumb2__)
-   mov ip, sp
-   push {ip, lr}
+   mov ip, sp
+   push{ip, lr}
 #else
-   do_push {sp, lr}
+   do_push {sp, lr}
 #endif
 98:cfi_push 98b - __aeabi_ldivmod, 0xe, -0xc, 0x10
-   bl SYM(__gnu_ldivmod_helper) __PLT__
-   ldr lr, [sp, #4]
-   add sp, sp, #8
-   do_pop {r2, r3}
+   bl  SYM(__gnu_ldivmod_helper) __PLT__
+   ldr lr, [sp, #4]
+   add sp, sp, #8
+   do_pop  {r2, r3}
RET
cfi_end LSYM(Lend_aeabi_ldivmod)

@@ -147,20 +147,20 @@ ARM_FUNC_START aeabi_ldivmod
 
 ARM_FUNC_START aeabi_uldivmod
cfi_start   __aeabi_uldivmod, LSYM(Lend_aeabi_uldivmod)
-   test_div_by_zero unsigned
+   test_div_by_zerounsigned
 
-   sub sp, sp, #8
+   sub sp, sp, #8
 #if defined(__thumb2__)
-   mov ip, sp
-   push {ip, lr}
+   mov ip, sp
+   push{ip, lr}
 #else
-   do_push {sp, lr}
+   do_push {sp, lr}
 #endif
 98:cfi_push 98b - __aeabi_uldivmod, 0xe, -0xc, 0x10
-   bl SYM(__gnu_uldivmod_helper) __PLT__
-   ldr lr, [sp, #4]
-   add sp, sp, #8
-   do_pop {r2, r3}
+   bl  SYM(__gnu_uldivmod_helper) __PLT__
+   ldr lr, [sp, #4]
+   add sp, sp, #8
+   do_pop  {r2, r3}
RET
cfi_end LSYM(Lend_aeabi_uldivmod)
 
-- 
1.9.1



[PATCH 3/9] Optimise __aeabi_uldivmod (stack manipulation)

2014-06-11 Thread Charles Baylis
2014-05-22  Charles Baylis  

* config/arm/bpabi.S (__aeabi_uldivmod): Optimise stack pointer
manipulation.
---
 libgcc/config/arm/bpabi.S | 54 +--
 1 file changed, 43 insertions(+), 11 deletions(-)

diff --git a/libgcc/config/arm/bpabi.S b/libgcc/config/arm/bpabi.S
index ae76cd3..67246b0 100644
--- a/libgcc/config/arm/bpabi.S
+++ b/libgcc/config/arm/bpabi.S
@@ -120,6 +120,46 @@ ARM_FUNC_START aeabi_ulcmp
 #endif
 .endm
 
+/* we can use STRD/LDRD on v5TE and later, and any Thumb-2 architecture. */
+#if (defined(__ARM_EABI__)\
+ && (defined(__thumb2__)  \
+ || (__ARM_ARCH >= 5 && defined(__TARGET_FEATURE_DSP
+#define CAN_USE_LDRD 1
+#else
+#define CAN_USE_LDRD 0
+#endif
+
+/* set up stack from for call to __udivmoddi4. At the end of the macro the
+   stack is arranged as follows:
+   sp+12   / space for remainder
+   sp+8\ (written by __udivmoddi4)
+   sp+4lr
+   sp+0sp+8 [rp (remainder pointer) argument for __udivmoddi4]
+
+ */
+.macro push_for_divide fname
+#if defined(__thumb2__) && CAN_USE_LDRD
+   sub ip, sp, #8
+   strdip, lr, [sp, #-16]!
+#else
+   sub sp, sp, #8
+   do_push {sp, lr}
+#endif
+98:cfi_push98b - \fname, 0xe, -0xc, 0x10
+.endm
+
+/* restore stack */
+.macro pop_for_divide
+   ldr lr, [sp, #4]
+#if CAN_USE_LDRD
+   ldrdr2, r3, [sp, #8]
+   add sp, sp, #16
+#else
+   add sp, sp, #8
+   do_pop  {r2, r3}
+#endif
+.endm
+
 #ifdef L_aeabi_ldivmod
 
 /* Perform 64 bit signed division.
@@ -165,18 +205,10 @@ ARM_FUNC_START aeabi_uldivmod
cfi_start   __aeabi_uldivmod, LSYM(Lend_aeabi_uldivmod)
test_div_by_zerounsigned
 
-   sub sp, sp, #8
-#if defined(__thumb2__)
-   mov ip, sp
-   push{ip, lr}
-#else
-   do_push {sp, lr}
-#endif
-98:cfi_push 98b - __aeabi_uldivmod, 0xe, -0xc, 0x10
+   push_for_divide __aeabi_uldivmod
+   /* arguments in (r0:r1), (r2:r3) and *sp */
bl  SYM(__gnu_uldivmod_helper) __PLT__
-   ldr lr, [sp, #4]
-   add sp, sp, #8
-   do_pop  {r2, r3}
+   pop_for_divide
RET
cfi_end LSYM(Lend_aeabi_uldivmod)
 
-- 
1.9.1



  1   2   >