Re: libsanitizer merge from upstream r208536

2014-05-21 Thread Konstantin Serebryany
On Wed, May 21, 2014 at 11:43 PM, Jakub Jelinek  wrote:
> On Wed, May 21, 2014 at 04:09:19PM +0400, Konstantin Serebryany wrote:
>> A new patch based on r209283.
>> This one has the H.J.'s patches for x32.
>
> Ok for trunk then.  But please help the ppc*/arm*/sparc* maintainers if 
> issues on
> those targets are reported.
Of course. arm should be in a good shape since there are arm users
upstream, including ourselves.
ppc may get broken -- I haven't heard from anyone there for a while.
Same for sparc.
I'll commit later today.


> Thanks.
>
> Jakub


Re: [PATCH, libgfortran] PR60324 Handle arbitrarily long path names

2014-05-21 Thread Janne Blomqvist
On Wed, May 21, 2014 at 4:35 PM, Steve Kargl
 wrote:
> On Mon, May 19, 2014 at 11:40:06PM +0300, Janne Blomqvist wrote:
>> Hello,
>>
>> some systems such as GNU Hurd, don't define PATH_MAX at all, and on
>> some other systems many syscalls apparently work for paths longer than
>> PATH_MAX. Thus GFortran shouldn't truncate paths to PATH_MAX
>> characters, but rather use heap allocated buffers limited only by the
>> available memory. The attached patch implements this, with the
>> exception of the backtrace functionality where we cannot use malloc
>> since backtrace might be called from a signal handler.
>>
>> Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
>>
>> 2014-05-19  Janne Blomqvist  
>>
>> PR libfortran/60324
>> * config.h.in: Regenerated.
>> * configure: Regenerated.
>> * configure.ac (AC_CHECK_FUNCS_ONCE): Check for strnlen and
>> strndup.
>> * libgfortran.h (fc_strdup): New prototype.
>
> Janne,
>
> I read through the diff, and did not see anything that threw up
> a caution sign.  I only have a cosmetic question.  Why a fc_
> prefix instead of the usual gfc_ prefix?  Otherwise, I think
> this is OK for trunk.

Thanks for the review. The fc_ prefix is shorthand for "fortran-to-c",
as fc_strdup converts a Fortran string to a C string. Similar to the
existing cf_strcpy and fstrlen.


-- 
Janne Blomqvist


PR lto/61012 (ICE on undefined symbol)

2014-05-21 Thread Jan Hubicka
Hi,
this patch fixes an ICE on undefined symbol. The testcase does not really go 
easily to testsuite
because it needs the undefined symbols to trigger. THe bug is however clear - 
one of the
loops is not properly skipping the static symbols.

Bootstrapped/regtested x86_64-linux, comitted to mainline and branch.
Honza

PR lto/61012
* lto-symtab.c (lto_symtab_merge_decls_1): Do not ICE on undefined 
externals
mixed with variables.
Index: lto-symtab.c
===
--- lto-symtab.c(revision 210672)
+++ lto-symtab.c(working copy)
@@ -453,7 +453,12 @@ lto_symtab_merge_decls_1 (symtab_node *f
  cgraph or a varpool node.  */
   if (!prevailing)
 {
-  prevailing = first;
+  for (prevailing = first;
+  prevailing; prevailing = prevailing->next_sharing_asm_name)
+   if (lto_symtab_symbol_p (prevailing))
+ break;
+  if (!prevailing)
+   return;
   /* For variables chose with a priority variant with vnode
 attached (i.e. from unit where external declaration of
 variable is actually used).


Re: [PATCH] proposed fix for bug # 61144

2014-05-21 Thread Rich Felker
On Wed, May 21, 2014 at 11:17:53AM +0200, Richard Biener wrote:
> On Wed, May 21, 2014 at 3:59 AM, Rich Felker  wrote:
> > Bug # 61144 is a regression in 4.9.0 that breaks building of musl libc
> > due to aggressive and semantically-incorrect constant folding of weak
> > aliases. The attached patch seems to fix the issue. A weak alias
> > should never be a candidate for constant folding because it may always
> > be replaced by a strong definition from another translation unit.
> >
> > For details see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61144
> >
> > I do not have a copyright assignment on file but this patch should be
> > sufficiently trivial not to require it.
> 
> Please add a testcase.  Also I wonder why it isn't better to generalize

How should a testcase be done? On the PR there's a testcase that shows
the problem in the generated code, but no automated check for it.
Testing this is actually a bit of a pain unless you're allowed to run
the generated program.

>   /* Variables declared 'const' without an initializer
>  have zero as the initializer if they may not be
>  overridden at link or run time.  */
>   if (!DECL_INITIAL (real_decl)
>   && (DECL_EXTERNAL (decl) || decl_replaceable_p (decl)))
> return error_mark_node;
> 
> Honza?

Indeed, this may be a better place to do it as long as
decl_replaceable_p reliably returns true for weak aliases. If so, the
following might work:

   if ((!DECL_INITIAL (real_decl) && DECL_EXTERNAL (decl))
   || decl_replaceable_p (decl)))
 return error_mark_node;

On the other hand, I might just separate it out into two separate if
statements since they should probably have their own comments.

I would appreciate help from anyone familiar with GCC internals on
getting this right.

Rich


Re: [PATCH, AArch64] Fix for PR61202

2014-05-21 Thread Xinliang David Li
Since it is in trunk and gcc-4_9-branch, there is no need to put into
google branches -- will get it automatically after next merge.

David

On Wed, May 21, 2014 at 8:13 PM, Carrot Wei  wrote:
> Committed to trunk, 4.9, and waiting for the release of 4.8.3.
>
> OK for google/main and google/4.9?
>
> thanks
> Carrot
>
> On Wed, May 21, 2014 at 1:34 AM, Richard Biener  wrote:
>> On Wed, 21 May 2014, Marcus Shawcroft wrote:
>>
>>> On 21 May 2014 09:28, Marcus Shawcroft  wrote:
>>> > On 20 May 2014 18:37, Carrot Wei  wrote:
>>> >> Hi James
>>> >>
>>> >> Thank you for pointing this out. In the new patch I removed the
>>> >> modification of vqdmulh_n_s32 and vqdmulhq_n_s32.
>>> >>
>>> >> Passed dejagnu testing on aarch64 qemu again. OK for trunk, 4.9 and 4.8?
>>> >>
>>> >> 2014-05-20  Guozhi Wei  
>>> >>
>>> >> * config/aarch64/arm_neon.h (vqdmulh_n_s16): Change
>>> >> the last operand's constraint.
>>> >> (vqdmulhq_n_s16): Likewise.
>>> >
>>> > Thank you.  This is OK to commit on trunk, 4.9 and 4.8
>>> > /Marcus
>>>
>>> Actually, I've jumped the gun by saying OK for 4.8. Please hold off on
>>> the 4.8 backport until one of the release maintainers says its OK.
>>> Richie can we take this now or do you want us to hold off?
>>
>> Please wait for 4.8.3 to be released for non-regression fixes or
>> regression fixes that are not against a working 4.8.2.
>>
>> Thanks,
>> Richard.


Re: [PATCH, AArch64] Fix for PR61202

2014-05-21 Thread Carrot Wei
Committed to trunk, 4.9, and waiting for the release of 4.8.3.

OK for google/main and google/4.9?

thanks
Carrot

On Wed, May 21, 2014 at 1:34 AM, Richard Biener  wrote:
> On Wed, 21 May 2014, Marcus Shawcroft wrote:
>
>> On 21 May 2014 09:28, Marcus Shawcroft  wrote:
>> > On 20 May 2014 18:37, Carrot Wei  wrote:
>> >> Hi James
>> >>
>> >> Thank you for pointing this out. In the new patch I removed the
>> >> modification of vqdmulh_n_s32 and vqdmulhq_n_s32.
>> >>
>> >> Passed dejagnu testing on aarch64 qemu again. OK for trunk, 4.9 and 4.8?
>> >>
>> >> 2014-05-20  Guozhi Wei  
>> >>
>> >> * config/aarch64/arm_neon.h (vqdmulh_n_s16): Change
>> >> the last operand's constraint.
>> >> (vqdmulhq_n_s16): Likewise.
>> >
>> > Thank you.  This is OK to commit on trunk, 4.9 and 4.8
>> > /Marcus
>>
>> Actually, I've jumped the gun by saying OK for 4.8. Please hold off on
>> the 4.8 backport until one of the release maintainers says its OK.
>> Richie can we take this now or do you want us to hold off?
>
> Please wait for 4.8.3 to be released for non-regression fixes or
> regression fixes that are not against a working 4.8.2.
>
> Thanks,
> Richard.


Re: Warning flags for compatibility with clang.

2014-05-21 Thread Andrew Pinski
On Wed, May 21, 2014 at 7:58 PM, Andrew Pinski  wrote:
> On Wed, May 21, 2014 at 7:50 PM, Pedro Giffuni  wrote:
>> Hello;
>>
>> FWIW, I have been looking at some changes from Apple's GCC and these two
>> small changes should be interesting to have in the official gcc.
>>
>> Implement -Wmost for compatibility with clang.
>> http://svnweb.freebsd.org/base?view=revision&revision=259920
>>
>> Add Apple compatible -Wnewline-eof
>> http://svnweb.freebsd.org/base?view=revision&revision=259555
>
> There is an older patch for this:
> https://gcc.gnu.org/ml/gcc-patches/2007-04/msg00457.html
>
> I really don't like it and hate editors which don't add a newline at
> the end of the file.


Oh we no longer warn about the newline missing at eof which is why the
patch was needed in the first place.

Thanks,
Andrew

>
> Thanks,
> Andrew Pinski
>
>
>>
>> I don't own them but I doubt any of them is copyrightable. Perhaps they are
>> available in the old Apple branches that the FSF has control of.
>>
>> Regards,
>>
>> Pedro.


Re: Warning flags for compatibility with clang.

2014-05-21 Thread Andrew Pinski
On Wed, May 21, 2014 at 7:50 PM, Pedro Giffuni  wrote:
> Hello;
>
> FWIW, I have been looking at some changes from Apple's GCC and these two
> small changes should be interesting to have in the official gcc.
>
> Implement -Wmost for compatibility with clang.
> http://svnweb.freebsd.org/base?view=revision&revision=259920
>
> Add Apple compatible -Wnewline-eof
> http://svnweb.freebsd.org/base?view=revision&revision=259555

There is an older patch for this:
https://gcc.gnu.org/ml/gcc-patches/2007-04/msg00457.html

I really don't like it and hate editors which don't add a newline at
the end of the file.

Thanks,
Andrew Pinski


>
> I don't own them but I doubt any of them is copyrightable. Perhaps they are
> available in the old Apple branches that the FSF has control of.
>
> Regards,
>
> Pedro.


Warning flags for compatibility with clang.

2014-05-21 Thread Pedro Giffuni

Hello;

FWIW, I have been looking at some changes from Apple's GCC and these two 
small changes should be interesting to have in the official gcc.


Implement -Wmost for compatibility with clang.
http://svnweb.freebsd.org/base?view=revision&revision=259920

Add Apple compatible -Wnewline-eof
http://svnweb.freebsd.org/base?view=revision&revision=259555

I don't own them but I doubt any of them is copyrightable. Perhaps they 
are available in the old Apple branches that the FSF has control of.


Regards,

Pedro.


Re: Add flag to optionally ignore ELF interposition

2014-05-21 Thread Thiago Macieira
Em ter 20 maio 2014 22:04:32 você escreveu:
> Hi,
> as disucssed some time ago, our assumption that every symbol of shared
> library can be interposed at runtime is expensive and prevents a lot of
> useful optimizations, including inlining or IPA propagation.
> 
> While this is useful feature, it is rather incommon to use it for bigger C++
> projects, like firefox and at least clang seems to ignore the ELF
> interposition rules and always inline/propagate. This patch adds flag to
> control the behaviour. Symbols explicitly delcared WEAK are still
> considered as interposable.
> 
> Bootstrapped/regtested x86_64-linux, will commit it tomorrow if there are
> no complains. (Feedback is welcome!)

This patch seems to be controlling the behaviour of the compiler when seeing 
functions global that may or may not be interposed in the future. There 
doesn't seem to be a correct way to declare "no, this can't be interposed". Is 
there any plan of doing that?

In other words, if a function is not declared inline and GCC decides not to 
inline it anyway, then it and the linker will generate an indirect call 
through the PLT, with an associated (lazy) relocation. It's worse for 
variables: all non-hidden global variables must always be accessed indirectly 
via the GOT.

We have a couple of solutions for forbidding interposing (-Bsymbolic and 
protected visibility) and thus improve code generation, but they seem to 
always cause trouble in some places. The most common one for variables is copy 
relocation, whereas for functions it's the official function pointer address 
(will resolve to the PLT in the main executable).

Large projects would really appreciate being able to declare some symbols not 
interposable at all.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center
  PGP/GPG: 0x6EF45358; fingerprint:
  E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358



Re: [PATCH] Fix PR 61225

2014-05-21 Thread Zhenqiang Chen
On 21 May 2014 20:43, Steven Bosscher  wrote:
> On Wed, May 21, 2014 at 11:58 AM, Zhenqiang Chen wrote:
>> Hi,
>>
>> The patch fixes the gcc.target/i386/pr49095.c FAIL in PR61225. The
>> test case tends to check a peephole2 optimization, which optimizes the
>> following sequence
>>
>> 2: bx:SI=ax:SI
>> 25: ax:SI=[bx:SI]
>> 7: {ax:SI=ax:SI-0x1;clobber flags:CC;}
>> 8: [bx:SI]=ax:SI
>> 9: flags:CCZ=cmp(ax:SI,0)
>> to
>>2: bx:SI=ax:SI
>>41: {flags:CCZ=cmp([bx:SI]-0x1,0);[bx:SI]=[bx:SI]-0x1;}
>>
>> The enhanced shrink-wrapping, which calls copyprop_hardreg_forward
>> changes the INSN 25 to
>>
>> 25: ax:SI=[ax:SI]
>>
>> Then peephole2 can not optimize it since two memory_operands look like
>> different.
>>
>> To fix it, the patch adds another peephole2 rule to read one more
>> insn. From the register copy, it knows the address is the same.
>
> That is one complex peephole2 to deal with a transformation like this.
> It seems to be like it's a too specific solution for a bigger problem.
>
> Could you please try one of the following solutions instead:

Thanks for the comments.

> 1. Track register values for peephole2 and try different alternatives
> based on known register equivalences? E.g. in your example, perhaps
> there is already a REG_EQUAL/REG_EQUIV note available on insn 25 after
> copyprop_hardreg_forward, to annotate that [ax:SI] is equivalent to
> [bx:SI] at that point (or if that information is not available, it is
> not very difficult to make it available). Then you could try applying
> peephole2 on the original pattern but also on patterns modified with
> the known equivalences (i.e. try peephole2 on multiple equivalent
> patterns for the same insn). This may expose other peephole2
> opportunities, not just the specific one your patch addresses.

I will try this one.

> 2. Avoid copy-prop'ing ax:SI into [bx:SI] to begin with. At insn 7,
> both ax:SI and bx:SI are live, so insn 2 is not dead (i.e. cannot be
> eliminated) and there is no benefit in this transformation. It only
> hides (or at least makes it harder to see) that [ax:SI] in insn 25 is
> the same memory reference as [bx:SI] in insn 8. So perhaps the copy
> propagation should simply not be done unless it turns at least one
> instruction into dead code.

This is a good heuristics. But it will lead copy-prop much more
complexity. copy-prop pass scans INSN one by one to do the
propagation. If there have multi reference INSNs, you can not make the
decision until changing the last reference.

> Any reason why this transformation isn't done much earlier, e.g. in combine?

I do not know. The similar peephole2 rule was added to fix pr49095.
Will try it if Solution 1 does not work.

Thanks!
-Zhenqiang


Re: [RS6000] PR61231 lwa_operand related fix

2014-05-21 Thread David Edelsohn
On Wed, May 21, 2014 at 8:13 PM, Alan Modra  wrote:
> This fixes another case where we use the wrong memory constraint.  See
> the analysis in the PR.  The rule for operand predicate and
> constraints is simply that the union of all constraints must exactly
> match the operand predicate.
>
> Bootstrapped and regression tested powerpc64-linux and
> powerpc64le-linux.  OK for mainline and active branches?
>
> Note that I didn't see the bootstrap miscompares reported in the PR,
> so perhaps there is some other issue to fix besides this one..
>
> PR target/61231
> * config/rs6000/rs6000.c (mem_operand_gpr): Handle SImode.
> * config/rs6000/rs6000.md (extendsidi2_lfiwax, extendsidi2_nocell):
> Use "Y" constraint rather than "m".

Okay.

Thanks, David


[RS6000] PR61231 lwa_operand related fix

2014-05-21 Thread Alan Modra
This fixes another case where we use the wrong memory constraint.  See
the analysis in the PR.  The rule for operand predicate and
constraints is simply that the union of all constraints must exactly
match the operand predicate.

Bootstrapped and regression tested powerpc64-linux and
powerpc64le-linux.  OK for mainline and active branches?

Note that I didn't see the bootstrap miscompares reported in the PR,
so perhaps there is some other issue to fix besides this one..

PR target/61231
* config/rs6000/rs6000.c (mem_operand_gpr): Handle SImode.
* config/rs6000/rs6000.md (extendsidi2_lfiwax, extendsidi2_nocell):
Use "Y" constraint rather than "m".

Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 210661)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -6124,7 +6127,8 @@ mem_operand_gpr (rtx op, enum machine_mode mode)
 return false;
 
   extra = GET_MODE_SIZE (mode) - UNITS_PER_WORD;
-  gcc_assert (extra >= 0);
+  if (extra < 0)
+extra = 0;
 
   if (GET_CODE (addr) == LO_SUM)
 /* For lo_sum addresses, we must allow any offset except one that
Index: gcc/config/rs6000/rs6000.md
===
--- gcc/config/rs6000/rs6000.md (revision 210661)
+++ gcc/config/rs6000/rs6000.md (working copy)
@@ -745,7 +745,7 @@
 
 (define_insn "*extendsidi2_lfiwax"
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r,??wm,!wl,!wu")
-   (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r,r,Z,Z")))]
+   (sign_extend:DI (match_operand:SI 1 "lwa_operand" "Y,r,r,Z,Z")))]
   "TARGET_POWERPC64 && TARGET_LFIWAX"
   "@
lwa%U1%X1 %0,%1
@@ -758,7 +758,7 @@
 
 (define_insn "*extendsidi2_nocell"
   [(set (match_operand:DI 0 "gpc_reg_operand" "=r,r")
-   (sign_extend:DI (match_operand:SI 1 "lwa_operand" "m,r")))]
+   (sign_extend:DI (match_operand:SI 1 "lwa_operand" "Y,r")))]
   "TARGET_POWERPC64 && rs6000_gen_cell_microcode && !TARGET_LFIWAX"
   "@
lwa%U1%X1 %0,%1

-- 
Alan Modra
Australia Development Lab, IBM


Re: [RFC][AArch64] Define TARGET_SPILL_CLASS

2014-05-21 Thread Andrew Pinski
On Wed, May 21, 2014 at 4:44 PM, Kugan
 wrote:
> Compiling some applications with -mgeneral-regs-only produces better
> code (runs faster) compared to not using it. The difference here is that
> when -mgeneral-regs-only is not used, floating point register are also
> used in register allocation. Then IRA/LRA has to move them to core
> registers before performing operations.
>
> I experimented with TARGET_SPILL_CLASS (as in attached patch) to make
> floating point register class as just spill class for integer pseudos.
> Though this benefits the application which had this issue. Overall
> performance with speck2k is neutral (some of the benchmarks benefits a
> lot but others regress). I am looking to see if I can make it perform
> better overall. Any suggestions welcome.
>
> Attached experimental patch passes regression but 168.wupwise and
> 187.facerec miscompares now. I am looking at fixing this as well.
>
> Thanks,
> Kugan
>
> gcc/
> 2014-05-22  Kugan Vivekanandarajah  
>
> * config/aarch64/aarch64.c (generic_regmove_cost) : Adjust GP2FP and
> FP2GP costs.
> (aarch64_spill_class) : New function.


> (TARGET_SHIFT_TRUNCATION_MASK) : Define.

No you are not defining TARGET_SHIFT_TRUNCATION_MASK, remove it from
the changelog.

Thanks,
Andrew Pinski


[RFC][AArch64] Define TARGET_SPILL_CLASS

2014-05-21 Thread Kugan
Compiling some applications with -mgeneral-regs-only produces better
code (runs faster) compared to not using it. The difference here is that
when -mgeneral-regs-only is not used, floating point register are also
used in register allocation. Then IRA/LRA has to move them to core
registers before performing operations.

I experimented with TARGET_SPILL_CLASS (as in attached patch) to make
floating point register class as just spill class for integer pseudos.
Though this benefits the application which had this issue. Overall
performance with speck2k is neutral (some of the benchmarks benefits a
lot but others regress). I am looking to see if I can make it perform
better overall. Any suggestions welcome.

Attached experimental patch passes regression but 168.wupwise and
187.facerec miscompares now. I am looking at fixing this as well.

Thanks,
Kugan

gcc/
2014-05-22  Kugan Vivekanandarajah  

* config/aarch64/aarch64.c (generic_regmove_cost) : Adjust GP2FP and
FP2GP costs.
(aarch64_spill_class) : New function.
(TARGET_SHIFT_TRUNCATION_MASK) : Define.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index a3147ee..16d1b51 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -184,8 +184,8 @@ __extension__
 static const struct cpu_regmove_cost generic_regmove_cost =
 {
   NAMED_PARAM (GP2GP, 1),
-  NAMED_PARAM (GP2FP, 2),
-  NAMED_PARAM (FP2GP, 2),
+  NAMED_PARAM (GP2FP, 5),
+  NAMED_PARAM (FP2GP, 5),
   /* We currently do not provide direct support for TFmode Q->Q move.
  Therefore we need to raise the cost above 2 in order to have
  reload handle the situation.  */
@@ -4882,6 +4882,18 @@ aarch64_register_move_cost (enum machine_mode mode 
ATTRIBUTE_UNUSED,
   return regmove_cost->FP2FP;
 }
 
+/* Return class of registers which could be used for pseudo of MODE
+   and of class RCLASS for spilling instead of memory.  */
+static reg_class_t
+aarch64_spill_class (reg_class_t rclass, enum machine_mode mode)
+{
+  if ((GET_MODE_CLASS (mode) == MODE_INT)
+   && reg_class_subset_p (rclass, GENERAL_REGS))
+return FP_REGS;
+  return NO_REGS;
+}
+
+
 static int
 aarch64_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED,
  reg_class_t rclass ATTRIBUTE_UNUSED,
@@ -8431,6 +8443,9 @@ aarch64_cannot_change_mode_class (enum machine_mode from,
 #undef TARGET_SECONDARY_RELOAD
 #define TARGET_SECONDARY_RELOAD aarch64_secondary_reload
 
+#undef TARGET_SPILL_CLASS
+#define TARGET_SPILL_CLASS aarch64_spill_class
+
 #undef TARGET_SHIFT_TRUNCATION_MASK
 #define TARGET_SHIFT_TRUNCATION_MASK aarch64_shift_truncation_mask
 


Re: [PATCH][MIPS] Implement O32 FPXX ABI (GCC)

2014-05-21 Thread Richard Sandiford
Matthew Fortune  writes:
>> > *) Because GCC can be built to have mfpxx or mfp64 as the default option
>> >the ASM_SPEC has to handle these specially such that they are not
>> >passed in conjunction with -msingle-float. Depending on how all this
>> >option handling pans out then this may also need to account for
>> >msoft-float as well. It is an error to have -msoft-float and -mfp64 in
>> >the assembler.
>> 
>> The assembler and GCC shouldn't treat the options differently though.
>> Either it should be OK for both or neither.
>
> I wasn't sure if you were applying this rule to options set by --with- at
> configure time as well as user supplied options. If I move this logic
> to OPTION_DEFAULT_SPECS instead and not apply the --with-fp option if
> -msingle-float is given then that will fix the issue too. Is that OK?

--with-foo is just a way of setting the default -mfoo option when no
explicit -mfoo option is given.  We shouldn't generally distinguish
between them.

>> > @@ -5141,7 +5141,7 @@ mips_get_arg_info (struct mips_arg_info *info,
>> const CUMULATIVE_ARGS *cum,
>> > || SCALAR_FLOAT_TYPE_P (type)
>> > || VECTOR_FLOAT_TYPE_P (type))
>> > && (GET_MODE_CLASS (mode) == MODE_FLOAT
>> > -   || mode == V2SFmode)
>> > +   || (TARGET_PAIRED_SINGLE_FLOAT && mode == V2SFmode))
>> > && GET_MODE_SIZE (mode) <= UNITS_PER_FPVALUE);
>> >break;
>> 
>> This looks odd.  We shouldn't have V2SF values if there's no ISA support
>> for them.
>
> True. This is a safety measure against future vector support. I/We wish to
> completely restrict this ABI extension to the paired single-float
> hardware feature. This detail is easy to forget, I would like to keep
> the check but you get final call of course.

But the problem is that the change gives a specific behaviour for
!TARGET_PAIRED_SINGLE_FLOAT && mode == V2SFmode, which at the moment
should be a nonsensical condition.  I want to avoid defining an ABI
for something that shouldn't happen.

I'd be happy with an assert like:

  gcc_assert (TARGET_PAIRED_SINGLE_FLOAT || mode != V2SFmode);

instead.

>> > @@ -5636,7 +5636,7 @@ mips_return_fpr_pair (enum machine_mode mode,
>> >  {
>> >int inc;
>> >
>> > -  inc = (TARGET_NEWABI ? 2 : MAX_FPRS_PER_FMT);
>> > +  inc = ((TARGET_NEWABI || mips_abi == ABI_32) ? 2 : MAX_FPRS_PER_FMT);
>> 
>> Formatting nit: no extra brackets here.
>
> Is this a no brackets at all case, or brackets on the condition? There are
> both styles in GCC but it is difficult to tell which is most common/correct.

Sorry, I meant just the new brackets.

>> > @@ -6508,13 +6508,27 @@ mips_output_64bit_xfer (char direction, unsigned
>> int gpreg, unsigned int fpreg)
>> >if (TARGET_64BIT)
>> >  fprintf (asm_out_file, "\tdm%cc1\t%s,%s\n", direction,
>> > reg_names[gpreg], reg_names[fpreg]);
>> > -  else if (TARGET_FLOAT64)
>> > +  else if (ISA_HAS_MXHC1)
>> >  {
>> >fprintf (asm_out_file, "\tm%cc1\t%s,%s\n", direction,
>> >   reg_names[gpreg + TARGET_BIG_ENDIAN], reg_names[fpreg]);
>> >fprintf (asm_out_file, "\tm%chc1\t%s,%s\n", direction,
>> >   reg_names[gpreg + TARGET_LITTLE_ENDIAN], reg_names[fpreg]);
>> >  }
>> > +  else if (TARGET_FLOATXX && direction == 't')
>> > +{
>> > +  /* Use the argument save area to move via memory.  */
>> > +  fprintf (asm_out_file, "\tsw\t%s,0($sp)\n", reg_names[gpreg]);
>> > +  fprintf (asm_out_file, "\tsw\t%s,4($sp)\n", reg_names[gpreg + 1]);
>> > +  fprintf (asm_out_file, "\tldc1\t%s,0($sp)\n", reg_names[fpreg]);
>> > +}
>> > +  else if (TARGET_FLOATXX && direction == 'f')
>> > +{
>> > +  /* Use the argument save area to move via memory.  */
>> > +  fprintf (asm_out_file, "\tsdc1\t%s,0($sp)\n", reg_names[fpreg]);
>> > +  fprintf (asm_out_file, "\tlw\t%s,0($sp)\n", reg_names[gpreg]);
>> > +  fprintf (asm_out_file, "\tlw\t%s,4($sp)\n", reg_names[gpreg + 1]);
>> > +}
>> 
>> The argument save area might be in use.  E.g. if an argument register
>> gets spilled, we'll generally try to spill it to the save area rather
>> than create a new stack slot for it.
>> 
>> This case should always be handled via SECONDARY_MEMORY_NEEDED.
>
> It is handled via SECONDARY_MEMORY_NEEDED for normal code generation. This
> function needs a better name! It is solely used as part of generating a
> mips16 stub and as such the argument save area is fair game as far as I can
> see, this code is essentially pre-prologue or post-epilogue of the callee.
>
> Shall I rename the function (and related functions which are solely
> applicable to mips16 stubs) to make it clear?

I think the name's OK.  I'd just forgotten how the function was used.

So yeah, this looks good after all.

>> > @@ -12202,7 +12247,8 @@ mips_secondary_reload_class (enum reg_class
>> rclass,
>> >return NO_REGS;
>> >
>> >/* Otherwise, we need to reloa

[patch] Small enhancement to associate_plusminus

2014-05-21 Thread Eric Botcazou
Hi,

one of the transformations performed by associate_plusminus is:

  /* Second match patterns that allow contracting a plus-minus pair
 irrespective of overflow issues.

  [...]
(T)(P + A) - (T)P  -> (T)A

but it is actually applied only to POINTER_PLUS_EXPR and pointer types:

 /* (T)(ptr + adj) - (T)ptr -> (T)adj.  */

It turns out that this pattern arises for size computations of array slices in 
Ada, which are done in integer types; for the attached testcase, extending the 
transformation to integer types makes it possible to eliminate a call to the 
alloca builtin.

Tested on x86_64-suse-linux, OK for the mainline?


2014-05-21  Eric Botcazou  

* tree.h (PLUS_EXPR_CODE_P): New macro.
(PLUS_EXPR_P): Likewise.
(CASE_PLUS): Likewise.
* tree-ssa-forwprop.c (associate_plusminus): Extend (T)(P+A) - (T)P
-> (T)A transformation to integer types.


2014-05-21  Eric Botcazou  

* gnat.dg/opt37.ad[sb]: New test.


-- 
Eric Botcazoupackage Opt37 is

   type T_Bit is range 0 .. 1;
   for T_Bit'Size use 1;

   type Positive is range 0 .. (2 ** 31) - 1;
   type Unsigned32 is mod 2 ** 32;

   subtype T_Bit_Count is Positive;
   subtype T_Bit_Index is T_Bit_Count range 1 .. T_Bit_Count'Last;

   type T_Bit_Array is array (T_Bit_Count range <>) of T_Bit;
   pragma Pack (T_Bit_Array);

   function Func (Bit_Array : in T_Bit_Array;
  Bit_Index : in T_Bit_Index) return Positive;

end Opt37;-- { dg-compile }
-- { dg-options "-O2 -gnato -fdump-tree-optimized" }

package body Opt37 is

   function To_Unchecked (Bits : T_Bit_Array) return Unsigned32 is
  Value : Unsigned32 := 0;
   begin
  for I in Bits'Range loop
 Value := Value * 2 + Unsigned32 (Bits(I));
  end loop;
  return Value;
   end;

   function To_Scalar (Bits : T_Bit_Array) return Positive is
  Tmp   : Unsigned32;
  Value : Positive;
   begin
  Tmp := To_Unchecked (Bits);
  if Tmp in 0 .. Unsigned32 (Positive'last) then
 Value := Positive (Tmp);
  else
 Value := -Positive (Unsigned32'last - Tmp);
 if Value > Positive'first then
Value := Value - 1;
 else
raise Program_Error;
 end if;
  end if;
  return Value;
   end;

   function Func (Bit_Array : T_Bit_Array;
  Bit_Index : T_Bit_Index) return Positive is
   begin
  return To_Scalar (Bit_Array (Bit_Index .. Bit_Index + 1));
   end;

end Opt37;

-- { dg-final { scan-tree-dump-not "alloca" "optimized" } }
-- { dg-final { cleanup-tree-dump "optimized" } }Index: tree-ssa-forwprop.c
===
--- tree-ssa-forwprop.c	(revision 210676)
+++ tree-ssa-forwprop.c	(working copy)
@@ -2642,49 +2642,46 @@ associate_plusminus (gimple_stmt_iterato
 		  gimple_set_modified (stmt, true);
 		}
 	}
-	  else if (CONVERT_EXPR_CODE_P (def_code) && code == MINUS_EXPR
+	  else if (code == MINUS_EXPR
+		   && CONVERT_EXPR_CODE_P (def_code)
+		   && TREE_CODE (gimple_assign_rhs1 (def_stmt)) == SSA_NAME
 		   && TREE_CODE (rhs2) == SSA_NAME)
 	{
-	  /* (T)(ptr + adj) - (T)ptr -> (T)adj.  */
+	  /* (T)(P + A) - (T)P -> (T)A.  */
 	  gimple def_stmt2 = SSA_NAME_DEF_STMT (rhs2);
-	  if (TREE_CODE (gimple_assign_rhs1 (def_stmt)) == SSA_NAME
-		  && is_gimple_assign (def_stmt2)
+	  if (is_gimple_assign (def_stmt2)
 		  && can_propagate_from (def_stmt2)
 		  && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt2))
 		  && TREE_CODE (gimple_assign_rhs1 (def_stmt2)) == SSA_NAME)
 		{
-		  /* Now we have (T)A - (T)ptr.  */
-		  tree ptr = gimple_assign_rhs1 (def_stmt2);
+		  /* Now we have (T)X - (T)P.  */
+		  tree p = gimple_assign_rhs1 (def_stmt2);
 		  def_stmt2 = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (def_stmt));
 		  if (is_gimple_assign (def_stmt2)
-		  && gimple_assign_rhs_code (def_stmt2) == POINTER_PLUS_EXPR
-		  && gimple_assign_rhs1 (def_stmt2) == ptr)
+		  && can_propagate_from (def_stmt2)
+		  && PLUS_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt2))
+		  && gimple_assign_rhs1 (def_stmt2) == p)
 		{
-		  /* And finally (T)(ptr + X) - (T)ptr.  */
-		  tree adj = gimple_assign_rhs2 (def_stmt2);
-		  /* If the conversion of the pointer adjustment to the
-		 final type requires a sign- or zero-extension we
-			 have to punt - it is not defined which one is
-			 correct.  */
-		  if (TYPE_PRECISION (TREE_TYPE (rhs1))
-			  <= TYPE_PRECISION (TREE_TYPE (adj))
-			  || (TREE_CODE (adj) == INTEGER_CST
-			  && tree_int_cst_sign_bit (adj) == 0))
+		  /* And finally (T)(P + A) - (T)P.  */
+		  tree a = gimple_assign_rhs2 (def_stmt2);
+		  /* For pointer types, if the conversion of A to the final
+			 type requires a sign- or zero-extension, then we have
+			 to punt - it is not defined which one is correct.  */
+		  if (!POINTER_TYPE_P (TREE_TYPE (rhs1))
+			  || TYPE_PRECISION (

Re: libsanitizer merge from upstream r208536

2014-05-21 Thread Jakub Jelinek
On Wed, May 21, 2014 at 04:09:19PM +0400, Konstantin Serebryany wrote:
> A new patch based on r209283.
> This one has the H.J.'s patches for x32.

Ok for trunk then.  But please help the ppc*/arm*/sparc* maintainers if issues 
on
those targets are reported.
Thanks.

Jakub


Re: [MIPS] Add sbasic supoert ffor MSA (SIMD)

2014-05-21 Thread Richard Henderson
> +(define_expand "one_cmpl2"
> +  [(match_operand:IMSA 0 "register_operand")
> +   (match_operand:IMSA 1 "register_operand")]
> +  "ISA_HAS_MSA"
> +{
> +  if (mode == V16QImode)
> +emit_insn (gen_msa_nori_b (operands[0], operands[1], const0_rtx));
> +  else
> +{
> +  rtx reg = gen_reg_rtx (mode);
> +  emit_insn (gen_msa_ldi (reg, const0_rtx));
> +  emit_insn (gen_msa_nor_v_ (operands[0], reg, operands[1]));
> +}
> +  DONE;
> +})

Surely ~(x | x) would be preferable to ~(x | 0) if you actually have to load 0
into a register.

And most definitely combine would prefer to see NOT instead of a complex
expression.  I think you're better off with a define_insn than an expand.


r~


Re: [PATCH] Fix ubsan ICE on invalid (PR sanitizer/61272)

2014-05-21 Thread Jakub Jelinek
On Wed, May 21, 2014 at 08:46:22PM +0200, Marek Polacek wrote:
> 2014-05-21  Marek Polacek  
> 
>   PR sanitizer/61272
>   * ubsan.c (is_ubsan_builtin_p): Turn assert into a condition.
> 
>   * g++.dg/ubsan/pr61272.C: New test.

Ok, thanks.

Jakub


Re: [PATCH] Implement -fsanitize=float-cast-overflow (take 2)

2014-05-21 Thread Jakub Jelinek
On Wed, May 21, 2014 at 04:46:14PM +0200, Jakub Jelinek wrote:
> Here is a testcase that (IMHO, not tested with your patch) should
> test various boundary cases that shouldn't result in undefined behavior.
> I've tried to keep it portable across various architectures, assumes
> primarily two's complement and (likely) only supports binary and decimal
> floating point formats.
> Seems _Decimal{32,64,128} is not convertible
> to/from int128 right now, so that is disabled in the test for now.

Here is updated testcase + some also for the invalid values.
Compared to the previous testcase, this one I've actually tested with
Marek's patch, there were several issues.
On x86_64-linux, it mostly passes, with a few FAILs:
unix/-m32
FAIL: c-c++-common/ubsan/float-cast-overflow-10.c  -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  (internal compiler error)
FAIL: c-c++-common/ubsan/float-cast-overflow-10.c  -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  (test for excess errors)
FAIL: c-c++-common/ubsan/float-cast-overflow-10.c  -O2 -flto 
-fuse-linker-plugin -fno-fat-lto-objects  (internal compiler error)
FAIL: c-c++-common/ubsan/float-cast-overflow-10.c  -O2 -flto 
-fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
FAIL: c-c++-common/ubsan/float-cast-overflow-7.c  -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  (internal compiler error)
FAIL: c-c++-common/ubsan/float-cast-overflow-7.c  -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  (test for excess errors)
FAIL: c-c++-common/ubsan/float-cast-overflow-7.c  -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  (internal compiler error)
FAIL: c-c++-common/ubsan/float-cast-overflow-7.c  -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  (test for excess errors)
FAIL: c-c++-common/ubsan/float-cast-overflow-8.c  -O2  execution test
FAIL: c-c++-common/ubsan/float-cast-overflow-8.c  -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  execution test
FAIL: c-c++-common/ubsan/float-cast-overflow-8.c  -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  execution test
FAIL: c-c++-common/ubsan/float-cast-overflow-9.c  -O2  execution test
FAIL: c-c++-common/ubsan/float-cast-overflow-9.c  -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  execution test
FAIL: c-c++-common/ubsan/float-cast-overflow-9.c  -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  execution test
unix/-m64
FAIL: c-c++-common/ubsan/float-cast-overflow-10.c  -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  (internal compiler error)
FAIL: c-c++-common/ubsan/float-cast-overflow-10.c  -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  (test for excess errors)
FAIL: c-c++-common/ubsan/float-cast-overflow-10.c  -O2 -flto 
-fuse-linker-plugin -fno-fat-lto-objects  (internal compiler error)
FAIL: c-c++-common/ubsan/float-cast-overflow-10.c  -O2 -flto 
-fuse-linker-plugin -fno-fat-lto-objects  (test for excess errors)
FAIL: c-c++-common/ubsan/float-cast-overflow-7.c  -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  (internal compiler error)
FAIL: c-c++-common/ubsan/float-cast-overflow-7.c  -O2 -flto 
-fno-use-linker-plugin -flto-partition=none  (test for excess errors)
FAIL: c-c++-common/ubsan/float-cast-overflow-7.c  -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  (internal compiler error)
FAIL: c-c++-common/ubsan/float-cast-overflow-7.c  -O2 -flto -fuse-linker-plugin 
-fno-fat-lto-objects  (test for excess errors)

The LTO ICEs on float-cast-overflow-{7,10}.c seems to be related to decimal 
support:
/usr/src/gcc/gcc/testsuite/c-c++-common/ubsan/float-cast-overflow-7.c:147:1: 
internal compiler error: in decimal_to_decnumber, at dfp.c:138
0x116b4cb decimal_to_decnumber
../../gcc/dfp.c:138
0x116b56f encode_decimal32(real_format const*, long*, real_value const*)
../../gcc/dfp.c:165
0x9cebb5 encode_decimal_single
../../gcc/real.c:4495
0x9ccb0b real_to_target_fmt(long*, real_value const*, real_format const*)
../../gcc/real.c:2774
0x9ccb6d real_to_target(long*, real_value const*, machine_mode)
../../gcc/real.c:2789
0xa7c7ff simplify_immed_subreg
../../gcc/simplify-rtx.c:5290
0xa7d328 simplify_subreg(machine_mode, rtx_def*, machine_mode, unsigned int)
../../gcc/simplify-rtx.c:5516
0xa7de2e simplify_gen_subreg(machine_mode, rtx_def*, machine_mode, unsigned int)
../../gcc/simplify-rtx.c:5721
The execution test FAILs for -m32 are:
==4494==Sanitizer CHECK failed: 
../../../../../libsanitizer/ubsan/ubsan_value.cc:98 ((0 && "unexpected floating 
point bit width")) != (0) (0, 0)
supposedly on the first __float80 or long double message (on x86_64-linux 
__float80 seems to work, but
__float128 randomly crashes the testcase in some invocations, in others it 
finishes, therefore
I haven't enabled it at all right now in float-cast-overflow-9.c).
We are passing 96 for long double and __float80 bitsize on x86_64 -m32, while
libubsan handles only 80 and 128.  Can you talk to upstream what the bi

[PATCH] Fix ubsan ICE on invalid (PR sanitizer/61272)

2014-05-21 Thread Marek Polacek
When compiling invalid C++ code, CALL_EXPR that contains identifier_node
instead of a FUNCTION_DECL got into dump_expr - and is_ubsan_builtin_p
was expecting that it only gets FUNCTION_DECLs.  Fixed by changing the
assert into a condition so is_ubsan_builtin_p returns false for
non-functions.

Regtested/bootstrapped on x86_64-linux, ok for trunk?

2014-05-21  Marek Polacek  

PR sanitizer/61272
* ubsan.c (is_ubsan_builtin_p): Turn assert into a condition.

* g++.dg/ubsan/pr61272.C: New test.

diff --git gcc/testsuite/g++.dg/ubsan/pr61272.C 
gcc/testsuite/g++.dg/ubsan/pr61272.C
index e69de29..064678d 100644
--- gcc/testsuite/g++.dg/ubsan/pr61272.C
+++ gcc/testsuite/g++.dg/ubsan/pr61272.C
@@ -0,0 +1,24 @@
+// PR sanitizer/61272
+// { dg-do compile }
+// { dg-options "-fsanitize=undefined -std=c++11" }
+
+namespace std
+{
+  template < typename _Tp > class allocator;
+  template < typename _Alloc > struct allocator_traits {
+  private:
+  template < typename _Tp > auto construct ( _Alloc & __a, _Tp * __p)-> // 
{ dg-error "is private" }
+  decltype (_S_construct (__a, __p)) { }
+  };
+  namespace __gnu_cxx
+  {
+template < typename _Alloc > struct __alloc_traits:std::allocator_traits < 
_Alloc > // { dg-error "within this context" }
+{
+  typedef std::allocator_traits < _Alloc > _Base_type;
+  using _Base_type::construct;
+};
+template < typename _Tp, typename _Alloc > struct _Vector_base { typedef 
typename __gnu_cxx::__alloc_traits < _Alloc >::template rebind < _Tp >::other 
_Tp_alloc_type; }; // { dg-error "no class template" }
+template < typename _Tp, typename _Alloc = std::allocator < _Tp > >class 
vector : protected _Vector_base < _Tp, _Alloc > { };
+template < typename NumberT > struct Point2d { };
+typedef Point2d < int >GdsPoint;
+class GdsPointList : public vector < GdsPoint > {};}}
diff --git gcc/ubsan.c gcc/ubsan.c
index 11461d0..585569c 100644
--- gcc/ubsan.c
+++ gcc/ubsan.c
@@ -531,9 +531,9 @@ ubsan_instrument_unreachable (location_t loc)
 bool
 is_ubsan_builtin_p (tree t)
 {
-  gcc_checking_assert (TREE_CODE (t) == FUNCTION_DECL);
-  return strncmp (IDENTIFIER_POINTER (DECL_NAME (t)),
- "__builtin___ubsan_", 18) == 0;
+  return TREE_CODE (t) == FUNCTION_DECL
+&& strncmp (IDENTIFIER_POINTER (DECL_NAME (t)),
+"__builtin___ubsan_", 18) == 0;
 }
 
 /* Expand UBSAN_NULL internal call.  */

Marek


Re: [PATCH] Fix build failure in libcpp (PR c/61212)

2014-05-21 Thread Tom Tromey
> "Marek" == Marek Polacek  writes:

Marek> 2014-05-21  Marek Polacek  

Marek>  PR c/61212
Marek>  * files.c (find_file_in_dir): Add parens around &&.

Ok.  Thanks.

Tom


[PATCH] __attribute__ ((malloc)) doc fix (PR other/56955)

2014-05-21 Thread Paul Eggert
Attached is a proposed documentation patch for __attribute__ ((malloc)), 
taken from:


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56955#c9

Richard Biener suggested that I forward it to this list.
Index: gcc/ChangeLog
===
--- gcc/ChangeLog	(revision 210629)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2014-05-20  Paul Eggert  
+
+	PR other/56955
+	* doc/extend.texi (Function Attributes): Fix  __attribute__ ((malloc))
+	documentation; the old documentation didn't clearly state the
+	constraints on the contents of the pointed-to storage.
+
 2014-05-19  David Wohlferd 
 
 	* doc/extend.texi: Create Label Attributes section,
Index: gcc/doc/extend.texi
===
--- gcc/doc/extend.texi	(revision 210629)
+++ gcc/doc/extend.texi	(working copy)
@@ -3207,15 +3207,20 @@
 
 @item malloc
 @cindex @code{malloc} attribute
-The @code{malloc} attribute is used to tell the compiler that a function
-may be treated as if any non-@code{NULL} pointer it returns cannot
-alias any other pointer valid when the function returns and that the memory
-has undefined content.
-This often improves optimization.
-Standard functions with this property include @code{malloc} and
-@code{calloc}.  @code{realloc}-like functions do not have this
-property as the memory pointed to does not have undefined content.
+This tells the compiler that a function is @code{malloc}-like, i.e.,
+that if the function returns a non-null pointer @var{P}, then @var{P}
+cannot alias any other pointer valid when the function returns, and
+moreover the contents of any storage addressed by @var{P} cannot
+contain a pointer that aliases any other pointer valid when the
+function returns.
 
+Using this attribute often improves optimization.  Functions like
+@code{malloc} and @code{calloc} have this property because they return
+a pointer to uninitialized or zeroed-out storage.  However, functions
+like @code{realloc} do not have this property, as they can return a
+pointer to storage containing pointers that alias already-valid
+pointers.
+
 @item mips16/nomips16
 @cindex @code{mips16} attribute
 @cindex @code{nomips16} attribute


Re: [MIPS] Add sbasic supoert ffor MSA (SIMD)

2014-05-21 Thread Joseph S. Myers
On Wed, 21 May 2014, Graham Stott wrote:

> msa.h  is  included, which will be installed when configured/built/installed.
>  It provides prototypes, typedefs etc for the vector types used MSA its 
> contents follow the MSA whitepaper.

Unless it's part of the defined interface that the user may not have 
macros called "vector_size", "aligned", "a", "b" and "c", you should use 
the __*__ attribute names, and __a etc. parameter names, to be 
namespace-clean.

You shouldn't need to declare __builtin_* functions anyway.  And if a 
function can be represented directly with GNU C vector extensions, it's 
preferred to implement it that way inline in the header rather than having 
built-in functions duplicating existing GNU C functionality.  (Look at 
what AArch64 arm_neon.h does where possible, and what ARM arm_neon.h has 
been moved towards lately.  I don't now what the msa.h functions do, so I 
don't know if this actually applies to any of them - but it's something to 
consider, so that built-in functions are only defined where actually 
needed.)

Use appropriate @dots{} and @minus{} markup in the documentation.

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


Re: Add flag to optionally ignore ELF interposition

2014-05-21 Thread Jan Hubicka
> On Wed, 21 May 2014, Jan Hubicka wrote:
> 
> > I tought glibc uses handcoded local aliases for all its exported symbols 
> > except
> > for those where interposition is allowed.
> 
> It does that for exported symbols.  But there are lots of non-exported __* 
> functions used internally - and while some are declared hidden (or use the 
> facility for hidden aliases), I suspect lots are not, so it's only the 
> linker scripts that default-hide symbols that result in them not being 
> interposable (and I'm guessing this effect of a linker script is too late 
> for LTO to optimize based on that information).

This is actually good question, do you think you can check if such symbol get
LDPR_PREVAILING_DEF_IRONLY instead of LDPR_PREVAILING_DEF_IRONLY_EXP?
It would make sense for linker to do so and GCC will then privatize the symbols
(turn them to static).
If GNU LD or gold will declare them LDPR_PREVAILING_DEF_IRONLY_EXP, we probably 
could
fill in enhancement request.

The problem would be symbols that are used by non-LTO objects but still turned
hidden by the script - those would get LDPR_PREVAILING_DEF and since we do not
have LDPR_PREVAILING_DEF_EXP, we don't have the information that they are
hidden...
Introducing LDPR_PREVAILING_DEF_EXP is possible with another revision of plugin 
API,
but I am not sure it is worth the effort.

But yes, having way to tell this to non-LTO compiler would be nice. I wonder if
visibility attribute is right mechanism or the proposed 
-fsemantic-interposition=

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


Re: [PATCH] Implement -fsanitize=float-cast-overflow (take 2)

2014-05-21 Thread Joseph S. Myers
On Wed, 21 May 2014, Marek Polacek wrote:

> On Tue, May 20, 2014 at 09:50:10PM +, Joseph S. Myers wrote:
> > On Tue, 20 May 2014, Marek Polacek wrote:
> > 
> > > * is missing tests for long doubles/-mlong-double-128,
> > 
> > Also missing tests for float - as far as I can see, only double is tested.  
> > Ideally all of float, double, long double, __float128 (where supported), 
> > __float80 (where supported) would be tested (the functionality supported 
> > for __fp16 (ARM) is a bit more restricted) - hopefully using some shared 
> > macros to avoid too much duplication between tests.
>  
> Ok, I've added some tests for float, long double, __float128 and
> __float80.  A snag was in __float128 type: libubsan supposedly can't
> handle __float128 values and prints "0".  libubsan also can't handle
> __float80 types with -m32 it seems.

__float80 is normally the same as long double (in terms of representation 
anyway, whether or not it's a distinct type).  On x86, it's only 
-mlong-double-128 (64-bit Bionic) that means they are different; on IA64 
it's HP-UX where they are different.  (On x86_64, typically __float80 and 
__float128 will both have the same size, although different 
representations.)

It looks to me from i386.c like __float80 is just a built-in typedef for 
long double if long double is XFmode, but __float128 is always distinct 
(always created with a separate make_node (REAL_TYPE) call) (although for 
IA64 HP-UX, __float128 looks like it is a typedef - and for IA64 in 
general, it looks like __float80 is always distinct).  I don't know if 
cleanup in this area is worthwhile at this point - FWIW, draft TS 18661-3, 
soon to go to PDTS ballot, makes its types such as _Float64x and _Float128 
all distinct from each other and from the standard types such as long 
double.

I'd hope that if a type has the same representation as one of the standard 
types, it could be handled the same in libubsan without needing any 
special support there (so you'd need new support for __float128, but not 
for __float80 when that has the same representation as long double) - just 
as libgcc just needs one set of XFmode functions and one set of TFmode 
functions even if there are multiple types with those modes.

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


Re: emit __float128 typeinfo

2014-05-21 Thread Jason Merrill

On 04/25/2014 05:04 AM, Marc Glisse wrote:

Does this approach seem ok, or do we need to try harder to find a way to
get this typeinfo into libsupc++?


The latter, I think; these are base types, so they should go in the 
library.  Sorry for the slow response.


Jason



Re: [C++ patch] Fix c++/PR61133, implement the resolution of DR1760

2014-05-21 Thread Jason Merrill

Applied, thanks.

Jason


Re: Add flag to optionally ignore ELF interposition

2014-05-21 Thread Joseph S. Myers
On Wed, 21 May 2014, Jan Hubicka wrote:

> I tought glibc uses handcoded local aliases for all its exported symbols 
> except
> for those where interposition is allowed.

It does that for exported symbols.  But there are lots of non-exported __* 
functions used internally - and while some are declared hidden (or use the 
facility for hidden aliases), I suspect lots are not, so it's only the 
linker scripts that default-hide symbols that result in them not being 
interposable (and I'm guessing this effect of a linker script is too late 
for LTO to optimize based on that information).

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


Re: [PATCH] rs6000: Remove now unused predicate update_indexed_address_mem

2014-05-21 Thread David Edelsohn
On Wed, May 21, 2014 at 11:55 AM, Segher Boessenkool
 wrote:
> My previous patch left this hanging around.  Tested as usual; okay
> to apply?
>
>
> Segher
>
>
> 2014-05-21  Segher Boessenkool  
>
> gcc/
> * config/rs6000/predicates.md (update_indexed_address_mem): Delete.

Okay.

Thanks, David


Re: [RFC][AArch64] Define BASE_REG_CLASS to be GENERAL_REGS

2014-05-21 Thread Richard Earnshaw
On 21/05/14 16:21, Marcus Shawcroft wrote:
> On 15 May 2014 06:54, Kugan  wrote:
>> Hi All,
>>
>> In AArch64 back-end, BASE_REG_CLASS is defined to be POINTER_REGS.
>> Shouldn’t this be GENERAL_REGS?
> 
> Hi Kugan,
> 
> Are you aware of any problem caused by BASE_REG_CLASS being POINTER_REGS?
> 
> GENERAL_REGS and POINTER_REGS differ only in that the latter includes
> SP, the former does not.  It seems reasonable to me that
> BASE_REG_CLASS should be based on the set that includes SP..
> 
> Cheers
> /Marcus
> 

Indeed.  If you put SP into general regs then you'd need to use a
reg-class constraint other than "r" for most instructions (which would
break existing inline assembly).  If you make BASE_REG_CLASS ==
GENERAL_REGS you'll probably end up with accesses the stack becoming
very inefficient.

R.



[patch] c/61271 fix ICE for invalid cilkplus array notation

2014-05-21 Thread Jonathan Wakely

On 21/05/14 16:43 +0100, Jonathan Wakely wrote:

This is only one of several cases in the PR, but one that's simple
enough for me to write a test for and fix.

Tested x86_64-linux, OK for trunk?


There's a separate PR for this one now:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61276

So I'll update the ChangeLog entries to c++/61276 if it's approved.



commit 3ddcc29423746afb348c15160d33d3b1eec6fe12
Author: Jonathan Wakely 
Date:   Wed May 21 16:20:25 2014 +0100

   cp:
PR c/61271
* cp-array-notation.c (cilkplus_an_triplet_types_ok_p): Fix condition.
   
   testsuite:

PR c/61271
* g++.dg/cilk-plus/AN/array_function.cc: New.

diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c
index 0ff0967..ff82dee 100644
--- a/gcc/cp/cp-array-notation.c
+++ b/gcc/cp/cp-array-notation.c
@@ -26,7 +26,7 @@
   An array notation expression has 4 major components:
   1. The array name
   2. Start Index
-   3. Number of elements we need to acess (we call it length)
+   3. Number of elements we need to access (we call it length)
   4. Stride

   So, if we have something like A[0:5:2], we are accessing A[0], A[2], A[4],
@@ -1418,7 +1418,7 @@ cilkplus_an_triplet_types_ok_p (location_t loc, tree 
start_index, tree length,
  error_at (loc, "stride of array notation triplet is not an integer");
  return false;
}
-  if (!TREE_CODE (type) == FUNCTION_TYPE)
+  if (TREE_CODE (type) == FUNCTION_TYPE)
{
  error_at (loc, "array notation cannot be used with function type");
  return false;
diff --git a/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc 
b/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc
new file mode 100644
index 000..b111e21
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+void f() { }
+int main()
+{
+  f[0:1:1];  // { dg-error "function type" }
+}




Re: patch8.diff updated Was: Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-21 Thread Ian Lance Taylor
On Wed, May 21, 2014 at 12:47 AM, Svante Signell
 wrote:
> On Wed, 2014-05-21 at 01:27 +0200, Samuel Thibault wrote:
>> Svante Signell, le Fri 16 May 2014 10:03:05 +0200, a écrit :
>> > is used in gcc-4.9-4.9.0/src/libgo/go/net/fd_unix.go:
>> > func dupCloseOnExec(fd int) (newfd int, err error) {
>> > if atomic.LoadInt32(&tryDupCloexec) == 1 && syscall.F_DUPFD_CLOEXEC!=0 {
>> > r0, _, e1 := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd),
>> > syscall.F_DUPFD_CLOEXEC, 0)
>>
>> That code can not work as it is, fcntl is not a system call on
>> GNU/Hurd. Why isn't gccgo just using the C fcntl function?  That one
>> will just work and be portable.
>
> I don't know, I'm not a go developer. Ask Ian.

It's a bug.  That code, like most of libgo, is simply copied from the
master Go library, and I never noticed the direct use of
syscall.Syscall here.

Ian


Re: libsanitizer merge from upstream r208536

2014-05-21 Thread H.J. Lu
On Wed, May 21, 2014 at 5:09 AM, Konstantin Serebryany
 wrote:
> A new patch based on r209283.
> This one has the H.J.'s patches for x32.
>

This one is good on x32.

Thanks.

-- 
H.J.


[PATCH] rs6000: Remove now unused predicate update_indexed_address_mem

2014-05-21 Thread Segher Boessenkool
My previous patch left this hanging around.  Tested as usual; okay
to apply?


Segher


2014-05-21  Segher Boessenkool  

gcc/
* config/rs6000/predicates.md (update_indexed_address_mem): Delete.

---
 gcc/config/rs6000/predicates.md | 8 
 1 file changed, 8 deletions(-)

diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index 382fefa..f538b42 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -743,14 +743,6 @@ (define_special_predicate "update_address_mem"
|| GET_CODE (XEXP (op, 0)) == PRE_DEC
|| GET_CODE (XEXP (op, 0)) == PRE_MODIFY))"))
 
-;; Return 1 if the operand is a MEM with an update-indexed-form address. Note
-;; that PRE_INC/PRE_DEC will always be non-indexed (i.e. non X-form) since the
-;; increment is based on the mode size and will therefor always be a const.
-(define_special_predicate "update_indexed_address_mem"
-  (match_test "(MEM_P (op)
-   && GET_CODE (XEXP (op, 0)) == PRE_MODIFY
-   && indexed_address (XEXP (XEXP (op, 0), 1), mode))"))
-
 ;; Return 1 if the operand is a MEM with an indexed-form address.
 (define_special_predicate "indexed_address_mem"
   (match_test "(MEM_P (op)
-- 
1.8.1.4



Re: [PATCH 1/7] Add missing documentation of four IPA-CP params

2014-05-21 Thread Jeff Law

On 05/21/14 07:16, Martin Jambor wrote:

2014-05-16  Martin Jambor

* doc/invoke.texi (Optimize Options): Document parameters
ipa-cp-eval-threshold, ipa-max-agg-items, ipa-cp-loop-hint-bonus and
ipa-cp-array-index-hint-bonus.

OK.
jeff


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

2014-05-21 Thread Mark Wielaard
On Wed, 2014-05-21 at 10:33 -0400, Jason Merrill wrote:
> On 05/21/2014 09:27 AM, Mark Wielaard wrote:
> > +/* The C++ version of the enum_underlying_base_type langhook.
> > +   See also cp/semantics.c (finish_underlying_type).  */
> > +static tree cxx_enum_underlying_base_type (const_tree type)
> 
> We usually leave a blank line between the comment and the function. 
> Also, the function name should be at the beginning of the line for etags.

Fixed both issues.

> > +/* Default implementation of enum_underlying_base_type using 
> > type_for_size.  */
> > +tree
> > +lhd_enum_underlying_base_type (const_tree enum_type)
> 
> Blank line here, too.

Added.

> >tree (*reconstruct_complex_type) (tree, tree);
> > +
> > +  tree (*enum_underlying_base_type) (const_tree);
> 
> And please add a comment documenting the hook.

Documentation added.

> OK with those changes.

Pushed as attached.

Thanks,

Mark
>From 1b006e46754125c47544223aa6ee8a42d102fe4d Mon Sep 17 00:00:00 2001
From: mark 
Date: Wed, 21 May 2014 15:44:59 +
Subject: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. The default implementation will just use type_for_size.
The implementation for C++ will use the ENUM_UNDERLYING_TYPE if it exists.
Use this enum_underlying_base_type lang-hook in dwarf2out.c to add a
DW_AT_type base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF
	version >= 3 or not strict DWARF.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks.c (lhd_enum_underlying_base_type): New function.
	* gcc/langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (lhd_enum_underlying_base_type): New declaration.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@210717 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog   |   14 ++
 gcc/cp/ChangeLog|6 ++
 gcc/cp/cp-lang.c|   20 
 gcc/dwarf2out.c |5 +
 gcc/langhooks-def.h |5 -
 gcc/langhooks.c |9 +
 gcc/langhooks.h |6 ++
 7 files changed, 64 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d506727..452b4b0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2014-05-21  Mark Wielaard  
+
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF
+	version >= 3 or not strict DWARF.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks.c (lhd_enum_underlying_base_type): New function.
+	* gcc/langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (lhd_enum_underlying_base_type): New declaration.
+	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
 2014-05-21  Richard Biener  
 
 	* doc/invoke.texi (-flto-partition=): Document one and
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index adde47f..b0a06b1 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-05-21  Mark Wielaard  
+
+	PR debug/16063
+	* cp-lang.c (cxx_enum_underlying_base_type): New function.
+	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-05-21  Richard Sandiford  
 
 	* cvt.c (convert_to_void): Use void_node instead of void_zero_node.
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index c28c07a..014f393 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "stor-layout.h"
 #include "cp-tree.h"
 #include "c-family/c-common.h"
 #include "langhooks.h"
@@ -40,6 +41,7 @@ static enum classify_record cp_classify_record (tree type);
 static tree cp_eh_personality (void);
 static tree get_template_innermost_arguments_folded (const_tree);
 static tree get_template_argument_pack_elems_folded (const_tree);
+static tree cxx_enum_underlying_base_type (const_tree);
 
 /* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h;
consequently, there should be very few hooks below.  */
@@ -81,6 +83,8 @@ static tree get_template_argument_pack_elems_folded (const_tree);
 #define LANG_HOOKS_EH_PERSONALITY cp_eh_personality
 #undef LANG_HOOKS_EH_RUNTIME_TYPE
 #define LANG_HOOKS_EH_RUNTIME_TYPE build_eh_type_type
+#undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
+#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE cxx_enum_underlying_base_type
 
 /* Each front end provides its own lang hook initializer.  */
 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
@@ -219,5 +223,21 @@ get_template_argument_pack_el

[patch] c/61271 fix ICE for invalid cilkplus array notation

2014-05-21 Thread Jonathan Wakely

This is only one of several cases in the PR, but one that's simple
enough for me to write a test for and fix.

Tested x86_64-linux, OK for trunk?
commit 3ddcc29423746afb348c15160d33d3b1eec6fe12
Author: Jonathan Wakely 
Date:   Wed May 21 16:20:25 2014 +0100

cp:
	PR c/61271
	* cp-array-notation.c (cilkplus_an_triplet_types_ok_p): Fix condition.

testsuite:
	PR c/61271
	* g++.dg/cilk-plus/AN/array_function.cc: New.

diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c
index 0ff0967..ff82dee 100644
--- a/gcc/cp/cp-array-notation.c
+++ b/gcc/cp/cp-array-notation.c
@@ -26,7 +26,7 @@
An array notation expression has 4 major components:
1. The array name
2. Start Index
-   3. Number of elements we need to acess (we call it length)
+   3. Number of elements we need to access (we call it length)
4. Stride
 
So, if we have something like A[0:5:2], we are accessing A[0], A[2], A[4],
@@ -1418,7 +1418,7 @@ cilkplus_an_triplet_types_ok_p (location_t loc, tree start_index, tree length,
   error_at (loc, "stride of array notation triplet is not an integer");
   return false;
 }
-  if (!TREE_CODE (type) == FUNCTION_TYPE)
+  if (TREE_CODE (type) == FUNCTION_TYPE)
 {
   error_at (loc, "array notation cannot be used with function type");
   return false;
diff --git a/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc b/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc
new file mode 100644
index 000..b111e21
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cilk-plus/AN/array_function.cc
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+void f() { }
+int main()
+{
+  f[0:1:1];  // { dg-error "function type" }
+}


Re: [RFC][AArch64] Define BASE_REG_CLASS to be GENERAL_REGS

2014-05-21 Thread Marcus Shawcroft
On 15 May 2014 06:54, Kugan  wrote:
> Hi All,
>
> In AArch64 back-end, BASE_REG_CLASS is defined to be POINTER_REGS.
> Shouldn’t this be GENERAL_REGS?

Hi Kugan,

Are you aware of any problem caused by BASE_REG_CLASS being POINTER_REGS?

GENERAL_REGS and POINTER_REGS differ only in that the latter includes
SP, the former does not.  It seems reasonable to me that
BASE_REG_CLASS should be based on the set that includes SP..

Cheers
/Marcus


[patch] Fix warning in dragonflybsd locale

2014-05-21 Thread Jonathan Wakely

Fixes a warning noticed during bootstrap.

I haven't run the dragonfly tests yet, but will do soon.
Committed to trunk.
commit 23b042935b1e179415179a6298df72d638280a27
Author: Jonathan Wakely 
Date:   Wed May 21 16:08:28 2014 +0100

	* config/locale/dragonfly/c_locale.cc (facet::_S_create_c_locale):
	Fix warning.

diff --git a/libstdc++-v3/config/locale/dragonfly/c_locale.cc b/libstdc++-v3/config/locale/dragonfly/c_locale.cc
index 6c503db..b698f82 100644
--- a/libstdc++-v3/config/locale/dragonfly/c_locale.cc
+++ b/libstdc++-v3/config/locale/dragonfly/c_locale.cc
@@ -229,7 +229,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 char localspec[size__s + 6 + 1];
 
 if (__s == NULL) {
-   localspec[0] = NULL;
+   localspec[0] = '\0';
 } else {
strcpy (localspec, __s);
char * pch = strchr (localspec, '@');


[patch] libstdc++/61269 fix for clang

2014-05-21 Thread Jonathan Wakely

Fix a dumb thinko in my recent  changes.

Tested x86_64-linux, committed to trunk.

commit 2611cfac77420816ad312bcfd211f0899a697880
Author: Jonathan Wakely 
Date:   Wed May 21 14:40:55 2014 +0100

	PR libstdc++/61269
	* include/std/type_traits: Move include outside namespace std.
	* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
	Likewise.

diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 0eacd36..1ff2e62 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -37,19 +37,22 @@
 
 #include 
 
-namespace std _GLIBCXX_VISIBILITY(default)
-{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
-
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
 # if defined (__UINT_LEAST16_TYPE__) && defined(__UINT_LEAST32_TYPE__)
+namespace std
+{
   typedef __UINT_LEAST16_TYPE__ uint_least16_t;
   typedef __UINT_LEAST32_TYPE__ uint_least32_t;
+}
 # else
 #  include 
 # endif
 #endif
 
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
   /**
* @defgroup metaprogramming Metaprogramming
* @ingroup utilities
diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
index 6be3af0..04e6b71 100644
--- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc
@@ -19,7 +19,7 @@
 // with this library; see the file COPYING3.  If not see
 // .
 
-// { dg-error "static assertion failed" "" { target *-*-* } 2033 }
+// { dg-error "static assertion failed" "" { target *-*-* } 2036 }
 
 #include 
 
diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
index 77f8bb3..d711546 100644
--- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc
@@ -48,5 +48,5 @@ void test01()
 // { dg-error "required from here" "" { target *-*-* } 40 }
 // { dg-error "required from here" "" { target *-*-* } 42 }
 
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1744 }
-// { dg-error "declaration of" "" { target *-*-* } 1708 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1747 }
+// { dg-error "declaration of" "" { target *-*-* } 1711 }
diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
index 48ee225..c77205b 100644
--- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc
@@ -48,5 +48,5 @@ void test01()
 // { dg-error "required from here" "" { target *-*-* } 40 }
 // { dg-error "required from here" "" { target *-*-* } 42 }
 
-// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1647 }
-// { dg-error "declaration of" "" { target *-*-* } 1611 }
+// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1650 }
+// { dg-error "declaration of" "" { target *-*-* } 1614 }


Re: [RFC][AArch64] Remove CORE_REGS form reg_class

2014-05-21 Thread Marcus Shawcroft
On 15 May 2014 01:10, Kugan  wrote:
>
> Hi All,
>
> AAarch64 back-end defines GENERAL_REGS and CORE_REGS with the same set
> of register. Is there any reason why we need this?

Nope an artifact of the early evolution of AArch64. Long ago CORE_REGS
did not include SP.  Your patch is fine, commit it.

/Marcus


Re: [PATCH][AARCH64] Support tail indirect function call

2014-05-21 Thread Marcus Shawcroft
Hi,

On 18 March 2014 14:13, Jiong Wang  wrote:

> * config/aarch64/predicates.md (aarch64_call_insn_operand): New
> predicate.
> * config/aarch64/constraints.md ("Ucs", "Usf"):  New constraints.
> * config/aarch64/aarch64.md (*sibcall_insn, *sibcall_value_insn): Adjust
> for
> tailcalling through registers.
> * config/aarch64/aarch64.h (enum reg_class): New caller save register
> class.
> (REG_CLASS_NAMES): Likewise.
> (REG_CLASS_CONTENTS): Likewise.
> * config/aarch64/aarch64.c (aarch64_function_ok_for_sibcall): Allow
> tailcalling
> without decls.
>
> gcc/testsuite
>
> *gcc.target/aarch64/tail-indirect-call.c: New test.
>

Couple of comments:

+typedef void FP(int);

GNU style please, space before (.

+void f1(FP fp, int n) { (fp)(n); }

GNU style please, line breaks after void, '(' and ';'. Space between
')' an '('. Likewise in the following line.

We should really follow the test case name convention, see
https://gcc.gnu.org/wiki/TestCaseWriting, specifically paragraph 1.

+(define_register_constraint "Ucs" "CALLER_SAVE_REGS"
+ "@internal The caller save registers.  Useful for sibcalls.")

Please move this hunk up and place with the other
define_register_constraints.  Line break after @internal like the
other entries in this file  Drop the "Useful for ..." part of the
comment.

+   br\\t%0
+   b\\t%a0"
   [(set_attr "type" "branch")]

Don't forget to add another attribute value for the new alternative.
Likewise is the following pattern.

   CORE_REGS,
+  CALLER_SAVE_REGS,
   GENERAL_REGS,

Register classes should be ordered such that if class x is contained
in class y, class x has the lower number therefore CALLER_SAVE_REGS
should be above CORE_REG.

Cheers
/Marcus


Re: Eliminate write-only variables

2014-05-21 Thread Martin Jambor
Hi,

On Wed, May 21, 2014 at 05:10:55AM +0200, Jan Hubicka wrote:
> > 
> > Unfortunately, this commit has caused the following ICE for me when
> > LTO building 471.omnetpp from SPEC 2006 or Firefox (but not libxul,
> > something that gets built earlier):
> > 
> > lto1: internal compiler error: in gimple_get_virt_method_for_vtable,
> > at gimple-fold.c:3276
> > 0x7437a3 gimple_get_virt_method_for_vtable(long, tree_node*, unsigned
> > long, bool*)  
> > /home/mjambor/gcc/bisect/src/gcc/gimple-fold.c:3276  
> > 0x743993 gimple_get_virt_method_for_binfo(long, tree_node*, bool*)
> > /home/mjambor/gcc/bisect/src/gcc/gimple-fold.c:3377  
> > 0x7913f2 possible_polymorphic_call_targets(tree_node*, long,
> > ipa_polymorphic_call_context, bool*, void**, int*)  
> > /home/mjambor/gcc/bisect/src/gcc/ipa-devirt.c:1697  
> > 0x7b73a9 possible_polymorphic_call_targets  
> > /home/mjambor/gcc/bisect/src/gcc/ipa-utils.h:121  
> > 0x7b73a9 walk_polymorphic_call_targets  
> > /home/mjambor/gcc/bisect/src/gcc/ipa.c:177  
> > 0x7b73a9 symtab_remove_unreachable_nodes(bool, _IO_FILE*)  
> > /home/mjambor/gcc/bisect/src/gcc/ipa.c:407  
> > 0x86bf47 execute_todo  
> > /home/mjambor/gcc/bisect/src/gcc/passes.c:1843  
> > Please submit a full bug report...
> >  
> > I compile omnetpp with -Ofast -g -flto=8 -fwhole-program
> > -funroll-loops -fpeel-loops -march=native -mtune=native
> > 
> > I'm afraid I won't be able to prepare a more reduced testcase very
> > soon.
> 
> Actually I think where is a problem: when the variable is completely dead
> (that is no writes, reads and address taken), we still set the writeonly
> flag and clear DECL_INITIAL.  This may happen for vtables still in use
> by the type based devirt machinery. The following patch should fix it.
> 

I can confirm this patch fixes the omnetpp ICE.

> Bootstrapped/regtested and comitted to mainline. 
> It also fixes the debug output issue you pointed out.

:-)

Thanks,

Martin

> 
> Index: ipa.c
> ===
> --- ipa.c (revision 210653)
> +++ ipa.c (working copy)
> @@ -730,7 +730,7 @@ ipa_discover_readonly_nonaddressable_var
>   if (!address_taken)
> {
>   if (TREE_ADDRESSABLE (vnode->decl) && dump_file)
> -   fprintf (dump_file, " %s (addressable)", vnode->name ());
> +   fprintf (dump_file, " %s (non-addressable)", vnode->name ());
>   varpool_for_node_and_aliases (vnode, clear_addressable_bit, NULL, 
> true);
> }
>   if (!address_taken && !written
> @@ -743,7 +743,7 @@ ipa_discover_readonly_nonaddressable_var
> fprintf (dump_file, " %s (read-only)", vnode->name ());
>   varpool_for_node_and_aliases (vnode, set_readonly_bit, NULL, true);
> }
> - if (!vnode->writeonly && !read && !address_taken)
> + if (!vnode->writeonly && !read && !address_taken && written)
> {
>   if (dump_file)
> fprintf (dump_file, " %s (write-only)", vnode->name ());


Re: [PATCH] Implement -fsanitize=float-cast-overflow (take 2)

2014-05-21 Thread Jakub Jelinek
On Wed, May 21, 2014 at 02:51:00PM +0200, Marek Polacek wrote:
> On Tue, May 20, 2014 at 09:50:10PM +, Joseph S. Myers wrote:
> > On Tue, 20 May 2014, Marek Polacek wrote:
> > 
> > > * is missing tests for long doubles/-mlong-double-128,
> > 
> > Also missing tests for float - as far as I can see, only double is tested.  
> > Ideally all of float, double, long double, __float128 (where supported), 
> > __float80 (where supported) would be tested (the functionality supported 
> > for __fp16 (ARM) is a bit more restricted) - hopefully using some shared 
> > macros to avoid too much duplication between tests.
>  
> Ok, I've added some tests for float, long double, __float128 and
> __float80.  A snag was in __float128 type: libubsan supposedly can't
> handle __float128 values and prints "0".  libubsan also can't handle
> __float80 types with -m32 it seems.
> Common macros moved to float-cast.h.

Clearly libubsan doesn't support _Decimal* either, so I guess for now
we should just avoid emitting any __ubsan_* diagnostics for any of the
__float{80,128} or _Decimal{32,64,128} types for now, and work with upstream
to add support for that (given the problematic design where a type
is identified only by kind and bitsize, I guess for _Decimal* we need to use
a different (new) kind, not sure what can be done about __float{80,128},
as libubsan treats both bitsize 80 and 128 as long double.

Note that libstdc++ doesn't support conversion of _Decimal{32,64,128}
nor std::decimal::decimal{32,64,128} to strings, and not sure if libubsan
would like to be linked against something that rarely used as libdecnumber.
So, I guess at least for now, we should have a way to tell libubsan
about those types (both decimal and __float{80,128}, but if libubsan
can't easily print those values into strings, it should just print
 or something similar for now.

> Yes.  I suspect adding support for _Decimal* shouldn't be hard,
> what's needed is to find the place where the conversion from _Decimal
> to integer is taking place and add similar code as is in convert.c.
> Jakub says he's writing another testcase that tests various type
> combination conversions and max/min values - so we'll get even more
> coverage.

Here is a testcase that (IMHO, not tested with your patch) should
test various boundary cases that shouldn't result in undefined behavior.
I've tried to keep it portable across various architectures, assumes
primarily two's complement and (likely) only supports binary and decimal
floating point formats.
Seems _Decimal{32,64,128} is not convertible
to/from int128 right now, so that is disabled in the test for now.

Jakub
/* { dg-do run } */
/* { dg-options "-fsanitize=float-cast-overflow -fno-sanitize-recover" } */
/* FIXME: When _DecimalXX <-> {signed, unsigned} __int128 conversions are
   supported, -DBROKEN_DECIMAL_INT128 can be removed.  */
/* { dg-additional-options "-DUSE_DFP -DBROKEN_DECIMAL_INT128" { target dfp } } 
*/

#define CVTFN(type1, type2) \
__attribute__((noinline)) type1 \
cvt_##type1##_##type2 (type2 x) \
{   \
  return x; \
}

typedef signed char sc;
#define sc_MIN (-__SCHAR_MAX__ - 1)
#define sc_MAX __SCHAR_MAX__
typedef unsigned char uc;
#define uc_MIN 0
#define uc_MAX (2U * __SCHAR_MAX__ + 1U)
typedef char c;
#define c_MIN char) -1) > (char) 0) ? uc_MIN : sc_MIN)
#define c_MAX char) -1) > (char) 0) ? uc_MAX : sc_MAX)
typedef signed short ss;
#define ss_MIN (-__SHRT_MAX__ - 1)
#define ss_MAX __SHRT_MAX__
typedef unsigned short us;
#define us_MIN 0
#define us_MAX (2U * __SHRT_MAX__ + 1U)
typedef signed int si;
#define si_MIN (-__INT_MAX__ - 1)
#define si_MAX __INT_MAX__
typedef unsigned int ui;
#define ui_MIN 0
#define ui_MAX (2U * __INT_MAX__ + 1U)
typedef signed long sl;
#define sl_MIN (-__LONG_MAX__ - 1L)
#define sl_MAX __LONG_MAX__
typedef unsigned long ul;
#define ul_MIN 0L
#define ul_MAX (2UL * __LONG_MAX__ + 1UL)
typedef signed long long sll;
#define sll_MIN (-__LONG_LONG_MAX__ - 1LL)
#define sll_MAX __LONG_LONG_MAX__
typedef unsigned long long ull;
#define ull_MIN 0LL
#define ull_MAX (2ULL * __LONG_LONG_MAX__ + 1ULL)
#ifdef __SIZEOF_INT128__
typedef signed __int128 si128;
# define si128_MAX \
  ((signed __int128) unsigned __int128) 1) \
   << (__CHAR_BIT__ * __SIZEOF_INT128__ - 1)) - 1))
# define si128_MIN (-si128_MAX - 1)
typedef unsigned __int128 ui128;
#define ui128_MIN ((unsigned __int128) 0)
#define ui128_MAX (((unsigned __int128) 2) * si128_MAX + 1)
#endif

#ifdef __SIZEOF_INT128__
# define CVTS128(type2) CVTFN (si128, type2) CVTFN (ui128, type2)
#else
# define CVTS128(type2)
#endif

#define CVTS(type2) \
  CVTFN (sc, type2) CVTFN (c, type2) CVTFN (uc, type2)  \
  CVTFN (ss, type2) CVTFN (us, type2)   \
  CVTFN (si, type2) CVTFN (ui, type2)   \
  CVTFN (sl, type2) CVTFN (ul, type2)   \
  CVTFN (sll, type2) CVTFN (ull, type2) \
  CVTS128 (type2)

#if

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

2014-05-21 Thread Jason Merrill

On 05/21/2014 09:27 AM, Mark Wielaard wrote:

+/* The C++ version of the enum_underlying_base_type langhook.
+   See also cp/semantics.c (finish_underlying_type).  */
+static tree cxx_enum_underlying_base_type (const_tree type)


We usually leave a blank line between the comment and the function. 
Also, the function name should be at the beginning of the line for etags.



+/* Default implementation of enum_underlying_base_type using type_for_size.  */
+tree
+lhd_enum_underlying_base_type (const_tree enum_type)


Blank line here, too.


   tree (*reconstruct_complex_type) (tree, tree);
+
+  tree (*enum_underlying_base_type) (const_tree);


And please add a comment documenting the hook.

OK with those changes.

Jason



Re: [PATCH 7/7] Plug ipa-prop escape analysis into gimple_call_arg_flags

2014-05-21 Thread Richard Biener
On Wed, May 21, 2014 at 3:16 PM, Martin Jambor  wrote:
> Hi,
>
> this demonstrates how results of ipa-prop escape analysis from
> previous patches can be used at a later stage of compilation by
> directly returning them from gimple_call_arg_flags which currently
> relies on fnspec annotations.
>
> Bootstrapped and tested on x86_64-linux and also passes LTO bootstrap.
> I have only had a brief look at behavior of this in SPEC 2006 and for
> example in astar 1.19% of invocations of gimple_call_arg_flags return
> noescape where we previously never did and in calculix this increases
> from 15.62% (from annotations) to 18.14%.  Noclobber flag is reported
> far less often still but for example in gamess that number raises from
> 5.21% to 7.66%.
>
> Thanks,
>
> Martin
>
>
> 2014-04-30  Martin Jambor  
>
> * gimple.c: Include cgraph.h.
> (gimple_call_arg_flags): Also query bitmaps in cgraph_node.
>
> Index: src/gcc/gimple.c
> ===
> --- src.orig/gcc/gimple.c
> +++ src/gcc/gimple.c
> @@ -47,7 +47,7 @@ along with GCC; see the file COPYING3.
>  #include "demangle.h"
>  #include "langhooks.h"
>  #include "bitmap.h"
> -
> +#include "cgraph.h"
>
>  /* All the tuples have their operand vector (if present) at the very bottom
> of the structure.  Therefore, the offset required to find the
> @@ -1349,32 +1349,50 @@ int
>  gimple_call_arg_flags (const_gimple stmt, unsigned arg)
>  {
>tree attr = gimple_call_fnspec (stmt);
> +  int ret;
>
> -  if (!attr || 1 + arg >= (unsigned) TREE_STRING_LENGTH (attr))
> -return 0;
> -
> -  switch (TREE_STRING_POINTER (attr)[1 + arg])
> +  if (attr && 1 + arg < (unsigned) TREE_STRING_LENGTH (attr))
>  {
> -case 'x':
> -case 'X':
> -  return EAF_UNUSED;
> -
> -case 'R':
> -  return EAF_DIRECT | EAF_NOCLOBBER | EAF_NOESCAPE;
> -
> -case 'r':
> -  return EAF_NOCLOBBER | EAF_NOESCAPE;
> -
> -case 'W':
> -  return EAF_DIRECT | EAF_NOESCAPE;
> -
> -case 'w':
> -  return EAF_NOESCAPE;
> +  switch (TREE_STRING_POINTER (attr)[1 + arg])
> +   {
> +   case 'x':
> +   case 'X':
> + ret = EAF_UNUSED;
> + break;
> +   case 'R':
> + ret = EAF_DIRECT | EAF_NOCLOBBER | EAF_NOESCAPE;
> + break;
> +   case 'r':
> + ret = EAF_NOCLOBBER | EAF_NOESCAPE;
> + break;
> +   case 'W':
> + ret = EAF_DIRECT | EAF_NOESCAPE;
> + break;
> +   case 'w':
> + ret = EAF_NOESCAPE;
> + break;
> +   case '.':
> +   default:
> + ret = 0;
> +   }
> +}
> +  else
> +ret = 0;
>
> -case '.':
> -default:
> -  return 0;
> +  tree callee_decl = gimple_call_fndecl (stmt);
> +  if (callee_decl)
> +{
> +  cgraph_node *callee_node = cgraph_get_node (callee_decl);
> +  if (callee_node)
> +   {
> + if (cgraph_param_noescape_p (callee_node, arg))
> +   ret |= EAF_NOESCAPE;
> + if (cgraph_param_noclobber_p (callee_node, arg))
> +   ret |= EAF_NOCLOBBER;

That's quite expensive.  I guess we need a better way to store
those?

> +   }
>  }
> +
> +  return ret;
>  }
>
>  /* Detects return flags for the call STMT.  */
>


[PATCH] Fix build failure in libcpp (PR c/61212)

2014-05-21 Thread Marek Polacek
As described in the PR, the build fails when HAVE_DOS_BASED_FILE_SYSTEM
is in effect:

../../libcpp/files.c:393:56: error: suggest parentheses around ‘&&’
within ‘||’
[-Werror=parentheses]
   if (CPP_OPTION (pfile, canonical_system_headers) &&
   file->dir->sysp

This (untested, but trivial) patch fixes that.  Ok for trunk?

2014-05-21  Marek Polacek  

PR c/61212
* files.c (find_file_in_dir): Add parens around &&.

diff --git gcc/files.c gcc/files.c
index ad68682..91bc9dd 100644
--- gcc/files.c
+++ gcc/files.c
@@ -390,7 +390,7 @@ find_file_in_dir (cpp_reader *pfile, _cpp_file *file, bool 
*invalid_pch)
   /* We try to canonicalize system headers.  For DOS based file
* system, we always try to shorten non-system headers, as DOS
* has a tighter constraint on max path length.  */
-  if (CPP_OPTION (pfile, canonical_system_headers) && file->dir->sysp
+  if ((CPP_OPTION (pfile, canonical_system_headers) && file->dir->sysp)
 #ifdef HAVE_DOS_BASED_FILE_SYSTEM
  || !file->dir->sysp
 #endif

Marek


[PATCH] document -flto-partition=[n]one

2014-05-21 Thread Richard Biener

Committed.

Richard.

2014-05-21  Richard Biener  

* doc/invoke.texi (-flto-partition=): Document one and
none algorithms.

Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi (revision 210694)
+++ gcc/doc/invoke.texi (working copy)
@@ -8780,6 +8780,9 @@ as an algorithm disables partitioning an
 The default value is @code{balanced}. While @code{1to1} can be used
 as an workaround for various code ordering issues, the @code{max}
 partitioning is intended for internal testing only.
+The value @code{one} specifies that exactly one partition should be
+used while the value @code{none} bypasses partitioning and executes
+the link-time optimization step directly from the WPA phase.
 
 @item -flto-compression-level=@var{n}
 This option specifies the level of compression used for intermediate


[PATCH][match-and-simplify] Fix missed constant folding / operand canonicalization

2014-05-21 Thread Richard Biener

I noticed we fail to do $subject for the outermost stmt.  I did
so when trying to implement the basic constant folding patterns
required to make gimple_fold_stmt_to_constant replaceable by
gimple_match_and_simplify, thus patterns like

(match_and_simplify
  (plus @0 integer_zerop)
  @0)

Built on x86_64-unknown-linux-gnu, applied to branch.

Note this makes a few cases of the match-1.c and match-2.c
testcases fail because operands are swapped and we only have
one variant of commutative patterns (yeah, points to we need
a solution for that).

Richard.

2014-05-21  Richard Biener  

* gimple-match-head.c (constant_for_folding): New function.
(gimple_resimplify1, gimple_resimplify2, gimple_resimplify3):
Use it.  Strip NOPs from call stmt constant folding results
and return whether we re-simplified anything.
(maybe_push_res_to_seq): Allow is_gimple_val ADDR_EXPRs
as simple.
(gimple_match_and_simplify): Use constant_for_folding,
Strip NOPs from call stmt constant folding results.
(gimple_match_and_simplify): Use gimple_resimplify1 for the
stmt overload to get constant folding and argument
canonicalization.  Simplify SSA name copies.
(gimple_match_and_simplify): Valueize from a copy or
constant assignment for the SSA name overload.

Index: gcc/gimple-match-head.c
===
--- gcc/gimple-match-head.c (revision 210637)
+++ gcc/gimple-match-head.c (working copy)
@@ -35,6 +35,8 @@ along with GCC; see the file COPYING3.
 #include "tree-ssanames.h"
 #include "gimple-fold.h"
 #include "gimple-iterator.h"
+#include "expr.h"
+#include "tree-dfa.h"
 
 #define INTEGER_CST_P(node) (TREE_CODE(node) == INTEGER_CST)
 #define integral_op_p(node) INTEGRAL_TYPE_P(TREE_TYPE(node))
@@ -57,7 +59,9 @@ private:
   int rep;
 };
 
-/* Forward declarations of the private auto-generated matchers.  */
+/* Forward declarations of the private auto-generated matchers.  They
+   expect valueized operands in canonical order and they do not
+   perform simplification of all-constant operands.  */
 static bool gimple_match_and_simplify (code_helper, tree, tree,
   code_helper *, tree *,
   gimple_seq *, tree (*)(tree));
@@ -69,18 +73,31 @@ static bool gimple_match_and_simplify (c
   gimple_seq *, tree (*)(tree));
 
 
+/* Return whether T is a constant that we'll dispatch to fold to
+   evaluate fully constant expressions.  */
+
+static inline bool
+constant_for_folding (tree t)
+{
+  return (CONSTANT_CLASS_P (t)
+ /* The following is only interesting to string builtins.  */
+ || (TREE_CODE (t) == ADDR_EXPR
+ && TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST));
+}
+
+
 /* Helper that matches and simplifies the toplevel result from
a gimple_match_and_simplify run (where we don't want to build
a stmt in case it's used in in-place folding).  Replaces
*RES_CODE and *RES_OPS with a simplified and/or canonicalized
-   result.  */
+   result and returns whether any change was made.  */
 
-static void
+static bool
 gimple_resimplify1 (gimple_seq *seq,
code_helper *res_code, tree type, tree *res_ops,
tree (*valueize)(tree))
 {
-  if (CONSTANT_CLASS_P (res_ops[0]))
+  if (constant_for_folding (res_ops[0]))
 {
   tree tem;
   if (res_code->is_tree_code ())
@@ -89,13 +106,19 @@ gimple_resimplify1 (gimple_seq *seq,
{
  tree decl = builtin_decl_implicit (*res_code);
  tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 1, false);
+ if (tem)
+   {
+ /* fold_builtin_n wraps the result inside a NOP_EXPR.  */
+ STRIP_NOPS (tem);
+ tem = fold_convert (type, tem);
+   }
}
   if (tem != NULL_TREE
  && CONSTANT_CLASS_P (tem))
{
  res_ops[0] = tem;
  *res_code = TREE_CODE (res_ops[0]);
- return;
+ return true;
}
 }
 
@@ -108,21 +131,24 @@ gimple_resimplify1 (gimple_seq *seq,
   res_ops[0] = res_ops2[0];
   res_ops[1] = res_ops2[1];
   res_ops[2] = res_ops2[2];
+  return true;
 }
+
+  return false;
 }
 
 /* Helper that matches and simplifies the toplevel result from
a gimple_match_and_simplify run (where we don't want to build
a stmt in case it's used in in-place folding).  Replaces
*RES_CODE and *RES_OPS with a simplified and/or canonicalized
-   result.  */
+   result and returns whether any change was made.  */
 
-static void
+static bool
 gimple_resimplify2 (gimple_seq *seq,
code_helper *res_code, tree type, tree *res_ops,
tree (*valueize)(tree))
 {
-  if (CONSTANT_CLASS_P (res_ops[0]) && CONSTANT_CLASS_P (res_ops[1]))
+  if (constant_for_folding (res_ops[0]) && constant_for_f

Re: [patch, lto] add testcase for PR60179

2014-05-21 Thread Sandra Loosemore

On 05/21/2014 03:12 AM, Richard Biener wrote:

On Wed, May 21, 2014 at 3:51 AM, Sandra Loosemore
 wrote:

One of the consequences of the (now-fixed) bug in PR60179 is that Nios II
code using target pragmas to specify custom instructions failed to generate
those instructions with -flto.  We came up with this test case for it, but
there didn't seem to be an existing hook to scan LTO output.  Is this OK, or
is there a better way to do it?


Not really - though you should force LTO to generate a single
assembler file by using -flto-partition=one.


H, I notice there is no documentation for that option in the manual. 
 Looks like you just added it last month; maybe you should fix that?


-Sandra


Re: [PATCH][RFC] Handle realloc in PTA and alias analysis

2014-05-21 Thread Richard Biener
On Wed, 21 May 2014, Richard Biener wrote:

> 
> PR56955 prompted me to handle BUILT_IN_REALLOC just the same
> way we already handle BUILT_IN_STR[N]DUP.
> 
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
> 
> Now this will disambiguate *p and *q for p = realloc (q, n)
> for any value of n (including those that don't actually
> trigger re-allocation and thus where p == q after the call).
> I don't think that any such use would be valid - but I can
> certainly play safer here and implement the points-to part
> as a pass-through (that is, make p point to what q points).
> That's of course less optimization.

Like with incremental

Index: gcc/tree-ssa-structalias.c
===
--- gcc/tree-ssa-structalias.c.orig 2014-05-21 15:37:58.762890034 
+0200
+++ gcc/tree-ssa-structalias.c  2014-05-21 15:35:52.044898758 +0200
@@ -4313,6 +4313,17 @@ find_func_aliases_for_builtin_call (stru
process_all_all_constraints (lhsc, rhsc);
lhsc.release ();
rhsc.release ();
+   /* For realloc the resulting pointer can be equal to the
+  argument as well.  But only doing this wouldn't be
+  correct because with ptr == 0 realloc behaves like malloc.  
*/
+   if (DECL_FUNCTION_CODE (fndecl) == BUILT_IN_REALLOC)
+ {
+   get_constraint_for (gimple_call_lhs (t), &lhsc);
+   get_constraint_for (gimple_call_arg (t, 0), &rhsc);
+   process_all_all_constraints (lhsc, rhsc);
+   lhsc.release ();
+   rhsc.release ();
+ }
return true;
  }
break;

that of course makes it a somewhat pointless excercise if
points-to doesn't figure out sth fancy for the argument to
realloc (like its NULL or the result of an earlier malloc call,
still optimizes the testcase as expected).
 
> I can't quite find language that specifies that the
> object can no longer accessed via the pointer argument q
> (at least if p didn't return NULL and size was not NULL).
> The C99 standard explicitely mentions that p may have
> the same pointer value as q though.
>
> Thoughts?
> 
> Thanks,
> Richard.
> 
> 2014-05-21  Richard Biener  
> 
>   * tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Handle
>   BUILT_IN_REALLOC like BUILT_IN_STRDUP.
>   (call_may_clobber_ref_p_1): Likewise.
>   * tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
>   Likewise.
>   (handle_lhs_call): Use flags argument instead of recomputing it.
>   (find_func_aliases_for_call): Call handle_lhs_call with proper
>   call return flags.
> 
>   * gcc.dg/tree-ssa/alias-33.c: New testcase.
> 
> Index: gcc/tree-ssa-alias.c
> ===
> *** gcc/tree-ssa-alias.c.orig 2014-05-21 14:38:57.841133822 +0200
> --- gcc/tree-ssa-alias.c  2014-05-21 14:39:05.954133263 +0200
> *** ref_maybe_used_by_call_p_1 (gimple call,
> *** 1594,1599 
> --- 1594,1600 
>   /* These read memory pointed to by the first argument.  */
>   case BUILT_IN_STRDUP:
>   case BUILT_IN_STRNDUP:
> + case BUILT_IN_REALLOC:
> {
>   ao_ref dref;
>   tree size = NULL_TREE;
> *** call_may_clobber_ref_p_1 (gimple call, a
> *** 1958,1963 
> --- 1959,1965 
>   case BUILT_IN_MALLOC:
>   case BUILT_IN_ALIGNED_ALLOC:
>   case BUILT_IN_CALLOC:
> + case BUILT_IN_REALLOC:
>   case BUILT_IN_STRDUP:
>   case BUILT_IN_STRNDUP:
> /* Unix98 specifies that errno is set on allocation failure.  */
> Index: gcc/tree-ssa-structalias.c
> ===
> *** gcc/tree-ssa-structalias.c.orig   2014-05-21 14:38:57.844133822 +0200
> --- gcc/tree-ssa-structalias.c2014-05-21 14:45:50.896105384 +0200
> *** handle_lhs_call (gimple stmt, tree lhs,
> *** 3974,3980 
>   
> /* If the call returns an argument unmodified override the rhs
>constraints.  */
> -   flags = gimple_call_return_flags (stmt);
> if (flags & ERF_RETURNS_ARG
> && (flags & ERF_RETURN_ARG_MASK) < gimple_call_num_args (stmt))
>   {
> --- 3974,3979 
> *** find_func_aliases_for_builtin_call (stru
> *** 4299,4307 
>   return true;
> case BUILT_IN_STRDUP:
> case BUILT_IN_STRNDUP:
>   if (gimple_call_lhs (t))
> {
> ! handle_lhs_call (t, gimple_call_lhs (t), gimple_call_flags (t),
>vNULL, fndecl);
>   get_constraint_for_ptr_offset (gimple_call_lhs (t),
>  NULL_TREE, &lhsc);
> --- 4298,4308 
>   return true;
> case BUILT_IN_STRDUP:
> case BUILT_IN_STRNDUP:
> +   case BUILT_IN_REALLOC:
>   if (gimple_call_lhs (t))
> {
> ! handle_lhs_call (t, gimple_call_lhs (t),
> !   

[PATCH 2/7] Analyze BBs in DOM order in ipa-prop.c

2014-05-21 Thread Martin Jambor
Hi,

this patch has already been reviewed and pre-approved by Honza, so I'm
including this mainly for reference and I will commit it once the
previous (documentation) patch is approved.  The original submission
can be found at http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01681.html.

This patch introduce a better structure for holding intermediate
information about the current function during analysis called
function_body_info and above all analyzes BBs in DOM order which alone
improves results as seen in PR 53787.

Bootstrapped and tested on x86_64-linux.  I have also LTO-bootstrapped
it and LTO built Firefox with it. 

Thanks,

Martin



2014-05-15  Martin Jambor  

PR tree-optimization/53787
* params.def (PARAM_IPA_CP_LOOP_HINT_BONUS): New param.
* ipa-prop.h (ipa_node_params): Rename uses_analysis_done to
analysis_done, update all uses.
* ipa-prop.c: Include domwalk.h
(param_analysis_info): Removed.
(param_aa_status): New type.
(ipa_bb_info): Likewise.
(func_body_info): Likewise.
(ipa_get_bb_info): New function.
(aa_overwalked): Likewise.
(find_dominating_aa_status): Likewise.
(parm_bb_aa_status_for_bb): Likewise.
(parm_preserved_before_stmt_p): Changed to use new param AA info.
(load_from_unmodified_param): Accept func_body_info as a parameter
instead of parms_ainfo.
(parm_ref_data_preserved_p): Changed to use new param AA info.
(parm_ref_data_pass_through_p): Likewise.
(ipa_load_from_parm_agg_1): Likewise.  Update callers.
(compute_complex_assign_jump_func): Changed to use new param AA info.
(compute_complex_ancestor_jump_func): Likewise.
(ipa_compute_jump_functions_for_edge): Likewise.
(ipa_compute_jump_functions): Removed.
(ipa_compute_jump_functions_for_bb): New function.
(ipa_analyze_indirect_call_uses): Likewise, moved variable
declarations down.
(ipa_analyze_virtual_call_uses): Accept func_body_info instead of node
and info, moved variable declarations down.
(ipa_analyze_call_uses): Accept and pass on func_body_info instead of
node and info.
(ipa_analyze_stmt_uses): Likewise.
(ipa_analyze_params_uses): Removed.
(ipa_analyze_params_uses_in_bb): New function.
(ipa_analyze_controlled_uses): Likewise.
(free_ipa_bb_info): Likewise.
(analysis_dom_walker): New class.
(ipa_analyze_node): Handle node-specific forbidden analysis,
initialize and free func_body_info, use dominator walker.
(ipcp_modif_dom_walker): New class.
(ipcp_transform_function): Create and free func_body_info, use
ipcp_modif_dom_walker, moved a lot of functionality there.

Index: src/gcc/ipa-prop.c
===
--- src.orig/gcc/ipa-prop.c
+++ src/gcc/ipa-prop.c
@@ -59,14 +59,57 @@ along with GCC; see the file COPYING3.
 #include "ipa-utils.h"
 #include "stringpool.h"
 #include "tree-ssanames.h"
+#include "domwalk.h"
 
-/* Intermediate information about a parameter that is only useful during the
-   run of ipa_analyze_node and is not kept afterwards.  */
+/* Intermediate information that we get from alias analysis about a particular
+   parameter in a particular basic_block.  When a parameter or the memory it
+   references is marked modified, we use that information in all dominatd
+   blocks without cosulting alias analysis oracle.  */
+
+struct param_aa_status
+{
+  /* Set when this structure contains meaningful information.  If not, the
+ structure describing a dominating BB should be used instead.  */
+  bool valid;
+
+  /* Whether we have seen something which might have modified the data in
+ question.  PARM is for the parameter itself, REF is for data it points to
+ but using the alias type of individual accesses and PT is the same thing
+ but for computing aggregate pass-through functions using a very inclusive
+ ao_ref.  */
+  bool parm_modified, ref_modified, pt_modified;
+};
 
-struct param_analysis_info
+/* Information related to a given BB that used only when looking at function
+   body.  */
+
+struct ipa_bb_info
 {
-  bool parm_modified, ref_modified, pt_modified;
-  bitmap parm_visited_statements, pt_visited_statements;
+  /* Call graph edges going out of this BB.  */
+  vec cg_edges;
+  /* Alias analysis statuses of each formal parameter at this bb.  */
+  vec param_aa_statuses;
+};
+
+/* Structure with global information that is only used when looking at function
+   body. */
+
+struct func_body_info
+{
+  /* The node that is being analyzed.  */
+  cgraph_node *node;
+
+  /* Its info.  */
+  struct ipa_node_params *info;
+
+  /* Information about individual BBs. */
+  vec bb_infos;
+
+  /* Number of parameters.  */
+  int param_count;
+
+  /* Number of statements already walked by when analyzing this function.  */
+  unsig

[PATCH 4/7] Break up determine_known_aggregate_parts

2014-05-21 Thread Martin Jambor
Hi,

the main purpose of this patch is to break up function
determine_known_aggregate_parts so that the next patch can use the
standalone bits and to make the changes slightly easier for review.

However, this patch also removes some of the offset checks which Honza
correctly thought superfluous and even possibly filtering out useful
information.
 
Bootstrapped and tested and LTO-bootstrapped on x86_64-linux.
OK for trunk after the preceeding patches get in?

Thanks,

Martin


2014-02-19  Martin Jambor  

* ipa-prop.c (get_place_in_agg_contents_list): New function.
(build_agg_jump_func_from_list): Likewise.
(determine_known_aggregate_parts): Renamed to
determine_locally_known_aggregate_parts.  Moved some functionality
to the two functions above, removed bound checks.

Index: src/gcc/ipa-prop.c
===
--- src.orig/gcc/ipa-prop.c
+++ src/gcc/ipa-prop.c
@@ -1679,14 +1679,72 @@ struct ipa_known_agg_contents_list
   struct ipa_known_agg_contents_list *next;
 };
 
+/* Find the proper place in linked list of ipa_known_agg_contents_list
+   structures where to put a new one with the given LHS_OFFSET and LHS_SIZE,
+   unless there is a partial overlap, in which case return NULL, or such
+   element is already there, in which case set *ALREADY_THERE to true.  */
+
+static struct ipa_known_agg_contents_list **
+get_place_in_agg_contents_list (struct ipa_known_agg_contents_list **list,
+   HOST_WIDE_INT lhs_offset,
+   HOST_WIDE_INT lhs_size,
+   bool *already_there)
+{
+  struct ipa_known_agg_contents_list **p = list;
+  while (*p && (*p)->offset < lhs_offset)
+{
+  if ((*p)->offset + (*p)->size > lhs_offset)
+   return NULL;
+  p = &(*p)->next;
+}
+
+  if (*p && (*p)->offset < lhs_offset + lhs_size)
+{
+  if ((*p)->offset == lhs_offset && (*p)->size == lhs_size)
+   /* We already know this value is subsequently overwritten with
+  something else.  */
+   *already_there = true;
+  else
+   /* Otherwise this is a partial overlap which we cannot
+  represent.  */
+   return NULL;
+}
+  return p;
+}
+
+/* Build aggregate jump function from LIST, assuming there are exactly
+   CONST_COUNT constant entries there and that th offset of the passed argument
+   is ARG_OFFSET and store it into JFUNC.  */
+
+static void
+build_agg_jump_func_from_list (struct ipa_known_agg_contents_list *list,
+  int const_count, HOST_WIDE_INT arg_offset,
+  struct ipa_jump_func *jfunc)
+{
+  vec_alloc (jfunc->agg.items, const_count);
+  while (list)
+{
+  if (list->constant)
+   {
+ struct ipa_agg_jf_item item;
+ item.offset = list->offset - arg_offset;
+ gcc_assert ((item.offset % BITS_PER_UNIT) == 0);
+ item.value = unshare_expr_without_location (list->constant);
+ jfunc->agg.items->quick_push (item);
+   }
+  list = list->next;
+}
+}
+
 /* Traverse statements from CALL backwards, scanning whether an aggregate given
in ARG is filled in with constant values.  ARG can either be an aggregate
-   expression or a pointer to an aggregate.  ARG_TYPE is the type of the 
aggregate.
-   JFUNC is the jump function into which the constants are subsequently 
stored.  */
+   expression or a pointer to an aggregate.  ARG_TYPE is the type of the
+   aggregate.  JFUNC is the jump function into which the constants are
+   subsequently stored.  */
 
 static void
-determine_known_aggregate_parts (gimple call, tree arg, tree arg_type,
-struct ipa_jump_func *jfunc)
+determine_locally_known_aggregate_parts (gimple call, tree arg, tree arg_type,
+struct ipa_jump_func *jfunc)
 {
   struct ipa_known_agg_contents_list *list = NULL;
   int item_count = 0, const_count = 0;
@@ -1728,10 +1786,8 @@ determine_known_aggregate_parts (gimple
return;
  if (DECL_P (arg_base))
{
- tree size;
  check_ref = false;
- size = build_int_cst (integer_type_node, arg_size);
- ao_ref_init_from_ptr_and_size (&r, arg_base, size);
+ ao_ref_init (&r, arg_base);
}
  else
return;
@@ -1769,7 +1825,6 @@ determine_known_aggregate_parts (gimple
   gimple stmt = gsi_stmt (gsi);
   HOST_WIDE_INT lhs_offset, lhs_size, lhs_max_size;
   tree lhs, rhs, lhs_base;
-  bool partial_overlap;
 
   if (!stmt_may_clobber_ref_p_1 (stmt, &r))
continue;
@@ -1786,11 +1841,7 @@ determine_known_aggregate_parts (gimple
   lhs_base = get_ref_base_and_extent (lhs, &lhs_offset, &lhs_size,
  &lhs_max_size);
   if (lhs_max_size == -1
- || lhs_max_size != lhs_size
- || (lhs_

Re: [PATCH, libgfortran] PR60324 Handle arbitrarily long path names

2014-05-21 Thread Steve Kargl
On Mon, May 19, 2014 at 11:40:06PM +0300, Janne Blomqvist wrote:
> Hello,
> 
> some systems such as GNU Hurd, don't define PATH_MAX at all, and on
> some other systems many syscalls apparently work for paths longer than
> PATH_MAX. Thus GFortran shouldn't truncate paths to PATH_MAX
> characters, but rather use heap allocated buffers limited only by the
> available memory. The attached patch implements this, with the
> exception of the backtrace functionality where we cannot use malloc
> since backtrace might be called from a signal handler.
> 
> Regtested on x86_64-unknown-linux-gnu, Ok for trunk?
> 
> 2014-05-19  Janne Blomqvist  
> 
> PR libfortran/60324
> * config.h.in: Regenerated.
> * configure: Regenerated.
> * configure.ac (AC_CHECK_FUNCS_ONCE): Check for strnlen and
> strndup.
> * libgfortran.h (fc_strdup): New prototype.

Janne, 

I read through the diff, and did not see anything that threw up
a caution sign.  I only have a cosmetic question.  Why a fc_
prefix instead of the usual gfc_ prefix?  Otherwise, I think
this is OK for trunk.

-- 
Steve


[PATCH 5/7] Advanced aggregate jump function construction

2014-05-21 Thread Martin Jambor
Hi,

this patch bring about more sophisticated building of aggregate jump
functions under the optimistic assumption the aggregate will not
escape.  If it is then discovered to escape, the appropriate jump
functions are invalidated at IPA time before anything else can see
them.  Invalidating is done by storing NULL_TREE value, some other
functions had to be made aware of the possibility.

The implementation is not surprising, the patch keeps information
about aggregate contents at the beginning of each BB and deltas from
there to each call and BB end.  Merging information from different BB
predecessors and applying deltas is very simplistic and replaced in
the subsequent patch.

The only thing which could be perhaps unexpected is that whether an
aggregate jump function requires non-escaped-ness is stored on item by
item bases in order not to regress.  This way, all stores to one
particular aggregate performed immediately before the call will result
in a valid jump function regardless of whether the aggregate somehow
escapes - exactly the previous behavior.

Bootstrapped and tested on x86_64-linux, also passes LTO-bootstrap and
I have successfully built Firefox with LTO with it.  I'm sure there
will be comments but eventually I'd like to commit this to trunk.

Thanks,

Martin


2014-02-18  Martin Jambor  

* ipa-prop.h (ipa_agg_jf_item): New fields size and only_unescaped.
* ipa-prop.c (ipa_known_agg_contents_list): Moved up, new fields
counter and only_unescaped.
(AGG_CONTENTS_TOP): New macro.
(dump_agg_contents_list): New function.
(debug_agg_contents_list): Likewise.
(ipa_bb_info): New fields begin_agg_cnt, agg_deltas and queued.
(ipa_escape): New field decl_p.
(func_body_info): New fields call_agg_deltas_map agg_contents_pool and
worklist.
(ipa_print_node_jump_functions_for_edge): Expect NULL aggregate
values, also dump only_unescaped flag.
(build_agg_jump_func_from_list): New parameter honor_unescaped_flag,
also fill in new fields only_unescaped and size.  Assert that the
actual size does not exceed precision of size field.
(determine_locally_known_aggregate_parts): Fill in new field
only_unescaped, pass true honor_unescaped_flag.
(apply_agg_contents_deltas): New function.
(ipa_compute_jump_functions_for_edge): Build aggregate jump functions
from global information.
(ipa_analyze_stmt_uses): Removed, functionality integrated to
ipa_analyze_bb_statements.
(present_tracked_refs_p): New function.
(escape_all_tracked_references): Likewise.
(copy_aggg_deltas_to_cg_edge): Likewise.
(update_agg_deltas_for_stmt): Likewise.
(ipa_analyze_bb_statements): Create BB and call statement aggregate
deltas.
(free_ipa_bb_info): Also free aggregate contents vectors.
(analysis_dom_walker): Put into anonymous namespace.  Do not compute
jump functions.
(jfunc_builder_dom_walker): New class.
(create_escape_structures): Initialize call_agg_deltas_map,
agg_contents_pool and worklist fields.
(free_escape_structures): Deallocate the same three data structures.
(merge_agg_contents): New function.
(propagate_agg_cnts_through_bb): Likewise.
(propagate_agg_contents_accross_bbs): Likewise.
(ipa_verify_escaped_flags_match): Likewise.
(ipa_analyze_node): Propagate aggregate contents accross the function
and only then build jump functions.
(kill_invalid_escaped_agg_jfs): New function.
(ipa_spread_escapes): Call kill_invalid_escaped_agg_jfs on all call
graph edges.
(ipa_find_agg_cst_for_param): Ignore NULL values.
(ipa_write_jump_function): Stream new fields size and only_unescaped.
(ipa_read_jump_function): Likewise.
(ipcp_transform_function): Initialize new func_body_info fields.
* ipa-cp.c (propagate_aggs_accross_jump_function): Use size directly
from the aggregate jump function, check it fits the constant.  Ignore
NULL values.

testsuite/
* gcc.dg/ipa/ipcp-agg-11.c: New test.
* gcc.dg/ipa/ipcp-agg-12.c: Likewise.
* gcc.dg/ipa/ipcp-agg-13.c: Likewise.
* gcc.dg/ipa/ipcp-agg-14.c: Likewise.
* g++.dg/ipa/devirt-24.C: Bump scan-times to two times.


Index: src/gcc/ipa-prop.c
===
--- src.orig/gcc/ipa-prop.c
+++ src/gcc/ipa-prop.c
@@ -83,6 +83,82 @@ struct param_aa_status
   bool parm_modified, ref_modified, pt_modified;
 };
 
+/* Simple linked list describing known contents of an aggregate.  */
+
+struct ipa_known_agg_contents_list
+{
+  /* Offset and size of the described part of the aggregate.  */
+  HOST_WIDE_INT offset, size;
+  /* Known constant value or NULL if the contents is known to be unknown.  */
+  tree constant;
+  /* Pointer t

[PATCH 6/7] Real aggregate contents merge and application of deltas

2014-05-21 Thread Martin Jambor
Hi,

the previous patch used a very simplistic merging and delta
application of aggregate contents.  This patch replaces it with a real
one.

Because there are potentially many basic blocks and the contents of a
particular aggregate are very likely to be the same for many of them,
the description of the contents are shared among BBs.  In order to
facilitate this, each block knows whether it owns a particular
description and thus whether it can change it in place or has to copy
the list (list lengths are capped at PARAM_IPA_MAX_AGG_ITEMS).

I have gathered some information on the count of aggregate jump
functions (again I should have counted only pointer and aggregate
parameters but I realized it too late, other scalars arguments cannot
have jump function aggregate items so it needlessly makes the
per-jump-function columns even more puny).  Everything is with -Ofast
-flto:

 ||   | Unpatched |  |   |  |   
   |
 | Testcase   |  Jump | Aggregate |  per |   Patched |  per | 
increase |
 || functions | items |   jf | agg items |   jf |   
 % |
 
|+---+---+--+---+--+--+
 | FF libxul.so   |   1756545 | 82066 | 0.05 |102779 | 0.06 |
25.24 |
 | Tramp 3D   | 19421 |   330 | 0.02 |   577 | 0.03 |
74.85 |
 
|+---+---+--+---+--+--+
 | perlbench  | 28169 |76 | 0.00 |85 | 0.00 |
11.84 |
 | bzip2  |   858 | 0 | 0.00 | 0 | 0.00 | 
0.00 |
 | gcc|105977 |   156 | 0.00 |   166 | 0.00 | 
6.41 |
 | mcf|   161 | 1 | 0.01 | 2 | 0.01 |   
100.00 |
 | gobmk  | 28843 |41 | 0.00 |42 | 0.00 | 
2.44 |
 | hmmer  |  5122 |11 | 0.00 |14 | 0.00 |
27.27 |
 | sjeng  |  2089 | 6 | 0.00 | 6 | 0.00 | 
0.00 |
 | libquantum |   820 | 0 | 0.00 | 0 | 0.00 | 
0.00 |
 | h264ref|  8316 |30 | 0.00 |31 | 0.00 | 
3.33 |
 | omnetpp|   738 |19 | 0.03 |20 | 0.03 | 
5.26 |
 | xalancbmk  |121014 |  1220 | 0.01 |  1535 | 0.01 |
25.82 |
 
|+---+---+--+---+--+--+
 | bwaves |   384 |92 | 0.24 |97 | 0.25 | 
5.43 |
 | gamess |194795 | 44085 | 0.23 | 45319 | 0.23 | 
2.80 |
 | milc   |  3027 | 0 | 0.00 | 1 | 0.00 |   
100.00 |
 | zeusmp |  4849 |  1011 | 0.21 |  1063 | 0.22 | 
5.14 |
 | gromacs| 27421 |57 | 0.00 |79 | 0.00 |
38.60 |
 | cactusADM  | 15693 |   230 | 0.01 |   237 | 0.02 | 
3.04 |
 | leslie3d   |  1694 |   466 | 0.28 |   466 | 0.28 | 
0.00 |
 | namd   |  3050 |12 | 0.00 |   102 | 0.03 |   
750.00 |
 | soplex |  7904 |59 | 0.01 |   109 | 0.01 |
84.75 |
 | povray | 23981 |   317 | 0.01 |   351 | 0.01 |
10.73 |
 | calculix   | 42451 |  6175 | 0.15 |  7228 | 0.17 |
17.05 |
 | GemsFDTD   |  5782 |  1289 | 0.22 |  1519 | 0.26 |
17.84 |
 | tonto  | 81853 |  7900 | 0.10 |  8521 | 0.10 | 
7.86 |
 | lbm|   171 | 0 | 0.00 | 0 | 0.00 | 
0.00 |
 | wrf|121094 |  4330 | 0.04 |  4423 | 0.04 | 
2.15 |
 | sphinx3|  5880 | 9 | 0.00 |10 | 0.00 |
11.11 |
 
|+---+---+--+---+--+--+
 | ac.f90 |   474 |   287 | 0.61 |   300 | 0.63 | 
4.53 |
 | aermod.f90 | 33296 |  6923 | 0.21 |  6866 | 0.21 |
-0.82 |
 | air.f90|  1010 |   366 | 0.36 |   376 | 0.37 | 
2.73 |
 | capacita.f90   |   487 |80 | 0.16 |   153 | 0.31 |
91.25 |
 | channel2.f90   |   379 |   242 | 0.64 |   242 | 0.64 | 
0.00 |
 | doduc.f90  |   938 |   240 | 0.26 |   258 | 0.28 | 
7.50 |
 | fatigue2.f90   |  1936 |  1251 | 0.65 |  1259 | 0.65 | 
0.64 |
 | gas_dyn2.f90   |  1033 |   500 | 0.48 |   500 | 0.48 | 
0.00 |
 | induct2.f90|  3982 |  2179 | 0.55 |  2183 | 0.55 | 
0.18 |
 | linpk.f90  |85 |12 | 0.14 |12 | 0.14 | 
0.00 |
 | mdbx.f90   |   491 |   181 | 0.37 |   204 | 0.42 |
12.71 |
 | mp_prop_design.f90 |   518 |   334 | 0.64 |   334 | 0.64

[PATCH 7/7] Plug ipa-prop escape analysis into gimple_call_arg_flags

2014-05-21 Thread Martin Jambor
Hi,

this demonstrates how results of ipa-prop escape analysis from
previous patches can be used at a later stage of compilation by
directly returning them from gimple_call_arg_flags which currently
relies on fnspec annotations.

Bootstrapped and tested on x86_64-linux and also passes LTO bootstrap.
I have only had a brief look at behavior of this in SPEC 2006 and for
example in astar 1.19% of invocations of gimple_call_arg_flags return
noescape where we previously never did and in calculix this increases
from 15.62% (from annotations) to 18.14%.  Noclobber flag is reported
far less often still but for example in gamess that number raises from
5.21% to 7.66%.

Thanks,

Martin


2014-04-30  Martin Jambor  

* gimple.c: Include cgraph.h.
(gimple_call_arg_flags): Also query bitmaps in cgraph_node.

Index: src/gcc/gimple.c
===
--- src.orig/gcc/gimple.c
+++ src/gcc/gimple.c
@@ -47,7 +47,7 @@ along with GCC; see the file COPYING3.
 #include "demangle.h"
 #include "langhooks.h"
 #include "bitmap.h"
-
+#include "cgraph.h"
 
 /* All the tuples have their operand vector (if present) at the very bottom
of the structure.  Therefore, the offset required to find the
@@ -1349,32 +1349,50 @@ int
 gimple_call_arg_flags (const_gimple stmt, unsigned arg)
 {
   tree attr = gimple_call_fnspec (stmt);
+  int ret;
 
-  if (!attr || 1 + arg >= (unsigned) TREE_STRING_LENGTH (attr))
-return 0;
-
-  switch (TREE_STRING_POINTER (attr)[1 + arg])
+  if (attr && 1 + arg < (unsigned) TREE_STRING_LENGTH (attr))
 {
-case 'x':
-case 'X':
-  return EAF_UNUSED;
-
-case 'R':
-  return EAF_DIRECT | EAF_NOCLOBBER | EAF_NOESCAPE;
-
-case 'r':
-  return EAF_NOCLOBBER | EAF_NOESCAPE;
-
-case 'W':
-  return EAF_DIRECT | EAF_NOESCAPE;
-
-case 'w':
-  return EAF_NOESCAPE;
+  switch (TREE_STRING_POINTER (attr)[1 + arg])
+   {
+   case 'x':
+   case 'X':
+ ret = EAF_UNUSED;
+ break;
+   case 'R':
+ ret = EAF_DIRECT | EAF_NOCLOBBER | EAF_NOESCAPE;
+ break;
+   case 'r':
+ ret = EAF_NOCLOBBER | EAF_NOESCAPE;
+ break;
+   case 'W':
+ ret = EAF_DIRECT | EAF_NOESCAPE;
+ break;
+   case 'w':
+ ret = EAF_NOESCAPE;
+ break;
+   case '.':
+   default:
+ ret = 0;
+   }
+}
+  else
+ret = 0;
 
-case '.':
-default:
-  return 0;
+  tree callee_decl = gimple_call_fndecl (stmt);
+  if (callee_decl)
+{
+  cgraph_node *callee_node = cgraph_get_node (callee_decl);
+  if (callee_node)
+   {
+ if (cgraph_param_noescape_p (callee_node, arg))
+   ret |= EAF_NOESCAPE;
+ if (cgraph_param_noclobber_p (callee_node, arg))
+   ret |= EAF_NOCLOBBER;
+   }
 }
+
+  return ret;
 }
 
 /* Detects return flags for the call STMT.  */



[PATCH 1/7] Add missing documentation of four IPA-CP params

2014-05-21 Thread Martin Jambor
Hi,

in his review of the next patch of this series, Honza pointed out that
the path did not include documentation of a parameter it was adding.
When I set out to correct this I found out I had already been guilty
of not adding documentation of four other parameters before.

I'd like to correct this by this separate patch which I'd like to
propose also for 4.9 because it is missing there as well.  Checked by
running make info.  OK for both branches?

Thanks,

Martin


2014-05-16  Martin Jambor  

* doc/invoke.texi (Optimize Options): Document parameters
ipa-cp-eval-threshold, ipa-max-agg-items, ipa-cp-loop-hint-bonus and
ipa-cp-array-index-hint-bonus.

Index: src/gcc/doc/invoke.texi
===
--- src.orig/gcc/doc/invoke.texi
+++ src/gcc/doc/invoke.texi
@@ -10076,6 +10076,28 @@ parameter in order to propagate them and
 @option{ipa-cp-value-list-size} is the maximum number of values and types it
 stores per one formal parameter of a function.
 
+@item ipa-cp-eval-threshold
+IPA-CP calculates its own score of cloning profitability heuristics
+and performs those cloning opportunities with scores that exceed
+@option{ipa-cp-eval-threshold}.
+
+@item ipa-max-agg-items
+IPA-CP is also capable to propagate a number of scalar values passed
+in an aggregate. @option{ipa-max-agg-items} controls the maximum
+number of such values per one parameter.
+
+@item ipa-cp-loop-hint-bonus
+When IPA-CP determines that a cloning candidate would make the number
+of iterations of a loop known, it adds a bonus of
+@option{ipa-cp-loop-hint-bonus} bonus to the profitability score of
+the candidate.
+
+@item ipa-cp-array-index-hint-bonus
+When IPA-CP determines that a cloning candidate would make the index of
+an array access known, it adds a bonus of
+@option{ipa-cp-array-index-hint-bonus} bonus to the profitability
+score of the candidate.
+
 @item lto-partitions
 Specify desired number of partitions produced during WHOPR compilation.
 The number of partitions should exceed the number of CPUs used for compilation.



[PATCH 0/7] ipa-prop escape analysis

2014-05-21 Thread Martin Jambor
Hi,

this patch series implements ipa-prop escape and clobber analysis and
then more advanced jump function building on top of them.  Better
descriptions of individual patches are in their corresponding email
messages, they however need to be applied in this order and so I'm
sending them in this thread.

Thanks,

Martin



[Ada] Implement new restriction No_Fixed_IO

2014-05-21 Thread Arnaud Charlet
A new restriction No_Fixed_IO, which requires partition-wide consistent
use, forbids fixed I/O operations which may end up using floating-point
at run-time. These include any refernce to Fixed_IO or Decimal_IO in
packages Ada.Text_IO, Ada.Wide_Text_IO, and Ada.Wide_Wide_Text_IO, and
any use of the attributes Img, Image, Value, Wide_Image, Wide_Value,
Wide_Wide_Image, Wide_Wide_Value with ordinary or decimal fixed-point.
The following is compiled with -gnatws -gnatl:

 1. pragma Restrictions (No_Fixed_IO);
 2. with Text_IO;
 3. with Ada.Wide_Text_IO;
 4. with Ada.Wide_Wide_Text_IO;
 5. use Ada.Wide_Wide_Text_IO;
 6. package NoFixedIO is
 7.pragma Inspection_Point;
 8.type F is delta 0.25 range 0.0 .. 10.0;
 9.type D is delta 0.1 digits 3 range 0.0 .. 99.9;
10.package MyFIO is new Text_IO.Fixed_IO (F);
|
>>> violation of restriction "No_Fixed_Io" at line 1

11.package MyDIO is new Text_IO.Decimal_IO (D);
|
>>> violation of restriction "No_Fixed_Io" at line 1

12.package MyFIOW is new Ada.Wide_Text_IO.Fixed_IO (F);
  |
>>> violation of restriction "No_Fixed_Io" at line 1

13.package MyDIOW is new Ada.Wide_Text_IO.Decimal_IO (D);
  |
>>> violation of restriction "No_Fixed_Io" at line 1

14.package MyFIOWW is new Ada.Wide_Wide_Text_IO.Fixed_IO (F);
|
>>> violation of restriction "No_Fixed_Io" at line 1

15.package MyDIOWW is new Ada.Wide_Wide_Text_IO.Decimal_IO (D);
|
>>> violation of restriction "No_Fixed_Io" at line 1

16.FV : F;
17.DV : D;
18.S1 : String := FV'Img;
  |
>>> violation of restriction "No_Fixed_Io" at line 1

19.S2 : String := F'Image (FV);
  |
>>> violation of restriction "No_Fixed_Io" at line 1

20.S3 : String := D'Image (DV);
  |
>>> violation of restriction "No_Fixed_Io" at line 1

21.S4 : Wide_String := F'Wide_Image (FV);
   |
>>> violation of restriction "No_Fixed_Io" at line 1

22.S5 : Wide_String := D'Wide_Image (DV);
   |
>>> violation of restriction "No_Fixed_Io" at line 1

23.S6 : Wide_Wide_String := F'Wide_Wide_Image (FV);
|
>>> violation of restriction "No_Fixed_Io" at line 1

24.S7 : Wide_Wide_String := D'Wide_Wide_Image (DV);
|
>>> violation of restriction "No_Fixed_Io" at line 1

25.F1 : F := F'Value (S2);
 |
>>> violation of restriction "No_Fixed_Io" at line 1

26.D1 : D := D'Value (S3);
 |
>>> violation of restriction "No_Fixed_Io" at line 1

27.F2 : F := F'Wide_Value (S4);
 |
>>> violation of restriction "No_Fixed_Io" at line 1

28.D2 : D := D'Wide_Value (S5);
 |
>>> violation of restriction "No_Fixed_Io" at line 1

29.F3 : F := F'Wide_Wide_Value (S6);
 |
>>> violation of restriction "No_Fixed_Io" at line 1

30.D3 : D := D'Wide_Wide_Value (S7);
 |
>>> violation of restriction "No_Fixed_Io" at line 1

31. end NoFixedIO;

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

2014-05-21  Robert Dewar  

* restrict.ads (Implementation_Restriction): Add entry for
No_Fixed_IO.
* rtsfind.ads: Add entries for Fixed_IO and Decimal_IO in
Ada.[Wide_[Wide_]Text_IO.
* s-rident.ads (Restriction_Id): Add entry for No_Fixed_IO.
* sem_attr.adb (Analyze_Attribute): Disallow fixed point types
for Img, Image, Value, Wide_Image, Wide_Value, Wide_Wide_Image,
Wide_Wide_Value if restriction No_Fixed_IO is set.
* sem_util.adb (Set_Entity_Checks): Check restriction No_Fixed_IO.

Index: rtsfind.ads
===
--- rtsfind.ads (revision 210697)
+++ rtsfind.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

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

2014-05-21 Thread Mark Wielaard
On Tue, 2014-05-20 at 15:46 -0400, Jason Merrill wrote:
> Rather than define the hook for C, let's have a default version that 
> uses the type_for_size langhook; that should work better for Ada.

That also makes the patch simpler. Updated patch attached.

Bootstrapped on x86_64-unknown-linux-gnu with --enable-languages=c,c
++,objc,java,ada,fortran and ran against the gdb testsuite without
regressions (there is a tweak needed for one test regexp in
gdb.cp/var-tag.exp to deal with the extra type information, but Tom and
I already discussed on irc this isn't a regression, I'll submit a gdb
testsuite patch asap).

Thanks,

Mark
>From 6b3fbed4b2bfda22c6e55e151fbaef29c8208c39 Mon Sep 17 00:00:00 2001
From: Mark Wielaard 
Date: Wed, 21 May 2014 13:00:30 +0200
Subject: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. The default implementation will just uses type_for_size.
The implementation for C++ will use the ENUM_UNDERLYING_TYPE if it exists.
Use this enum_underlying_base_type lang-hook in dwarf2out.c to add a
DW_AT_type base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF
	version >= 3 or not strict DWARF.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks.c (lhd_enum_underlying_base_type): New function.
	* gcc/langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (lhd_enum_underlying_base_type): New declaration.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
---
 gcc/ChangeLog   |   14 ++
 gcc/cp/ChangeLog|6 ++
 gcc/cp/cp-lang.c|   18 ++
 gcc/dwarf2out.c |5 +
 gcc/langhooks-def.h |5 -
 gcc/langhooks.c |8 
 gcc/langhooks.h |2 ++
 7 files changed, 57 insertions(+), 1 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e2e3dd3..23f7296 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2014-05-21  Mark Wielaard  
+
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if DWARF
+	version >= 3 or not strict DWARF.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks.c (lhd_enum_underlying_base_type): New function.
+	* gcc/langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (lhd_enum_underlying_base_type): New declaration.
+	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
 2014-05-21  Oleg Endo  
 
 	PR target/54236
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 790b87e..085d0f5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2014-05-21  Mark Wielaard  
+
+	PR debug/16063
+	* cp-lang.c (cxx_enum_underlying_base_type): New function.
+	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-05-21  Igor Zamyatin  
 
 	PR c/60189
diff --git a/gcc/cp/cp-lang.c b/gcc/cp/cp-lang.c
index c28c07a..6a40d29 100644
--- a/gcc/cp/cp-lang.c
+++ b/gcc/cp/cp-lang.c
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "stor-layout.h"
 #include "cp-tree.h"
 #include "c-family/c-common.h"
 #include "langhooks.h"
@@ -40,6 +41,7 @@ static enum classify_record cp_classify_record (tree type);
 static tree cp_eh_personality (void);
 static tree get_template_innermost_arguments_folded (const_tree);
 static tree get_template_argument_pack_elems_folded (const_tree);
+static tree cxx_enum_underlying_base_type (const_tree);
 
 /* Lang hooks common to C++ and ObjC++ are declared in cp/cp-objcp-common.h;
consequently, there should be very few hooks below.  */
@@ -81,6 +83,8 @@ static tree get_template_argument_pack_elems_folded (const_tree);
 #define LANG_HOOKS_EH_PERSONALITY cp_eh_personality
 #undef LANG_HOOKS_EH_RUNTIME_TYPE
 #define LANG_HOOKS_EH_RUNTIME_TYPE build_eh_type_type
+#undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
+#define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE cxx_enum_underlying_base_type
 
 /* Each front end provides its own lang hook initializer.  */
 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
@@ -219,5 +223,19 @@ get_template_argument_pack_elems_folded (const_tree t)
   return fold_cplus_constants (get_template_argument_pack_elems (t));
 }
 
+/* The C++ version of the enum_underlying_base_type langhook.
+   See also cp/semantics.c (finish_underlying_type).  */
+static tree cxx_enum_underlying_base_type (const_tree type)
+{
+  tree underlying_type = ENUM_UNDERLYING_TYPE (type);
+
+  if (! ENUM_FIXED_UNDERLYING_TYPE_P (type))
+underlying_type
+  = c_common_type_for_mode (TYPE_MODE (underlying_type),
+ 

[Ada] Reject the use of volatiles in assertion expressions

2014-05-21 Thread Arnaud Charlet
This patch corrects the trigger which determines the proper context of a
volatile object with enabled property Async_Writers or Effective_Reads.


-- Source --


--  assert_exprs.ads

package Assert_Exprs with SPARK_Mode is
   type T is new Integer with Volatile;

   procedure Error (Input : T; Output : out T)
 with Pre  => Input > 1,
  Post => Output = Input * 2;
end Assert_Exprs;

--  assert_exprs.adb

package body Assert_Exprs with SPARK_Mode is
   procedure Error (Input : T; Output : out T) is
   begin
  Output := Input * 2;
   end Error;
end Assert_Exprs;


-- Compilation and output --


$ gcc -c -gnata assert_exprs.adb
assert_exprs.adb:4:17: volatile object cannot appear in this context (SPARK RM
  7.1.3(13))
assert_exprs.ads:5:19: volatile object cannot appear in this context (SPARK RM
  7.1.3(13))
assert_exprs.ads:6:19: volatile object cannot appear in this context (SPARK RM
  7.1.3(13))
assert_exprs.ads:6:28: volatile object cannot appear in this context (SPARK RM
  7.1.3(13))

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

2014-05-21  Hristian Kirtchev  

* freeze.adb (Freeze_Record_Type): Update the use of
Is_SPARK_Volatile.
* sem_ch3.adb (Analyze_Object_Contract): Update the use of
Is_SPARK_Volatile.
(Process_Discriminants): Update the use of Is_SPARK_Volatile.
* sem_ch5.adb (Analyze_Iterator_Specification): Update the use
of Is_SPARK_Volatile.
(Analyze_Loop_Parameter_Specification):
Update the use of Is_SPARK_Volatile.
* sem_ch6.adb (Process_Formals): Catch an illegal use of an IN
formal parameter when its type is volatile.
* sem_prag.adb (Analyze_Global_Item): Update the use of
Is_SPARK_Volatile.
* sem_res.adb (Resolve_Entity_Name): Correct the guard which
determines whether an entity is a volatile source SPARK object.
* sem_util.adb (Has_Enabled_Property): Accout for external
properties being set on objects other than abstract states
and variables. An example would be a formal parameter.
(Is_SPARK_Volatile): New routine.
(Is_SPARK_Volatile_Object):
Remove the entity-specific tests. Call routine Is_SPARK_Volatile
when checking entities and/or types.
* sem_util.ads (Is_SPARK_Volatile): New routine.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 210705)
+++ sem_ch3.adb (working copy)
@@ -2988,7 +2988,7 @@
  --  actuals in instantiations (SPARK RM 7.1.3(6)).
 
  if SPARK_Mode = On
-   and then Is_SPARK_Volatile_Object (Obj_Id)
+   and then Is_SPARK_Volatile (Obj_Id)
and then No (Corresponding_Generic_Association (Parent (Obj_Id)))
  then
 Error_Msg_N ("constant cannot be volatile", Obj_Id);
@@ -3000,7 +3000,7 @@
  --  they are not standard Ada legality rules.
 
  if SPARK_Mode = On then
-if Is_SPARK_Volatile_Object (Obj_Id) then
+if Is_SPARK_Volatile (Obj_Id) then
 
--  The declaration of a volatile object must appear at the
--  library level (SPARK RM 7.1.3(7), C.6(6)).
@@ -3030,7 +3030,7 @@
--  A non-volatile object cannot have volatile components
--  (SPARK RM 7.1.3(7)).
 
-   if not Is_SPARK_Volatile_Object (Obj_Id)
+   if not Is_SPARK_Volatile (Obj_Id)
  and then Has_Volatile_Component (Obj_Typ)
then
   Error_Msg_N
@@ -18051,7 +18051,7 @@
  --  (SPARK RM 7.1.3(6)).
 
  if SPARK_Mode = On
-   and then Is_SPARK_Volatile_Object (Defining_Identifier (Discr))
+   and then Is_SPARK_Volatile (Defining_Identifier (Discr))
  then
 Error_Msg_N ("discriminant cannot be volatile", Discr);
  end if;
Index: sem_ch5.adb
===
--- sem_ch5.adb (revision 210707)
+++ sem_ch5.adb (working copy)
@@ -1986,7 +1986,7 @@
 
   if SPARK_Mode = On
 and then not Of_Present (N)
-and then Is_SPARK_Volatile_Object (Ent)
+and then Is_SPARK_Volatile (Ent)
   then
  Error_Msg_N ("loop parameter cannot be volatile", Ent);
   end if;
@@ -2706,7 +2706,7 @@
   --  when SPARK_Mode is on as it is not a standard Ada legality check
   --  (SPARK RM 7.1.3(6)).
 
-  if SPARK_Mode = On and then Is_SPARK_Volatile_Object (Id) then
+  if SPARK_Mode = On and then Is_SPARK_Volatile (Id) then
  Error_Msg_N ("loop parameter cannot be volatile", Id);
   end if;
end Analyze_Loop_Parameter_Specification;
Index: sem_prag.adb
===
--- sem_prag.adb(revision 210702)
+++ sem_prag.adb(working copy)
@

[Ada] Warnings on use of uninitialized entities in an instance

2014-05-21 Thread Arnaud Charlet
This patch adds warnings to uses of potentially uninitialzed entities in
instances.  If an entity of a generic type has default initialization, then the
corresponding actual type should be fully initialized, or else there will be
uninitialized components in the instantiation that might go unreported, because
in general we do not emit warnings within instances. The new predicate
May_Need_Initialized_Actual allows the compiler to emit an appropriate
warning in the generic itself, and a corresponding one in the instance if
the actual is not fully initialized. In a sense, the use of a type that
requires full initialization is a weak part of the generic contract, and this
patch makes this weak obligation explicit.

Compiling warn.adb must yield:

warn.adb:12:06:
warning: variable "Problem" of a generic type is potentially uninitialized
warn.adb:12:06:
warning: instantiations must provide fully initialized type for "GR"
warn.adb:16:04: warning: in instantiation at line 7
warn.adb:16:04:
 warning: from its use in generic unit, actual for "GR" should be
 fully initialized type

---
procedure Warn is
   type R is record
  V : Integer;
   end record;

   generic
 type GR is private;
   package G is
  Thing : GR;
   end G;
   package body G is
 Problem : GR;
   end;

   type R2 is new R;
   package I is new G (R2);
begin
   null;
end;

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

2014-05-21  Ed Schonberg  

* sinfo.ads, sinfo.adb: New flag Needs_Initialized_Actual,
present in formal_Private_Definitions and on private extension
declarations of a formal derived type. Set when the use of the
formal type in a generic suggests that the actual should be a
fully initialized type.
* sem_warn.adb (May_Need_Initialized_Actual): new subprogram
to indicate that an entity of a generic type has default
initialization, and that the corresponing actual type in any
subsequent instantiation should be fully initialized.
* sem_ch12.adb (Check_Initialized_Type): new subprogram,
to emit a warning if the actual for a generic type on which
Needs_Initialized_Actual is set is not a fully initialized type.

Index: sinfo.adb
===
--- sinfo.adb   (revision 210697)
+++ sinfo.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- --
@@ -2224,6 +2224,15 @@
   return List2 (N);
end Names;
 
+   function Needs_Initialized_Actual
+ (N : Node_Id) return Boolean is
+   begin
+  pragma Assert (False
+or else NT (N).Nkind = N_Formal_Private_Type_Definition
+or else NT (N).Nkind = N_Private_Extension_Declaration);
+  return Flag18 (N);
+   end Needs_Initialized_Actual;
+
function Next_Entity
   (N : Node_Id) return Node_Id is
begin
@@ -5364,6 +5373,15 @@
   Set_List2_With_Parent (N, Val);
end Set_Names;
 
+   procedure Set_Needs_Initialized_Actual
+ (N : Node_Id; Val : Boolean := True) is
+   begin
+  pragma Assert (False
+or else NT (N).Nkind = N_Formal_Private_Type_Definition
+or else NT (N).Nkind = N_Private_Extension_Declaration);
+  Set_Flag18 (N, Val);
+   end Set_Needs_Initialized_Actual;
+
procedure Set_Next_Entity
   (N : Node_Id; Val : Node_Id) is
begin
Index: sinfo.ads
===
--- sinfo.ads   (revision 210697)
+++ sinfo.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- --
@@ -1701,6 +1701,12 @@
--present in an N_Subtype_Indication node, since we also use these in
--calls to Freeze_Expression.
 
+   --  Needs_Initialized_Actual (Flag18-Sem)
+   --Present in 

[Ada] Proper handling of packed array of small record with reverse SSO

2014-05-21 Thread Arnaud Charlet
This change ensures proper processing for a packed array of 4-bit records
specified with reverse scalar storage order.

The following program must compile quietly and execute as shown:

$ gnatmake -q reduced_pkd_array_small_rec
$ ./reduced_pkd_array_small_rec
Config 0 =  1
Config 1 =  3
Config 2 =  5
Config 3 =  7
Bit pattern:  19  87

with Ada.Text_Io; use Ada.Text_IO;
with System.Storage_Elements; use System.Storage_Elements;

procedure reduced_pkd_array_small_rec is

type Int3 is range 0 .. 7;
for Int3'Size use 3;

type Small_Rec is record
   B : Boolean := False;
   I : Int3:= 0;
end record;

pragma pack (Small_Rec);

for Small_Rec'Size use 4;
for Small_Rec'Bit_Order use System.High_Order_First;
for Small_Rec'Scalar_Storage_Order use System.High_Order_First;

for Small_Rec use record
B at 0 range 0 .. 0;
I at 0 range 1 .. 3;
end record;

type Pakd_Array is array (Integer range 0 .. 3) of Small_Rec;
pragma pack (Pakd_Array);
for Pakd_Array'Scalar_Storage_Order use System.High_Order_First;

Config : Pakd_Array;

SA : Storage_Array (1 .. Config'Size / 8);
for SA'Address use Config'Address;
pragma Import (Ada, SA);

begin
Config(0).I := 1;
Config(1).I := 3;
Config(2).I := 5;
Config(3).I := 7;

Put_Line ("Config 0 = " & Config(0).I'Img);
Put_Line ("Config 1 = " & Config(1).I'Img);
Put_Line ("Config 2 = " & Config(2).I'Img);
Put_Line ("Config 3 = " & Config(3).I'Img);

Put ("Bit pattern:");
for J in SA'Range loop
   Put (" " & SA (J)'Img);
end loop;
New_Line;
end;

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

2014-05-21  Thomas Quinot  

* exp_pakd.adb (Byte_Swap): Handle the case of a sub-byte
component. No byte swapping occurs, but this procedure also takes
care of appropriately justifying the argument.

Index: exp_pakd.adb
===
--- exp_pakd.adb(revision 210703)
+++ exp_pakd.adb(working copy)
@@ -576,20 +576,26 @@
   Shift   : Uint;
 
begin
-  pragma Assert (T_Size > 8);
+  if T_Size <= 8 then
+ Swap_F := Empty;
+ Swap_T := RTE (RE_Unsigned_8);
 
-  if T_Size <= 16 then
- Swap_RE := RE_Bswap_16;
+  else
+ if T_Size <= 16 then
+Swap_RE := RE_Bswap_16;
 
-  elsif T_Size <= 32 then
- Swap_RE := RE_Bswap_32;
+ elsif T_Size <= 32 then
+Swap_RE := RE_Bswap_32;
 
-  else pragma Assert (T_Size <= 64);
- Swap_RE := RE_Bswap_64;
+ else pragma Assert (T_Size <= 64);
+Swap_RE := RE_Bswap_64;
+ end if;
+
+ Swap_F := RTE (Swap_RE);
+ Swap_T := Etype (Swap_F);
+
   end if;
 
-  Swap_F := RTE (Swap_RE);
-  Swap_T := Etype (Swap_F);
   Shift := Esize (Swap_T) - T_Size;
 
   Arg := RJ_Unchecked_Convert_To (Swap_T, N);
@@ -601,10 +607,14 @@
  Right_Opnd => Make_Integer_Literal (Loc, Shift));
   end if;
 
-  Swapped :=
-Make_Function_Call (Loc,
-  Name   => New_Occurrence_Of (Swap_F, Loc),
-  Parameter_Associations => New_List (Arg));
+  if Present (Swap_F) then
+ Swapped :=
+   Make_Function_Call (Loc,
+ Name   => New_Occurrence_Of (Swap_F, Loc),
+ Parameter_Associations => New_List (Arg));
+  else
+ Swapped := Arg;
+  end if;
 
   if Right_Justify and then Shift > Uint_0 then
  Swapped :=


[Ada] Overriding_Indicators not legal on protected subprogram bodies

2014-05-21 Thread Arnaud Charlet
The compiler incorrectly allows overriding_indicators to be applied
to protected subprogram bodies (and flags a style error with -gnatyO
when they're missing), but those are disallowed by the Ada RM (see
RM-8.3.1(3-6) and AC95-00213 for confirmation of intent). This is
fixed, but the error can be changed to a warning with -gnatd.E to
ease transition for programs that were using such overriding_indicators.

The test below must report the following style warning and error
when compiled with:

$ gcc -c -gnatyO -gnatj60 prot_subp_indicator_bug.adb

prot_subp_indicator_bug.adb:17:07: (style) missing
   "overriding" indicator
   in declaration of "P"
prot_subp_indicator_bug.adb:32:07: overriding indicator not
   allowed for protected
   subprogram body

and the following warnings when compiled with:

$ gcc -c -gnatyO -gnatd.E -gnatj60 prot_subp_indicator_bug.adb

prot_subp_indicator_bug.adb:17:07: (style) missing
   "overriding" indicator
   in declaration of "P"
prot_subp_indicator_bug.adb:32:07: warning: overriding
   indicator not allowed
   for protected subprogram
   body

procedure Prot_Subp_Indicator_Bug is

   package Synch_Pkg is

  type Synch_Interface is synchronized interface;

  procedure P (X : out Synch_Interface) is abstract;

  procedure Q (X : in out Synch_Interface) is abstract;

   end Synch_Pkg;

   use Synch_Pkg;

   protected type Prot_Type is new Synch_Interface with

  procedure P;-- Warning "missing overriding indicator" OK with -gnatyO

  overriding  -- OK
  procedure Q;

   end Prot_Type;

   protected body Prot_Type is

  procedure P is -- Shouldn't get warning about adding overriding indicator
  begin
 null;
  end P;

  overriding -- Illegal (but only give a warning when using -gnatd.E)
  procedure Q is
  begin
 null;
  end Q;

   end Prot_Type;

begin
   null;
end Prot_Subp_Indicator_Bug;

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

2014-05-21  Gary Dismukes  

* debug.adb: Add case of illegal overriding_indicator for a
protected subprogram body to description of -gnatd.E switch.
* sem_ch6.adb (Verify_Overriding_Indicator): Issue error message
for cases of giving overriding_indicators on protected subprogram
bodies, but change this to a warning if -gnatd.E is enabled. No
longer give a style warning about missing indicators on protected
subprogram bodies.

Index: debug.adb
===
--- debug.adb   (revision 210697)
+++ debug.adb   (working copy)
@@ -614,6 +614,11 @@
--
--  Errors relating to the new rules about not defining equality
--  too late so that composition of equality can be assured.
+   --
+   --  Errors relating to overriding indicators on protected subprogram
+   --  bodies (not an Ada 2012 incompatibility, but might cause errors
+   --  for existing programs assuming they were legal because GNAT
+   --  formerly allowed them).
 
--  d.F  Sets GNATprove_Mode to True. This allows debugging the frontend in
--   the special mode used by GNATprove.
Index: sem_ch6.adb
===
--- sem_ch6.adb (revision 210697)
+++ sem_ch6.adb (working copy)
@@ -2782,6 +2782,16 @@
 elsif not Present (Overridden_Operation (Spec_Id)) then
Error_Msg_NE
  ("subprogram& is not overriding", Body_Spec, Spec_Id);
+
+--  Overriding indicators aren't allowed for protected subprogram
+--  bodies (see the Confirmation in Ada Comment AC95-00213). Change
+--  this to a warning if -gnatd.E is enabled.
+
+elsif Ekind (Scope (Spec_Id)) = E_Protected_Type then
+   Error_Msg_Warn := Error_To_Warning;
+   Error_Msg_N
+ ("

[Ada] Fix error in classification of restriction warnings

2014-05-21 Thread Arnaud Charlet
Some restriction warnings messages were still being tagged as
[enabled by default] instead of [restriction warning]. The
following program used not to give the warning since it got
incorrectly suppressed (compiled with -gnatj55 -gnatw.d -gnatl)

 1. pragma Warnings (Off, "[enabled by default]");
 2. pragma Restriction_Warnings
 3.   (No_Dependence => Ada.Containers);
 4. with Ada.Containers;
 |
>>> warning: violation of restriction
"No_Dependence => Ada.Containers" at line
3 [restriction warning]

 5. procedure Ololo (Unref : Integer) is
 6. type String is (A, B, C);
 7.
 8. procedure P (I, J : in out Integer) is
 9. begin
10.if I < J then
11.   I := I + 1;
12.   P (I, J);
13.end if;
14. end P;
15.
16. J, I  : Integer := 10;
17.
18. X, Y : Float := 1.0;
19. begin
20. if X = Y then
21.P (J, I);
22. end if;
23. end;

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

2014-05-21  Robert Dewar  

* errout.ads: Add documentation for use of >*> tag.
* restrict.adb: Make sure we use >*> tag for restriction warnings.

Index: errout.ads
===
--- errout.ads  (revision 210697)
+++ errout.ads  (working copy)
@@ -312,10 +312,10 @@
--Insertion character < (Less Than: conditional warning message)
--  The character < appearing anywhere in a message is used for a
--  conditional error message. If Error_Msg_Warn is True, then the
-   --  effect is the same as ? described above, and in particular << and
-   --   &`#", N);
   end if;
end Check_Restriction_No_Use_Of_Attribute;
 
@@ -336,7 +336,7 @@
  Error_Msg_Node_1 := Id;
  Error_Msg_Warn := No_Use_Of_Pragma_Warning (P_Id);
  Error_Msg_N
-   (" &`#", Id);
   end if;
end Check_Restriction_No_Use_Of_Pragma;
 
@@ -645,7 +645,7 @@
 
 if No_Dependences.Table (J).Warn then
Error_Msg
- ("??violation of restriction `No_Dependence '='> &`#",
+ ("?*?violation of restriction `No_Dependence '='> &`#",
   Sloc (Err));
 else
Error_Msg
@@ -691,7 +691,7 @@
  Error_Msg_Node_1 := Id;
  Error_Msg_Warn := No_Specification_Of_Aspect_Warning (A_Id);
  Error_Msg_N
-   (" &`#",
 Id);
   end if;
end Check_Restriction_No_Specification_Of_Aspect;


Re: CALL_INSN_FUNCTION_USAGE fix, PR52773

2014-05-21 Thread Jeff Law

On 05/21/14 03:37, Bernd Schmidt wrote:

On 06/19/2013 07:39 PM, Bernd Schmidt wrote:

This is bug that triggers on m68k. The loop unroller creates a MULT
expression and tries to force it into a register, which causes a libcall
to be generated. Since args are pushed we create a
   (use (mem (plus virtual_outgoing_args scratch)))
in CALL_INSN_FUNCTION_USAGE. Since we're past vregs, the
virtual_outgoing_args rtx survives to reload, which blows up.

Fixed by just using stack_pointer_rtx, since we use a scratch anyway
rather than a known offset. I also noticed that we actually add two of
these USEs, so I've fixed that as well.


Ping.

https://gcc.gnu.org/ml/gcc-patches/2013-06/msg01147.html

This is fine.  Thanks.

jeff



Re: [PATCH, PR61191, Cilk+] Fix ICE on syntax error

2014-05-21 Thread Jeff Law

On 05/21/14 06:48, Zamyatin, Igor wrote:

Please see the patch with the testcase

Thanks,
Igor

gcc/c/ChangeLog:

2014-05-20  Igor Zamyatin  

PR c/61191
* c-array-notation.c (fix_builtin_array_notation_fn): Check invalid
function parameters.

gcc/testsuite/ChangeLog

2014-05-20  Igor Zamyatin  

PR c/61191
* c-c++-common/cilk-plus/AN/pr61191.c: Check for correct
handling of the case with syntax error.

This is fine. Please install.

Thanks,
Jeff



[PATCH][RFC] Handle realloc in PTA and alias analysis

2014-05-21 Thread Richard Biener

PR56955 prompted me to handle BUILT_IN_REALLOC just the same
way we already handle BUILT_IN_STR[N]DUP.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

Now this will disambiguate *p and *q for p = realloc (q, n)
for any value of n (including those that don't actually
trigger re-allocation and thus where p == q after the call).
I don't think that any such use would be valid - but I can
certainly play safer here and implement the points-to part
as a pass-through (that is, make p point to what q points).
That's of course less optimization.

I can't quite find language that specifies that the
object can no longer accessed via the pointer argument q
(at least if p didn't return NULL and size was not NULL).
The C99 standard explicitely mentions that p may have
the same pointer value as q though.

Thoughts?

Thanks,
Richard.

2014-05-21  Richard Biener  

* tree-ssa-alias.c (ref_maybe_used_by_call_p_1): Handle
BUILT_IN_REALLOC like BUILT_IN_STRDUP.
(call_may_clobber_ref_p_1): Likewise.
* tree-ssa-structalias.c (find_func_aliases_for_builtin_call):
Likewise.
(handle_lhs_call): Use flags argument instead of recomputing it.
(find_func_aliases_for_call): Call handle_lhs_call with proper
call return flags.

* gcc.dg/tree-ssa/alias-33.c: New testcase.

Index: gcc/tree-ssa-alias.c
===
*** gcc/tree-ssa-alias.c.orig   2014-05-21 14:38:57.841133822 +0200
--- gcc/tree-ssa-alias.c2014-05-21 14:39:05.954133263 +0200
*** ref_maybe_used_by_call_p_1 (gimple call,
*** 1594,1599 
--- 1594,1600 
/* These read memory pointed to by the first argument.  */
case BUILT_IN_STRDUP:
case BUILT_IN_STRNDUP:
+   case BUILT_IN_REALLOC:
  {
ao_ref dref;
tree size = NULL_TREE;
*** call_may_clobber_ref_p_1 (gimple call, a
*** 1958,1963 
--- 1959,1965 
case BUILT_IN_MALLOC:
case BUILT_IN_ALIGNED_ALLOC:
case BUILT_IN_CALLOC:
+   case BUILT_IN_REALLOC:
case BUILT_IN_STRDUP:
case BUILT_IN_STRNDUP:
  /* Unix98 specifies that errno is set on allocation failure.  */
Index: gcc/tree-ssa-structalias.c
===
*** gcc/tree-ssa-structalias.c.orig 2014-05-21 14:38:57.844133822 +0200
--- gcc/tree-ssa-structalias.c  2014-05-21 14:45:50.896105384 +0200
*** handle_lhs_call (gimple stmt, tree lhs,
*** 3974,3980 
  
/* If the call returns an argument unmodified override the rhs
   constraints.  */
-   flags = gimple_call_return_flags (stmt);
if (flags & ERF_RETURNS_ARG
&& (flags & ERF_RETURN_ARG_MASK) < gimple_call_num_args (stmt))
  {
--- 3974,3979 
*** find_func_aliases_for_builtin_call (stru
*** 4299,4307 
return true;
case BUILT_IN_STRDUP:
case BUILT_IN_STRNDUP:
if (gimple_call_lhs (t))
  {
!   handle_lhs_call (t, gimple_call_lhs (t), gimple_call_flags (t),
 vNULL, fndecl);
get_constraint_for_ptr_offset (gimple_call_lhs (t),
   NULL_TREE, &lhsc);
--- 4298,4308 
return true;
case BUILT_IN_STRDUP:
case BUILT_IN_STRNDUP:
+   case BUILT_IN_REALLOC:
if (gimple_call_lhs (t))
  {
!   handle_lhs_call (t, gimple_call_lhs (t),
!gimple_call_return_flags (t) | ERF_NOALIAS,
 vNULL, fndecl);
get_constraint_for_ptr_offset (gimple_call_lhs (t),
   NULL_TREE, &lhsc);
*** find_func_aliases_for_call (struct funct
*** 4535,4541 
else
handle_rhs_call (t, &rhsc);
if (gimple_call_lhs (t))
!   handle_lhs_call (t, gimple_call_lhs (t), flags, rhsc, fndecl);
rhsc.release ();
  }
else
--- 4536,4543 
else
handle_rhs_call (t, &rhsc);
if (gimple_call_lhs (t))
!   handle_lhs_call (t, gimple_call_lhs (t),
!gimple_call_return_flags (t), rhsc, fndecl);
rhsc.release ();
  }
else
Index: gcc/testsuite/gcc.dg/tree-ssa/alias-33.c
===
*** /dev/null   1970-01-01 00:00:00.0 +
--- gcc/testsuite/gcc.dg/tree-ssa/alias-33.c2014-05-21 14:39:06.003133260 
+0200
***
*** 0 
--- 1,20 
+ /* { dg-do run } */
+ /* { dg-options "-O -fdump-tree-fre1-details" } */
+ 
+ int j;
+ int main ()
+ {
+   int i = 1;
+   int **p;
+   j = 0;
+   p = __builtin_malloc (sizeof (int *));
+   *p = &i;
+   p = __builtin_realloc (p, 2 * sizeof (int *));
+   **p = 0;
+   if (i != 0)
+ __builtin_abort ();
+   return j;
+ }
+ 
+ /* { dg-final { scan-tree-dump "Replaced j with 0" "fre1" } } */
+

[Ada] Update SPARK cross references for local packages

2014-05-21 Thread Arnaud Charlet
Cross references for GNATprove on SPARK code should not use local packages
as valid scopes, but instead the enclosing subprogram, which is the
meaningful scope to distinguish between local and global variables.

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

2014-05-21  Yannick Moy  

* lib-xref-spark_specific.adb, lib-xref.ads, lib-xref.adb
(Enclosing_Subprogram_Or_Package): Only return a library-level
package.

Index: lib-xref-spark_specific.adb
===
--- lib-xref-spark_specific.adb (revision 210697)
+++ lib-xref-spark_specific.adb (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 2011-2013, Free Software Foundation, Inc. --
+--  Copyright (C) 2011-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- --
@@ -23,10 +23,9 @@
 --  --
 --
 
-with SPARK_Xrefs; use SPARK_Xrefs;
-with Einfo;   use Einfo;
-with Nmake;   use Nmake;
-with Put_SPARK_Xrefs;
+with SPARK_Xrefs; use SPARK_Xrefs;
+with Einfo;   use Einfo;
+with Nmake;   use Nmake;
 
 with GNAT.HTable;
 
@@ -972,7 +971,9 @@
-- Enclosing_Subprogram_Or_Package --
-
 
-   function Enclosing_Subprogram_Or_Package (N : Node_Id) return Entity_Id is
+   function Enclosing_Subprogram_Or_Library_Package
+ (N : Node_Id) return Entity_Id
+   is
   Result : Entity_Id;
 
begin
@@ -990,13 +991,27 @@
   while Present (Result) loop
  case Nkind (Result) is
 when N_Package_Specification =>
-   Result := Defining_Unit_Name (Result);
-   exit;
 
+   --  Only return a library-level package
+
+   if Is_Library_Level_Entity (Defining_Entity (Result)) then
+  Result := Defining_Entity (Result);
+  exit;
+   else
+  Result := Parent (Result);
+   end if;
+
 when N_Package_Body =>
-   Result := Defining_Unit_Name (Result);
-   exit;
 
+   --  Only return a library-level package
+
+   if Is_Library_Level_Entity (Defining_Entity (Result)) then
+  Result := Defining_Entity (Result);
+  exit;
+   else
+  Result := Parent (Result);
+   end if;
+
 when N_Subprogram_Specification =>
Result := Defining_Unit_Name (Result);
exit;
@@ -1045,7 +1060,7 @@
   end if;
 
   return Result;
-   end Enclosing_Subprogram_Or_Package;
+   end Enclosing_Subprogram_Or_Library_Package;
 
-
-- Entity_Hash --
@@ -1107,7 +1122,7 @@
Create_Heap;
 end if;
 
-Ref_Scope := Enclosing_Subprogram_Or_Package (N);
+Ref_Scope := Enclosing_Subprogram_Or_Library_Package (N);
 
 Deref.Ent := Heap;
 Deref.Loc := Loc;
Index: lib-xref.ads
===
--- lib-xref.ads(revision 210697)
+++ lib-xref.ads(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 1998-2013, Free Software Foundation, Inc. --
+--  Copyright (C) 1998-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- --
@@ -624,8 +624,12 @@
 
package SPARK_Specific is
 
-  function Enclosing_Subprogram_Or_Package (N : Node_Id) return Entity_Id;
-  --  Return the closest enclosing subprogram of package
+  function Enclosing_Subprogram_Or_Library_Package
+(N : Node_Id) return Entity_Id;
+  --  Return the closest enclosing subprogram of package. Only return a
+  --  library level package. If the package is enclosed in a subprogram,
+  --  return the subprogram. This ensures that GNATprove can distinguish
+  --  local variables from global variables.
 
  

Re: [PATCH] Implement -fsanitize=float-cast-overflow (take 2)

2014-05-21 Thread Marek Polacek
On Tue, May 20, 2014 at 09:50:10PM +, Joseph S. Myers wrote:
> On Tue, 20 May 2014, Marek Polacek wrote:
> 
> > * is missing tests for long doubles/-mlong-double-128,
> 
> Also missing tests for float - as far as I can see, only double is tested.  
> Ideally all of float, double, long double, __float128 (where supported), 
> __float80 (where supported) would be tested (the functionality supported 
> for __fp16 (ARM) is a bit more restricted) - hopefully using some shared 
> macros to avoid too much duplication between tests.
 
Ok, I've added some tests for float, long double, __float128 and
__float80.  A snag was in __float128 type: libubsan supposedly can't
handle __float128 values and prints "0".  libubsan also can't handle
__float80 types with -m32 it seems.
Common macros moved to float-cast.h.

> > * doesn't instrument _Decimal to integer conversions yet.
> 
> So the code
> 
> > +  else if (REAL_MODE_FORMAT (mode)->b == 10)
> > +{
> > +  /* For _Decimal128 up to 34 decimal digits, - sign,
> > +dot, e, exponent.  */
> 
> isn't actually being used yet?

Yes.  I suspect adding support for _Decimal* shouldn't be hard,
what's needed is to find the place where the conversion from _Decimal
to integer is taking place and add similar code as is in convert.c.
Jakub says he's writing another testcase that tests various type
combination conversions and max/min values - so we'll get even more
coverage.

I tested the following with -m32/-m64 on x86_64 and ppc64.

2014-05-21  Marek Polacek  
Jakub Jelinek  

* builtins.def: Change SANITIZE_FLOAT_DIVIDE to SANITIZE_NONDEFAULT.
* gcc.c (sanitize_spec_function): Likewise.
* convert.c (convert_to_integer): Include "ubsan.h".  Add floating-point
to integer instrumentation.
* doc/invoke.texi: Document -fsanitize=float-cast-overflow.
* flag-types.h (enum sanitize_code): Add SANITIZE_FLOAT_CAST and
SANITIZE_NONDEFAULT.
* opts.c (common_handle_option): Handle -fsanitize=float-cast-overflow.
* sanitizer.def (BUILT_IN_UBSAN_HANDLE_FLOAT_CAST_OVERFLOW,
BUILT_IN_UBSAN_HANDLE_FLOAT_CAST_OVERFLOW_ABORT): Add.
* ubsan.c: Include "realmpfr.h" and "dfp.h".
(get_ubsan_type_info_for_type): Handle REAL_TYPEs.
(ubsan_instrument_float_cast): New function.
* ubsan.h (ubsan_instrument_float_cast): Declare.

* c-c++-common/ubsan/float-cast-overflow-1.c: New test.
* c-c++-common/ubsan/float-cast-overflow-2.c: New test.
* c-c++-common/ubsan/float-cast-overflow-3.c: New test.
* c-c++-common/ubsan/float-cast-overflow-4.c: New test.
* c-c++-common/ubsan/float-cast-overflow-5.c: New test.
* c-c++-common/ubsan/float-cast-overflow-6.c: New test.
* c-c++-common/ubsan/float-cast.h: New test.
* g++.dg/ubsan/float-cast-overflow-bf.C: New test.
* gcc.dg/ubsan/float-cast-overflow-bf.c: New test.

diff --git gcc/builtins.def gcc/builtins.def
index d400ecb..cd823a3 100644
--- gcc/builtins.def
+++ gcc/builtins.def
@@ -176,7 +176,7 @@ along with GCC; see the file COPYING3.  If not see
   DEF_BUILTIN (ENUM, "__builtin_" NAME, BUILT_IN_NORMAL, TYPE, TYPE,\
   true, true, true, ATTRS, true, \
  (flag_sanitize & (SANITIZE_ADDRESS | SANITIZE_THREAD \
-   | SANITIZE_UNDEFINED | SANITIZE_FLOAT_DIVIDE)))
+   | SANITIZE_UNDEFINED | SANITIZE_NONDEFAULT)))
 
 #undef DEF_CILKPLUS_BUILTIN
 #define DEF_CILKPLUS_BUILTIN(ENUM, NAME, TYPE, ATTRS)  \
diff --git gcc/convert.c gcc/convert.c
index 91c1da2..b8f3671 100644
--- gcc/convert.c
+++ gcc/convert.c
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "diagnostic-core.h"
 #include "target.h"
 #include "langhooks.h"
+#include "ubsan.h"
 
 /* Convert EXPR to some pointer or reference type TYPE.
EXPR must be pointer, reference, integer, enumeral, or literal zero;
@@ -394,6 +395,7 @@ convert_to_integer (tree type, tree expr)
   tree intype = TREE_TYPE (expr);
   unsigned int inprec = element_precision (intype);
   unsigned int outprec = element_precision (type);
+  location_t loc = EXPR_LOCATION (expr);
 
   /* An INTEGER_TYPE cannot be incomplete, but an ENUMERAL_TYPE can
  be.  Consider `enum E = { a, b = (enum E) 3 };'.  */
@@ -844,7 +846,17 @@ convert_to_integer (tree type, tree expr)
   return build1 (CONVERT_EXPR, type, expr);
 
 case REAL_TYPE:
-  return build1 (FIX_TRUNC_EXPR, type, expr);
+  if (flag_sanitize & SANITIZE_FLOAT_CAST)
+   {
+ expr = save_expr (expr);
+ tree check = ubsan_instrument_float_cast (loc, type, expr);
+ expr = build1 (FIX_TRUNC_EXPR, type, expr);
+ if (check == NULL)
+   return expr;
+ return fold_build2 (COMPOUND_EXPR, TREE_TYPE (expr), check, expr);
+   }
+  else
+   return build1 (FIX_TRUNC_EXPR, type, expr);
 
 case FIXED_POINT_TYPE:
 

RE: [PATCH, PR61191, Cilk+] Fix ICE on syntax error

2014-05-21 Thread Zamyatin, Igor
Please see the patch with the testcase

Thanks,
Igor

gcc/c/ChangeLog:

2014-05-20  Igor Zamyatin  

PR c/61191
* c-array-notation.c (fix_builtin_array_notation_fn): Check invalid
function parameters.

gcc/testsuite/ChangeLog

2014-05-20  Igor Zamyatin  

PR c/61191
* c-c++-common/cilk-plus/AN/pr61191.c: Check for correct
handling of the case with syntax error.

diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c
index 0ac6ba8..127f9a1 100644
--- a/gcc/c/c-array-notation.c
+++ b/gcc/c/c-array-notation.c
@@ -229,6 +229,8 @@ fix_builtin_array_notation_fn (tree an_builtin_fn, tree 
*new_var)
   /* Fully fold any EXCESSIVE_PRECISION EXPR that can occur in the function
  parameter.  */
   func_parm = c_fully_fold (func_parm, false, NULL);
+  if (func_parm == error_mark_node)
+return error_mark_node;
   
   location = EXPR_LOCATION (an_builtin_fn);
   
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61191.c 
b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61191.c
new file mode 100644
index 000..e27819b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61191.c
@@ -0,0 +1,10 @@
+/* PR c/61191 */
+/* { dg-do compile } */
+/* { dg-options "-fcilkplus" } */
+
+double f(double * A, double * B)
+{
+  return __sec_reduce_add((B[0:500])(;
+/* { dg-error "expected expression before ';' token" "" {target *-*-*} 7 } */
+/* { dg-error "called object" "" {target *-*-*} 7 } */
+} /* { dg-error "expected" } */

> -Original Message-
> From: Jeff Law [mailto:l...@redhat.com]
> Sent: Tuesday, May 20, 2014 8:36 PM
> To: H.J. Lu; Zamyatin, Igor
> Cc: GCC Patches (gcc-patches@gcc.gnu.org)
> Subject: Re: [PATCH, PR61191, Cilk+] Fix ICE on syntax error
> 
> On 05/20/14 09:27, H.J. Lu wrote:
> > On Tue, May 20, 2014 at 7:31 AM, Zamyatin, Igor
>  wrote:
> >> Hi all!
> >>
> >> The following patch fixes the ICE for the cilk code with syntax error.
> >>
> >> Regtested on x86_64.
> >> Ok for trunk and 4.9?
> >>
> >> Thanks,
> >> Igor
> >>
> >>
> >> gcc/c/ChangeLog:
> >>
> >> 2014-05-20  Igor Zamyatin  
> >>
> >> * c-array-notation.c (fix_builtin_array_notation_fn): Check invalid
> >> function parameters.
> >>
> >>
> >> diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c
> >> index 0ac6ba8..127f9a1 100644
> >> --- a/gcc/c/c-array-notation.c
> >> +++ b/gcc/c/c-array-notation.c
> >> @@ -229,6 +229,8 @@ fix_builtin_array_notation_fn (tree an_builtin_fn,
> tree *new_var)
> >> /* Fully fold any EXCESSIVE_PRECISION EXPR that can occur in the
> function
> >>parameter.  */
> >> func_parm = c_fully_fold (func_parm, false, NULL);
> >> +  if (func_parm == error_mark_node)
> >> +return error_mark_node;
> >>
> >> location = EXPR_LOCATION (an_builtin_fn);
> >>
> >
> > You should include a testcase.
> Agreed.  This definitely should include a testcase.
> 
> jeff


[Ada] Implement legality rules for shared volatile variables

2014-05-21 Thread Arnaud Charlet
This patch implements the rules defined in SPARK 2014 RM section C.6. The rules
forbit certain constructs to be labelled as volatile.


-- Source --


--  shared_variables.ads

package Shared_Variables
  with SPARK_Mode => On
is
   type T is new Integer
 with Volatile;  --  OK

   type Colour is (Red, Green, Blue)
 with Volatile;  --  OK

   S : Integer
 with Volatile;  --  OK

   type R is record
  F1 : Integer;
  F2 : Integer with Volatile;  --  illegal, SPARK RM C.6(1)
  F3 : Boolean;
   end record;

   type R2 is record
  F1 : Integer;
  F2 : T;  --  illegal, SPARK RM C.6(2)
   end record;

   type R3 (D : Colour) is record  --  illegal, SPARK RM C.6(3)
  Intensity : Natural;
   end record;

   type R4 (D : Boolean) is record
  F1 : Integer;
   end record with Volatile;--  illegal, SPARK RM C.6(4)

   type R5 (D : Boolean := False) is record
  F1 : Integer;
   end record;  --  legal

   SV : R5 with Volatile;   --  illegal, SPARK RM C.6(4)

   type R6 is tagged record
  F1 : Integer;
   end record with Volatile;--  illegal, SPARK RM C.6(5)

   type R7 is tagged record
  F1 : Integer;
   end record;  --  legal

   SV2 : R7 with Volatile;  --  illegal, SPARK RM C.6(5)
end Shared_Variables;


-- Compilation and output --


$ gcc -c shared_variables.ads
shared_variables.ads:15:07: component "F2" of non-volatile record type "R"
  cannot be volatile
shared_variables.ads:15:25: argument of aspect "Volatile" must denote a full
  type or object declaration
shared_variables.ads:21:07: component "F2" of non-volatile record type "R2"
  cannot be volatile
shared_variables.ads:24:13: discriminant cannot be volatile
shared_variables.ads:28:09: discriminated type "R4" cannot be volatile
shared_variables.ads:36:04: discriminated object "SV" cannot be volatile
shared_variables.ads:38:09: tagged type "R6" cannot be volatile
shared_variables.ads:46:04: tagged object "SV2" cannot be volatile

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

2014-05-21  Hristian Kirtchev  

* freeze.adb (Freeze_Record_Type): Ensure that a discriminated
or a tagged type is not labelled as volatile. Ensure that a
non-volatile type has no volatile components.
* sem_ch3.adb (Analyze_Object_Contract): Add local constant
Obj_Typ. Code reformatting.  Ensure that a discriminated or
tagged object is not labelled as volatile.
* sem_prag.adb (Process_Atomic_Shared_Volatile): Ensure that
pragma Volatile applies to a full type declaration or an object
declaration when SPARK mode is on.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 210695)
+++ sem_ch3.adb (working copy)
@@ -2980,12 +2980,13 @@
-
 
procedure Analyze_Object_Contract (Obj_Id : Entity_Id) is
-  AR_Val : Boolean := False;
-  AW_Val : Boolean := False;
-  ER_Val : Boolean := False;
-  EW_Val : Boolean := False;
-  Prag   : Node_Id;
-  Seen   : Boolean := False;
+  Obj_Typ : constant Entity_Id := Etype (Obj_Id);
+  AR_Val  : Boolean := False;
+  AW_Val  : Boolean := False;
+  ER_Val  : Boolean := False;
+  EW_Val  : Boolean := False;
+  Prag: Node_Id;
+  Seen: Boolean := False;
 
begin
   if Ekind (Obj_Id) = E_Constant then
@@ -3008,26 +3009,43 @@
  --  they are not standard Ada legality rules.
 
  if SPARK_Mode = On then
+if Is_SPARK_Volatile_Object (Obj_Id) then
 
---  A non-volatile object cannot have volatile components
---  (SPARK RM 7.1.3(7)).
+   --  The declaration of a volatile object must appear at the
+   --  library level (SPARK RM 7.1.3(7), C.6(6)).
 
-if not Is_SPARK_Volatile_Object (Obj_Id)
-  and then Has_Volatile_Component (Etype (Obj_Id))
-then
-   Error_Msg_N
- ("non-volatile variable & cannot have volatile components",
-  Obj_Id);
+   if not Is_Library_Level_Entity (Obj_Id) then
+  Error_Msg_N
+("volatile variable & must be declared at library level",
+ Obj_Id);
 
---  The declaration of a volatile object must appear at the library
---  level.
+   --  An object of a discriminated type cannot be volatile
+   --  (SPARK RM C.6(4)).
 
-elsif Is_SPARK_Volatile_Object (Obj_Id)
-  and then not Is_Library_Level_Entity (Obj_Id)
-then
-   Error_Msg_N
- ("volatile variable & must be declared at library level "
-  & "(SPARK RM 7.1.3(5))", Obj_Id);
+   elsif Has_Discri

[Ada] PR ada/9535 improved consistency of stream primitives for datagram sockets

2014-05-21 Thread Arnaud Charlet
This change implements a suggested improvement to the behaviour of
stream primitives for streams backed by datagram sockets: a Read or
Write call now corresponds to exactly one Receive_Socket or Send_Socket call.

Test case:
$ gnatmake -q udp_stream
$ ./udp_stream
Got 5 characters: <>

with Ada.Streams; use Ada.Streams;
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.Sockets; use GNAT.Sockets;

procedure UDP_Stream is
   A : Sock_Addr_Type;
   S1, S2 : Socket_Type;
begin
   Create_Socket (S1, Family_Inet, Socket_Datagram);
   A.Addr := Loopback_Inet_Addr;
   A.Port := Any_Port;
   Bind_Socket (S1, A);
   A := Get_Socket_Name (S1);

   Create_Socket (S2, Family_Inet, Socket_Datagram);
   Connect_Socket (S2, A);

   String'Write (Stream (S2, A), "hello");
   declare
  SEA  : Stream_Element_Array (1 .. 16);
  Last : Stream_Element_Offset;
  Str  : String (1 .. 16);
  for Str'Address use SEA'Address;
  pragma Import (Ada, Str);
   begin
  Read (Stream (S1, A).all, SEA, Last);
  Put_Line
("Got" & Last'Img & " characters: <<"
 & Str (1 .. Integer (Last)) & ">>");
   end;
end UDP_Stream;

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

2014-05-21  Thomas Quinot  

* g-socket.adb (Read and Write for Datagram_Socket_Stream_Type):
Provide a behaviour more consistent with underlying datagram
socket: do not attempt to loop over Send_Socket/Receive_Socket
iterating along the buffer.

Index: g-socket.adb
===
--- g-socket.adb(revision 210687)
+++ g-socket.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
--- Copyright (C) 2001-2013, AdaCore --
+-- Copyright (C) 2001-2014, AdaCore --
 --  --
 -- 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- --
@@ -244,13 +244,6 @@
  (Stream : in out Stream_Socket_Stream_Type;
   Item   : Ada.Streams.Stream_Element_Array);
 
-   procedure Stream_Write
- (Socket : Socket_Type;
-  Item   : Ada.Streams.Stream_Element_Array;
-  To : access Sock_Addr_Type);
-   --  Common implementation for the Write operation of Datagram_Socket_Stream_
-   --  Type and Stream_Socket_Stream_Type.
-
procedure Wait_On_Socket
  (Socket   : Socket_Type;
   For_Read : Boolean;
@@ -1732,27 +1725,12 @@
   Item   : out Ada.Streams.Stream_Element_Array;
   Last   : out Ada.Streams.Stream_Element_Offset)
is
-  First : Ada.Streams.Stream_Element_Offset  := Item'First;
-  Index : Ada.Streams.Stream_Element_Offset  := First - 1;
-  Max   : constant Ada.Streams.Stream_Element_Offset := Item'Last;
-
begin
-  loop
- Receive_Socket
-   (Stream.Socket,
-Item (First .. Max),
-Index,
-Stream.From);
-
- Last := Index;
-
- --  Exit when all or zero data received. Zero means that the socket
- --  peer is closed.
-
- exit when Index < First or else Index = Max;
-
- First := Index + 1;
-  end loop;
+  Receive_Socket
+(Stream.Socket,
+ Item,
+ Last,
+ Stream.From);
end Read;
 
--
@@ -2419,43 +2397,6 @@
   return Stream_Access (S);
end Stream;
 
-   --
-   -- Stream_Write --
-   --
-
-   procedure Stream_Write
- (Socket : Socket_Type;
-  Item   : Ada.Streams.Stream_Element_Array;
-  To : access Sock_Addr_Type)
-   is
-  First : Ada.Streams.Stream_Element_Offset;
-  Index : Ada.Streams.Stream_Element_Offset;
-  Max   : constant Ada.Streams.Stream_Element_Offset := Item'Last;
-
-   begin
-  First := Item'First;
-  Index := First - 1;
-  while First <= Max loop
- Send_Socket (Socket, Item (First .. Max), Index, To);
-
- --  Exit when all or zero data sent. Zero means that the socket has
- --  been closed by peer.
-
- exit when Index < First or else Index = Max;
-
- First := Index + 1;
-  end loop;
-
-  --  For an empty array, we have First > Max, and hence Index >= Max (no
-  --  error, the loop above is never executed). After a successful send,
-  --  Index = Max. The only remaining case, Index < Max, is therefore
-  --  always an actual send failure.
-
-  if Index < Max then
- Raise_Socket_Error (Socket_Errno);
-  end if;
-   end Stream_Write;
-
--
-- To_C --
--
@@ -2695,8 +2636,20 @@
  (Stream : in 

Re: [PATCH] Fix PR 61225

2014-05-21 Thread Steven Bosscher
On Wed, May 21, 2014 at 11:58 AM, Zhenqiang Chen wrote:
> Hi,
>
> The patch fixes the gcc.target/i386/pr49095.c FAIL in PR61225. The
> test case tends to check a peephole2 optimization, which optimizes the
> following sequence
>
> 2: bx:SI=ax:SI
> 25: ax:SI=[bx:SI]
> 7: {ax:SI=ax:SI-0x1;clobber flags:CC;}
> 8: [bx:SI]=ax:SI
> 9: flags:CCZ=cmp(ax:SI,0)
> to
>2: bx:SI=ax:SI
>41: {flags:CCZ=cmp([bx:SI]-0x1,0);[bx:SI]=[bx:SI]-0x1;}
>
> The enhanced shrink-wrapping, which calls copyprop_hardreg_forward
> changes the INSN 25 to
>
> 25: ax:SI=[ax:SI]
>
> Then peephole2 can not optimize it since two memory_operands look like
> different.
>
> To fix it, the patch adds another peephole2 rule to read one more
> insn. From the register copy, it knows the address is the same.

That is one complex peephole2 to deal with a transformation like this.
It seems to be like it's a too specific solution for a bigger problem.

Could you please try one of the following solutions instead:

1. Track register values for peephole2 and try different alternatives
based on known register equivalences? E.g. in your example, perhaps
there is already a REG_EQUAL/REG_EQUIV note available on insn 25 after
copyprop_hardreg_forward, to annotate that [ax:SI] is equivalent to
[bx:SI] at that point (or if that information is not available, it is
not very difficult to make it available). Then you could try applying
peephole2 on the original pattern but also on patterns modified with
the known equivalences (i.e. try peephole2 on multiple equivalent
patterns for the same insn). This may expose other peephole2
opportunities, not just the specific one your patch addresses.

2. Avoid copy-prop'ing ax:SI into [bx:SI] to begin with. At insn 7,
both ax:SI and bx:SI are live, so insn 2 is not dead (i.e. cannot be
eliminated) and there is no benefit in this transformation. It only
hides (or at least makes it harder to see) that [ax:SI] in insn 25 is
the same memory reference as [bx:SI] in insn 8. So perhaps the copy
propagation should simply not be done unless it turns at least one
instruction into dead code.


Any reason why this transformation isn't done much earlier, e.g. in combine?

Ciao!
Steven


[Ada] Fix error of not diagnosing bad body with non-standard file names

2014-05-21 Thread Arnaud Charlet
If Source_File_Name pragmas with patterns were used to specify a non-
standard naming scheme, then the compiler would fail to diagnose an
attempt to compile a spec which did not need a body when in fact a
body file was present.

Given a gnat.adc file containing:

 1. pragma Source_File_Name_Project
 2.   (Spec_File_Name  => "*.1.ada",
 3.Casing  => lowercase,
 4.Dot_Replacement => "-");
 5. pragma Source_File_Name_Project
 6.   (Body_File_Name  => "*.2.ada",
 7.Casing  => lowercase,
 8.Dot_Replacement => "-");

where pkg.1.ada contains

 1. package Pkg is end;

and pkg.2.ada contains

 1. package body Pkg is end;

the compiling the spec using gcc -c -x ada pkg.1.ada generates

 1. package Pkg is end;
|
>>> package "Pkg" does not allow a body
>>> remove incorrect body in file "pkg.2.ada"

Previously this message was not given in this case

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

2014-05-21  Robert Dewar  

* gnat1drv.adb (Check_Bad_Body): Use Source_File_Is_Body to
simplify the needed test, and also deal with failure to catch
situations with non-standard names.
* sinput-l.ads, sinput-l.adb (Source_File_Is_No_Body): New function
(Source_File_Is_Subunit): Removed, no longer used.

Index: gnat1drv.adb
===
--- gnat1drv.adb(revision 210687)
+++ gnat1drv.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- --
@@ -633,7 +633,6 @@
  Sname := Unit_Name (Main_Unit);
 
  --  If we do not already have a body name, then get the body name
- --  (but how can we have a body name here???)
 
  if not Is_Body_Name (Sname) then
 Sname := Get_Body_Name (Sname);
@@ -651,19 +650,15 @@
  --  to include both in a partition, this is diagnosed at bind time. In
  --  Ada 83 mode this is not a warning case.
 
- --  Note: if weird file names are being used, we can have a situation
- --  where the file name that supposedly contains body in fact contains
- --  a spec, or we can't tell what it contains. Skip the error message
- --  in these cases.
+ --  Note that in general we do not give the message if the file in
+ --  question does not look like a body. This includes weird cases,
+ --  but in particular means that if the file is just a No_Body pragma,
+ --  then we won't give the message (that's the whole point of this
+ --  pragma, to be used this way and to cause the body file to be
+ --  ignored in this context).
 
- --  Also ignore body that is nothing but pragma No_Body; (that's the
- --  whole point of this pragma, to be used this way and to cause the
- --  body file to be ignored in this context).
-
  if Src_Ind /= No_Source_File
-   and then Get_Expected_Unit_Type (Fname) = Expect_Body
-   and then not Source_File_Is_Subunit (Src_Ind)
-   and then not Source_File_Is_No_Body (Src_Ind)
+   and then Source_File_Is_Body (Src_Ind)
  then
 Errout.Finalize (Last_Call => False);
 
@@ -693,8 +688,8 @@
 else
--  For generic instantiations, we never allow a body
 
-   if Nkind (Original_Node (Unit (Main_Unit_Node)))
-   in N_Generic_Instantiation
+   if Nkind (Original_Node (Unit (Main_Unit_Node))) in
+N_Generic_Instantiation
then
   Bad_Body_Error
 ("generic instantiation for $$ does not allow a body");
Index: sinput-l.adb
===
--- sinput-l.adb(revision 210687)
+++ sinput-l.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. --
 --  

[Ada] Do not complain about restricted references within defining units

2014-05-21 Thread Arnaud Charlet
Restrictions No_Abort_Statements and No_Dynamic_Attachment follow exactly
the RM rule which forbids any references to certain entities. But this
should not apply to the units in which these entities are declared, since
otherwise, for example, a pragma Inline for one of these entities is a
violation of this restriction. This patch avoids complaining about any
reference to restricted entities from within their own extended units.

Given a gnat.adc file containing

pragma Restrictions (No_Abort_Statements);

with this patch, you can compile s-taside.ads using -gnatc -gnatg
and the compilation does not flag a restriction violation.

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

2014-05-21  Robert Dewar  

* sem_util.adb (Set_Entity_With_Checks): Don't complain about
references to restricted entities within the units in which they
are declared.

Index: sem_util.adb
===
--- sem_util.adb(revision 210695)
+++ sem_util.adb(working copy)
@@ -15877,6 +15877,11 @@
 
   if Restriction_Check_Required (No_Abort_Statements)
 and then (Is_RTE (Val, RE_Abort_Task))
+
+--  A special extra check, don't complain about a reference from within
+--  the Ada.Task_Identification package itself!
+
+and then not In_Same_Extended_Unit (N, Val)
   then
  Check_Restriction (No_Abort_Statements, Post_Node);
   end if;
@@ -15892,6 +15897,10 @@
   Is_RTE (Val, RE_Exchange_Handler) or else
   Is_RTE (Val, RE_Detach_Handler)   or else
   Is_RTE (Val, RE_Reference))
+--  A special extra check, don't complain about a reference from within
+--  the Ada.Interrupts package itself!
+
+and then not In_Same_Extended_Unit (N, Val)
   then
  Check_Restriction (No_Dynamic_Attachment, Post_Node);
   end if;


[Ada] Add missing entities to Stand.Tree_Read and Stand.Tree_Write

2014-05-21 Thread Arnaud Charlet
Several entities were not written by Tree_Write and correspondingly
not set by Tree_Read. Theoretically this could affect ASIS if it used
any routines needing these entities, but we have never observed any
issues in this area, so it is likely this is just a latent bug with
no observable functional effect. No test required.

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

2014-05-21  Robert Dewar  

* stand.adb (Tree_Read): Read missing entities.
(Tree_Write): Write missing entities.

Index: stand.adb
===
--- stand.adb   (revision 210687)
+++ stand.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- --
@@ -29,6 +29,7 @@
 --  --
 --
 
+with Elists;  use Elists;
 with System;  use System;
 with Tree_IO; use Tree_IO;
 
@@ -46,9 +47,32 @@
   Tree_Read_Int (Int (Standard_Package_Node));
   Tree_Read_Int (Int (Last_Standard_Node_Id));
   Tree_Read_Int (Int (Last_Standard_List_Id));
+
+  Tree_Read_Int (Int (Boolean_Literals (False)));
+  Tree_Read_Int (Int (Boolean_Literals (True)));
+
   Tree_Read_Int (Int (Standard_Void_Type));
   Tree_Read_Int (Int (Standard_Exception_Type));
   Tree_Read_Int (Int (Standard_A_String));
+  Tree_Read_Int (Int (Standard_A_Char));
+  Tree_Read_Int (Int (Standard_Debug_Renaming_Type));
+
+  --  Deal with Predefined_Float_Types, which is an Elist. We wrote the
+  --  entities out in sequence, terminated by an Empty entry.
+
+  declare
+ Elmt : Entity_Id;
+  begin
+ Predefined_Float_Types := New_Elmt_List;
+ loop
+Tree_Read_Int (Int (Elmt));
+exit when Elmt = Empty;
+Append_Elmt (Elmt, Predefined_Float_Types);
+ end loop;
+  end;
+
+  --  Remainder of special entities
+
   Tree_Read_Int (Int (Any_Id));
   Tree_Read_Int (Int (Any_Type));
   Tree_Read_Int (Int (Any_Access));
@@ -59,10 +83,12 @@
   Tree_Read_Int (Int (Any_Discrete));
   Tree_Read_Int (Int (Any_Fixed));
   Tree_Read_Int (Int (Any_Integer));
+  Tree_Read_Int (Int (Any_Modular));
   Tree_Read_Int (Int (Any_Numeric));
   Tree_Read_Int (Int (Any_Real));
   Tree_Read_Int (Int (Any_Scalar));
   Tree_Read_Int (Int (Any_String));
+  Tree_Read_Int (Int (Raise_Type));
   Tree_Read_Int (Int (Universal_Integer));
   Tree_Read_Int (Int (Universal_Real));
   Tree_Read_Int (Int (Universal_Fixed));
@@ -70,12 +96,12 @@
   Tree_Read_Int (Int (Standard_Integer_16));
   Tree_Read_Int (Int (Standard_Integer_32));
   Tree_Read_Int (Int (Standard_Integer_64));
-  Tree_Read_Int (Int (Standard_Unsigned_64));
   Tree_Read_Int (Int (Standard_Short_Short_Unsigned));
   Tree_Read_Int (Int (Standard_Short_Unsigned));
   Tree_Read_Int (Int (Standard_Unsigned));
   Tree_Read_Int (Int (Standard_Long_Unsigned));
   Tree_Read_Int (Int (Standard_Long_Long_Unsigned));
+  Tree_Read_Int (Int (Standard_Unsigned_64));
   Tree_Read_Int (Int (Abort_Signal));
   Tree_Read_Int (Int (Standard_Op_Rotate_Left));
   Tree_Read_Int (Int (Standard_Op_Rotate_Right));
@@ -96,9 +122,34 @@
   Tree_Write_Int (Int (Standard_Package_Node));
   Tree_Write_Int (Int (Last_Standard_Node_Id));
   Tree_Write_Int (Int (Last_Standard_List_Id));
+
+  Tree_Write_Int (Int (Boolean_Literals (False)));
+  Tree_Write_Int (Int (Boolean_Literals (True)));
+
   Tree_Write_Int (Int (Standard_Void_Type));
   Tree_Write_Int (Int (Standard_Exception_Type));
   Tree_Write_Int (Int (Standard_A_String));
+  Tree_Write_Int (Int (Standard_A_Char));
+  Tree_Write_Int (Int (Standard_Debug_Renaming_Type));
+
+  --  Deal with Predefined_Float_Types, which is an Elist. Write the
+  --  entities out in sequence, terminated by an Empty entry.
+
+  declare
+ Elmt : Elmt_Id;
+
+  begin
+ Elmt := First_Elmt (Predefined_Float_Types);
+ while Present (Elmt) loop
+Tree_Write_Int (Int (Node (Elmt)));
+Next_Elmt (Elmt);
+ end loop;
+
+ Tree_Write_Int (Int (Empty));
+  end;
+
+  --  Remainder of special entries
+
  

[Ada] Allow warning tag in pragma Warnings (Off, string)

2014-05-21 Thread Arnaud Charlet
This patch allows the use of a warning tag as the second parameter of
a pragma Warnings (Off\On, ...) pragma. The effect is to control all
error messages in that category. This tag may be either [-gnatw?] for
a particular category of errors, or [restriction warning] to cover all
restriction warnings, or [enabled by default] to deal with all other
warnings that are set by default.

The following test is compiled with -gnatj55 -gnatl

 1. pragma Restriction_Warnings (No_Wide_Characters);
 2. package RWarnTag2 is
 3.pragma Warnings (Off, "[restriction warning]");
 4.Y : Wide_Wide_Character := 'Y';
 5.pragma Warnings (On, "[restriction warning]");
 6.X : Wide_Wide_Character := 'X';
   |
>>> warning: violation of restriction
"No_Wide_Characters" at line 1

 7. end;

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

2014-05-21  Robert Dewar  

* errout.adb, erroutc.adb, erroutc.ads: Allow warning tag in pragma
Warnings (Off, string).

Index: errout.adb
===
--- errout.adb  (revision 210693)
+++ errout.adb  (working copy)
@@ -1339,14 +1339,16 @@
   Cur := First_Error_Msg;
   while Cur /= No_Error_Msg loop
  declare
-CE : Error_Msg_Object renames Errors.Table (Cur);
+CE  : Error_Msg_Object renames Errors.Table (Cur);
+Tag : constant String := Get_Warning_Tag (Cur);
 
  begin
 if (CE.Warn and not CE.Deleted)
-  and then (Warning_Specifically_Suppressed (CE.Sptr, CE.Text) /=
+  and then
+   (Warning_Specifically_Suppressed (CE.Sptr, CE.Text, Tag) /=
No_String
-  or else
-Warning_Specifically_Suppressed (CE.Optr, CE.Text) /=
+  or else
+Warning_Specifically_Suppressed (CE.Optr, CE.Text, Tag) /=
No_String)
 then
Delete_Warning (Cur);
Index: erroutc.adb
===
--- erroutc.adb (revision 210693)
+++ erroutc.adb (working copy)
@@ -1457,7 +1457,8 @@
 
function Warning_Specifically_Suppressed
  (Loc : Source_Ptr;
-  Msg : String_Ptr) return String_Id
+  Msg : String_Ptr;
+  Tag : String) return String_Id
is
begin
   --  Loop through specific warning suppression entries
@@ -1473,7 +1474,9 @@
 if SWE.Config
   or else (SWE.Start <= Loc and then Loc <= SWE.Stop)
 then
-   if Matches (Msg.all, SWE.Msg.all) then
+   if Matches (Msg.all, SWE.Msg.all)
+ or else Matches (Tag, SWE.Msg.all)
+   then
   SWE.Used := True;
   return SWE.Reason;
end if;
Index: erroutc.ads
===
--- erroutc.ads (revision 210693)
+++ erroutc.ads (working copy)
@@ -556,12 +556,14 @@
 
function Warning_Specifically_Suppressed
  (Loc : Source_Ptr;
-  Msg : String_Ptr) return String_Id;
+  Msg : String_Ptr;
+  Tag : String) return String_Id;
--  Determines if given message to be posted at given location is suppressed
--  by specific ON/OFF Warnings pragmas specifying this particular message.
--  If the warning is not suppressed then No_String is returned, otherwise
--  the corresponding warning string is returned (or the null string if no
-   --  Warning argument was present in the pragma).
+   --  Warning argument was present in the pragma). Tag is the error message
+   --  tag for the message in question.
 
function Warning_Treated_As_Error (Msg : String) return Boolean;
--  Returns True if the warning message Msg matches any of the strings


[patch] check that sys/sdt.h can be used with the target

2014-05-21 Thread Matthias Klose
The HAVE_SYS_SDT_H define succeeds when the file sys/sdt.h is found. It doesn't
use the target compiler for that check, like AC_CHECK_HEADER does.  This patch
uses AC_COMPILE to check for the header and ensure that a dummy program succeeds
to build.

This is a different patch than the one proposed at
https://gcc.gnu.org/ml/gcc-patches/2012-12/msg01122.html

I think the conditional with the file check can be removed too, kept it for now.

Ok for the trunk?

  Matthias


PR other/61257
* configure.ac: Build a test program before defining HAVE_SYS_SDT_H.
* configure: Regenerate.

Index: gcc/configure.ac
===
--- gcc/configure.ac(revision 210677)
+++ gcc/configure.ac(working copy)
@@ -4971,9 +4971,13 @@
 AC_MSG_CHECKING(sys/sdt.h in the target C library)
 have_sys_sdt_h=no
 if test -f $target_header_dir/sys/sdt.h; then
-  have_sys_sdt_h=yes
-  AC_DEFINE(HAVE_SYS_SDT_H, 1,
-[Define if your target C library provides sys/sdt.h])
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]],
+ [[DTRACE_PROBE(foo,bar); return 0;]])
+],[
+ have_sys_sdt_h=yes
+ AC_DEFINE(HAVE_SYS_SDT_H, 1,
+   [Define if your target C library provides sys/sdt.h])
+])
 fi
 AC_MSG_RESULT($have_sys_sdt_h)
 


Re: [Patch, GCC/Thumb1] Improve 64bit constant load for Thumb1

2014-05-21 Thread Ramana Radhakrishnan
On Wed, May 21, 2014 at 10:29 AM, Terry Guo  wrote:
>
>
>> -Original Message-
>> From: Ramana Radhakrishnan [mailto:ramana@googlemail.com]
>> Sent: Wednesday, May 21, 2014 4:56 PM
>> To: Terry Guo
>> Cc: gcc-patches; Richard Earnshaw; Ramana Radhakrishnan
>> Subject: Re: [Patch, GCC/Thumb1] Improve 64bit constant load for Thumb1
>>
>> -(define_split
>> +; Split the load of 64-bit constant into two loads for high and low
>> 32-bit parts respectively
>> +; to see if we can load them in fewer instructions or fewer cycles.
>> +; For the small 64-bit integer constants that satisfy constraint J,
>> the instruction pattern
>> +; thumb1_movdi_insn has a better way to handle them.
>> >+(define_split
>> >+  [(set (match_operand:ANY64 0 "arm_general_register_operand" "")
>> >+(match_operand:ANY64 1 "const_double_operand" ""))]
>> >+  "TARGET_THUMB1 && reload_completed && !satisfies_constraint_J
>> (operands[1])"
>> >+  [(set (match_dup 0) (match_dup 1))
>> >+   (set (match_dup 2) (match_dup 3))]
>>
>> Not ok - this splitter used to kick in in ARM state, now you've turned it 
>> off.
>> Look at the movdi patterns in ARM state which deal with it immediate
>> moves with a #.
>>
>> So, the condition should read
>>
>> (TARGET_32BIT) || ( TARGET_THUMB1 && )
>>
>> Ok with that change and if no regressions.
>>
>> regards
>> Ramana
>>
>
> Thanks for reviewing. This is a total new splitter dedicated for Thumb1 
> targets. The one for ARM isn't touched.
>

Bah - sorry I must have misread the patch. This is OK - please apply.
I was changing a very similar splitter yesterday so that I could
define TARGET_SUPPORTS_WIDE_INT and which is why I must have misread
it.


Ramana

> BR,
> Terry
>
>>
>>
>>
>> On Fri, Apr 11, 2014 at 8:36 AM, Terry Guo  wrote:
>> > Hi there,
>> >
>> > Current gcc prefers to using two LDR instructions to load 64bit constants.
>> > This could miss some chances that 64bit load can be done in fewer
>> > instructions or fewer cycles. For example, below code to load
>> > 0x10001
>> >
>> > mov r0, #1
>> > mov r1, #1
>> >
>> > is better than current solution:
>> >
>> > ldr r1, .L2+4
>> > ldr r0, .L2
>> > .L2:
>> > .word   1
>> > .word   1
>> >
>> > The attached patch intends to split 64bit load to take advantage of
>> > such chances. Tested with gcc regression test on cortex-m0. No new
>> regressions.
>> >
>> > Is it ok to stage 1?
>> >
>> > BR,
>> > Terry
>> >
>> > gcc/
>> > 2014-04-11  Terry Guo  
>> >
>> > * config/arm/arm.md (split 64-bit constant for Thumb1): New
>> > split pattern.
>> >
>> > gcc/testsuite/
>> > 2014-04-11  Terry Guo  
>> >
>> > * gcc.target/arm/thumb1-load-64bit-constant-1.c: New test.
>> > * gcc.target/arm/thumb1-load-64bit-constant-2.c: Ditto.
>> > * gcc.target/arm/thumb1-load-64bit-constant-3.c: Ditto.
>
>
>


[Ada] Clearer documentation of -gnatw.g and -gnatyg switches

2014-05-21 Thread Arnaud Charlet
This patch provides more precise documentation of the GNAT mode warning
switch -gnatw.g and the GNAT mode style switch -gnatyg, in both the users
guide and the usage information. Documentation change only, no test needed.

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

2014-05-21  Robert Dewar  

* gnat_ugn.texi: Clearly document -gnatw.g (GNAT warnings).
Clearly document -gnatyg (GNAT style switches).
* usage.adb: Add line line for -gnatw.g (GNAT warnings) More
detail for line for -gnatyg (GNAT style switches) -gnatw.d/D is
available for VMS after all.
* warnsw.adb: Reorganize to eliminate duplicated code
(Restore_Warnings): Add a couple of missing entries
(Save_Warnings): Add a couple of missing entries.
* warnsw.ads: Add missing entries to Warning_Record (not clear
what the impact is).

Index: usage.adb
===
--- usage.adb   (revision 210687)
+++ usage.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- --
@@ -121,8 +121,8 @@
Write_Eol;
 
--  Individual lines for switches. Write_Switch_Char outputs fourteen
-   --  characters, so the remaining message is allowed to be a maximum
-   --  of 65 characters to be comfortable in an 80 character window.
+   --  characters, so the remaining message is allowed to be a maximum of
+   --  65 characters to be comfortable in an 80 character window.
 
--  Line for -gnata switch
 
@@ -494,16 +494,8 @@
Write_Line (".C*  turn off warnings for unrepped components");
Write_Line ("dturn on warnings for implicit dereference");
Write_Line ("D*   turn off warnings for implicit dereference");
-
-   --  Switches -gnatw.d/w.D not available on VMS
-
-   if not OpenVMS_On_Target then
-  Write_Line
-(".d   turn on tagging of warnings with -gnatw switch");
-  Write_Line
-(".D*  turn off tagging of warnings with -gnatw switch");
-   end if;
-
+   Write_Line (".d   turn on tagging of warnings with -gnatw switch");
+   Write_Line (".D*  turn off tagging of warnings with -gnatw switch");
Write_Line ("etreat all warnings (but not info) as errors");
Write_Line (".e   turn on every optional info/warning " &
   "(no exceptions)");
@@ -511,6 +503,7 @@
Write_Line ("F*   turn off warnings for unreferenced formal");
Write_Line ("g*+  turn on warnings for unrecognized pragma");
Write_Line ("Gturn off warnings for unrecognized pragma");
+   Write_Line (".g   turn on GNAT warnings, same as Aao.sI.C.V.X");
Write_Line ("hturn on warnings for hiding declarations");
Write_Line ("H*   turn off warnings for hiding declarations");
Write_Line (".h   turn on warnings for holes in records");
@@ -640,7 +633,7 @@
Write_Line ("dcheck no DOS line terminators");
Write_Line ("echeck end/exit labels present");
Write_Line ("fcheck no form feeds/vertical tabs in source");
-   Write_Line ("gcheck standard GNAT style rules");
+   Write_Line ("gcheck standard GNAT style rules, same as ydISux");
Write_Line ("hcheck no horizontal tabs in source");
Write_Line ("icheck if-then layout");
Write_Line ("Icheck mode in");
Index: gnat_ugn.texi
===
--- gnat_ugn.texi   (revision 210691)
+++ gnat_ugn.texi   (working copy)
@@ -4018,7 +4018,7 @@
 applications programs, it is intended only for use by the compiler
 and its run-time library. For documentation, see the GNAT sources.
 Note that @option{^-gnatg^/GNAT_INTERNAL^} implies
-@option{^-gnatwae^/WARNINGS=ALL,ERRORS^} and
+@option{^-gnatw.ge^/WARNINGS=GNAT,ERRORS^} and
 @option{^-gnatyg^/STYLE_CHECKS=GNAT^}
 so that all standard warnings and all standard style options are turned on.
 All warnings and style messages are treated as errors.
@@ -5167,6 +5167,14 @@
 @cindex @option{-gnatwG} (@command{gcc})
 This switch suppresses warnings for unrecognized pragmas.
 
+@item -gnatw.g
+@emph{Warnings used for GNAT sources}
+@cindex @option{-gnatw.g} (@command{gcc})
+This switch se

[Ada] Tag restriction warning messages

2014-05-21 Thread Arnaud Charlet
Restriction warning messages are now tagged [restriction warning]
if -gnatw.d is used, instead of [enabled by default]. This new
tag can be used in pragma Warning_As_Errors. The following is
compiled with -gnatw.d -gnatj50 -gnatl

 1. pragma Warning_As_Error ("[restriction warning]");
 2. pragma Restriction_Warnings (No_Wide_Characters);
 3. package RWarnTag is
 4.X : Wide_Wide_Character := 'X';
   |
>>> error: violation of restriction
"No_Wide_Characters" at line 2
[restriction warning]
[warning-as-error]

 5. end;

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

2014-05-21  Robert Dewar  

* errout.adb (Set_Msg_Insertion_Warning): Handle ?*? (restriction
warning) case.
* errout.ads: Document ?*? (restriction warning) insertion.
* erroutc.adb (Get_Warning_Tag): Deal with ?*? (restriction
warning) case.
* erroutc.ads: Document use of * for restriction warning tag.
* restrict.adb (Restriction_Msg): Tag with ?*? instead of ??.

Index: errout.adb
===
--- errout.adb  (revision 210687)
+++ errout.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- --
@@ -2764,7 +2764,9 @@
  elsif P + 1 <= Text'Last
and then (Text (P) in 'a' .. 'z'
or else
- Text (P) in 'A' .. 'Z')
+ Text (P) in 'A' .. 'Z'
+   or else
+ Text (P) = '*')
and then Text (P + 1) = C
  then
 Warning_Msg_Char := Text (P);
Index: errout.ads
===
--- errout.ads  (revision 210687)
+++ errout.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- --
@@ -60,10 +60,12 @@
--  Exception raised if Raise_Exception_On_Error is true
 
Warning_Doc_Switch : Boolean renames Err_Vars.Warning_Doc_Switch;
-   --  If this is set True, then the ??/?x?/?X? sequences in error messages
-   --  are active (see errout.ads for details). If this switch is False, then
-   --  these sequences are ignored (i.e. simply equivalent to a single ?). The
-   --  -gnatw.d switch sets this flag True, -gnatw.D sets this flag False.
+   --  If this is set True, then the ??/?*?/?x?/?X? sequences in error messages
+   --  generate appropriate tags for the output error messages. If this switch
+   --  is False, then these sequences are still recognized (for the purposes
+   --  of implementing pragmas Warnings (Off,..) and Warning_As_Pragma(...) but
+   --  do not result in adding the error message tag. The -gnatw.d switch sets
+   --  this flag True, -gnatw.D sets this flag False.
 
---
-- Suppression of Error Messages --
@@ -281,7 +283,7 @@
--  messages, and the usual style is to include it, since it makes it
--  clear that the continuation is part of a warning message.
--
-   --  Note: this usage is obsolete, use ??, ?x? or ?X? instead to specify
+   --  Note: this usage is obsolete, use ?? ?*? ?x? ?X? instead to specify
--  the string to be added when Warn_Doc_Switch is set to True. If this
--  switch is True, then for simple ? messages it has no effect. This
--  simple form is to ease transition and will be removed later.
@@ -302,6 +304,11 @@
--  letter corresponding to the lower case letter x in the message.
--  For continuations, use this on each continuation message.
 
+   --Insertion character ?*? (restriction warning)
+   --  Like ?, but if the flag Warn_Doc_Switch is True, adds the string
+   --  "[restriction warning]" at the en

[Ada] Fix possible overflow in table handling

2014-05-21 Thread Arnaud Charlet
The Reallocate procedures in g-htable.adb and g-dyntab.adb
are subject to problems with possible intermediate overflow.
This has never been reported to cause problems, but in theory
it could cause performance degradation, so it is now fixed.
No test, because too much trouble to construct, and we have
never had an instance of this reported.

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

2014-05-21  Robert Dewar  

* g-table.adb, g-dyntab.adb (Reallocate): Fix possible overflow in
computing new table size.

Index: g-table.adb
===
--- g-table.adb (revision 210687)
+++ g-table.adb (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
--- Copyright (C) 1998-2013, AdaCore --
+-- Copyright (C) 1998-2014, AdaCore --
 --  --
 -- 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- --
@@ -196,21 +196,25 @@

 
procedure Reallocate is
-  New_Size : size_t;
+  New_Size   : size_t;
+  New_Length : Long_Long_Integer;
 
begin
   if Max < Last_Val then
  pragma Assert (not Locked);
 
+ --  Now increment table length until it is sufficiently large. Use
+ --  the increment value or 10, which ever is larger (the reason
+ --  for the use of 10 here is to ensure that the table does really
+ --  increase in size (which would not be the case for a table of
+ --  length 10 increased by 3% for instance). Do the intermediate
+ --  calculation in Long_Long_Integer to avoid overflow.
+
  while Max < Last_Val loop
-
---  Increase length using the table increment factor, but make
---  sure that we add at least ten elements (this avoids a loop
---  for silly small increment values)
-
-Length := Integer'Max
-(Length * (100 + Table_Increment) / 100,
- Length + 10);
+New_Length :=
+  Long_Long_Integer (Length) *
+(100 + Long_Long_Integer (Table_Increment)) / 100;
+Length := Integer'Max (Integer (New_Length), Length + 10);
 Max := Min + Length - 1;
  end loop;
   end if;
Index: g-dyntab.adb
===
--- g-dyntab.adb(revision 210687)
+++ g-dyntab.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
--- Copyright (C) 2000-2013, AdaCore --
+-- Copyright (C) 2000-2014, AdaCore --
 --  --
 -- 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- --
@@ -187,13 +187,24 @@
 
begin
   if T.P.Max < T.P.Last_Val then
+
+ --  Now increment table length until it is sufficiently large. Use
+ --  the increment value or 10, which ever is larger (the reason
+ --  for the use of 10 here is to ensure that the table does really
+ --  increase in size (which would not be the case for a table of
+ --  length 10 increased by 3% for instance). Do the intermediate
+ --  calculation in Long_Long_Integer to avoid overflow.
+
  while T.P.Max < T.P.Last_Val loop
-New_Length := T.P.Length * (100 + Table_Increment) / 100;
+New_Length :=
+  Integer
+(Long_Long_Integer (T.P.Length) *
+  (100 + Long_Long_Integer (Table_Increment)) / 100);
 
 if New_Length > T.P.Length then
T.P.Length := New_Length;
 else
-   T.P.Length := T.P.Length + 1;
+   T.P.Length := T.P.Length + 10;
 end if;
 
 T.P.Max := Min + T.P.Length - 1;


[Ada] Detect illegal component of dereference of access-to-constant

2014-05-21 Thread Arnaud Charlet
This patch detects an error that was previously undetected. In particular, it
is illegal to rename a subcomponent of an object designated by an
access-to-constant value if that subcomponent depends on discriminants.
The following test should get an error:
% gnatmake -f -q acc_const_test.adb
acc_const_test.adb:17:46: illegal renaming of discriminant-dependent component
gnatmake: "acc_const_test.adb" compilation error
%

with Ada.Text_IO; use Ada.Text_IO;
procedure Acc_Const_Test is

   subtype Int is Integer range 1..100;

   type Desig (Discrim : Int := 1) is
  record
 Discrim_Dependent : String (1..Discrim);
  end record;

   type Ref_Const is access constant Desig;

   Var : aliased Desig := (Discrim => 4, Discrim_Dependent => "abcd");

   Ref_Const_Obj : Ref_Const := Var'Access;

   Char : Character renames Ref_Const_Obj.all.Discrim_Dependent(4);
   -- Illegal in Ada 2005.

begin
   Var := (Discrim => 1, Discrim_Dependent => "X");
   --  Raises C_E in Ada 95.

   Put_Line ("Char = " & Char);
end Acc_Const_Test;

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

2014-05-21  Bob Duff  

* sem_util.adb (Is_Dependent_Component_Of_Mutable_Object):
This was returning False if the Object is a constant view. Fix
it to return True in that case, because it might be a view of
a variable.
(Has_Discriminant_Dependent_Constraint): Fix latent
bug; this function was crashing when passed a discriminant.

Index: sem_util.adb
===
--- sem_util.adb(revision 210689)
+++ sem_util.adb(working copy)
@@ -7300,39 +7300,46 @@
  (Comp : Entity_Id) return Boolean
is
   Comp_Decl  : constant Node_Id := Parent (Comp);
-  Subt_Indic : constant Node_Id :=
- Subtype_Indication (Component_Definition (Comp_Decl));
+  Subt_Indic : Node_Id;
   Constr : Node_Id;
   Assn   : Node_Id;
 
begin
-  if Nkind (Subt_Indic) = N_Subtype_Indication then
- Constr := Constraint (Subt_Indic);
+  --  Discriminants can't depend on discriminants
 
- if Nkind (Constr) = N_Index_Or_Discriminant_Constraint then
-Assn := First (Constraints (Constr));
-while Present (Assn) loop
-   case Nkind (Assn) is
-  when N_Subtype_Indication |
-   N_Range  |
-   N_Identifier
-  =>
- if Depends_On_Discriminant (Assn) then
-return True;
- end if;
+  if Ekind (Comp) = E_Discriminant then
+ return False;
 
-  when N_Discriminant_Association =>
- if Depends_On_Discriminant (Expression (Assn)) then
-return True;
- end if;
+  else
+ Subt_Indic := Subtype_Indication (Component_Definition (Comp_Decl));
 
-  when others =>
- null;
+ if Nkind (Subt_Indic) = N_Subtype_Indication then
+Constr := Constraint (Subt_Indic);
 
-   end case;
+if Nkind (Constr) = N_Index_Or_Discriminant_Constraint then
+   Assn := First (Constraints (Constr));
+   while Present (Assn) loop
+  case Nkind (Assn) is
+ when N_Subtype_Indication |
+  N_Range  |
+  N_Identifier
+   =>
+if Depends_On_Discriminant (Assn) then
+   return True;
+end if;
 
-   Next (Assn);
-end loop;
+ when N_Discriminant_Association =>
+if Depends_On_Discriminant (Expression (Assn)) then
+   return True;
+end if;
+
+ when others =>
+null;
+  end case;
+
+  Next (Assn);
+   end loop;
+end if;
  end if;
   end if;
 
@@ -9740,11 +9747,6 @@
function Is_Dependent_Component_Of_Mutable_Object
  (Object : Node_Id) return Boolean
is
-  P   : Node_Id;
-  Prefix_Type : Entity_Id;
-  P_Aliased   : Boolean := False;
-  Comp: Entity_Id;
-
   function Is_Declared_Within_Variant (Comp : Entity_Id) return Boolean;
   --  Returns True if and only if Comp is declared within a variant part
 
@@ -9759,17 +9761,41 @@
  return Nkind (Parent (Comp_List)) = N_Variant;
   end Is_Declared_Within_Variant;
 
+  P   : Node_Id;
+  Prefix_Type : Entity_Id;
+  P_Aliased   : Boolean := False;
+  Comp: Entity_Id;
+
+  Deref : Node_Id := Object;
+  --  Dereference node, in something like X.all.Y(2)
+
--  Start of processing for Is_Dependent_Component

[Ada] Handling of deferred references with nested prefixed calls

2014-05-21 Thread Arnaud Charlet
When handling deferred references, if an actual that is the prefix of an
enclosing prefixed call has been rewritten, we must use Nkind and Sloc to
identify the corresponding formal. The First_Named_Actual of the enclosing
call may be meaningless after the surrounding expansion.

No simple example available.

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

2014-05-21  Ed Schonberg  

* sem_util.adb (Find_Actual): If an actual that is the prefix
of an enclosing prefixed call has been rewritten, use Nkind
and Sloc to identify the corresponding formal, when handling
deferred references.

Index: sem_util.adb
===
--- sem_util.adb(revision 210687)
+++ sem_util.adb(working copy)
@@ -5518,6 +5518,16 @@
  while Present (Formal) and then Present (Actual) loop
 if Actual = N then
return;
+
+--  An actual that is the prefix in a prefixed call may have
+--  been rewritten in the call, after the deferred reference
+--  was collected. Check if sloc and kinds match.
+
+elsif Sloc (Actual) = Sloc (N)
+  and then Nkind (Actual) = Nkind (N)
+then
+   return;
+
 else
Actual := Next_Actual (Actual);
Formal := Next_Formal (Formal);


[Ada] Add usage line for gnatmake switch -d

2014-05-21 Thread Arnaud Charlet
A new line is added in the gnatmake usage for switch -d:
   -dDisplay compilation progress

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

2014-05-21  Vincent Celier  

* makeusg.adb: Add switch -d to usage.

Index: makeusg.adb
===
--- makeusg.adb (revision 210687)
+++ makeusg.adb (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, 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- --
@@ -86,6 +86,11 @@
   "invoke compiler with mapping file mapp");
Write_Eol;
 
+   --  Line for -d
+
+   Write_Str ("  -d   Display compilation progress");
+   Write_Eol;
+
--  Line for -D
 
Write_Str ("  -D dir   Specify dir as the object directory");


Re: [patch] Remove shadow variable

2014-05-21 Thread Thomas Schwinge
Hi Jim!

On Fri, 9 May 2014 11:03:35 -0500, James Norris  
wrote:
> Removed three occurrences of a shadow variable.
> 
> Bootstrapped and tested on x86-64-unknown-linux-gnu.
> 
> 2014-05-09  James Norris  
> 
> * omp-low.c (expand_parallel_call): Remove shadow variable.
> (expand_omp_taskreg): Likewise.

(Jakub committed this in r210423.)

The shadow gsi in expand_omp_target can also go, I think?  Please commit
that if you agree (but first commit your update to the MAINTAINERS file).


Grüße,
 Thomas


pgpcZNcWY9ZZk.pgp
Description: PGP signature


[PATCH] Fix PR 61225

2014-05-21 Thread Zhenqiang Chen
Hi,

The patch fixes the gcc.target/i386/pr49095.c FAIL in PR61225. The
test case tends to check a peephole2 optimization, which optimizes the
following sequence

2: bx:SI=ax:SI
25: ax:SI=[bx:SI]
7: {ax:SI=ax:SI-0x1;clobber flags:CC;}
8: [bx:SI]=ax:SI
9: flags:CCZ=cmp(ax:SI,0)
to
   2: bx:SI=ax:SI
   41: {flags:CCZ=cmp([bx:SI]-0x1,0);[bx:SI]=[bx:SI]-0x1;}

The enhanced shrink-wrapping, which calls copyprop_hardreg_forward
changes the INSN 25 to

25: ax:SI=[ax:SI]

Then peephole2 can not optimize it since two memory_operands look like
different.

To fix it, the patch adds another peephole2 rule to read one more
insn. From the register copy, it knows the address is the same.

Bootstrap and no make check regression on X86-64.

OK for trunk?

Thanks!
-Zhenqiang

ChangeLog:
2014-05-21  Zhenqiang Chen  

Part of PR rtl-optimization/61225
* config/i386/i386.md: New peephole2 rule.
* rtl.c (rtx_equal_p_if_reg_equal): New function.
* rtl.h (rtx_equal_p_if_reg_equal): New prototype.

testsuite/ChangeLog:
2014-05-21  Zhenqiang Chen  

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

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 44e80ec..40639a5 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -17021,6 +17021,49 @@
 operands[5], const0_rtx);
 })

+;; Attempt to use arith or logical operations with memory outputs with
+;; setting of flags.  The difference from previous pattern is that it includes
+;; one more register copy insn, which is copy-forwarded to the address.
+(define_peephole2
+  [(set (match_operand:SWI 6 "register_operand")
+   (match_operand:SWI 0 "register_operand"))
+   (set (match_dup 0)
+   (match_operand:SWI 1 "memory_operand"))
+   (parallel [(set (match_dup 0)
+  (match_operator:SWI 3 "plusminuslogic_operator"
+[(match_dup 0)
+ (match_operand:SWI 2 "")]))
+ (clobber (reg:CC FLAGS_REG))])
+   (set (match_operand:SWI 7 "memory_operand") (match_dup 0))
+   (set (reg FLAGS_REG) (compare (match_dup 0) (const_int 0)))]
+  "(TARGET_READ_MODIFY_WRITE || optimize_insn_for_size_p ())
+   && peep2_reg_dead_p (5, operands[0])
+   && !reg_overlap_mentioned_p (operands[0], operands[2])
+   && !reg_overlap_mentioned_p (operands[0], operands[6])
+   && (GET_MODE (operands[0]) == GET_MODE (operands[6]))
+   && (MEM_ADDR_SPACE (operands[1]) == MEM_ADDR_SPACE (operands[7]))
+   && rtx_equal_p_if_reg_equal (operands[0], operands[6],
+   XEXP (operands[1], 0), XEXP (operands[7], 0))
+   && (mode != QImode
+   || immediate_operand (operands[2], QImode)
+   || q_regs_operand (operands[2], QImode))
+   && ix86_match_ccmode (peep2_next_insn (4),
+(GET_CODE (operands[3]) == PLUS
+ || GET_CODE (operands[3]) == MINUS)
+? CCGOCmode : CCNOmode)"
+  [(set (match_dup 6) (match_dup 0))
+   (parallel [(set (match_dup 4) (match_dup 5))
+ (set (match_dup 1) (match_op_dup 3 [(match_dup 1)
+ (match_dup 2)]))])]
+{
+  operands[4] = SET_DEST (PATTERN (peep2_next_insn (4)));
+  operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[3]), mode,
+   copy_rtx (operands[1]),
+   copy_rtx (operands[2]));
+  operands[5] = gen_rtx_COMPARE (GET_MODE (operands[4]),
+operands[5], const0_rtx);
+})
+
(define_peephole2
   [(parallel [(set (match_operand:SWI 0 "register_operand")
   (match_operator:SWI 2 "plusminuslogic_operator"
diff --git a/gcc/rtl.c b/gcc/rtl.c
index 520f9a8..99418fc 100644
--- a/gcc/rtl.c
+++ b/gcc/rtl.c
@@ -654,6 +654,82 @@ rtx_equal_p (const_rtx x, const_rtx y)
   return 1;
 }

+/* Return 1 if X and Y are equal rtx's if RX used in X and RY used
+   Y are equal.  */
+
+int
+rtx_equal_p_if_reg_equal (const_rtx rx, const_rtx ry,
+ const_rtx x, const_rtx y)
+{
+  int i;
+  enum rtx_code code;
+  const char *fmt;
+
+  gcc_assert (REG_P (rx) && REG_P (ry) && x && y);
+
+  code = GET_CODE (x);
+  /* Rtx's of different codes cannot be equal.  */
+  if (code != GET_CODE (y))
+return 0;
+
+  if (rtx_equal_p (x, y) == 1)
+return 1;
+
+  /* Since rx == ry, if x == rx && y == ry, x == y.  */
+  if (REG_P (x) && REG_P (y)
+  && GET_MODE (x) == GET_MODE (rx)
+  && REGNO (x) == REGNO (rx)
+  && GET_MODE (y) == GET_MODE (ry)
+  && REGNO (y) == REGNO (ry))
+return 1;
+
+  /* Compare the elements.  If any pair of corresponding elements
+ fail to match, return 0 for the whole thing.  */
+
+  fmt = GET_RTX_FORMAT (code);
+  for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
+{
+  switch (fmt[i])
+   {
+   case 'e':
+ if (rtx_equal_p (XEXP (x, i), XEXP (y, i)) == 0)
+   {
+ rtx xi = XEXP (x, i);
+ 

Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-21 Thread Samuel Thibault
Svante Signell, le Wed 21 May 2014 11:42:30 +0200, a écrit :
> On Wed, 2014-05-21 at 11:27 +0200, Samuel Thibault wrote:
> > Guaranteeing long term support *is* about taking up the work of checking
> > periodically that the port works fine.  If anybody does it, then it's
> > fine.  If nobody does it, then the port will be dropped.  It's as simple
> > as this.  You're welcome for doing it of course.
> 
> I've been doing this since 2012 and I said I could continue doing it,
> but that did not seem to be sufficient.

I must have missed an episode then.  The only context I have is

“
That's actually the biggest concern when people submit a new port: they
submit it, get it approved, commit it and then are no longer available
for any maintenance when these files need to be updated/become outdated/
no longer compile or run.
”

Does it mean it is a lack of reviewer/commiter which is pointed out?

> Well dropping patches not upstream is a nop, right?

Yes, sure.

> > > >  I guess that's not what you want, so I don't know what you meant.
> > > 
> > > If that happens -> means if the port is bitrotting for a long time just
> > > remove support upstream. We were talking upstream here, not Debian ...
> > 
> > What support?  I really don't undestand what you mean.
> 
> Remove support for a language for bitrotting architectures (obsolete
> ports) like is done for old Solaris 9 (*-*-solaris2.9)
> http://www.gnu.org/software/gcc/gcc-4.9/changes.html

I fully understand that. What I don't understand is what you said
initially:

“
> > > > > (Of course it can at least run on Debian systems if/when accepted.)
> > > > 
> > > > Sure, but will it continue working on the long term?  That's the concern
> > > > of upstream.
> 
> If that happens why not just remove support for that architecture? The
> same happens for plain C, C++, etc on outdated architectures.
”

Again, what I understand from your "why not just remove support for that
architecture" is that you propose to remove the Hurd port.  I obviously
guess that it's not what you meant, so I don't understand what you
actually meant.

Samuel


Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-21 Thread Svante Signell
On Wed, 2014-05-21 at 11:27 +0200, Samuel Thibault wrote:
> Svante Signell, le Wed 21 May 2014 11:22:44 +0200, a écrit :
> > On Wed, 2014-05-21 at 10:47 +0200, Samuel Thibault wrote:
> > > Svante Signell, le Wed 21 May 2014 10:40:37 +0200, a écrit :
> > > > > > What kind of person do you have to be to be accepted, a GNU/Hurd
> > > > > > developer or a GNU/Ada developer having a gnu.org account?
> > > > > 
> > > > > Nothing special, just like for contributing to any opensource project;
> > > > > just someone who checks from times to times (in particular before
> > > > > releases) that the port works fine, and submit patches if needed.
> > > > 
> > > > I've been working on the Hurd port of gnat since late 2011 including the
> > > > toughest: bootstrapping, does that count?
> > > 
> > > Count for what?
> > > 
> > > Opensource is about patches correctness, not people fame.
> > > 
> > > If anybody, whoever he is, takes up the work and produces correct
> > > patches, then they'll be applied.  It's as simple as this.
> > 
> > In this case if long term support can be guaranteed, yes!
> 
> I don't understand what you mean.
> 
> Guaranteeing long term support *is* about taking up the work of checking
> periodically that the port works fine.  If anybody does it, then it's
> fine.  If nobody does it, then the port will be dropped.  It's as simple
> as this.  You're welcome for doing it of course.

I've been doing this since 2012 and I said I could continue doing it,
but that did not seem to be sufficient.

> > > > > > > > (Of course it can at least run on Debian systems if/when 
> > > > > > > > accepted.)
> > > > > > > 
> > > > > > > Sure, but will it continue working on the long term?  That's the 
> > > > > > > concern
> > > > > > > of upstream.
> > > > 
> > > > If that happens why not just remove support for that architecture? The
> > > > same happens for plain C, C++, etc on outdated architectures.
> > > 
> > > Uh?  I'm not sure what you mean here.  What I understand is "why not
> > > remove support for GNU/Hurd?" which'd mean dropping your patches.
> > 
> > How can they be removed, they are not upstream yet?
> 
> I even less understand what you meant then.

Well dropping patches not upstream is a nop, right?

> > >  I guess that's not what you want, so I don't know what you meant.
> > 
> > If that happens -> means if the port is bitrotting for a long time just
> > remove support upstream. We were talking upstream here, not Debian ...
> 
> What support?  I really don't undestand what you mean.

Remove support for a language for bitrotting architectures (obsolete
ports) like is done for old Solaris 9 (*-*-solaris2.9)
http://www.gnu.org/software/gcc/gcc-4.9/changes.html



Re: CALL_INSN_FUNCTION_USAGE fix, PR52773

2014-05-21 Thread Bernd Schmidt

On 06/19/2013 07:39 PM, Bernd Schmidt wrote:

This is bug that triggers on m68k. The loop unroller creates a MULT
expression and tries to force it into a register, which causes a libcall
to be generated. Since args are pushed we create a
   (use (mem (plus virtual_outgoing_args scratch)))
in CALL_INSN_FUNCTION_USAGE. Since we're past vregs, the
virtual_outgoing_args rtx survives to reload, which blows up.

Fixed by just using stack_pointer_rtx, since we use a scratch anyway
rather than a known offset. I also noticed that we actually add two of
these USEs, so I've fixed that as well.


Ping.

https://gcc.gnu.org/ml/gcc-patches/2013-06/msg01147.html


Bernd



Re: [PATCH, PR C++/61038] - g++ -E is unusable with UDL strings

2014-05-21 Thread Andreas Schwab
Ed Smith-Rowland <3dw...@verizon.net> writes:

> Index: ../gcc/testsuite/g++.dg/cpp0x/pr61038.C
> ===
> --- ../gcc/testsuite/g++.dg/cpp0x/pr61038.C   (revision 0)
> +++ ../gcc/testsuite/g++.dg/cpp0x/pr61038.C   (working copy)
> @@ -0,0 +1,23 @@
> +// PR c++/61038
> +// { dg-do compile { target c++11 } }
> +// { dg-options "-E" }
> +
> +void
> +operator "" _s(const char *, unsigned long)

../../gcc/gcc/testsuite/g++.dg/cpp0x/pr61038.C:8:43: error: ‘void 
operator""_s(const char*, long unsigned int)’ has invalid argument list

Andreas.

* g++.dg/cpp0x/pr61038.C (operator "" _s): Use size_t.

Index: g++.dg/cpp0x/pr61038.C
===
--- g++.dg/cpp0x/pr61038.C  (revision 210686)
+++ g++.dg/cpp0x/pr61038.C  (working copy)
@@ -5,7 +5,7 @@
 #include 
 
 void
-operator "" _s(const char *, unsigned long)
+operator "" _s(const char *, size_t)
 { }
 
 void

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


Re: Reload codegen improvement

2014-05-21 Thread Bernd Schmidt

On 01/07/2014 05:22 PM, Bernd Schmidt wrote:

This fixes a problem identified by Chung-Lin. Once reload is done, all
equivalencing insns for pseudos that didn't get a hard reg but could be
eliminated using their REG_EQUIV are deleted. However, we still can
produce reloads and reload insns for them in certain cases, leading to
unnecessary spilling. This patch corrects this by making sure we use
identical tests when deciding whether to ignore an insn while reloading,
and whether to delete it afterwards.

Bootstrapped and tested on x86_64-linux (with lra_p disabled). Chung-Lin
says he's tested it as well, I think on arm (probably with something 4.8
based). Will commit in a few days if no objections.


I decided to wait until after 4.9.  Now committed after testing on 
bfin-elf - the trick of disabling LRA on x86_64 no longer works, the 
target doesn't build with reload enabled.


(I saw one compare-debug randomly failing or passing, which happens with 
or without this change. It seems to be caused by something in IRA).



Bernd



RE: [Patch, GCC/Thumb1] Improve 64bit constant load for Thumb1

2014-05-21 Thread Terry Guo


> -Original Message-
> From: Ramana Radhakrishnan [mailto:ramana@googlemail.com]
> Sent: Wednesday, May 21, 2014 4:56 PM
> To: Terry Guo
> Cc: gcc-patches; Richard Earnshaw; Ramana Radhakrishnan
> Subject: Re: [Patch, GCC/Thumb1] Improve 64bit constant load for Thumb1
> 
> -(define_split
> +; Split the load of 64-bit constant into two loads for high and low
> 32-bit parts respectively
> +; to see if we can load them in fewer instructions or fewer cycles.
> +; For the small 64-bit integer constants that satisfy constraint J,
> the instruction pattern
> +; thumb1_movdi_insn has a better way to handle them.
> >+(define_split
> >+  [(set (match_operand:ANY64 0 "arm_general_register_operand" "")
> >+(match_operand:ANY64 1 "const_double_operand" ""))]
> >+  "TARGET_THUMB1 && reload_completed && !satisfies_constraint_J
> (operands[1])"
> >+  [(set (match_dup 0) (match_dup 1))
> >+   (set (match_dup 2) (match_dup 3))]
> 
> Not ok - this splitter used to kick in in ARM state, now you've turned it off.
> Look at the movdi patterns in ARM state which deal with it immediate
> moves with a #.
> 
> So, the condition should read
> 
> (TARGET_32BIT) || ( TARGET_THUMB1 && )
> 
> Ok with that change and if no regressions.
> 
> regards
> Ramana
> 

Thanks for reviewing. This is a total new splitter dedicated for Thumb1 
targets. The one for ARM isn't touched.

BR,
Terry

> 
> 
> 
> On Fri, Apr 11, 2014 at 8:36 AM, Terry Guo  wrote:
> > Hi there,
> >
> > Current gcc prefers to using two LDR instructions to load 64bit constants.
> > This could miss some chances that 64bit load can be done in fewer
> > instructions or fewer cycles. For example, below code to load
> > 0x10001
> >
> > mov r0, #1
> > mov r1, #1
> >
> > is better than current solution:
> >
> > ldr r1, .L2+4
> > ldr r0, .L2
> > .L2:
> > .word   1
> > .word   1
> >
> > The attached patch intends to split 64bit load to take advantage of
> > such chances. Tested with gcc regression test on cortex-m0. No new
> regressions.
> >
> > Is it ok to stage 1?
> >
> > BR,
> > Terry
> >
> > gcc/
> > 2014-04-11  Terry Guo  
> >
> > * config/arm/arm.md (split 64-bit constant for Thumb1): New
> > split pattern.
> >
> > gcc/testsuite/
> > 2014-04-11  Terry Guo  
> >
> > * gcc.target/arm/thumb1-load-64bit-constant-1.c: New test.
> > * gcc.target/arm/thumb1-load-64bit-constant-2.c: Ditto.
> > * gcc.target/arm/thumb1-load-64bit-constant-3.c: Ditto.





Re: [PATCH] Add support for GNU/Hurd in gnat-4.9

2014-05-21 Thread Samuel Thibault
Svante Signell, le Wed 21 May 2014 11:22:44 +0200, a écrit :
> On Wed, 2014-05-21 at 10:47 +0200, Samuel Thibault wrote:
> > Svante Signell, le Wed 21 May 2014 10:40:37 +0200, a écrit :
> > > > > What kind of person do you have to be to be accepted, a GNU/Hurd
> > > > > developer or a GNU/Ada developer having a gnu.org account?
> > > > 
> > > > Nothing special, just like for contributing to any opensource project;
> > > > just someone who checks from times to times (in particular before
> > > > releases) that the port works fine, and submit patches if needed.
> > > 
> > > I've been working on the Hurd port of gnat since late 2011 including the
> > > toughest: bootstrapping, does that count?
> > 
> > Count for what?
> > 
> > Opensource is about patches correctness, not people fame.
> > 
> > If anybody, whoever he is, takes up the work and produces correct
> > patches, then they'll be applied.  It's as simple as this.
> 
> In this case if long term support can be guaranteed, yes!

I don't understand what you mean.

Guaranteeing long term support *is* about taking up the work of checking
periodically that the port works fine.  If anybody does it, then it's
fine.  If nobody does it, then the port will be dropped.  It's as simple
as this.  You're welcome for doing it of course.

> > > > > > > (Of course it can at least run on Debian systems if/when 
> > > > > > > accepted.)
> > > > > > 
> > > > > > Sure, but will it continue working on the long term?  That's the 
> > > > > > concern
> > > > > > of upstream.
> > > 
> > > If that happens why not just remove support for that architecture? The
> > > same happens for plain C, C++, etc on outdated architectures.
> > 
> > Uh?  I'm not sure what you mean here.  What I understand is "why not
> > remove support for GNU/Hurd?" which'd mean dropping your patches.
> 
> How can they be removed, they are not upstream yet?

I even less understand what you meant then.

> >  I guess that's not what you want, so I don't know what you meant.
> 
> If that happens -> means if the port is bitrotting for a long time just
> remove support upstream. We were talking upstream here, not Debian ...

What support?  I really don't undestand what you mean.

Samuel


Make the Blackfin port build again

2014-05-21 Thread Bernd Schmidt
This is probably fallout from the 64-bit HWI changes. We can generate an 
invalid CONST_INT due to missing sign extension.


Tested on bfin-elf and committed.


Bernd

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a80370b..ac95586 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,8 @@
 2014-05-21  Bernd Schmidt  
 
+	* config/bfin/bfin.c (split_load_immediate): Use gen_int_mode in a few
+	more places.
+
 	* cfgrtl.c (cfg_layout_initialize): Weaken assert to only trigger if
 	flag_reorder_blocks_and_partition.
 	* hw-doloop.c (reorg_loops): Avoid reordering if that flag is set.
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index f860099..7945de4 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -2588,7 +2588,7 @@ split_load_immediate (rtx operands[])
   && (D_REGNO_P (regno)
 	  || (regno >= REG_P0 && regno <= REG_P7 && num_zero <= 2)))
 {
-  emit_insn (gen_movsi (operands[0], GEN_INT (shifted)));
+  emit_insn (gen_movsi (operands[0], gen_int_mode (shifted, SImode)));
   emit_insn (gen_ashlsi3 (operands[0], operands[0], GEN_INT (num_zero)));
   return 1;
 }
@@ -2602,13 +2602,15 @@ split_load_immediate (rtx operands[])
   if (log2constp (val & 0x))
 	{
 	  emit_insn (gen_movsi (operands[0], GEN_INT (val & 0x)));
-	  emit_insn (gen_iorsi3 (operands[0], operands[0], GEN_INT (val & 0x)));
+	  emit_insn (gen_iorsi3 (operands[0], operands[0],
+ gen_int_mode (val & 0x, SImode)));
 	  return 1;
 	}
   else if (log2constp (val | 0x) && (val & 0x8000) != 0)
 	{
 	  emit_insn (gen_movsi (operands[0], GEN_INT (tmp)));
-	  emit_insn (gen_andsi3 (operands[0], operands[0], GEN_INT (val | 0x)));
+	  emit_insn (gen_andsi3 (operands[0], operands[0],
+ gen_int_mode (val | 0x, SImode)));
 	}
 }
 
@@ -2617,7 +2619,9 @@ split_load_immediate (rtx operands[])
   if (tmp >= -64 && tmp <= 63)
 	{
 	  emit_insn (gen_movsi (operands[0], GEN_INT (tmp)));
-	  emit_insn (gen_movstricthi_high (operands[0], GEN_INT (val & -65536)));
+	  emit_insn (gen_movstricthi_high (operands[0],
+	   gen_int_mode (val & -65536,
+			 SImode)));
 	  return 1;
 	}
 
@@ -2645,7 +2649,7 @@ split_load_immediate (rtx operands[])
 {
   /* If optimizing for size, generate a sequence that has more instructions
 	 but is shorter.  */
-  emit_insn (gen_movsi (operands[0], GEN_INT (shifted_compl)));
+  emit_insn (gen_movsi (operands[0], gen_int_mode (shifted_compl, SImode)));
   emit_insn (gen_ashlsi3 (operands[0], operands[0],
 			  GEN_INT (num_compl_zero)));
   emit_insn (gen_one_cmplsi2 (operands[0], operands[0]));


Re: [Patch, bfin/c6x] Fix ICE for backends that rely on reorder_loops.

2014-05-21 Thread Bernd Schmidt

On 01/09/2014 05:20 AM, Jeff Law wrote:

On 01/07/14 09:07, Bernd Schmidt wrote:



If someone explicitly chooses that option we can turn off the reordering
in hw-doloop. That should happen sufficiently rarely that it isn't a
problem. That's what the patch below does - bootstraped on x86_64-linux,
tested there and with bfin-elf. Ok?

Yes.  This is fine.


Looks like I got sufficiently distracted by travel and other things that 
this never got checked in. Now fixed.



Bernd




  1   2   >