[ARM] Fix neon-reload-class.c testcase

2015-06-05 Thread Kugan
Hi All,

After my patch for cprop is committed
(https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=224048),
neon-reload-class.c is failing in arm mode. But this is kind of expected
behaviour so I looked at the original patch related to
neon-reload-class.c, which is:
https://gcc.gnu.org/ml/gcc-patches/2011-04/msg01968.html

As I understand, it was added to make sure that these constants are not
created as constant pool. from that point of view it looks like we
should remove the check for movw/movt.

I also checked the asm generated before the constant split for arm
(https://gcc.gnu.org/viewcvs?rev=223235&root=gcc&view=rev) just to be
sure that this is not due to the earlier patch. Reason for this is that
the constant generation has changed compared to what was shown in
https://gcc.gnu.org/ml/gcc-patches/2011-04/msg01968.html.


I am also attaching the three versions of the neon-reload-class.s.

1. neon-reload-class_before_arm_split.s - before r223235
2. neon-reload-class_before_cprop.s - before r224048
3. neon-reload-class_new.s - after 224048

Is this OK for trunk?

Thanks,
Kugan

gcc/testsuite/ChangeLog:

2015-06-05  Kugan Vivekanandarajah  

* gcc.target/arm/neon-reload-class.c: Remove movw and movt.


diff --git a/gcc/testsuite/gcc.target/arm/neon-reload-class.c 
b/gcc/testsuite/gcc.target/arm/neon-reload-class.c
index c63aa04..48950f7 100644
--- a/gcc/testsuite/gcc.target/arm/neon-reload-class.c
+++ b/gcc/testsuite/gcc.target/arm/neon-reload-class.c
@@ -15,4 +15,4 @@ _op_blend_p_caa_dp(unsigned *s, unsigned* e, unsigned *d, 
unsigned c) {
 
 /* These constants should be emitted as immediates rather than loaded from 
memory.  */
 
-/* { dg-final { scan-assembler-not "(\\.d?word|mov(w|t))" } } */
+/* { dg-final { scan-assembler-not "(\\.d?word)" } } */
.arch armv7-a
.fpu neon
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 2
.eabi_attribute 30, 2
.eabi_attribute 34, 1
.eabi_attribute 18, 4
.arm
.syntax divided
.file   "neon-reload-class.c"
.text
.align  2
.global _op_blend_p_caa_dp
.type   _op_blend_p_caa_dp, %function
_op_blend_p_caa_dp:
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 0, uses_anonymous_args = 0
cmp r2, r1
bxcslr
stmfd   sp!, {r4, r5, r6, r7, lr}
add r6, r1, #3
add lr, r2, #4
add r4, r2, #16
sub r6, r6, lr
add r7, r0, #16
mov r5, r4
cmp r2, r7
cmpcc   r0, r5
mov ip, r6, lsr #2
mov r4, r7
add r5, ip, #1
movcs   r4, #1
movcc   r4, #0
cmp r5, #4
movls   r4, #0
andhi   r4, r4, #1
cmp r4, #0
beq .L3
sub ip, ip, #3
cmp r6, #11
mov ip, ip, lsr #2
add ip, ip, #1
mov r7, ip, asl #2
bls .L4
vdup.32 q10, r3
mov r6, r0
mov r4, r2
mov lr, #0
.L5:
vld1.32 {q8}, [r6]
add lr, lr, #1
cmp ip, lr
add r6, r6, #16
vmovq9, q8  @ v4si
vshr.u32q8, q8, #8
vand.i16q9, #255
vand.i16q8, #255
vmul.i32q9, q9, q10
vmul.i32q8, q8, q10
vshr.u32q9, q9, #8
vand.i16q9, #255
vand.i16q8, #65280
vadd.i32q8, q8, q9
vst1.32 {q8}, [r4]
add r4, r4, #16
bhi .L5
cmp r5, r7
mov r7, r7, asl #2
add r0, r0, r7
add r2, r2, r7
ldmeqfd sp!, {r4, r5, r6, r7, pc}
add lr, r2, #4
.L4:
mov r5, #255
mov r6, #65280
sub r0, r0, #4
movtr5, 255
movtr6, 65280
.L7:
ldr ip, [r0, #4]!
cmp r1, lr
and r4, ip, r5
and ip, r5, ip, lsr #8
mul r4, r3, r4
mul ip, r3, ip
and r4, r5, r4, lsr #8
and ip, ip, r6
add ip, ip, r4
str ip, [r2]
mov r2, lr
ldmlsfd sp!, {r4, r5, r6, r7, pc}
add lr, lr, #4
b   .L7
.L3:
mov r5, #255
mov r6, #65280
sub r0, r0, #4
movtr5, 255
movtr6, 65280
.L10:
ldr ip, [r0, #4]!
cmp r1, lr
and r4, ip, r5
and ip, r5, ip, lsr #8
mul r4, r3, r4
mul ip, r3, ip
and r4, r5, r4, lsr #8
and ip, ip, r6
add ip, ip, r4
str ip, [r2]
mov r2, lr
ldmlsfd sp!, {r4, r5, r6, r7, pc}
add lr, lr, #4
b   .L10
.size   _op_blend_p_c

Re: [ARM] Fix neon-reload-class.c testcase

2015-06-05 Thread Kyrill Tkachov

Hi Kugan,

On 05/06/15 09:01, Kugan wrote:

Hi All,

After my patch for cprop is committed
(https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=224048),
neon-reload-class.c is failing in arm mode. But this is kind of expected
behaviour so I looked at the original patch related to
neon-reload-class.c, which is:
https://gcc.gnu.org/ml/gcc-patches/2011-04/msg01968.html

As I understand, it was added to make sure that these constants are not
created as constant pool. from that point of view it looks like we
should remove the check for movw/movt.

I also checked the asm generated before the constant split for arm
(https://gcc.gnu.org/viewcvs?rev=223235&root=gcc&view=rev) just to be
sure that this is not due to the earlier patch. Reason for this is that
the constant generation has changed compared to what was shown in
https://gcc.gnu.org/ml/gcc-patches/2011-04/msg01968.html.


I am also attaching the three versions of the neon-reload-class.s.

1. neon-reload-class_before_arm_split.s - before r223235
2. neon-reload-class_before_cprop.s - before r224048
3. neon-reload-class_new.s - after 224048

Is this OK for trunk?


I see that the new code is better and it is indeed still not
loading the immediates from memory, which is what the test tests for.
So as long as scanning for \\.d?word is enough to catch the presence
of a constant pool this should be ok.

Kyrill



Thanks,
Kugan

gcc/testsuite/ChangeLog:

2015-06-05  Kugan Vivekanandarajah  

* gcc.target/arm/neon-reload-class.c: Remove movw and movt.






Re: [PATCH][libstdc++-v3] Add _GLIBCXX_HAVE_LIMIT_FSIZE to guard 27_io/fpos/14775.cc

2015-06-05 Thread Jonathan Wakely
On 4 June 2015 at 16:29, Renlin Li wrote:
> Hi Jonathan,
>
> I have committed it on trunk.
>
> Is it Okay for me to backport it to branch 5.0, 4.9 to remove failing noise?

I accidentally replied off-list yesterday.

Backporting this is OK, thanks.


Re: [GCC, ARM] armv8 linux toolchain asan testcase fail due to stl missing conditional code

2015-06-05 Thread Shiva Chen
Hi, Kyrill

I update the patch as Richard's suggestion.

-  return \"str\t%1, %0\";
+  return \"str%(%)\t%1, %0\";
 else
-  return \"stl\t%1, %0\";
+  return \"stl%?\t%1, %0\";
   }
-)
+  [(set_attr "predicable" "yes")
+   (set_attr "predicable_short_it" "no")])
+  [(set_attr "predicable" "yes")
+   (set_attr "predicable_short_it" "no")])


Let me sum up.

We add predicable attribute to allow gcc do if-conversion in
ce1/ce2/ce3 not only in final phase by final_prescan_insn finite state
machine.

We set predicalble_short_it to "no" to restrict conditional code
generation on armv8 with thumb mode.

However, we could use the flags -mno-restrict-it to force generating
conditional code on thumb mode.

Therefore, we have to consider the assembly output format for strb
with condition code on arm/thumb mode.

Because arm/thumb mode use different syntax for strb,
we output the assembly as str%(%)
which will put the condition code in the right place according to
TARGET_UNIFIED_ASM.

Is there still missing something ?

Thanks,

Shiva

2015-06-04 18:00 GMT+08:00 Kyrill Tkachov :
> Hi Shiva,
>
> On 04/06/15 10:57, Shiva Chen wrote:
>>
>> Hi, Kyrill
>>
>> Thanks for the tips of syntax.
>>
>> It seems that correct syntax for
>>
>> ldrb with condition code is ldreqb
>>
>> ldab with condition code is ldabeq
>>
>>
>> So I modified the pattern as follow
>>
>>{
>>  enum memmodel model = (enum memmodel) INTVAL (operands[2]);
>>  if (model == MEMMODEL_RELAXED
>>  || model == MEMMODEL_CONSUME
>>  || model == MEMMODEL_RELEASE)
>>return \"ldr%?\\t%0, %1\";
>>  else
>>return \"lda%?\\t%0, %1\";
>>}
>>[(set_attr "predicable" "yes")
>> (set_attr "predicable_short_it" "no")])
>>
>> It seems we don't have to worry about thumb mode,
>
>
> I suggest you use Richard's suggestion from:
>  https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00384.html
> to write this in a clean way.
>
>>
>> Because we already set "predicable" "yes" and predicable_short_it" "no"
>> for the pattern.
>
>
> That's not quite true. The user may compile for armv8-a with
> -mno-restrict-it which will turn off this
> restriction for Thumb and allow the conditional execution of this.
> In any case, I think Richard's suggestion above should work.
>
> Thanks,
> Kyrill
>
>
>>
>> The new patch could build gcc and run gcc regression test successfully.
>>
>> Please correct me if I still missing something.
>>
>> Thanks,
>>
>> Shiva
>>
>> -Original Message-
>> From: Richard Earnshaw [mailto:richard.earns...@foss.arm.com]
>> Sent: Thursday, June 04, 2015 4:42 PM
>> To: Kyrill Tkachov; Shiva Chen
>> Cc: Ramana Radhakrishnan; GCC Patches; ni...@redhat.com; Shiva Chen
>> Subject: Re: [GCC, ARM] armv8 linux toolchain asan testcase fail due to
>> stl missing conditional code
>>
>> On 04/06/15 09:17, Kyrill Tkachov wrote:
>>>
>>> Hi Shiva,
>>>
>>> On 04/06/15 04:13, Shiva Chen wrote:

 Hi, Ramana

 Currently, I work for Marvell and the company have copyright assignment
 on file.

 Hi, all

 After adding the attribute and rebuild gcc, I got the assembler error
 message

 load_n.s:39: Error: bad instruction `ldrbeq r0,[r0]'

 When i look into armv8 ISA document, it seems ldrb Encoding A1 have
 conditional code field.

 Does it mean we should also patch assembler or I just miss
 understanding something ?

 Following command use to generate load_n.s:

 /home/shivac/build-system-trunk/Release/build/armv8-marvell-linux-gnu
 eabihf-hard/gcc-final/./gcc/cc1 -fpreprocessed load_n.i -quiet
 -dumpbase load_n.c -march=armv8-a -mfloat-abi=hard -mfpu=fp-armv8
 -mtls-dialect=gnu -auxbase-strip .libs/load_1_.o -g3 -O2 -Wall
 -Werror -version -fPIC -funwind-tables -o load_n.s


 The test.c is a simple test case to reproduce missing conditional
 code in mmap.c.

 Any suggestion ?
>>>
>>> I reproduced the assembler failure with your patch.
>>>
>>> The reason is that for arm mode we use divided syntax, where the
>>> condition field goes in a different place. So, while ldrbeq r0,[r0] is
>>> rejected, ldreqb r0, [r0] works.
>>> Since we always use divided syntax for arm mode, I think you'll need
>>> to put the condition field in the right place depending on arm or thumb
>>> mode.
>>> Ugh, this is becoming ugly :(
>>>
>> Use %(>   The compiler will then put the condition in the correct place.
>>
>> So:
>>
>> +  return \"str%(%)\t%1, %0\";
>>
>> R.
>>
>>> Kyrill
>>>

 Shiva

 2015-06-03 17:29 GMT+08:00 Shiva Chen :
>
> Hi, Ramana
>
> I'm not sure what copyright assignment means ?
>
> Does it mean the patch have copyright assignment or not ?
>
> I update the patch to add "predicable" and  "predicable_short_it"
> attribute as suggestion.
>
> However, I don't have svn write access yet.
>
> Shiva
>
> 2015-06-03 16:36 GMT+08:

Re: [libcpp/C PATCH] Fix two ICEs with location offsets (PR c/66415)

2015-06-05 Thread Marek Polacek
On Thu, Jun 04, 2015 at 09:05:51PM +, Joseph Myers wrote:
> OK in the absence of objections from Dodji as line map maintainer within 
> 48 hours.

Thanks.

[Adding Dodji to CC.]

Marek


Re: [GCC, ARM] armv8 linux toolchain asan testcase fail due to stl missing conditional code

2015-06-05 Thread Kyrill Tkachov

Hi Shiva,

On 05/06/15 09:29, Shiva Chen wrote:

Hi, Kyrill

I update the patch as Richard's suggestion.

-  return \"str\t%1, %0\";
+  return \"str%(%)\t%1, %0\";
  else
-  return \"stl\t%1, %0\";
+  return \"stl%?\t%1, %0\";
}
-)
+  [(set_attr "predicable" "yes")
+   (set_attr "predicable_short_it" "no")])
+  [(set_attr "predicable" "yes")
+   (set_attr "predicable_short_it" "no")])


Let me sum up.

We add predicable attribute to allow gcc do if-conversion in
ce1/ce2/ce3 not only in final phase by final_prescan_insn finite state
machine.

We set predicalble_short_it to "no" to restrict conditional code
generation on armv8 with thumb mode.

However, we could use the flags -mno-restrict-it to force generating
conditional code on thumb mode.

Therefore, we have to consider the assembly output format for strb
with condition code on arm/thumb mode.

Because arm/thumb mode use different syntax for strb,
we output the assembly as str%(%)
which will put the condition code in the right place according to
TARGET_UNIFIED_ASM.

Is there still missing something ?


That's all correct, and well summarised :)
The patch looks good to me, but please include the testcase
(test.c from earlier) appropriately marked up for the testsuite.
I think to the level of dg-assemble, just so we know everything is
wired up properly.

Thanks for dealing with this.
Kyrill



Thanks,

Shiva

2015-06-04 18:00 GMT+08:00 Kyrill Tkachov :

Hi Shiva,

On 04/06/15 10:57, Shiva Chen wrote:

Hi, Kyrill

Thanks for the tips of syntax.

It seems that correct syntax for

ldrb with condition code is ldreqb

ldab with condition code is ldabeq


So I modified the pattern as follow

{
  enum memmodel model = (enum memmodel) INTVAL (operands[2]);
  if (model == MEMMODEL_RELAXED
  || model == MEMMODEL_CONSUME
  || model == MEMMODEL_RELEASE)
return \"ldr%?\\t%0, %1\";
  else
return \"lda%?\\t%0, %1\";
}
[(set_attr "predicable" "yes")
 (set_attr "predicable_short_it" "no")])

It seems we don't have to worry about thumb mode,


I suggest you use Richard's suggestion from:
  https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00384.html
to write this in a clean way.


Because we already set "predicable" "yes" and predicable_short_it" "no"
for the pattern.


That's not quite true. The user may compile for armv8-a with
-mno-restrict-it which will turn off this
restriction for Thumb and allow the conditional execution of this.
In any case, I think Richard's suggestion above should work.

Thanks,
Kyrill



The new patch could build gcc and run gcc regression test successfully.

Please correct me if I still missing something.

Thanks,

Shiva

-Original Message-
From: Richard Earnshaw [mailto:richard.earns...@foss.arm.com]
Sent: Thursday, June 04, 2015 4:42 PM
To: Kyrill Tkachov; Shiva Chen
Cc: Ramana Radhakrishnan; GCC Patches; ni...@redhat.com; Shiva Chen
Subject: Re: [GCC, ARM] armv8 linux toolchain asan testcase fail due to
stl missing conditional code

On 04/06/15 09:17, Kyrill Tkachov wrote:

Hi Shiva,

On 04/06/15 04:13, Shiva Chen wrote:

Hi, Ramana

Currently, I work for Marvell and the company have copyright assignment
on file.

Hi, all

After adding the attribute and rebuild gcc, I got the assembler error
message

load_n.s:39: Error: bad instruction `ldrbeq r0,[r0]'

When i look into armv8 ISA document, it seems ldrb Encoding A1 have
conditional code field.

Does it mean we should also patch assembler or I just miss
understanding something ?

Following command use to generate load_n.s:

/home/shivac/build-system-trunk/Release/build/armv8-marvell-linux-gnu
eabihf-hard/gcc-final/./gcc/cc1 -fpreprocessed load_n.i -quiet
-dumpbase load_n.c -march=armv8-a -mfloat-abi=hard -mfpu=fp-armv8
-mtls-dialect=gnu -auxbase-strip .libs/load_1_.o -g3 -O2 -Wall
-Werror -version -fPIC -funwind-tables -o load_n.s


The test.c is a simple test case to reproduce missing conditional
code in mmap.c.

Any suggestion ?

I reproduced the assembler failure with your patch.

The reason is that for arm mode we use divided syntax, where the
condition field goes in a different place. So, while ldrbeq r0,[r0] is
rejected, ldreqb r0, [r0] works.
Since we always use divided syntax for arm mode, I think you'll need
to put the condition field in the right place depending on arm or thumb
mode.
Ugh, this is becoming ugly :(


Use %(%)\t%1, %0\";

R.


Kyrill


Shiva

2015-06-03 17:29 GMT+08:00 Shiva Chen :

Hi, Ramana

I'm not sure what copyright assignment means ?

Does it mean the patch have copyright assignment or not ?

I update the patch to add "predicable" and  "predicable_short_it"
attribute as suggestion.

However, I don't have svn write access yet.

Shiva

2015-06-03 16:36 GMT+08:00 Kyrill Tkachov :

On 03/06/15 09:32, Ramana Radhakrishnan wrote:

This pattern is not predicable though, i.e. it doesn't have the
"predicable" attribute set to "yes".
Therefore the compiler should be trying to branch a

Re: [C/C++ PATCH] Implement -Wshift-overflow (PR c++/55095) (take 3)

2015-06-05 Thread Marek Polacek
On Thu, Jun 04, 2015 at 09:04:19PM +, Joseph Myers wrote:
> The C changes are OK.

Jason, do you want to approve the C++ parts?

Thanks,

Marek


Re: [GCC, ARM] armv8 linux toolchain asan testcase fail due to stl missing conditional code

2015-06-05 Thread Shiva Chen
Hi, Kyrill

I add the testcase as stl-cond.c.

Could you help to check the testcase ?

If it's OK, Could you help me to apply the patch ?


Thanks,

Shiva

2015-06-05 16:34 GMT+08:00 Kyrill Tkachov :
> Hi Shiva,
>
> On 05/06/15 09:29, Shiva Chen wrote:
>>
>> Hi, Kyrill
>>
>> I update the patch as Richard's suggestion.
>>
>> -  return \"str\t%1, %0\";
>> +  return \"str%(%)\t%1, %0\";
>>   else
>> -  return \"stl\t%1, %0\";
>> +  return \"stl%?\t%1, %0\";
>> }
>> -)
>> +  [(set_attr "predicable" "yes")
>> +   (set_attr "predicable_short_it" "no")])
>> +  [(set_attr "predicable" "yes")
>> +   (set_attr "predicable_short_it" "no")])
>>
>>
>> Let me sum up.
>>
>> We add predicable attribute to allow gcc do if-conversion in
>> ce1/ce2/ce3 not only in final phase by final_prescan_insn finite state
>> machine.
>>
>> We set predicalble_short_it to "no" to restrict conditional code
>> generation on armv8 with thumb mode.
>>
>> However, we could use the flags -mno-restrict-it to force generating
>> conditional code on thumb mode.
>>
>> Therefore, we have to consider the assembly output format for strb
>> with condition code on arm/thumb mode.
>>
>> Because arm/thumb mode use different syntax for strb,
>> we output the assembly as str%(%)
>> which will put the condition code in the right place according to
>> TARGET_UNIFIED_ASM.
>>
>> Is there still missing something ?
>
>
> That's all correct, and well summarised :)
> The patch looks good to me, but please include the testcase
> (test.c from earlier) appropriately marked up for the testsuite.
> I think to the level of dg-assemble, just so we know everything is
> wired up properly.
>
> Thanks for dealing with this.
> Kyrill
>
>
>>
>> Thanks,
>>
>> Shiva
>>
>> 2015-06-04 18:00 GMT+08:00 Kyrill Tkachov :
>>>
>>> Hi Shiva,
>>>
>>> On 04/06/15 10:57, Shiva Chen wrote:

 Hi, Kyrill

 Thanks for the tips of syntax.

 It seems that correct syntax for

 ldrb with condition code is ldreqb

 ldab with condition code is ldabeq


 So I modified the pattern as follow

 {
   enum memmodel model = (enum memmodel) INTVAL (operands[2]);
   if (model == MEMMODEL_RELAXED
   || model == MEMMODEL_CONSUME
   || model == MEMMODEL_RELEASE)
 return \"ldr%?\\t%0, %1\";
   else
 return \"lda%?\\t%0, %1\";
 }
 [(set_attr "predicable" "yes")
  (set_attr "predicable_short_it" "no")])

 It seems we don't have to worry about thumb mode,
>>>
>>>
>>> I suggest you use Richard's suggestion from:
>>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00384.html
>>> to write this in a clean way.
>>>
 Because we already set "predicable" "yes" and predicable_short_it" "no"
 for the pattern.
>>>
>>>
>>> That's not quite true. The user may compile for armv8-a with
>>> -mno-restrict-it which will turn off this
>>> restriction for Thumb and allow the conditional execution of this.
>>> In any case, I think Richard's suggestion above should work.
>>>
>>> Thanks,
>>> Kyrill
>>>
>>>
 The new patch could build gcc and run gcc regression test successfully.

 Please correct me if I still missing something.

 Thanks,

 Shiva

 -Original Message-
 From: Richard Earnshaw [mailto:richard.earns...@foss.arm.com]
 Sent: Thursday, June 04, 2015 4:42 PM
 To: Kyrill Tkachov; Shiva Chen
 Cc: Ramana Radhakrishnan; GCC Patches; ni...@redhat.com; Shiva Chen
 Subject: Re: [GCC, ARM] armv8 linux toolchain asan testcase fail due to
 stl missing conditional code

 On 04/06/15 09:17, Kyrill Tkachov wrote:
>
> Hi Shiva,
>
> On 04/06/15 04:13, Shiva Chen wrote:
>>
>> Hi, Ramana
>>
>> Currently, I work for Marvell and the company have copyright
>> assignment
>> on file.
>>
>> Hi, all
>>
>> After adding the attribute and rebuild gcc, I got the assembler error
>> message
>>
>> load_n.s:39: Error: bad instruction `ldrbeq r0,[r0]'
>>
>> When i look into armv8 ISA document, it seems ldrb Encoding A1 have
>> conditional code field.
>>
>> Does it mean we should also patch assembler or I just miss
>> understanding something ?
>>
>> Following command use to generate load_n.s:
>>
>> /home/shivac/build-system-trunk/Release/build/armv8-marvell-linux-gnu
>> eabihf-hard/gcc-final/./gcc/cc1 -fpreprocessed load_n.i -quiet
>> -dumpbase load_n.c -march=armv8-a -mfloat-abi=hard -mfpu=fp-armv8
>> -mtls-dialect=gnu -auxbase-strip .libs/load_1_.o -g3 -O2 -Wall
>> -Werror -version -fPIC -funwind-tables -o load_n.s
>>
>>
>> The test.c is a simple test case to reproduce missing conditional
>> code in mmap.c.
>>
>> Any suggestion ?
>
> I reproduced the assembler failure with your patch.
>
> The reason is that for arm mode we use divid

Re: [debug-early] fix problem with template parameter packs

2015-06-05 Thread Aldy Hernandez

On 06/04/2015 07:31 PM, Aldy Hernandez wrote:

On 06/04/2015 02:39 PM, Jason Merrill wrote:

On 06/04/2015 02:23 PM, Jason Merrill wrote:

On 06/03/2015 10:42 AM, Aldy Hernandez wrote:

+  /* Die was generated early via dwarf2out_early_global_decl.  */
+  BOOL_BITFIELD dumped_early : 1;


Missed a "dump".

Actually, why do we need this flag?  The uses I see are

* to avoid declaring prototype parameters multiple times


It used to verify the sanity of the late limbo list.  I can remove this
though if you want.

dwarf2out_decl() also has a sanity check to verify that early dumped
DIEs are not generated again.  I can remove this as well if you prefer.

And finally, I believe the big block you speak of below has a check for
dumped_early, that may or may not allow it to distinguish for things
that happen in LTO which still acts like traditional late dwarf.  I
haven't checked this though... but if you want it removed I can check
and retest.


I'm not a huge fan of removing the dumped_early bit because of the 
sanity checks, but theoretically they shouldn't be necessary when LTO 
changes are in.  LTO will be our test.  I've removed them however as 
you've requested.






Can't we just assume that if we have an old DIE, it already has
parameters?

* to make the logic in gen_variable_die even more horrible

It's really not clear to me that we need the new big block of code.  I
would think that it should be enough to update this:


   /* If the compiler emitted a definition for the DECL declaration
+ and we already emitted a DIE for it, don't emit a second
  DIE for it again. Allow re-declarations of DECLs that are
  inside functions, though.  */
-  if (old_die && declaration && !local_scope_p (context_die))
 return;


to add locations instead of just returning when !early_dwarf.

Incidentally, why did you change "declaration" to "!declaration" in this
condition?


Ah, wait.  If we revert that mysterious change, it's clear again that
this check is just dealing with avoiding duplicate declarations, so
within this condition isn't the right place for adding locations to
early DIEs; that should probably happen right after this.


This was in Michael Matz's original prototype.  I'm surprised it
survived this long.

So... if I revert the !declaration change and move the big block below
said change, would you be OK with it, or did you still want some changes
to it?


Like the attached patch.

How does this look?

Aldy
gcc/

	* dwarf2out.c: Remove deferred_locations*.
	(dwarf2_debug_hooks): Add early_finish hook.
	Remove global_decl hook.
	Add early_global_decl and late_global_decl hook.
	New global early_dwarf.
	New structure set_early_dwarf.
	(output_die): Indicate whether a DIE was generated early
	when generating assembly with -dA.
	(struct limbo_die_struct): Document created_for field.
	Remove file_table_last_lookup.
	(remove_AT): Return TRUE if successful.
	(remove_child_TAG): Clear die_parent.
	(reparent_child): New function abstracted from...
	(splice_child_die): ...here.
	(new_die): ICE if a DIE ends up in limbo too late.
	(print_die): Display "(DUMPED EARLY)" if appropriate.
	(check_die): New.
	(defer_location): Remove.
	(add_subscript_info): Reuse DW_TAG_subrange_type if available.
	(fill_variable_array_bounds): New.
	(decl_start_label): Call fill_variable_array_bounds.
	(gen_formal_parameter_die): Rewrite to reuse previously generated
	DIEs.
	(gen_subprogram_die): Same.
	(gen_variable_die): Same.
	(gen_const_die): Same.
	(gen_label_die): Same.
	(gen_lexical_block_die): Same.
	(decl_will_get_specification_p): New.
	(local_function_static): New.
	(gen_struct_or_union_type_die): Fill in variable-length fields.
	(gen_typedef_die): Fill in variable-length typedefs.
	(gen_tagged_type_die): Gracefully return on error_mark_node.
	Handle re-entrancy.
	(gen_type_die_with_usage): Handle variable-length types.
	Remove duplicate code for ARRAY_TYPE case.
	(process_scope_var): Only process imported modules during early
	dwarf.
	(dwarf2out_early_global_decl): New.
	(dwarf2out_late_global_decl): Rename from dwarf2out_global_decl.
	(dwarf2out_type_decl): Set early_dwarf while calling
	dwarf2out_decl.
	(dwarf2out_decl): Verify that we did not recreate a previously
	generated DIE.
	Do not return on DECL_EXTERNALs in VAR_DECLs.
	Abstract some code to local_function_static.
	(lookup_filename): Remove use of file_table_last_lookup.
	Gracefully exit on missing file_name.
	(dwarf2out_finish): Verify limbo list.
	Remove deferred_locations_list use.
	Move deferred_asm_name and limbo flushing to...
	(dwarf2out_early_finish): ...here.  New.
	(dwarf2out_c_finalize): Remove set of deferred_location_list,
	deferred_asm_name, and file_table_last_lookup.
	* cgraph.h (referred_to_p): Add default argument.
	* cgraphunit.c (referred_to_p): Add and handle include_self
	argument.
	(analyze_functions): Add first_time argument.
	Call check_global_declaration for all symbols.
	Call late_global_decl for nodes for moribund nodes.
	(fin

Re: Heads-up: testsuite: removed cleanup-ipa-dump, cleanup-rtl-dump,cleanup-tree-dump, cleanup-dump, cleanup-saved-temps

2015-06-05 Thread Tom de Vries

On 02/06/15 20:40, Bernhard Reutner-Fischer wrote:

On June 2, 2015 5:38:06 PM GMT+02:00, Bernhard 
Reutner-Fischer  wrote:

>On June 2, 2015 2:08:47 PM GMT+02:00, Richard Biener
>  wrote:

>>
>>Committed.  Seems to cause half of the vectorizer tests to be dropped
>>and test-summary breaking for me.

As a gentle reminder to reviewers and all:


>Right. There should be no cleanup-tree-dump left on trunk.


My overnight testing of a patch also broke on a harmless cleanup-tree-dump.

What is the rationale to have this as an error rather than a warning?

Thanks,
- Tom


Re: [Patch, fortran, PR44672, v9] [F08] ALLOCATE with SOURCE and no array-spec

2015-06-05 Thread Andre Vehreschild
Hi all,

attached is the most recent version of the patch. It addresses the standard
violation of allocate(foo, source=[bar(something)]), where foo after the
allocate was a zero-based array instead of a one-based. Furthermore does this
patch fix calling _vptr->_copy () routines, which come without an interface
specification leading to pass all arguments by reference. When copying a
deferred length string this is hazardous, because a __copy_character_* ()
routines third and fourth arguments are passed by value. This is fixed by
simply counting the actual arguments and using pass by value for third and
fourth to _copy routine.

Bootstraps and regtests ok on x86_64-linux-gnu/f21.

Ok for trunk?

- Andre
-- 
Andre Vehreschild * Email: vehre ad gmx dot de 


pr44672_9.clog
Description: Binary data
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 905d47c..211c781 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -2396,6 +2396,9 @@ typedef struct gfc_code
 {
   gfc_typespec ts;
   gfc_alloc *list;
+  /* Take the array specification from expr3 to allocate arrays
+	 without an explicit array specification.  */
+  unsigned arr_spec_from_expr3:1;
 }
 alloc;
 
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index e615cc6..315170a 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -6805,7 +6805,7 @@ conformable_arrays (gfc_expr *e1, gfc_expr *e2)
have a trailing array reference that gives the size of the array.  */
 
 static bool
-resolve_allocate_expr (gfc_expr *e, gfc_code *code)
+resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec)
 {
   int i, pointer, allocatable, dimension, is_abstract;
   int codimension;
@@ -7104,13 +7104,24 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code)
   if (!ref2 || ref2->type != REF_ARRAY || ref2->u.ar.type == AR_FULL
   || (dimension && ref2->u.ar.dimen == 0))
 {
-  gfc_error ("Array specification required in ALLOCATE statement "
-		 "at %L", &e->where);
-  goto failure;
+  /* F08:C633.  */
+  if (code->expr3)
+	{
+	  if (!gfc_notify_std (GFC_STD_F2008, "Array specification required "
+			   "in ALLOCATE statement at %L", &e->where))
+	goto failure;
+	  *array_alloc_wo_spec = true;
+	}
+  else
+	{
+	  gfc_error ("Array specification required in ALLOCATE statement "
+		 "at %L", &e->where);
+	  goto failure;
+	}
 }
 
   /* Make sure that the array section reference makes sense in the
-context of an ALLOCATE specification.  */
+ context of an ALLOCATE specification.  */
 
   ar = &ref2->u.ar;
 
@@ -7125,7 +7136,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code)
 
   for (i = 0; i < ar->dimen; i++)
 {
-  if (ref2->u.ar.type == AR_ELEMENT)
+  if (ar->type == AR_ELEMENT || ar->type == AR_FULL)
 	goto check_symbols;
 
   switch (ar->dimen_type[i])
@@ -7202,6 +7213,7 @@ failure:
   return false;
 }
 
+
 static void
 resolve_allocate_deallocate (gfc_code *code, const char *fcn)
 {
@@ -7376,8 +7388,16 @@ resolve_allocate_deallocate (gfc_code *code, const char *fcn)
 
   if (strcmp (fcn, "ALLOCATE") == 0)
 {
+  bool arr_alloc_wo_spec = false;
   for (a = code->ext.alloc.list; a; a = a->next)
-	resolve_allocate_expr (a->expr, code);
+	resolve_allocate_expr (a->expr, code, &arr_alloc_wo_spec);
+
+  if (arr_alloc_wo_spec && code->expr3)
+	{
+	  /* Mark the allocate to have to take the array specification
+	 from the expr3.  */
+	  code->ext.alloc.arr_spec_from_expr3 = 1;
+	}
 }
   else
 {
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index f552ff9..7494cf9 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -5001,7 +5001,8 @@ static tree
 gfc_array_init_size (tree descriptor, int rank, int corank, tree * poffset,
 		 gfc_expr ** lower, gfc_expr ** upper, stmtblock_t * pblock,
 		 stmtblock_t * descriptor_block, tree * overflow,
-		 tree expr3_elem_size, tree *nelems, gfc_expr *expr3)
+		 tree expr3_elem_size, tree *nelems, gfc_expr *expr3,
+		 tree expr3_desc, bool e3_is_array_constr)
 {
   tree type;
   tree tmp;
@@ -5016,7 +5017,7 @@ gfc_array_init_size (tree descriptor, int rank, int corank, tree * poffset,
   tree var;
   stmtblock_t thenblock;
   stmtblock_t elseblock;
-  gfc_expr *ubound;
+  gfc_expr *ubound = NULL;
   gfc_se se;
   int n;
 
@@ -5044,7 +5045,18 @@ gfc_array_init_size (tree descriptor, int rank, int corank, tree * poffset,
 
   /* Set lower bound.  */
   gfc_init_se (&se, NULL);
-  if (lower == NULL)
+  if (expr3_desc != NULL_TREE)
+	{
+	  if (e3_is_array_constr)
+	/* The lbound of a constant array [] starts at zero, but when
+	   allocating it, the standard expects the array to start at
+	   one.  */
+	se.expr = gfc_index_one_node;
+	  else
+	se.expr = gfc_conv_descriptor_lbound_get (expr3_desc,
+		  gfc_rank_cst[n]);
+	}
+  else if (lower == N

Re: [patch] Implement Ada support for DragonFly, improve it for FreeBSD

2015-06-05 Thread Arnaud Charlet
Patch is OK.

Arno

>>> Is a new submission necessary or can this be handled by committer?
>> Preferably yes. 
>>> A new submission will take me a few days because I'm traveling ATM.
> 
> There was a significant amount of bitrot.  Apparently right after I
> submitted the patch, many macros were adjusted by Adacore hitting the
> same files and copyrights as I did.  I updated the patch set by hand and
> tested it against the 31 may snapshot.  I also fixed the
> TOOLS_TARGET_PAIRS issue of course.  same URL:
> 
> http://leaf.dragonflybsd.org/~marino/freebsd/gnat-dragonfly-support.diff
> 
> I also updated the suggested commit message as Eric suggested:
> 
> http://leaf.dragonflybsd.org/~marino/freebsd/gnat-dragonfly-support.msg.txt
> 
> Hopefully this patch isn't already bitrotted!
> 
> John
> 


Re: [GCC, ARM] armv8 linux toolchain asan testcase fail due to stl missing conditional code

2015-06-05 Thread Kyrill Tkachov

Hi Shiva,

On 05/06/15 10:42, Shiva Chen wrote:

Hi, Kyrill

I add the testcase as stl-cond.c.

Could you help to check the testcase ?

If it's OK, Could you help me to apply the patch ?



This looks ok to me.
One nit on the testcase:

diff --git a/gcc/testsuite/gcc.target/arm/stl-cond.c 
b/gcc/testsuite/gcc.target/arm/stl-cond.c
new file mode 100755
index 000..44c6249
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/stl-cond.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_arch_v8a_ok } */
+/* { dg-options "-O2" } */

This should also have -marm as the problem exhibited itself in arm state.
I'll commit this patch with this change in 24 hours on your behalf if no one
objects.

Ramana, Richard, we need to backport it to GCC 5 as well, right?

Thanks,
Kyrill



Thanks,

Shiva

2015-06-05 16:34 GMT+08:00 Kyrill Tkachov :

Hi Shiva,

On 05/06/15 09:29, Shiva Chen wrote:

Hi, Kyrill

I update the patch as Richard's suggestion.

-  return \"str\t%1, %0\";
+  return \"str%(%)\t%1, %0\";
   else
-  return \"stl\t%1, %0\";
+  return \"stl%?\t%1, %0\";
 }
-)
+  [(set_attr "predicable" "yes")
+   (set_attr "predicable_short_it" "no")])
+  [(set_attr "predicable" "yes")
+   (set_attr "predicable_short_it" "no")])


Let me sum up.

We add predicable attribute to allow gcc do if-conversion in
ce1/ce2/ce3 not only in final phase by final_prescan_insn finite state
machine.

We set predicalble_short_it to "no" to restrict conditional code
generation on armv8 with thumb mode.

However, we could use the flags -mno-restrict-it to force generating
conditional code on thumb mode.

Therefore, we have to consider the assembly output format for strb
with condition code on arm/thumb mode.

Because arm/thumb mode use different syntax for strb,
we output the assembly as str%(%)
which will put the condition code in the right place according to
TARGET_UNIFIED_ASM.

Is there still missing something ?


That's all correct, and well summarised :)
The patch looks good to me, but please include the testcase
(test.c from earlier) appropriately marked up for the testsuite.
I think to the level of dg-assemble, just so we know everything is
wired up properly.

Thanks for dealing with this.
Kyrill



Thanks,

Shiva

2015-06-04 18:00 GMT+08:00 Kyrill Tkachov :

Hi Shiva,

On 04/06/15 10:57, Shiva Chen wrote:

Hi, Kyrill

Thanks for the tips of syntax.

It seems that correct syntax for

ldrb with condition code is ldreqb

ldab with condition code is ldabeq


So I modified the pattern as follow

 {
   enum memmodel model = (enum memmodel) INTVAL (operands[2]);
   if (model == MEMMODEL_RELAXED
   || model == MEMMODEL_CONSUME
   || model == MEMMODEL_RELEASE)
 return \"ldr%?\\t%0, %1\";
   else
 return \"lda%?\\t%0, %1\";
 }
 [(set_attr "predicable" "yes")
  (set_attr "predicable_short_it" "no")])

It seems we don't have to worry about thumb mode,


I suggest you use Richard's suggestion from:
   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00384.html
to write this in a clean way.


Because we already set "predicable" "yes" and predicable_short_it" "no"
for the pattern.


That's not quite true. The user may compile for armv8-a with
-mno-restrict-it which will turn off this
restriction for Thumb and allow the conditional execution of this.
In any case, I think Richard's suggestion above should work.

Thanks,
Kyrill



The new patch could build gcc and run gcc regression test successfully.

Please correct me if I still missing something.

Thanks,

Shiva

-Original Message-
From: Richard Earnshaw [mailto:richard.earns...@foss.arm.com]
Sent: Thursday, June 04, 2015 4:42 PM
To: Kyrill Tkachov; Shiva Chen
Cc: Ramana Radhakrishnan; GCC Patches; ni...@redhat.com; Shiva Chen
Subject: Re: [GCC, ARM] armv8 linux toolchain asan testcase fail due to
stl missing conditional code

On 04/06/15 09:17, Kyrill Tkachov wrote:

Hi Shiva,

On 04/06/15 04:13, Shiva Chen wrote:

Hi, Ramana

Currently, I work for Marvell and the company have copyright
assignment
on file.

Hi, all

After adding the attribute and rebuild gcc, I got the assembler error
message

load_n.s:39: Error: bad instruction `ldrbeq r0,[r0]'

When i look into armv8 ISA document, it seems ldrb Encoding A1 have
conditional code field.

Does it mean we should also patch assembler or I just miss
understanding something ?

Following command use to generate load_n.s:

/home/shivac/build-system-trunk/Release/build/armv8-marvell-linux-gnu
eabihf-hard/gcc-final/./gcc/cc1 -fpreprocessed load_n.i -quiet
-dumpbase load_n.c -march=armv8-a -mfloat-abi=hard -mfpu=fp-armv8
-mtls-dialect=gnu -auxbase-strip .libs/load_1_.o -g3 -O2 -Wall
-Werror -version -fPIC -funwind-tables -o load_n.s


The test.c is a simple test case to reproduce missing conditional
code in mmap.c.

Any suggestion ?

I reproduced the assembler failure with your patch.

The reason is that for arm mode we use divided syntax, w

Re: [GCC, ARM] armv8 linux toolchain asan testcase fail due to stl missing conditional code

2015-06-05 Thread Richard Earnshaw
On 05/06/15 14:08, Kyrill Tkachov wrote:
> Hi Shiva,
> 
> On 05/06/15 10:42, Shiva Chen wrote:
>> Hi, Kyrill
>>
>> I add the testcase as stl-cond.c.
>>
>> Could you help to check the testcase ?
>>
>> If it's OK, Could you help me to apply the patch ?
>>
> 
> This looks ok to me.
> One nit on the testcase:
> 
> diff --git a/gcc/testsuite/gcc.target/arm/stl-cond.c
> b/gcc/testsuite/gcc.target/arm/stl-cond.c
> new file mode 100755
> index 000..44c6249
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/arm/stl-cond.c
> @@ -0,0 +1,18 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target arm_arch_v8a_ok } */
> +/* { dg-options "-O2" } */
> 
> This should also have -marm as the problem exhibited itself in arm state.
> I'll commit this patch with this change in 24 hours on your behalf if no
> one
> objects.
> 

Explicit use of -marm will break multi-lib testing.  I've forgotten the
correct hook, but there's most-likely something that will give you the
right behaviour, even if it means that thumb-only multi-lib testing
skips this test.

R.

> Ramana, Richard, we need to backport it to GCC 5 as well, right?
> 
> Thanks,
> Kyrill
> 
> 
>> Thanks,
>>
>> Shiva
>>
>> 2015-06-05 16:34 GMT+08:00 Kyrill Tkachov :
>>> Hi Shiva,
>>>
>>> On 05/06/15 09:29, Shiva Chen wrote:
 Hi, Kyrill

 I update the patch as Richard's suggestion.

 -  return \"str\t%1, %0\";
 +  return \"str%(%)\t%1, %0\";
else
 -  return \"stl\t%1, %0\";
 +  return \"stl%?\t%1, %0\";
  }
 -)
 +  [(set_attr "predicable" "yes")
 +   (set_attr "predicable_short_it" "no")])
 +  [(set_attr "predicable" "yes")
 +   (set_attr "predicable_short_it" "no")])


 Let me sum up.

 We add predicable attribute to allow gcc do if-conversion in
 ce1/ce2/ce3 not only in final phase by final_prescan_insn finite state
 machine.

 We set predicalble_short_it to "no" to restrict conditional code
 generation on armv8 with thumb mode.

 However, we could use the flags -mno-restrict-it to force generating
 conditional code on thumb mode.

 Therefore, we have to consider the assembly output format for strb
 with condition code on arm/thumb mode.

 Because arm/thumb mode use different syntax for strb,
 we output the assembly as str%(%)
 which will put the condition code in the right place according to
 TARGET_UNIFIED_ASM.

 Is there still missing something ?
>>>
>>> That's all correct, and well summarised :)
>>> The patch looks good to me, but please include the testcase
>>> (test.c from earlier) appropriately marked up for the testsuite.
>>> I think to the level of dg-assemble, just so we know everything is
>>> wired up properly.
>>>
>>> Thanks for dealing with this.
>>> Kyrill
>>>
>>>
 Thanks,

 Shiva

 2015-06-04 18:00 GMT+08:00 Kyrill Tkachov
 :
> Hi Shiva,
>
> On 04/06/15 10:57, Shiva Chen wrote:
>> Hi, Kyrill
>>
>> Thanks for the tips of syntax.
>>
>> It seems that correct syntax for
>>
>> ldrb with condition code is ldreqb
>>
>> ldab with condition code is ldabeq
>>
>>
>> So I modified the pattern as follow
>>
>>  {
>>enum memmodel model = (enum memmodel) INTVAL (operands[2]);
>>if (model == MEMMODEL_RELAXED
>>|| model == MEMMODEL_CONSUME
>>|| model == MEMMODEL_RELEASE)
>>  return \"ldr%?\\t%0, %1\";
>>else
>>  return \"lda%?\\t%0, %1\";
>>  }
>>  [(set_attr "predicable" "yes")
>>   (set_attr "predicable_short_it" "no")])
>>
>> It seems we don't have to worry about thumb mode,
>
> I suggest you use Richard's suggestion from:
>https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00384.html
> to write this in a clean way.
>
>> Because we already set "predicable" "yes" and predicable_short_it"
>> "no"
>> for the pattern.
>
> That's not quite true. The user may compile for armv8-a with
> -mno-restrict-it which will turn off this
> restriction for Thumb and allow the conditional execution of this.
> In any case, I think Richard's suggestion above should work.
>
> Thanks,
> Kyrill
>
>
>> The new patch could build gcc and run gcc regression test
>> successfully.
>>
>> Please correct me if I still missing something.
>>
>> Thanks,
>>
>> Shiva
>>
>> -Original Message-
>> From: Richard Earnshaw [mailto:richard.earns...@foss.arm.com]
>> Sent: Thursday, June 04, 2015 4:42 PM
>> To: Kyrill Tkachov; Shiva Chen
>> Cc: Ramana Radhakrishnan; GCC Patches; ni...@redhat.com; Shiva Chen
>> Subject: Re: [GCC, ARM] armv8 linux toolchain asan testcase fail
>> due to
>> stl missing conditional code
>>
>> On 04/06/15 09:17, Kyrill Tkachov wrote:
>

Re: [GCC, ARM] armv8 linux toolchain asan testcase fail due to stl missing conditional code

2015-06-05 Thread Kyrill Tkachov


On 05/06/15 14:11, Richard Earnshaw wrote:

On 05/06/15 14:08, Kyrill Tkachov wrote:

Hi Shiva,

On 05/06/15 10:42, Shiva Chen wrote:

Hi, Kyrill

I add the testcase as stl-cond.c.

Could you help to check the testcase ?

If it's OK, Could you help me to apply the patch ?


This looks ok to me.
One nit on the testcase:

diff --git a/gcc/testsuite/gcc.target/arm/stl-cond.c
b/gcc/testsuite/gcc.target/arm/stl-cond.c
new file mode 100755
index 000..44c6249
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/stl-cond.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_arch_v8a_ok } */
+/* { dg-options "-O2" } */

This should also have -marm as the problem exhibited itself in arm state.
I'll commit this patch with this change in 24 hours on your behalf if no
one
objects.


Explicit use of -marm will break multi-lib testing.  I've forgotten the
correct hook, but there's most-likely something that will give you the
right behaviour, even if it means that thumb-only multi-lib testing
skips this test.


So I think what we want is:

dg-require-effective-target arm_arm_ok

The comment in target-supports.exp is:
# Return 1 if this is an ARM target where -marm causes ARM to be
# used (not Thumb)

Kyrill



R.


Ramana, Richard, we need to backport it to GCC 5 as well, right?

Thanks,
Kyrill



Thanks,

Shiva

2015-06-05 16:34 GMT+08:00 Kyrill Tkachov :

Hi Shiva,

On 05/06/15 09:29, Shiva Chen wrote:

Hi, Kyrill

I update the patch as Richard's suggestion.

-  return \"str\t%1, %0\";
+  return \"str%(%)\t%1, %0\";
else
-  return \"stl\t%1, %0\";
+  return \"stl%?\t%1, %0\";
  }
-)
+  [(set_attr "predicable" "yes")
+   (set_attr "predicable_short_it" "no")])
+  [(set_attr "predicable" "yes")
+   (set_attr "predicable_short_it" "no")])


Let me sum up.

We add predicable attribute to allow gcc do if-conversion in
ce1/ce2/ce3 not only in final phase by final_prescan_insn finite state
machine.

We set predicalble_short_it to "no" to restrict conditional code
generation on armv8 with thumb mode.

However, we could use the flags -mno-restrict-it to force generating
conditional code on thumb mode.

Therefore, we have to consider the assembly output format for strb
with condition code on arm/thumb mode.

Because arm/thumb mode use different syntax for strb,
we output the assembly as str%(%)
which will put the condition code in the right place according to
TARGET_UNIFIED_ASM.

Is there still missing something ?

That's all correct, and well summarised :)
The patch looks good to me, but please include the testcase
(test.c from earlier) appropriately marked up for the testsuite.
I think to the level of dg-assemble, just so we know everything is
wired up properly.

Thanks for dealing with this.
Kyrill



Thanks,

Shiva

2015-06-04 18:00 GMT+08:00 Kyrill Tkachov
:

Hi Shiva,

On 04/06/15 10:57, Shiva Chen wrote:

Hi, Kyrill

Thanks for the tips of syntax.

It seems that correct syntax for

ldrb with condition code is ldreqb

ldab with condition code is ldabeq


So I modified the pattern as follow

  {
enum memmodel model = (enum memmodel) INTVAL (operands[2]);
if (model == MEMMODEL_RELAXED
|| model == MEMMODEL_CONSUME
|| model == MEMMODEL_RELEASE)
  return \"ldr%?\\t%0, %1\";
else
  return \"lda%?\\t%0, %1\";
  }
  [(set_attr "predicable" "yes")
   (set_attr "predicable_short_it" "no")])

It seems we don't have to worry about thumb mode,

I suggest you use Richard's suggestion from:
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00384.html
to write this in a clean way.


Because we already set "predicable" "yes" and predicable_short_it"
"no"
for the pattern.

That's not quite true. The user may compile for armv8-a with
-mno-restrict-it which will turn off this
restriction for Thumb and allow the conditional execution of this.
In any case, I think Richard's suggestion above should work.

Thanks,
Kyrill



The new patch could build gcc and run gcc regression test
successfully.

Please correct me if I still missing something.

Thanks,

Shiva

-Original Message-
From: Richard Earnshaw [mailto:richard.earns...@foss.arm.com]
Sent: Thursday, June 04, 2015 4:42 PM
To: Kyrill Tkachov; Shiva Chen
Cc: Ramana Radhakrishnan; GCC Patches; ni...@redhat.com; Shiva Chen
Subject: Re: [GCC, ARM] armv8 linux toolchain asan testcase fail
due to
stl missing conditional code

On 04/06/15 09:17, Kyrill Tkachov wrote:

Hi Shiva,

On 04/06/15 04:13, Shiva Chen wrote:

Hi, Ramana

Currently, I work for Marvell and the company have copyright
assignment
on file.

Hi, all

After adding the attribute and rebuild gcc, I got the assembler
error
message

load_n.s:39: Error: bad instruction `ldrbeq r0,[r0]'

When i look into armv8 ISA document, it seems ldrb Encoding A1 have
conditional code field.

Does it mean we should also patch assembler or I just miss
understanding something ?

Following command use to generate l

Re: [debug-early] fix problem with template parameter packs

2015-06-05 Thread Jason Merrill

On 06/04/2015 07:31 PM, Aldy Hernandez wrote:

So... if I revert the !declaration change and move the big block below
said change, would you be OK with it, or did you still want some changes
to it?


I'm still hoping to simplify it.  Actually, I think we can just remove the


   if (old_die && declaration && !local_scope_p (context_die))


check; since inverting its logic didn't seem to break anything before, 
it can just go.


And I'd like to rework the logic in the big block so we don't have three 
ways of getting to the same thing.  Does this work?


   if (declaration)
 {
   /* A declaration that has been previously dumped, needs no 

  further annotations, since it doesn't need location on 


  the second pass.  */
   return;
 }
   else if (origin && old_die->die_parent != context_die)
 {
   /* If we will be creating an inlined instance, we need a 

  new DIE that will get annotated with 

  DW_AT_abstract_origin.  Clear things so we can get a 


  new DIE.  */
   gcc_assert (!DECL_ABSTRACT_P (decl));
   old_die = NULL;
 }
   else
 {
   /* If a DIE was dumped early, it still needs location info. 


  Skip to where we fill the location bits.  */
   var_die = old_die;
   goto gen_variable_die_location;
 }

Jason



Re: [PATCH, libmpx, i386, PR driver/65444] Pass '-z bndplt' when building dynamic objects with MPX

2015-06-05 Thread Ilya Enkovich
On 04 Jun 15:53, Joseph Myers wrote:
> On Thu, 4 Jun 2015, Ilya Enkovich wrote:
> 
> > 2015-06-03 18:59 GMT+03:00 Joseph Myers :
> > > You could, for example, have
> > >
> > > #if SOMETHING
> > > #define MSG "%nsome msg"
> > > #else
> > > #define MSG ""
> > > #endif
> > >
> > > and have another spec using MSG - that should work.
> > 
> > In this case I should define SOMETHING in configure of gcc, not in
> > configure of libmpx, right? But it would mean I check host linker, not
> > target.
> 
> gcc/ configure tests on the linker generally test the build-x-target 
> linker, which is required to have the same version and be configured the 
> same as the host-x-target linker.  (The tests mustn't actually try to link 
> anything, but they can e.g. see if a particular option is mentioned in 
> --help output.  In general they also have version number checks for the 
> case of an in-tree linker build.)
> 
> -- 
> Joseph S. Myers
> jos...@codesourcery.com

Thanks for help!  Here is a new patch version with a check moved into 
gcc/configure.  Does it look OK?

Thanks,
Ilya
--
gcc/

2015-06-05  Ilya Enkovich  

* config/i386/linux-common.h (LINK_MPX): New.
(MPX_SPEC): Use LINK_MPX instead of %(link_mpx).
* configure.ac: Add HAVE_LD_BNDPLT_SUPPORT macro
indicating '-z bndplt' support by linker.
* configure: Regenerate.
* config.in: Regenerate.

libmpx/

2015-06-05  Ilya Enkovich  

* configure.ac: Remove link_mpx.
* libmpx.spec.in: Likewise.
* configure: Regenerate.


diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
index dd79ec6..63dd8d8 100644
--- a/gcc/config/i386/linux-common.h
+++ b/gcc/config/i386/linux-common.h
@@ -59,9 +59,20 @@ along with GCC; see the file COPYING3.  If not see
  %:include(libmpx.spec)%(link_libmpx)"
 #endif
 
+#ifndef LINK_MPX
+#if defined (HAVE_LD_BNDPLT_SUPPORT)
+#define LINK_MPX "-z bndplt "
+#else
+#define LINK_MPX \
+  "%nGCC was configured with a linker with no '-z bndplt' support. " \
+  "It significantly reduces MPX coverage for dynamic codes. " \
+  "It is strongly recommended to use GCC properly configured for MPX."
+#endif
+#endif
+
 #ifndef MPX_SPEC
 #define MPX_SPEC "\
- %{mmpx:%{fcheck-pointer-bounds:%{!static:%:include(libmpx.spec)%(link_mpx)}}}"
+ %{mmpx:%{fcheck-pointer-bounds:%{!static:" LINK_MPX "}}}"
 #endif
 
 #ifndef LIBMPX_SPEC
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b27433e..7306a70 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -5859,6 +5859,27 @@ if test "$gcc_cv_no_pie" = "yes"; then
 fi
 AC_SUBST([NO_PIE_FLAG])
 
+# Check linker supports '-z bndplt'
+ld_bndplt_support=no
+AC_MSG_CHECKING(linker -z bndplt option)
+if test x"$ld_is_gold" = xno; then
+  if test $in_tree_ld = yes ; then
+if test "$gcc_cv_gld_major_version" -eq 2 -a "$gcc_cv_gld_minor_version" 
-ge 25 -o "$gcc_cv_gld_major_version" -gt 2; then
+  ld_bndplt_support=yes
+fi
+  elif test x$gcc_cv_ld != x; then
+# Check if linker supports -a bndplt option
+if $gcc_cv_ld --help 2>/dev/null | grep -- '-z bndplt' > /dev/null; then
+  ld_bndplt_support=yes
+fi
+  fi
+fi
+if test x"$ld_bndplt_support" = xyes; then
+  AC_DEFINE(HAVE_LD_BNDPLT_SUPPORT, 1,
+   [Define if your linker supports -z bndplt])
+fi
+AC_MSG_RESULT($ld_bndplt_support)
+
 # Configure the subdirectories
 # AC_CONFIG_SUBDIRS($subdirs)
 
diff --git a/libmpx/configure.ac b/libmpx/configure.ac
index 463e855..18ba687 100644
--- a/libmpx/configure.ac
+++ b/libmpx/configure.ac
@@ -39,18 +39,7 @@ AC_MSG_RESULT($LIBMPX_SUPPORTED)
 AM_CONDITIONAL(LIBMPX_SUPPORTED, [test "x$LIBMPX_SUPPORTED" = "xyes"])
 
 link_libmpx="-lpthread"
-link_mpx=""
-AC_MSG_CHECKING([whether ld accepts -z bndplt])
-echo "int main() {};" > conftest.c
-if AC_TRY_COMMAND([${CC} ${CFLAGS} -Wl,-z,bndplt -o conftest conftest.c 
1>&AS_MESSAGE_LOG_FD])
-then
-AC_MSG_RESULT([yes])
-link_mpx="$link_mpx -z bndplt"
-else
-AC_MSG_RESULT([no])
-fi
 AC_SUBST(link_libmpx)
-AC_SUBST(link_mpx)
 
 AM_INIT_AUTOMAKE(foreign no-dist no-dependencies)
 AM_ENABLE_MULTILIB(, ..)
diff --git a/libmpx/libmpx.spec.in b/libmpx/libmpx.spec.in
index 34d0bdf..a80bba7 100644
--- a/libmpx/libmpx.spec.in
+++ b/libmpx/libmpx.spec.in
@@ -1,5 +1,3 @@
 # This spec file is read by gcc when linking.  It is used to specify the
 # standard libraries we need in order to link with libmpx.
 *link_libmpx: @link_libmpx@
-
-*link_mpx: @link_mpx@


Re: [libstdc++ PATCH] Implement __is_nothrow_swappable and use it

2015-06-05 Thread Jonathan Wakely

On 01/05/15 12:47 +0300, Ville Voutilainen wrote:

This patch partially solves the problem described in N4426, which is
basically LWG
issue 2456, which in turn is caused by CWG DR 1330. Some remarks:
- the __is_swappable and __is_nothrow_swappable are at this time not
meant to be general traits, they make the shortcut of automatically transforming
their template parameter into a reference, which the truly general trait
as described in N4426 wouldn't do.
- swap is now constrained..
- ..which means that everything from bits/move.h moves to type_traits since
swap now needs type_traits. type_traits becomes ok to include in pre-c++14
modes, but only enables the parts that work in pre-c++14 modes.
- this patch does _not_ yet implement N4426.


I've committed this slightly altered patch, which doesn't move swap
into  but just declares it there. The definition remains
in  and including  in c++98 mode is still
an error.

Tested powerpc64le-linux, committed to trunk.
commit d485df2eebd2869b3a17a3d67b2a394dbbbedab9
Author: Jonathan Wakely 
Date:   Fri Jun 5 13:20:53 2015 +0100

2015-06-04  Ville Voutilainen  

	Add __is_nothrow_swappable and take it into use.
	* include/bits/algorithmfwd.h (swap): Only declare for C++98 mode.
	* include/bits/move.h (swap): Add constraints in C++11 and later.
	* include/bits/stl_pair.h (swap): Use __is_nothrow_swappable
	for the free swap function for pair.
	* include/bits/stl_queue.h (swap): Use __is_nothrow_swappable
	for the free swap functions for queue and priority_queue.
	* include/bits/stl_stack.h (swap): Use __is_nothrow_swappable
	for the free swap function for stack.
	* include/debug/array (swap): Use __is_nothrow_swappable
	for the free swap function for array.
	* include/profile/array (swap): Likewise.
	* include/std/array (swap): Likewise.
	* include/std/tuple (_Tuple_impl::_M_swap): Use __is_nothrow_swappable.
	* include/std/type_traits (__is_swappable_impl::__is_swappable,
	__is_nothrow_swappable_impl, __is_nothrow_swappable): New.
	* testsuite/20_util/is_nothrow_swappable/requirements/
	explicit_instantiation.cc: New.
	* testsuite/20_util/is_nothrow_swappable/requirements/typedefs.cc:
	New.
	* testsuite/20_util/is_nothrow_swappable/value.cc: New.

diff --git a/libstdc++-v3/include/bits/algorithmfwd.h b/libstdc++-v3/include/bits/algorithmfwd.h
index 1dfc4ad..c972f33 100644
--- a/libstdc++-v3/include/bits/algorithmfwd.h
+++ b/libstdc++-v3/include/bits/algorithmfwd.h
@@ -566,22 +566,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _BIter 
 stable_partition(_BIter, _BIter, _Predicate);
 
-  template 
-void 
-swap(_Tp&, _Tp&)
-#if __cplusplus >= 201103L
-noexcept(__and_,
-	is_nothrow_move_assignable<_Tp>>::value)
-#endif
-;
+#if __cplusplus < 201103L
+  // For C++11 swap() is declared in .
 
   template
-void
-swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
-#if __cplusplus >= 201103L
-noexcept(noexcept(swap(*__a, *__b)))
+inline void
+swap(_Tp& __a, _Tp& __b);
+
+  template
+inline void
+swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm]);
 #endif
-;
 
   template
 _FIter2 
diff --git a/libstdc++-v3/include/bits/move.h b/libstdc++-v3/include/bits/move.h
index 1dfd667..88c4f7b 100644
--- a/libstdc++-v3/include/bits/move.h
+++ b/libstdc++-v3/include/bits/move.h
@@ -172,11 +172,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*  @return   Nothing.
   */
   template
-inline void
-swap(_Tp& __a, _Tp& __b)
+inline
 #if __cplusplus >= 201103L
+typename enable_if<__and_,
+			  is_move_assignable<_Tp>>::value>::type
+swap(_Tp& __a, _Tp& __b)
 noexcept(__and_,
 	is_nothrow_move_assignable<_Tp>>::value)
+#else
+void
+swap(_Tp& __a, _Tp& __b)
 #endif
 {
   // concept requirements
@@ -191,10 +196,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // DR 809. std::swap should be overloaded for array types.
   /// Swap the contents of two arrays.
   template
-inline void
-swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
+inline
 #if __cplusplus >= 201103L
+typename enable_if<__is_swappable_impl::__is_swappable<_Tp>::value>::type
+swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
 noexcept(noexcept(swap(*__a, *__b)))
+#else
+void
+swap(_Tp (&__a)[_Nm], _Tp (&__b)[_Nm])
 #endif
 {
   for (size_t __n = 0; __n < _Nm; ++__n)
diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h
index 3daeb60..490b005 100644
--- a/libstdc++-v3/include/bits/stl_pair.h
+++ b/libstdc++-v3/include/bits/stl_pair.h
@@ -192,8 +192,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   void
   swap(pair& __p)
-  noexcept(noexcept(swap(first, __p.first))
-	   && noexcept(swap(second, __p.second)))
+  noexcept(__is_nothrow_swappable<_T1>::value
+   && __is_nothrow_swappable<_T2>::value)
   {
 	using std::swap;
 	swap(first, __p.first);
diff --git a/libstdc++-v3/include/bit

Re: [debug-early] fix problem with template parameter packs

2015-06-05 Thread Aldy Hernandez

On 06/05/2015 10:02 AM, Jason Merrill wrote:

On 06/04/2015 07:31 PM, Aldy Hernandez wrote:

So... if I revert the !declaration change and move the big block below
said change, would you be OK with it, or did you still want some changes
to it?


I'm still hoping to simplify it.  Actually, I think we can just remove the


   if (old_die && declaration && !local_scope_p (context_die))


check; since inverting its logic didn't seem to break anything before,
it can just go.

And I'd like to rework the logic in the big block so we don't have three
ways of getting to the same thing.  Does this work?


g++.dg/debug/dwarf2/static-data-member1.C fails because it doesn't get a 
DW_AT_specification.  How about:


  if (old_die)
{
  if (declaration)
{
  /* A declaration that has been previously dumped, needs no
 further annotations, since it doesn't need location on
 the second pass.  */
  return;
}
  else if (decl_will_get_specification_p (old_die, decl, declaration)
   && !get_AT (old_die, DW_AT_specification))
{
  /* Fall-thru so we can make a new variable die along with a
 DW_AT_specification.  */
}
  else if (origin && old_die->die_parent != context_die)
{
  /* If we will be creating an inlined instance, we need a
 new DIE that will get annotated with
 DW_AT_abstract_origin.  Clear things so we can get a
 new DIE.  */
  gcc_assert (!DECL_ABSTRACT_P (decl));
  old_die = NULL;
}
  else
{
  /* If a DIE was dumped early, it still needs location info.
 Skip to where we fill the location bits.  */
  var_die = old_die;
  goto gen_variable_die_location;
}
}



[patch] Adjust hash-table.h and it's pre-requisite includes.

2015-06-05 Thread Andrew MacLeod
There is a horrible morass of include dependencies between hash-map.h, 
mem-stats.h and hash-table.h.  There are even includes in both 
directions (mem-stats.h and hash-map.h include each other, as do 
hash-map.h and hash-table.h.. blech).  Some of those files need parts of 
the other file to compile, and those whole mess is quite awful.  They 
also manage to include vec.h into their little party 3 times as well, 
and it also has some icky #ifdefs.


So I spent some time sorting out the situation, and reduced it down to a 
straight dependency list, rooted by hash-table.h.  There are no double 
direction includes, and no header is included more than once.   Once 
sorted out, I moved the root of this tree into coretypes.h since pretty 
much every file requires everything in the dependency chain.   This 
chain consists of statistics.h, ggc.h, vec.h, hashtab.h, inchash.h, 
mem-stats-traits.h, hash-map-traits.h, mem-stats.h, hash-map.h and 
hash-table.h.


With hash-table.h at the root of the dependency list,  I wondered how 
many files actually need just that.  So I flattened a source tree such 
that coretypes.h included the other required include files, but each .c 
file included hash-table.h.  Then I  tried removing the includes.  It 
turned out that virtually every file needs hash-table.h.  Part of that 
is due to how tightly integrated with mem-stats.h it is (they still need 
each other), and that is used throughout the compiler.  So I think it 
makes sense to put that in coretypes.h.


I also noticed that hash-set.h is included in a lot of places as well.  
Wondering how much it was actually needed, I preformed the same 
flattening exercise and found that only about 10% of the files in gcc 
core didn't need it to compile... the rest all needed it due to 
hash_set being in a prototype parameter list or in a structure 
declared in a commonly used header file (function.h, gimple-walk.h, 
tree-core.h, tree.h,...) .  It would be a lot of work to remove this 
dependency (if its  even possible), so I added hash-set.h to coretypes.h 
as well.   rtl.h needed hash-table.h added to the GENERATOR list, but 
not hash-set.. I guess the generators don't use it much :-)


The only other thing of note is the change to vec.h.  It had an ugly set 
of checks to see whether it was being used in a generator file, and if 
not whether GC was available, then included it if it wasn't or provided 
3 prototypes if it wasn't suppose to be included. These allows it to 
compile when GC isn't available (those routines referencing the GC 
functions would never be referred to when GC isnt available).With my 
other changes, most of those checks weren't necessary.  I also figured 
it was best to simply include those 3 prototypes for ggc_free, 
ggc_round_alloc_size, and ggc_realloc all the time.  When there isn't 
ggc.h, things remain as they are now. If there is a ggc.h included, it 
will provide static confirmation that those prototypes are up-to-date 
and in sync with how ggc.h defines them.


The first patch contains all of those changes.  The second one is fully 
automated and removes all these headers  from every other .c and .h file 
in the compiler.   This also included changes to many of the gen*.c 
routines. I adjusted the #include list for all the *generated* .c files 
to also be up to date with this patchset as well at the previous one 
which moved wide-int and friends into coretypes.h


This bootstraps with all languages enabled  on x86_64-unknown-linux-gnu 
with no new regressions.  It also causes no failures for all the  
targets in config-list.mk.


OK for trunk?

Andrew

	* coretypes.h: Include hash-table.h and hash-set.h for host files.
	* ggc.h: Don't include statistics.h>
	* hash-map.h: Remove all includes.
	* hash-set.h: Likewise.
	* hash-table.h: Add statistics.h, inchash.h and hash-map-traits.h to
	the include list. Remove .
	* inchash.h: Remove all includes.
	* mem-stats.h: Likewise.
	* vec.h: No special processing for generators or ggc.  

Index: coretypes.h
===
--- coretypes.h	(revision 224136)
+++ coretypes.h	(working copy)
@@ -307,6 +307,8 @@
 #include "double-int.h"
 #include "real.h"
 #include "fixed-value.h"
-#endif
+#include "hash-table.h"
+#include "hash-set.h"
+#endif /* GENERATOR_FILE && !USED_FOR_TARGET */
 
 #endif /* coretypes.h */
Index: ggc.h
===
--- ggc.h	(revision 224135)
+++ ggc.h	(working copy)
@@ -20,7 +20,6 @@
 
 #ifndef GCC_GGC_H
 #define GCC_GGC_H
-#include "statistics.h"
 
 /* Symbols are marked with `ggc' for `gcc gc' so as not to interfere with
an external gc library that might be linked in.  */
Index: hash-map.h
===
--- hash-map.h	(revision 224135)
+++ hash-map.h	(working copy)
@@ -21,13 +21,6 @@
 #ifndef hash_map_h
 #define hash_map_h
 
-#include 
-#include 
-#include "hash-table.h"
-#include 

Re: [debug-early] fix problem with template parameter packs

2015-06-05 Thread Jason Merrill

Looks good.

Jason


[patch] Add std::shared_mutex for C++17

2015-06-05 Thread Jonathan Wakely

This implements
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4508.html
which was recently applied to the C++ working paper.

The guts of shared_timed_mutex are moved out into two helper classes
(one using pthread_rwlock_t and one using std::condition_variable)
that implement everything except the timed functions, which can then
be re-used by both shared_mutex and shared_timed_mutex.

The existing shared_timed_mutex class just inherits from one of the
new types and adds the timed functions.

The new shared_mutex class just uses one of the new helper types.

Some targets can use the pthread_rwlock_t-based implementation for
shared_mutex but not for shared_timed_mutex (I think this is the case
for darwin and hpux). It's possible this patch will need tweaking for
those targets, but I hope it's OK.

There's a TODO in the patch, because SD-6 doesn't define a
feature-test macro for std::shared_mutex.

Tested powerpc64le-linux, committed to trunk.

commit 35e47469169a724f6eb0dfc0a4b79aba1c81f213
Author: Jonathan Wakely 
Date:   Fri Jun 5 17:05:04 2015 +0100

	* include/std/shared_mutex (__shared_mutex_pthread,
	__shared_mutex_cv): New helper types implementing the shared mutex
	requirements.
	(shared_mutex): New type for C++17.
	(shared_timed_mutex): Derive from one of the new helper types.
	* testsuite/30_threads/shared_mutex/cons/1.cc: New.
	* testsuite/30_threads/shared_mutex/cons/assign_neg.cc: New.
	* testsuite/30_threads/shared_mutex/cons/copy_neg.cc: New.
	* testsuite/30_threads/shared_mutex/requirements/standard_layout.cc:
	New.
	* testsuite/30_threads/shared_mutex/try_lock/1.cc: New.
	* testsuite/30_threads/shared_mutex/try_lock/2.cc: New.

diff --git a/libstdc++-v3/include/std/shared_mutex b/libstdc++-v3/include/std/shared_mutex
index b72a822..0a893ee 100644
--- a/libstdc++-v3/include/std/shared_mutex
+++ b/libstdc++-v3/include/std/shared_mutex
@@ -52,25 +52,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
 #ifdef _GLIBCXX_HAS_GTHREADS
 
+#if __cplusplus > 201402L
+// TODO: #define __cpp_lib_shared_mutex 201505
+  class shared_mutex;
+#endif
+
 #define __cpp_lib_shared_timed_mutex 201402
+  class shared_timed_mutex;
 
-  /// shared_timed_mutex
-  class shared_timed_mutex
+#if _GLIBCXX_USE_PTHREAD_RWLOCK_T
+  /// A shared mutex type implemented using pthread_rwlock_t.
+  class __shared_mutex_pthread
   {
-#if _GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK
-typedef chrono::system_clock	__clock_t;
+friend class shared_timed_mutex;
 
 #ifdef PTHREAD_RWLOCK_INITIALIZER
 pthread_rwlock_t	_M_rwlock = PTHREAD_RWLOCK_INITIALIZER;
 
   public:
-shared_timed_mutex() = default;
-~shared_timed_mutex() = default;
+__shared_mutex_pthread() = default;
+~__shared_mutex_pthread() = default;
 #else
 pthread_rwlock_t	_M_rwlock;
 
   public:
-shared_timed_mutex()
+__shared_mutex_pthread()
 {
   int __ret = pthread_rwlock_init(&_M_rwlock, NULL);
   if (__ret == ENOMEM)
@@ -83,7 +89,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   _GLIBCXX_DEBUG_ASSERT(__ret == 0);
 }
 
-~shared_timed_mutex()
+~__shared_mutex_pthread()
 {
   int __ret __attribute((__unused__)) = pthread_rwlock_destroy(&_M_rwlock);
   // Errors not handled: EBUSY, EINVAL
@@ -91,10 +97,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }
 #endif
 
-shared_timed_mutex(const shared_timed_mutex&) = delete;
-shared_timed_mutex& operator=(const shared_timed_mutex&) = delete;
-
-// Exclusive ownership
+__shared_mutex_pthread(const __shared_mutex_pthread&) = delete;
+__shared_mutex_pthread& operator=(const __shared_mutex_pthread&) = delete;
 
 void
 lock()
@@ -116,48 +120,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   return true;
 }
 
-template
-  bool
-  try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time)
-  {
-	return try_lock_until(__clock_t::now() + __rel_time);
-  }
-
-template
-  bool
-  try_lock_until(const chrono::time_point<__clock_t, _Duration>& __atime)
-  {
-	auto __s = chrono::time_point_cast(__atime);
-	auto __ns = chrono::duration_cast(__atime - __s);
-
-	__gthread_time_t __ts =
-	  {
-	static_cast(__s.time_since_epoch().count()),
-	static_cast(__ns.count())
-	  };
-
-	int __ret = pthread_rwlock_timedwrlock(&_M_rwlock, &__ts);
-	// On self-deadlock, we just fail to acquire the lock.  Technically,
-	// the program violated the precondition.
-	if (__ret == ETIMEDOUT || __ret == EDEADLK)
-	  return false;
-	// Errors not handled: EINVAL
-	_GLIBCXX_DEBUG_ASSERT(__ret == 0);
-	return true;
-  }
-
-template
-  bool
-  try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time)
-  {
-	// DR 887 - Sync unknown clock to known clock.
-	const typename _Clock::time_point __c_entry = _Clock::now();
-	const __clock_t::time_point __s_entry = __clock_t::now();
-	const auto __delta = __abs_t

Re: [debug-early] fix problem with template parameter packs

2015-06-05 Thread Aldy Hernandez

On 06/05/2015 12:20 PM, Jason Merrill wrote:

Looks good.

Jason


Attached is the latest against mainline, with the aforementioned change, 
and without the dumped_early bit.


Retested for --enable-languages=all,go,ada, for both GCC and GDB.

Let me know how this looks.

Aldy
gcc/

	* dwarf2out.c: Remove deferred_locations*.
	(dwarf2_debug_hooks): Add early_finish hook.
	Remove global_decl hook.
	Add early_global_decl and late_global_decl hook.
	New global early_dwarf.
	New structure set_early_dwarf.
	(output_die): Indicate whether a DIE was generated early
	when generating assembly with -dA.
	(struct limbo_die_struct): Document created_for field.
	Remove file_table_last_lookup.
	(remove_AT): Return TRUE if successful.
	(remove_child_TAG): Clear die_parent.
	(reparent_child): New function abstracted from...
	(splice_child_die): ...here.
	(new_die): ICE if a DIE ends up in limbo too late.
	(print_die): Display "(DUMPED EARLY)" if appropriate.
	(check_die): New.
	(defer_location): Remove.
	(add_subscript_info): Reuse DW_TAG_subrange_type if available.
	(fill_variable_array_bounds): New.
	(decl_start_label): Call fill_variable_array_bounds.
	(gen_formal_parameter_die): Rewrite to reuse previously generated
	DIEs.
	(gen_subprogram_die): Same.
	(gen_variable_die): Same.
	(gen_const_die): Same.
	(gen_label_die): Same.
	(gen_lexical_block_die): Same.
	(decl_will_get_specification_p): New.
	(local_function_static): New.
	(gen_struct_or_union_type_die): Fill in variable-length fields.
	(gen_typedef_die): Fill in variable-length typedefs.
	(gen_tagged_type_die): Gracefully return on error_mark_node.
	Handle re-entrancy.
	(gen_type_die_with_usage): Handle variable-length types.
	Remove duplicate code for ARRAY_TYPE case.
	(process_scope_var): Only process imported modules during early
	dwarf.
	(dwarf2out_early_global_decl): New.
	(dwarf2out_late_global_decl): Rename from dwarf2out_global_decl.
	(dwarf2out_type_decl): Set early_dwarf while calling
	dwarf2out_decl.
	(dwarf2out_decl): Verify that we did not recreate a previously
	generated DIE.
	Do not return on DECL_EXTERNALs in VAR_DECLs.
	Abstract some code to local_function_static.
	(lookup_filename): Remove use of file_table_last_lookup.
	Gracefully exit on missing file_name.
	(dwarf2out_finish): Verify limbo list.
	Remove deferred_locations_list use.
	Move deferred_asm_name and limbo flushing to...
	(dwarf2out_early_finish): ...here.  New.
	(dwarf2out_c_finalize): Remove set of deferred_location_list,
	deferred_asm_name, and file_table_last_lookup.
	* cgraph.h (referred_to_p): Add default argument.
	* cgraphunit.c (referred_to_p): Add and handle include_self
	argument.
	(analyze_functions): Add first_time argument.
	Call check_global_declaration for all symbols.
	Call late_global_decl for nodes for moribund nodes.
	(finalize_compilation_unit): Add new argument to
	analyze_functions.
	Call early_global_decl for functions.
	Call early_finish debug hook.
	* dbxout.c (dbxout_early_global_decl): New.
	(dbxout_late_global_decl): New.  Adapted from dbxout_global_decl.
	(dbx_debug_hooks): Add new hooks.
	(xcoff_debug_hooks): Same.
	* debug.c (do_nothing_debug_hooks): Add early_finish field.
	Add early and late debug hooks.
	Remove global_decl hook.
	* debug.h (struct gcc_debug_hooks): Add early_finish,
	early_global_decl, and late_global_decl fields.
	Remove global_decl field.
	Document gcc_debug_hooks.
	* gengtype.c (output_typename): Remove.
	* godump.c (go_early_global_decl): New.
	(go_late_global_decl): New.
	(go_global_decl): Remove.
	(dump_go_spec_init): Remove global_decl.  Add
	{early,late}_global_decl.
	* langhooks-def.h (LANG_HOOKS_WRITE_GLOBALS): Remove.
	(LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): New.
	* langhooks.c (lhd_warn_unused_global_decl): Adjust comment.
	(write_global_declarations): Remove.
	(global_decl_processing): New.
	* langhooks.h (struct lang_hooks_for_decls): Remove
	final_write_globals field.
	Add post_compilation_parsing_cleanups field.
	* passes.c (rest_of_decl_compilation): Call early_global_decl.
	* sdbout.c: Add early and late_global_decl hooks.  Remove
	sdbout_global_decl hook.
	Add early_finish field for sdb_debug_hooks.
	(sdbout_global_decl): Remove.
	(sdbout_early_global_decl): New.
	(sdbout_late_global_decl): New.
	* timevar.def (TV_PHASE_LATE_PARSING_CLEANUPS): New.
	* toplev.c (check_global_declaration): Rename from
	check_global_declaration_1.
	Adapt to use symtab infrastructure.
	(check_global_declarations): Remove.
	(emit_debug_global_declarations): Remove.
	(compile_file): Remove call to final_write_globals langhook.
	Run the actual compilation process.
	Perform any post compilation parser cleanups.
	Generate late debug info.
	* toplev.h (check_global_declaration): New.
	(check_global_declaration_1): Remove.
	(check_global_declarations): Remove.
	(write_global_declarations): Remove.
	(emit_debug_global_declarations): Remove.
	(global_decl_processing): New.
	* tree-core.h (struct tree_block): Add DIE field.
	* tree.h (BL

Re: [debug-early] fix problem with template parameter packs

2015-06-05 Thread Jason Merrill

On 06/05/2015 12:33 PM, Aldy Hernandez wrote:

+  /* The tree for which this DIE was created for.  We use this to


Too many "for"s.


-  fprintf (outfile, "DIE %4ld: %s (%p)\n",
+  fprintf (outfile, "DIE %4ld: %s (%p)",
   die->die_offset, dwarf_tag_name (die->die_tag),
   (void*) die);
+  fputc ('\n', outfile);


I don't think you need this change.


   else if (declaration)
-gen_formal_types_die (decl, subr_die);
+{
+  /* Only generate a prototype's parameters once.  */
+  if (!old_die)
+   gen_formal_types_die (decl, subr_die);
+}


I think this is dead code now, since you return early if declaration && 
old_die.


OK with those changes.

Jason



[patch] Add std::bool_constant for C++17

2015-06-05 Thread Jonathan Wakely

This implements
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4389.html
which was voted into the working paper in Lenexa. Like the last patch,
this has a TODO placeholder for the feature-test macro.

It also updates the manual to document the status of all the library
papers from Lenexa.

Tested powerpc64le-linux, committed to trunk.

commit 3403af1ca5120ffb33d9aff076026ddf8cc01626
Author: Jonathan Wakely 
Date:   Fri Jun 5 17:54:11 2015 +0100

	* doc/xml/manual/status_cxx2017.xml: Update status tables.
	* doc/html/manual/*: Regenerate.
	* include/std/type_traits (bool_constant): Define.
	* testsuite/20_util/bool_constant/requirements.cc: New.
	* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc:
	Likewise.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc:
	Likewise.

diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
index 55f3cd2..d110572 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
@@ -162,6 +162,67 @@ not in any particular release.
   
 
 
+
+  
+  
+	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4366.html";>
+	  N4387
+	
+  
+  
+LWG 2228: Missing SFINAE rule in unique_ptr templated assignment
+  
+  N
+  
+
+
+
+  
+  
+	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4387.html";>
+	  N4387
+	
+  
+   Improving pair and tuple, revision 3 
+  N
+  
+
+
+
+  
+	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4389.html";>
+	  N4389
+	
+  
+   Wording for bool_constant, revision 1 
+  Y
+  
+
+
+
+  
+	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4508.html";>
+	  N4508
+	
+  
+  A proposal to add shared_mutex (untimed) (Revision 4)
+  Y
+  
+
+
+
+  
+	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4510.html";>
+	  N4510
+	
+  
+  
+Minimal incomplete type support for standard containers, revision 4
+  
+  Y
+  
+
+
   
 
 
@@ -241,6 +302,69 @@ not in any particular release.
   Library Fundamentals 2 TS
 
 
+
+
+  
+  
+	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4388.html";>
+	  N4388
+	
+  
+  Const-Propagating Wrapper
+  N
+  Library Fundamentals 2 TS
+
+
+
+  
+  
+	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4391.html";>
+	  N4391
+	
+  
+   make_array, revision 4 
+  N
+  Library Fundamentals 2 TS
+
+
+
+  
+  
+	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf";>
+	  N4502
+	
+  
+   Support for the C++ Detection Idiom, V2 
+  N
+  Library Fundamentals 2 TS
+
+
+
+  
+  
+	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4519.pdf";>
+	  N4519
+	
+  
+   Source-Code Information Capture 
+  N
+  Library Fundamentals 2 TS
+
+
+
+  
+  
+	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4521.html";>
+	  N4521
+	
+  
+   Merge Fundamentals V1 into V2 
+  N
+  Library Fundamentals 2 TS
+
+
+
+
   
 
 
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index 2eae61b..e09c856 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -92,6 +92,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template
 using __bool_constant = integral_constant;
 
+#if __cplusplus > 201402L
+// TODO: #define __cpp_lib_bool_constant 201505
+  template
+using bool_constant = integral_constant;
+#endif
+
   // Meta programming helper types.
 
   template
diff --git a/libstdc++-v3/testsuite/20_util/bool_constant/requirements.cc b/libstdc++-v3/testsuite/20_util/bool_constant/requirements.cc
new file mode 100644
index 000..ddc02df
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/bool_constant/requirements.cc
@@ -0,0 +1,26 @@
+// Copyright (C) 2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope th

Re: Heads-up: testsuite: removed cleanup-ipa-dump, cleanup-rtl-dump,cleanup-tree-dump, cleanup-dump, cleanup-saved-temps

2015-06-05 Thread Mike Stump
On Jun 5, 2015, at 4:02 AM, Tom de Vries  wrote:
> On 02/06/15 20:40, Bernhard Reutner-Fischer wrote:
>> On June 2, 2015 5:38:06 PM GMT+02:00, Bernhard 
>> Reutner-Fischer  wrote:
>>> >On June 2, 2015 2:08:47 PM GMT+02:00, Richard Biener
>>> >  wrote:
 >>
 >>Committed.  Seems to cause half of the vectorizer tests to be dropped
 >>and test-summary breaking for me.
>> As a gentle reminder to reviewers and all:
>> 
>>> >Right. There should be no cleanup-tree-dump left on trunk.
> 
> My overnight testing of a patch also broke on a harmless cleanup-tree-dump.
> 
> What is the rationale to have this as an error rather than a warning?

So that we can clean up trunk and ensure no one puts dirty stuff on it?

[debug-early, jit] Port of jit to debug-early

2015-06-05 Thread David Malcolm
"jit" isn't part of "all" languages, and currently fails to build on
the aldyh/debug-early branch:

../../src/gcc/jit/jit-playback.c: In member function ‘void 
gcc::jit::playback::context::write_global_decls_2()’:
../../src/gcc/jit/jit-playback.c:710:20: error: ‘const struct gcc_debug_hooks’ 
has no member named ‘global_decl’
   debug_hooks->global_decl (decl);

This patch (on top of today's 1a07de5e93cc9e18d899a6a1b7d01436167ab1b1)
fixes the build of the jit.

"make check-jit" works, with:
  # of expected passes7609

I verified the debuggability of jitted code by hand by

  (a) running jit.dg/test-using-globals.c
  and inspecting globals, and

  (b) running jit.dg/test-fibonacci.c and
  single-stepping through the code in gdb:

  (gdb) break my_fibonacci
  (gdb) run
  Breakpoint 1, my_fibonacci (x=10) at 
/home/david/coding-3/gcc-git-jit-early-debug/src/gcc/testsuite/jit.dg/test-fibonacci.c:19
  19FIRST_LINE + 3:   if (x < 2)
  (gdb) next
  16FIRST_LINE + 0: int
  (gdb) next
  19FIRST_LINE + 3:   if (x < 2)
  (gdb) next
  22FIRST_LINE + 6: return my_fibonacci (x - 1) + my_fibonacci 
(x - 2);

OK for your branch?

gcc/jit/ChangeLog:
* dummy-frontend.c (jit_langhook_write_globals): Rename to...
(jit_langhook_post_compilation_parsing_cleanups): ...this, and
eliminate calls to finalize_compilation_unit and
write_global_decls_2.
(LANG_HOOKS_WRITE_GLOBALS): Rename to...
(LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): ...this and
redirect from jit_langhook_write_globals to
jit_langhook_post_compilation_parsing_cleanups.
* jit-playback.c
(gcc::jit::playback::context::write_global_decls_1): Rename to...
(gcc::jit::playback::context::finalize_global_decls): ...this.
(gcc::jit::playback::context::write_global_decls_1): Delete.
* jit-playback.h
(gcc::jit::playback::context::write_global_decls_1): Rename to...
(gcc::jit::playback::context::finalize_global_decls): ...this.
(gcc::jit::playback::context::write_global_decls_1): Delete.
---
 gcc/jit/dummy-frontend.c | 14 +-
 gcc/jit/jit-playback.c   | 25 ++---
 gcc/jit/jit-playback.h   |  4 +---
 3 files changed, 8 insertions(+), 35 deletions(-)

diff --git a/gcc/jit/dummy-frontend.c b/gcc/jit/dummy-frontend.c
index 8f7d06a..374df6f 100644
--- a/gcc/jit/dummy-frontend.c
+++ b/gcc/jit/dummy-frontend.c
@@ -222,18 +222,13 @@ jit_langhook_getdecls (void)
 }
 
 static void
-jit_langhook_write_globals (void)
+jit_langhook_post_compilation_parsing_cleanups (void)
 {
   gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
   gcc_assert (ctxt);
   JIT_LOG_SCOPE (ctxt->get_logger ());
 
-  ctxt->write_global_decls_1 ();
-
-  /* This is the hook that runs the middle and backends: */
-  symtab->finalize_compilation_unit ();
-
-  ctxt->write_global_decls_2 ();
+  ctxt->finalize_global_decls ();
 }
 
 #undef LANG_HOOKS_NAME
@@ -263,8 +258,9 @@ jit_langhook_write_globals (void)
 #undef LANG_HOOKS_GETDECLS
 #define LANG_HOOKS_GETDECLSjit_langhook_getdecls
 
-#undef LANG_HOOKS_WRITE_GLOBALS
-#define LANG_HOOKS_WRITE_GLOBALS   jit_langhook_write_globals
+#undef LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS
+#define LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS \
+  jit_langhook_post_compilation_parsing_cleanups
 
 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index c75c076..0d329b0 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -673,14 +673,13 @@ as_truth_value (tree expr, location *loc)
   return expr;
 }
 
-/* For use by jit_langhook_write_globals.
+/* For use by jit_langhook_post_compilation_parsing_cleanups
Calls varpool_node::finalize_decl on each global.  */
 
 void
 playback::context::
-write_global_decls_1 ()
+finalize_global_decls ()
 {
-  /* Compare with e.g. the C frontend's c_write_global_declarations.  */
   JIT_LOG_SCOPE (get_logger ());
 
   int i;
@@ -692,26 +691,6 @@ write_global_decls_1 ()
 }
 }
 
-/* For use by jit_langhook_write_globals.
-   Calls debug_hooks->global_decl on each global.  */
-
-void
-playback::context::
-write_global_decls_2 ()
-{
-  /* Compare with e.g. the C frontend's c_write_global_declarations_2. */
-  JIT_LOG_SCOPE (get_logger ());
-
-  int i;
-  tree decl;
-  FOR_EACH_VEC_ELT (m_globals, i, decl)
-{
-  gcc_assert (TREE_CODE (decl) == VAR_DECL);
-  debug_hooks->global_decl (decl);
-}
-}
-
-
 /* Construct a playback::rvalue instance (wrapping a tree) for a
unary op.  */
 
diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h
index e9832f0..84d99e4 100644
--- a/gcc/jit/jit-playback.h
+++ b/gcc/jit/jit-playback.h
@@ -215,9 +215,7 @@ public:
 return m_recording_ctxt->errors_occurred ();
   }
 
-  /* For use by jit_langhook_write_global

C++ PATCH for c++/66405 (ICE with variadic alias template)

2015-06-05 Thread Jason Merrill
When substituting one pack expansion into another, we try to simplify 
the expansion by substituting one pattern into the other, but this 
doesn't work in this case, because the argument expansion is partially 
instantiated (the enclosing class template's parms are bound, but not 
the member template's) and therefore the expansion has extra args 
attached that we can't throw away.  It would probably be possible to 
propagate the extra args to the resulting substituted expansion, but 
it's simpler not to try to do the expansion.


Tested x86_64-pc-linux-gnu, applying to trunk and 5.


commit 39ee96b66659979cfdfa54117343b69903d210b0
Author: Jason Merrill 
Date:   Fri Jun 5 14:28:34 2015 -0400

	PR c++/66405
	* pt.c (argument_pack_element_is_expansion_p): Return 2 if
	the expansion has extra args.
	(use_pack_expansion_extra_args_p): Return true in that case.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 87b35fa..4a9fff0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9740,16 +9740,22 @@ make_fnparm_pack (tree spec_parm)
   return extract_fnparm_pack (NULL_TREE, &spec_parm);
 }
 
-/* Return true iff the Ith element of the argument pack ARG_PACK is a
-   pack expansion.  */
+/* Return 1 if the Ith element of the argument pack ARG_PACK is a
+   pack expansion with no extra args, 2 if it has extra args, or 0
+   if it is not a pack expansion.  */
 
-static bool
+static int
 argument_pack_element_is_expansion_p (tree arg_pack, int i)
 {
   tree vec = ARGUMENT_PACK_ARGS (arg_pack);
   if (i >= TREE_VEC_LENGTH (vec))
-return false;
-  return PACK_EXPANSION_P (TREE_VEC_ELT (vec, i));
+return 0;
+  tree elt = TREE_VEC_ELT (vec, i);
+  if (!PACK_EXPANSION_P (elt))
+return 0;
+  if (PACK_EXPANSION_EXTRA_ARGS (elt))
+return 2;
+  return 1;
 }
 
 
@@ -9799,7 +9805,12 @@ use_pack_expansion_extra_args_p (tree parm_packs,
 	{
 	  tree arg = TREE_VALUE (parm_pack);
 
-	  if (argument_pack_element_is_expansion_p (arg, i))
+	  int exp = argument_pack_element_is_expansion_p (arg, i);
+	  if (exp == 2)
+	/* We can't substitute a pack expansion with extra args into
+	   our pattern.  */
+	return true;
+	  else if (exp)
 	has_expansion_arg = true;
 	  else
 	has_non_expansion_arg = true;
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-alias1.C b/gcc/testsuite/g++.dg/cpp0x/variadic-alias1.C
new file mode 100644
index 000..e931bc5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic-alias1.C
@@ -0,0 +1,13 @@
+// PR c++/66405
+// { dg-do compile { target c++11 } }
+
+template  struct B;
+template  using and_c = B;
+template  using Constructible = int;
+template  struct common_tuple {
+  template {}...> >
+common_tuple();
+  void foo();
+};
+template <> void common_tuple<>::foo(){}


[java] include missing file after debug-early merge

2015-06-05 Thread Aldy Hernandez
Must've crossed paths with Andrew Macleod in his header refactoring or 
something.  I added a call to global_decl_processing() which is now 
missing the relevant header file.


I'm testing this and committing as obvious, once I retest mainline once 
again.


Aldy
commit d681ceeaef7dcc598a469d86c60e370c21a4f4ed
Author: Aldy Hernandez 
Date:   Fri Jun 5 15:24:49 2015 -0400

* jcf-parse.c: Include toplev.h.

diff --git a/gcc/java/jcf-parse.c b/gcc/java/jcf-parse.c
index ba216a1..721696b 100644
--- a/gcc/java/jcf-parse.c
+++ b/gcc/java/jcf-parse.c
@@ -55,6 +55,7 @@ The Free Software Foundation is independent of Sun 
Microsystems, Inc.  */
 #include "cgraph.h"
 #include "bitmap.h"
 #include "target.h"
+#include "toplev.h"
 
 #ifdef HAVE_LOCALE_H
 #include 


Re: [debug-early, jit] Port of jit to debug-early

2015-06-05 Thread Aldy Hernandez

On 06/05/2015 03:00 PM, David Malcolm wrote:

"jit" isn't part of "all" languages, and currently fails to build on
the aldyh/debug-early branch:


The debug-early work is now in mainline.  Feel free to commit when you 
deem appropriate, since you are the jit maintainer ;-).



  static void
-jit_langhook_write_globals (void)
+jit_langhook_post_compilation_parsing_cleanups (void)
  {
gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
gcc_assert (ctxt);
JIT_LOG_SCOPE (ctxt->get_logger ());

-  ctxt->write_global_decls_1 ();
-
-  /* This is the hook that runs the middle and backends: */
-  symtab->finalize_compilation_unit ();
-
-  ctxt->write_global_decls_2 ();
+  ctxt->finalize_global_decls ();


This hook gets called after the compilation proper has run, and we're 
trying to avoid it.  We're trying to get all the front-ends to finish 
their thing and avoid depending on the compilation proper.


Can you not get this to work without running finalize_global_decls after 
the compilation proper?  If not, then I see no problem with your 
patchafter all, C++ is still using this hook :(.


Thanks for working on this.

Aldy


[wwwdocs] Move gcc/README.Portability to wwwdocs codingconventions.html

2015-06-05 Thread Ciro Santilli
Mentioned as a FIXME under gcc/doc/sourcebuild.texi

This converts half of README.Portability to wwwdocs.

If you think this is fine, before merging I can convert the rest, and
also include the patch to GCC that removes README.Portability and the
FIXME.

--- htdocs/codingconventions.html2014-07-09 02:03:05.0 +0200
+++ codingconventions2.html2015-05-16 11:49:39.0 +0200
@@ -30,8 +30,13 @@
 
 Assertions
 Character Testing
+Empty Macro Arguments
 Error Node Testing
+Free NULL Check
+Long Integer
Literal Suffix
 Parameters Affecting Generated Code
+Parenthesis Around
String Initializers
+Trigraphs
 Inlining Functions
 
 
@@ -708,6 +713,24 @@
 language accepted.


+Empty Macro Arguments
+
+ISO C (6.8.3 in the 1990 standard) specifies the following:
+
+If (before argument substitution) any argument consists of no
+preprocessing tokens, the behavior is undefined.
+
+This was relaxed by ISO C99, but some older compilers emit an error,
+so code like:
+
+
+#define foo(x, y) x y
+foo (bar, )
+
+
+needs to be coded in some other way.
+
+
 Error Node Testing

 Testing for ERROR_MARKs should be done by comparing
@@ -716,12 +739,67 @@
 
href="https://gcc.gnu.org/ml/gcc-patches/2000-10/msg00792.html";>message.


+Free NULL Check
+
+Don't check if a pointer is NULL before freeing it.
+
+Since SunOS 4 stopped being a reasonable portability target,
+(which happened around 2007) there has been no need to guard
+against free (NULL).  Thus, any guard like the following
+constitutes a redundant test:
+
+
+if (P)
+  free (P);
+
+
+However, if your profiling exposes a test like this in a
+performance-critical loop, say where P is nearly always NULL, and
+the cost of calling free on a NULL pointer would be prohibitively
+high, consider using __builtin_expect, e.g., like this:
+
+
+if (__builtin_expect (ptr != NULL, 0))
+  free (ptr);
+
+
+
+Long Integer Literal Suffix
+
+Never use lower case l since it can be confused
+with the number 1.  Use upper case L instead.
+
+
 Parameters Affecting Generated Code

 Internal numeric parameters that may affect generated code should
 be controlled by --param rather than being hardcoded.


+Parenthesis
Around String Initializers
+
+Don't use parenthesis around string initializers.
+
+Irix6 cc -n32 and OSF4 cc have problems with
+constant string initializers with parenthesis around it, e.g.:
+
+
+const char string[] = ("A string");
+
+
+This is unfortunate since this is what the GNU gettext macro N_
+produces.  You need to find a different way to code it.
+
+Some compilers like MSVC++ have fairly low limits on the maximum
+length of a string literal; 509 is the lowest we've come across.  You
+may need to break up a long printf statement into many smaller ones. 
+
+
+Trigraphs
+
+Don't use trigraphs because some compilers do not accept them.
+
+
 Inlining Functions

 


Re: [wwwdocs] Move gcc/README.Portability to wwwdocs codingconventions.html

2015-06-05 Thread Joseph Myers
On Fri, 5 Jun 2015, Ciro Santilli wrote:

> Mentioned as a FIXME under gcc/doc/sourcebuild.texi
> 
> This converts half of README.Portability to wwwdocs.

Since GCC is now in C++, what's compatible with C90 (or with any 
particular C compiler) is no longer relevant.  So the question is what's 
compatible with C++98 and with C++ compilers that might be used to build 
GCC, and some of these items need more of a rework than just moving from 
one place to another.

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


Re: [debug-early, jit] Port of jit to debug-early

2015-06-05 Thread David Malcolm
On Fri, 2015-06-05 at 15:37 -0400, Aldy Hernandez wrote:
> On 06/05/2015 03:00 PM, David Malcolm wrote:
> > "jit" isn't part of "all" languages, and currently fails to build on
> > the aldyh/debug-early branch:
> 
> The debug-early work is now in mainline.  Feel free to commit when you 
> deem appropriate, since you are the jit maintainer ;-).

Given that it fixes the build of the jit, I've gone ahead and committed
the patch as-is to trunk (r224170).

> >   static void
> > -jit_langhook_write_globals (void)
> > +jit_langhook_post_compilation_parsing_cleanups (void)
> >   {
> > gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
> > gcc_assert (ctxt);
> > JIT_LOG_SCOPE (ctxt->get_logger ());
> >
> > -  ctxt->write_global_decls_1 ();
> > -
> > -  /* This is the hook that runs the middle and backends: */
> > -  symtab->finalize_compilation_unit ();
> > -
> > -  ctxt->write_global_decls_2 ();
> > +  ctxt->finalize_global_decls ();
> 
> This hook gets called after the compilation proper has run, and we're 
> trying to avoid it.  We're trying to get all the front-ends to finish 
> their thing and avoid depending on the compilation proper.
> 
> Can you not get this to work without running finalize_global_decls after 
> the compilation proper?  If not, then I see no problem with your 
> patchafter all, C++ is still using this hook :(.

Am investigating.

Thanks
Dave



Re: [wwwdocs] Move gcc/README.Portability to wwwdocs codingconventions.html

2015-06-05 Thread Mikhail Maltsev
05.06.2015 23:45, Ciro Santilli writes:
[snip]
> +high, consider using __builtin_expect, e.g., like this:
> +
> +
> +if (__builtin_expect (ptr != NULL, 0))
> +  free (ptr);
> +

It's strange, that we don't have macros for this, e.g.:
#define likely(x)   __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect((x), 0)

Is it worth adding them to, say, system.h or ansidecl.h?

-- 
Regards,
Mikhail Maltsev


Re: Add tree heterogeneous lookup in alternative modes

2015-06-05 Thread François Dumont

On 04/06/2015 14:41, Jonathan Wakely wrote:

On 03/06/15 21:56 +0200, François Dumont wrote:

Hi

   Here is a patch to add heterogeneous lookup to alternative modes. 


Excellent.

To do so I had to expose __is_transparent as __has_is_transparent to 
avoid confilct with existing __is_transparent.


That's a better name, thanks.



Should I put it in __detail namespace ?


Could it just be protected instead of at namespace scope?


No, debug containers are inheriting from normal containers, not from 
_Rb_tree.




If it can't be protected it's OK here you put it, it doesn't need to
be in __detail.

But maybe we should rename the _Kt parameter of __hash_is_transparent
to _Unused, _Dummy or something like that. It only exists to make the
specialization dependent on a template argument of the functions that
use it.



I renamed it into _SfinaeType to make the purpose of this type clearer.




   * include/bits/stl_tree.h (_Rb_tree<>::__is_transparent<>): Move to
   outer scope and rename in ...


"rename to ..."

not "rename into..." :-)



   (std::__hash_is_transparent<>): ... this.


In  ...


@@ -429,12 +477,34 @@
  std::pair
  equal_range(const key_type& __x) const
  {
-std::pair<_Base_iterator, _Base_iterator> __res =
+std::pair<_Base_const_iterator, _Base_const_iterator> __res =
_Base::equal_range(__x);
return std::make_pair(const_iterator(__res.first, this),
  const_iterator(__res.second, this));
  }


Huh! Did calls to this function even compile before this fix?


I had a closer look and yes, it was compiling because for set iterator 
and const_iterator are just the same:


  // DR 103. set::iterator is required to be modifiable,
  // but this allows modification of keys.
  typedef typename _Rep_type::const_iterator iterator;
  typedef typename _Rep_type::const_iterator const_iterator;

However I slightly changed some tests to make sure the const version of 
equal_range and some others are used.


If it is still fine I will commit the attached patch tomorrow.

François

Index: include/bits/stl_tree.h
===
--- include/bits/stl_tree.h	(revision 224099)
+++ include/bits/stl_tree.h	(working copy)
@@ -341,7 +341,17 @@
   _Rb_tree_rebalance_for_erase(_Rb_tree_node_base* const __z,
 			   _Rb_tree_node_base& __header) throw ();
 
+#if __cplusplus > 201103L
+  template>
+struct __has_is_transparent
+{ };
 
+  template
+struct __has_is_transparent<_Cmp, _SfinaeType,
+__void_t>
+{ typedef void type; };
+#endif
+
   template >
 class _Rb_tree
@@ -1109,16 +1119,9 @@
   equal_range(const key_type& __k) const;
 
 #if __cplusplus > 201103L
-  template>
-	struct __is_transparent { };
-
-  template
-	struct
-	__is_transparent<_Cmp, _Kt, __void_t>
-	{ typedef void type; };
-
   template::type>
+	   typename _Req =
+		 typename __has_is_transparent<_Compare, _Kt>::type>
 	iterator
 	_M_find_tr(const _Kt& __k)
 	{
@@ -1127,7 +1130,8 @@
 	}
 
   template::type>
+	   typename _Req =
+		 typename __has_is_transparent<_Compare, _Kt>::type>
 	const_iterator
 	_M_find_tr(const _Kt& __k) const
 	{
@@ -1138,7 +1142,8 @@
 	}
 
   template::type>
+	   typename _Req =
+		 typename __has_is_transparent<_Compare, _Kt>::type>
 	size_type
 	_M_count_tr(const _Kt& __k) const
 	{
@@ -1147,7 +1152,8 @@
 	}
 
   template::type>
+	   typename _Req =
+		 typename __has_is_transparent<_Compare, _Kt>::type>
 	iterator
 	_M_lower_bound_tr(const _Kt& __k)
 	{
@@ -1156,7 +1162,8 @@
 	}
 
   template::type>
+	   typename _Req =
+		 typename __has_is_transparent<_Compare, _Kt>::type>
 	const_iterator
 	_M_lower_bound_tr(const _Kt& __k) const
 	{
@@ -1174,7 +1181,8 @@
 	}
 
   template::type>
+	   typename _Req =
+		 typename __has_is_transparent<_Compare, _Kt>::type>
 	iterator
 	_M_upper_bound_tr(const _Kt& __k)
 	{
@@ -1183,7 +1191,8 @@
 	}
 
   template::type>
+	   typename _Req =
+		 typename __has_is_transparent<_Compare, _Kt>::type>
 	const_iterator
 	_M_upper_bound_tr(const _Kt& __k) const
 	{
@@ -1201,7 +1210,8 @@
 	}
 
   template::type>
+	   typename _Req =
+		 typename __has_is_transparent<_Compare, _Kt>::type>
 	pair
 	_M_equal_range_tr(const _Kt& __k)
 	{
@@ -1211,7 +1221,8 @@
 	}
 
   template::type>
+	   typename _Req =
+		 typename __has_is_transparent<_Compare, _Kt>::type>
 	pair
 	_M_equal_range_tr(const _Kt& __k) const
 	{
Index: include/debug/map.h
===
--- include/debug/map.h	(revision 224099)
+++ include/debug/map.h	(working copy)
@@ -412,10 +412,28 @@
   find(const key_type& __x)
   { return iterator(_Base::find(__x), this); }
 
+#if __cplusplus > 201103L
+  template::type>
+	iterator
+	find(const _Kt& __x)
+	{ return { _Base::find(__x), this }; }
+#endif
+
   const_iterator
   find(const key_type& __x) cons

Re: [debug-early, jit] Port of jit to debug-early

2015-06-05 Thread David Malcolm
On Fri, 2015-06-05 at 16:18 -0400, David Malcolm wrote:
> On Fri, 2015-06-05 at 15:37 -0400, Aldy Hernandez wrote:
> > On 06/05/2015 03:00 PM, David Malcolm wrote:
> > > "jit" isn't part of "all" languages, and currently fails to build on
> > > the aldyh/debug-early branch:
> > 
> > The debug-early work is now in mainline.  Feel free to commit when you 
> > deem appropriate, since you are the jit maintainer ;-).
> 
> Given that it fixes the build of the jit, I've gone ahead and committed
> the patch as-is to trunk (r224170).
> 
> > >   static void
> > > -jit_langhook_write_globals (void)
> > > +jit_langhook_post_compilation_parsing_cleanups (void)
> > >   {
> > > gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
> > > gcc_assert (ctxt);
> > > JIT_LOG_SCOPE (ctxt->get_logger ());
> > >
> > > -  ctxt->write_global_decls_1 ();
> > > -
> > > -  /* This is the hook that runs the middle and backends: */
> > > -  symtab->finalize_compilation_unit ();
> > > -
> > > -  ctxt->write_global_decls_2 ();
> > > +  ctxt->finalize_global_decls ();
> > 
> > This hook gets called after the compilation proper has run, and we're 
> > trying to avoid it.  We're trying to get all the front-ends to finish 
> > their thing and avoid depending on the compilation proper.
> > 
> > Can you not get this to work without running finalize_global_decls after 
> > the compilation proper?  If not, then I see no problem with your 
> > patchafter all, C++ is still using this hook :(.
> 
> Am investigating.

All that it was doing was calling varpool_node::finalize_decl on each
global; it appears that it's OK to instead call that on them as soon as
they're created (despite the name).

I've committed the attached patch to trunk (r224173) which removes the
hook; "make check-jit" gives the same results as before, and I again
hand-tested (with gdb) jit.dg's test-using-global.c and
test-fibonacci.c.
Index: gcc/jit/ChangeLog
===
--- gcc/jit/ChangeLog	(revision 224172)
+++ gcc/jit/ChangeLog	(revision 224173)
@@ -1,5 +1,16 @@
 2015-06-05  David Malcolm  
 
+	* dummy-frontend.c
+	(jit_langhook_post_compilation_parsing_cleanups): Remove.
+	(LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS): Remove
+	* jit-playback.c (gcc::jit::playback::context::new_global): Add
+	call to varpool_node::finalize_decl.
+	(gcc::jit::playback::context::finalize_global_decls): Remove.
+	* jit-playback.h
+	(gcc::jit::playback::context::finalize_global_decls): Remove.
+
+2015-06-05  David Malcolm  
+
 	* dummy-frontend.c (jit_langhook_write_globals): Rename to...
 	(jit_langhook_post_compilation_parsing_cleanups): ...this, and
 	eliminate calls to finalize_compilation_unit and
Index: gcc/jit/dummy-frontend.c
===
--- gcc/jit/dummy-frontend.c	(revision 224172)
+++ gcc/jit/dummy-frontend.c	(revision 224173)
@@ -218,16 +218,6 @@
   return NULL;
 }
 
-static void
-jit_langhook_post_compilation_parsing_cleanups (void)
-{
-  gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
-  gcc_assert (ctxt);
-  JIT_LOG_SCOPE (ctxt->get_logger ());
-
-  ctxt->finalize_global_decls ();
-}
-
 #undef LANG_HOOKS_NAME
 #define LANG_HOOKS_NAME		"libgccjit"
 
@@ -255,10 +245,6 @@
 #undef LANG_HOOKS_GETDECLS
 #define LANG_HOOKS_GETDECLS		jit_langhook_getdecls
 
-#undef LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS
-#define LANG_HOOKS_POST_COMPILATION_PARSING_CLEANUPS \
-  jit_langhook_post_compilation_parsing_cleanups
-
 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
 #include "gt-jit-dummy-frontend.h"
Index: gcc/jit/jit-playback.c
===
--- gcc/jit/jit-playback.c	(revision 224172)
+++ gcc/jit/jit-playback.c	(revision 224173)
@@ -514,6 +514,8 @@
 
   varpool_node::get_create (inner);
 
+  varpool_node::finalize_decl (inner);
+
   m_globals.safe_push (inner);
 
   return new lvalue (this, inner);
@@ -668,24 +670,6 @@
   return expr;
 }
 
-/* For use by jit_langhook_post_compilation_parsing_cleanups
-   Calls varpool_node::finalize_decl on each global.  */
-
-void
-playback::context::
-finalize_global_decls ()
-{
-  JIT_LOG_SCOPE (get_logger ());
-
-  int i;
-  tree decl;
-  FOR_EACH_VEC_ELT (m_globals, i, decl)
-{
-  gcc_assert (TREE_CODE (decl) == VAR_DECL);
-  varpool_node::finalize_decl (decl);
-}
-}
-
 /* Construct a playback::rvalue instance (wrapping a tree) for a
unary op.  */
 
Index: gcc/jit/jit-playback.h
===
--- gcc/jit/jit-playback.h	(revision 224172)
+++ gcc/jit/jit-playback.h	(revision 224173)
@@ -215,8 +215,6 @@
 return m_recording_ctxt->errors_occurred ();
   }
 
-  void finalize_global_decls ();
-
 private:
   void dump_generated_code ();
 


Re: [debug-early, jit] Port of jit to debug-early

2015-06-05 Thread Aldy Hernandez

On 06/05/2015 05:17 PM, David Malcolm wrote:

On Fri, 2015-06-05 at 16:18 -0400, David Malcolm wrote:

On Fri, 2015-06-05 at 15:37 -0400, Aldy Hernandez wrote:

On 06/05/2015 03:00 PM, David Malcolm wrote:

"jit" isn't part of "all" languages, and currently fails to build on
the aldyh/debug-early branch:


The debug-early work is now in mainline.  Feel free to commit when you
deem appropriate, since you are the jit maintainer ;-).


Given that it fixes the build of the jit, I've gone ahead and committed
the patch as-is to trunk (r224170).


   static void
-jit_langhook_write_globals (void)
+jit_langhook_post_compilation_parsing_cleanups (void)
   {
 gcc::jit::playback::context *ctxt = gcc::jit::active_playback_ctxt;
 gcc_assert (ctxt);
 JIT_LOG_SCOPE (ctxt->get_logger ());

-  ctxt->write_global_decls_1 ();
-
-  /* This is the hook that runs the middle and backends: */
-  symtab->finalize_compilation_unit ();
-
-  ctxt->write_global_decls_2 ();
+  ctxt->finalize_global_decls ();


This hook gets called after the compilation proper has run, and we're
trying to avoid it.  We're trying to get all the front-ends to finish
their thing and avoid depending on the compilation proper.

Can you not get this to work without running finalize_global_decls after
the compilation proper?  If not, then I see no problem with your
patchafter all, C++ is still using this hook :(.


Am investigating.


All that it was doing was calling varpool_node::finalize_decl on each
global; it appears that it's OK to instead call that on them as soon as
they're created (despite the name).


Perfect.  The earlier the better.

In most of the front-ends I think we are calling finalize_decl via 
rest_of_decl_compilation which is where we also call the 
early_global_decl hook.




I've committed the attached patch to trunk (r224173) which removes the
hook; "make check-jit" gives the same results as before, and I again
hand-tested (with gdb) jit.dg's test-using-global.c and
test-fibonacci.c.



Excellent.

Thanks.


[patch, testsuite] Remove superfluous -std={c99,gnu99} in libgomp.c

2015-06-05 Thread Tom de Vries

Hi,

this patch removes a superfluous -std=c99 or -std=gnu99 setting in the 
libgomp/testsuite/libgomp.c testcases (and a superfluous -fopenmp 
setting in some cases as well).


The setting is superfluous because -std=gnu11 is the new default for C 
mode, which allows loop initial declaration.


In a few cases (for-{1,2,3}.c, pr35625.c)  we remove the whole 
dg-options line which did not have an -On setting, which means the 
optimization level at which the testcase compiles is changed from -O0 to 
the default -O2.


Tested with a c build. for-2.c fails, filed as PR66429 - 'ICE in 
expand_GOMP_SIMD_LAST_LANE'.


OK for trunk?

Thanks,
- Tom
Remove superfluous -std={c99,gnu99} in libgomp.c

2015-06-05  Tom de Vries  

	* testsuite/libgomp.c/collapse-3.c: Remove superfluous dg-options line
	with -std={gnu99,c99}.
	* testsuite/libgomp.c/for-1.c: Same.
	* testsuite/libgomp.c/for-2.c: Same.
	* testsuite/libgomp.c/for-3.c: Same.
	* testsuite/libgomp.c/pr35625.c: Same.
	* testsuite/libgomp.c/pr39154.c: Same.
	* testsuite/libgomp.c/simd-16.c: Same.
	* testsuite/libgomp.c/simd-17.c: Same.
---
 libgomp/testsuite/libgomp.c/collapse-3.c | 1 -
 libgomp/testsuite/libgomp.c/for-1.c  | 2 --
 libgomp/testsuite/libgomp.c/for-2.c  | 2 --
 libgomp/testsuite/libgomp.c/for-3.c  | 2 --
 libgomp/testsuite/libgomp.c/pr35625.c| 1 -
 libgomp/testsuite/libgomp.c/pr39154.c| 1 -
 libgomp/testsuite/libgomp.c/simd-16.c| 1 -
 libgomp/testsuite/libgomp.c/simd-17.c| 1 -
 8 files changed, 11 deletions(-)

diff --git a/libgomp/testsuite/libgomp.c/collapse-3.c b/libgomp/testsuite/libgomp.c/collapse-3.c
index 4674f83..d780ab9 100644
--- a/libgomp/testsuite/libgomp.c/collapse-3.c
+++ b/libgomp/testsuite/libgomp.c/collapse-3.c
@@ -1,5 +1,4 @@
 /* { dg-do run } */
-/* { dg-options "-O2 -std=gnu99" } */
 
 #include 
 #include 
diff --git a/libgomp/testsuite/libgomp.c/for-1.c b/libgomp/testsuite/libgomp.c/for-1.c
index e702453..e0b9560 100644
--- a/libgomp/testsuite/libgomp.c/for-1.c
+++ b/libgomp/testsuite/libgomp.c/for-1.c
@@ -1,5 +1,3 @@
-/* { dg-options "-std=gnu99 -fopenmp" } */
-
 extern void abort (void);
 
 #define M(x, y, z) O(x, y, z)
diff --git a/libgomp/testsuite/libgomp.c/for-2.c b/libgomp/testsuite/libgomp.c/for-2.c
index ae81008..cc64a52 100644
--- a/libgomp/testsuite/libgomp.c/for-2.c
+++ b/libgomp/testsuite/libgomp.c/for-2.c
@@ -1,5 +1,3 @@
-/* { dg-options "-std=gnu99 -fopenmp" } */
-
 extern void abort (void);
 
 #define M(x, y, z) O(x, y, z)
diff --git a/libgomp/testsuite/libgomp.c/for-3.c b/libgomp/testsuite/libgomp.c/for-3.c
index 06cbf4f..f313f86 100644
--- a/libgomp/testsuite/libgomp.c/for-3.c
+++ b/libgomp/testsuite/libgomp.c/for-3.c
@@ -1,5 +1,3 @@
-/* { dg-options "-std=gnu99 -fopenmp" } */
-
 extern void abort ();
 
 #define M(x, y, z) O(x, y, z)
diff --git a/libgomp/testsuite/libgomp.c/pr35625.c b/libgomp/testsuite/libgomp.c/pr35625.c
index f2978f9..c60f719 100644
--- a/libgomp/testsuite/libgomp.c/pr35625.c
+++ b/libgomp/testsuite/libgomp.c/pr35625.c
@@ -1,6 +1,5 @@
 /* PR libgomp/35625 */
 /* { dg-do run } */
-/* { dg-options "-std=c99" } */
 
 int
 main (void)
diff --git a/libgomp/testsuite/libgomp.c/pr39154.c b/libgomp/testsuite/libgomp.c/pr39154.c
index 5a4c89e..0abdb27 100644
--- a/libgomp/testsuite/libgomp.c/pr39154.c
+++ b/libgomp/testsuite/libgomp.c/pr39154.c
@@ -1,6 +1,5 @@
 /* PR middle-end/39154 */
 /* { dg-do compile } */
-/* { dg-options "-O2 -std=gnu99" } */
 
 extern void abort (void);
 
diff --git a/libgomp/testsuite/libgomp.c/simd-16.c b/libgomp/testsuite/libgomp.c/simd-16.c
index c8c29c7..4a4e811 100644
--- a/libgomp/testsuite/libgomp.c/simd-16.c
+++ b/libgomp/testsuite/libgomp.c/simd-16.c
@@ -1,5 +1,4 @@
 /* { dg-do run } */
-/* { dg-options "-O2 -std=c99" } */
 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
 /* { dg-additional-options "-mavx" { target avx_runtime } } */
 
diff --git a/libgomp/testsuite/libgomp.c/simd-17.c b/libgomp/testsuite/libgomp.c/simd-17.c
index 136e6e6..6556cbd 100644
--- a/libgomp/testsuite/libgomp.c/simd-17.c
+++ b/libgomp/testsuite/libgomp.c/simd-17.c
@@ -1,5 +1,4 @@
 /* { dg-do run } */
-/* { dg-options "-O2 -std=c99" } */
 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
 /* { dg-additional-options "-mavx" { target avx_runtime } } */
 
-- 
1.9.1



[patch, testsuite] Remove -fopenmp in dg-options in libgomp.c

2015-06-05 Thread Tom de Vries

Hi,

this patch removes superfluous -fopenmp settings.

In the case of target-8.c, we remove the whole dg-options line which did 
not have an -On setting, which means the optimization level at which the 
testcase compiles is changed from -O0 to the default -O2.


Tested with a c build.

OK for trunk?

Thanks,
- Tom
Remove -fopenmp in dg-options in libgomp.c

2015-06-05  Tom de Vries  

	* testsuite/libgomp.c/atomic-18.c: Remove superfluous -fopenmp setting
	in dg-options.
	* testsuite/libgomp.c/atomic-3.c: Same.
	* testsuite/libgomp.c/debug-1.c: Same.
	* testsuite/libgomp.c/nqueens-1.c: Same.
	* testsuite/libgomp.c/pr26171.c: Same.
	* testsuite/libgomp.c/pr48591.c: Same.
	* testsuite/libgomp.c/pr64824.c: Same.
	* testsuite/libgomp.c/pr64868.c: Same.
	* testsuite/libgomp.c/pr66133.c: Same.
	* testsuite/libgomp.c/pr66199-1.c: Same.
	* testsuite/libgomp.c/pr66199-2.c: Same.
	* testsuite/libgomp.c/target-8.c: Same.
---
 libgomp/testsuite/libgomp.c/atomic-18.c | 1 -
 libgomp/testsuite/libgomp.c/atomic-3.c  | 2 +-
 libgomp/testsuite/libgomp.c/debug-1.c   | 2 +-
 libgomp/testsuite/libgomp.c/nqueens-1.c | 1 -
 libgomp/testsuite/libgomp.c/pr26171.c   | 2 +-
 libgomp/testsuite/libgomp.c/pr48591.c   | 2 +-
 libgomp/testsuite/libgomp.c/pr64824.c   | 1 -
 libgomp/testsuite/libgomp.c/pr64868.c   | 1 -
 libgomp/testsuite/libgomp.c/pr66133.c   | 1 -
 libgomp/testsuite/libgomp.c/pr66199-1.c | 1 -
 libgomp/testsuite/libgomp.c/pr66199-2.c | 1 -
 libgomp/testsuite/libgomp.c/target-8.c  | 1 -
 12 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/libgomp/testsuite/libgomp.c/atomic-18.c b/libgomp/testsuite/libgomp.c/atomic-18.c
index bd048c1..4f7361e 100644
--- a/libgomp/testsuite/libgomp.c/atomic-18.c
+++ b/libgomp/testsuite/libgomp.c/atomic-18.c
@@ -1,6 +1,5 @@
 /* PR c/64824 */
 /* { dg-do run } */
-/* { dg-options "-O2 -fopenmp" } */
 
 void
 f1 (void)
diff --git a/libgomp/testsuite/libgomp.c/atomic-3.c b/libgomp/testsuite/libgomp.c/atomic-3.c
index 5b8fdc1..818242d 100644
--- a/libgomp/testsuite/libgomp.c/atomic-3.c
+++ b/libgomp/testsuite/libgomp.c/atomic-3.c
@@ -1,5 +1,5 @@
 /* { dg-do run } */
-/* { dg-options "-fopenmp -O0" } */
+/* { dg-options "-O0" } */
 
 #include 
 #include 
diff --git a/libgomp/testsuite/libgomp.c/debug-1.c b/libgomp/testsuite/libgomp.c/debug-1.c
index 09bcf7f..8fa9b54 100644
--- a/libgomp/testsuite/libgomp.c/debug-1.c
+++ b/libgomp/testsuite/libgomp.c/debug-1.c
@@ -1,6 +1,6 @@
 /* PR debug/36617 */
 /* { dg-do run } */
-/* { dg-options "-g -fopenmp -O0" } */
+/* { dg-options "-g -O0" } */
 
 int
 f1 (void)
diff --git a/libgomp/testsuite/libgomp.c/nqueens-1.c b/libgomp/testsuite/libgomp.c/nqueens-1.c
index 9742b7a..db5517f 100644
--- a/libgomp/testsuite/libgomp.c/nqueens-1.c
+++ b/libgomp/testsuite/libgomp.c/nqueens-1.c
@@ -1,5 +1,4 @@
 /* { dg-do run } */
-/* { dg-options "-O2 -fopenmp" } */
 /* { dg-require-effective-target tls_runtime } */
 
 #include 
diff --git a/libgomp/testsuite/libgomp.c/pr26171.c b/libgomp/testsuite/libgomp.c/pr26171.c
index eacc9a7..322a0c7 100644
--- a/libgomp/testsuite/libgomp.c/pr26171.c
+++ b/libgomp/testsuite/libgomp.c/pr26171.c
@@ -1,6 +1,6 @@
 /* PR c/26171 */
 /* { dg-do run } */
-/* { dg-options "-fopenmp" } */
+/* { dg-options "-O0" } */
 /* { dg-require-effective-target tls_runtime } */
 
 int thrv = 0;
diff --git a/libgomp/testsuite/libgomp.c/pr48591.c b/libgomp/testsuite/libgomp.c/pr48591.c
index 8df97f1..2f617af 100644
--- a/libgomp/testsuite/libgomp.c/pr48591.c
+++ b/libgomp/testsuite/libgomp.c/pr48591.c
@@ -1,6 +1,6 @@
 /* PR middle-end/48591 */
 /* { dg-do run { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* ia64-*-linux* x86_64-*-freebsd* } } */
-/* { dg-options "-fopenmp" } */
+/* { dg-options "-O0" } */
 
 extern void abort (void);
 
diff --git a/libgomp/testsuite/libgomp.c/pr64824.c b/libgomp/testsuite/libgomp.c/pr64824.c
index 544d0b0..b39675b 100644
--- a/libgomp/testsuite/libgomp.c/pr64824.c
+++ b/libgomp/testsuite/libgomp.c/pr64824.c
@@ -1,6 +1,5 @@
 /* PR c/64824 */
 /* { dg-do run } */
-/* { dg-options "-O2 -fopenmp" } */
 
 int
 main ()
diff --git a/libgomp/testsuite/libgomp.c/pr64868.c b/libgomp/testsuite/libgomp.c/pr64868.c
index acdf998..f93caf2 100644
--- a/libgomp/testsuite/libgomp.c/pr64868.c
+++ b/libgomp/testsuite/libgomp.c/pr64868.c
@@ -1,6 +1,5 @@
 /* PR c/64868 */
 /* { dg-do run } */
-/* { dg-options "-O2 -fopenmp" } */
 
 float f = 2.0f;
 double d = 4.0;
diff --git a/libgomp/testsuite/libgomp.c/pr66133.c b/libgomp/testsuite/libgomp.c/pr66133.c
index e98e5aa..90685cd 100644
--- a/libgomp/testsuite/libgomp.c/pr66133.c
+++ b/libgomp/testsuite/libgomp.c/pr66133.c
@@ -1,6 +1,5 @@
 /* PR middle-end/66133 */
 /* { dg-do run } */
-/* { dg-options "-O2 -fopenmp" } */
 
 #include 
 #include 
diff --git a/libgomp/testsuite/libgomp.c/pr66199-1.c b/libgomp/testsuite/libgomp.c/pr66199-1.c
index 6fd9f87..20482a4 100644
--- a/libgomp/testsuite/libgomp.c/pr66199-1.c
+++ b/libgomp/testsuite/libgomp.c/pr66199-1.c
@@ -1,6 +1,5 @@
 /* P

Re: Add tree heterogeneous lookup in alternative modes

2015-06-05 Thread Jonathan Wakely

On 05/06/15 23:00 +0200, François Dumont wrote:

On 04/06/2015 14:41, Jonathan Wakely wrote:

On 03/06/15 21:56 +0200, François Dumont wrote:

Hi

  Here is a patch to add heterogeneous lookup to alternative 
modes.


Excellent.

To do so I had to expose __is_transparent as __has_is_transparent 
to avoid confilct with existing __is_transparent.


That's a better name, thanks.



Should I put it in __detail namespace ?


Could it just be protected instead of at namespace scope?


No, debug containers are inheriting from normal containers, not from 
_Rb_tree.


Ah yes, of course.



If it can't be protected it's OK here you put it, it doesn't need to
be in __detail.

But maybe we should rename the _Kt parameter of __hash_is_transparent
to _Unused, _Dummy or something like that. It only exists to make the
specialization dependent on a template argument of the functions that
use it.



I renamed it into _SfinaeType to make the purpose of this type clearer.




  * include/bits/stl_tree.h (_Rb_tree<>::__is_transparent<>): Move to
  outer scope and rename in ...


"rename to ..."

not "rename into..." :-)


Nope :-)


  (std::__hash_is_transparent<>): ... this.


In  ...


@@ -429,12 +477,34 @@
 std::pair
 equal_range(const key_type& __x) const
 {
-std::pair<_Base_iterator, _Base_iterator> __res =
+std::pair<_Base_const_iterator, _Base_const_iterator> __res =
   _Base::equal_range(__x);
   return std::make_pair(const_iterator(__res.first, this),
 const_iterator(__res.second, this));
 }


Huh! Did calls to this function even compile before this fix?


I had a closer look and yes, it was compiling because for set iterator 
and const_iterator are just the same:


Ah, yes, of course (again).


 // DR 103. set::iterator is required to be modifiable,
 // but this allows modification of keys.
 typedef typename _Rep_type::const_iterator iterator;
 typedef typename _Rep_type::const_iterator const_iterator;

However I slightly changed some tests to make sure the const version 
of equal_range and some others are used.


If it is still fine I will commit the attached patch tomorrow.


Yes, OK, thanks.



[s390] Revert TPF C++ library changes

2015-06-05 Thread DJ Delorie

IBM made changes to no longer require 2 versions of libstdc++, so this
patch changes things back to the previous (compatible) way.

Also, TPF debuggers don't support discriminators, despite what GAS
supports, so disable them.

Ok?

* config/s390/tpf.h (LIBSTDCXX): Change to CPP1.
(LIB_SPEC): Add.
(SUPPORTS_DISCRIMINATOR): Define.

Index: config/s390/tpf.h
===
--- config/s390/tpf.h   (revision 224174)
+++ config/s390/tpf.h   (working copy)
@@ -91,12 +91,16 @@ along with GCC; see the file COPYING3.  
 #define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)"
 
 #undef ASM_SPEC
 #define ASM_SPEC "%{m31&m64}%{mesa&mzarch}%{march=*} \
   -alshd=%b.lst"
 
+#undef LIB_SPEC
+#define LIB_SPEC "-lCTIS -lCISO -lCLBM -lCTAL -lCFVS -lCTBX -lCTXO \
+  -lCJ00 -lCTDF -lCOMX -lCOMS -lCTHD -lCTAD -lTPFSTUB"
+
 #define ENTRY_SPEC "%{mmain:-entry=_start} \
 %{!mmain:-entry=0}"
 
 /* All linking is done shared on TPF-OS.  */
 /* FIXME: When binutils patch for new emulation is committed
then change emulation to elf64_s390_tpf.  */
@@ -107,12 +111,15 @@ along with GCC; see the file COPYING3.  
%{shared: -shared} \
%{!shared:-shared} \
%(entry_spec)"
 
 /* IBM copies these libraries over with these names.  */
 #define MATH_LIBRARY "CLBM"
-#define LIBSTDCXX "CPP2"
+#define LIBSTDCXX "CPP1"
 
 #undef TARGET_LIBC_HAS_FUNCTION
 #define TARGET_LIBC_HAS_FUNCTION gnu_libc_has_function
 
+/* GAS supports it, but the debuggers don't, so avoid it.  */
+#define SUPPORTS_DISCRIMINATOR 0
+
 #endif /* ! _TPF_H */


[PATCH, committed] PR fortran/66347

2015-06-05 Thread Steve Kargl
I've committed the following under and "obviously correct"
after regression testing completed without any new failures.

2015-06-05  Steven G. Kargl  

PR fortran/66347
* resolve.c (apply_default_init_local): Do not dereference a NULL
pointer.

2015-06-05  Steven G. Kargl  

PR fortran/66347
* gfortran.dg/blockdata_9.f: New test.


Index: fortran/resolve.c
===
--- fortran/resolve.c   (revision 224174)
+++ fortran/resolve.c   (working copy)
@@ -10949,7 +10949,7 @@ apply_default_init_local (gfc_symbol *sy
  result variable, which are also nonstatic.  */
   if (sym->attr.save || sym->ns->save_all
   || (flag_max_stack_var_size == 0 && !sym->attr.result
- && !sym->ns->proc_name->attr.recursive
+ && (sym->ns->proc_name && !sym->ns->proc_name->attr.recursive)
  && (!sym->attr.dimension || !is_non_constant_shape_array (sym
 {
   /* Don't clobber an existing initializer!  */
Index: testsuite/gfortran.dg/blockdata_9.f
===
--- testsuite/gfortran.dg/blockdata_9.f (revision 0)
+++ testsuite/gfortran.dg/blockdata_9.f (working copy)
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-options "-fno-automatic -finit-local-zero" }
+! PR fortran/66347
+
+  block data
+  implicit none
+  integer i, n
+  parameter (n=1)
+  character*2 s1(n)
+  character*8 s2(n)
+  common /foo/ s1, s2
+  data (s1(i),s2(i),i=1,n)/"ab","12345678"/
+  end

-- 
Steve


[patch committed SH] Fix PR target/66410

2015-06-05 Thread Kaz Kojima
The attached patch is to fix PR target/66410 which is an ICE in
lra-assigns.c:assign_by_spills with -mlra.
The insn *mov[qh]i has Snd/r alternative which is problematic
when Snd is memory with index addressing and r is reloading with
r0 because only r0 can become the index register on this target.
The patch disparages this case for RA.  It fixes PR and various
libstdc++ test failures happen on trunk with -mlra.  Tested on
sh4-unknown-linux-gnu with no new failures.  Committed.

Regards,
kaz
--
2015-06-05  Kaz Kojima  

PR target/66410
* config/sh/constraints.md (Sid, Ssd): New memory constraints.
* config/sh/sh.md (*mov): Use Sid and Ssd alternatives
instead of Snd.  Disparage Sid/z alternative with '^'.

diff --git a/config/sh/constraints.md b/config/sh/constraints.md
index bd059a4..4d1eb2d 100644
--- a/config/sh/constraints.md
+++ b/config/sh/constraints.md
@@ -309,6 +309,19 @@
   (and (match_code "mem")
(match_test "! satisfies_constraint_Sdd (op)")))
 
+(define_memory_constraint "Sid"
+  "A memory reference that uses index addressing."
+  (and (match_code "mem")
+   (match_code "plus" "0")
+   (match_code "reg" "00")
+   (match_code "reg" "01")))
+
+(define_memory_constraint "Ssd"
+  "A memory reference that excludes index and displacement addressing."
+  (and (match_code "mem")
+   (match_test "! satisfies_constraint_Sid (op)")
+   (match_test "! satisfies_constraint_Sdd (op)")))
+
 (define_memory_constraint "Sbv"
   "A memory reference, as used in SH2A bclr.b, bset.b, etc."
   (and (match_test "MEM_P (op) && GET_MODE (op) == QImode")
diff --git a/config/sh/sh.md b/config/sh/sh.md
index 634a612..2d10ddb 100644
--- a/config/sh/sh.md
+++ b/config/sh/sh.md
@@ -7430,18 +7430,18 @@ label:
 ;; Q/r has to come first, otherwise PC relative loads might wrongly get
 ;; placed into delay slots.  Since there is no QImode PC relative load, the
 ;; Q constraint and general_movsrc_operand will reject it for QImode.
-;; The Snd alternatives should come before Sdd in order to avoid a preference
-;; of using r0 als the register operand for addressing modes other than
-;; displacement addressing.
+;; The Sid/Ssd alternatives should come before Sdd in order to avoid
+;; a preference of using r0 als the register operand for addressing modes
+;; other than displacement addressing.  Sid/z is disparaged by '^'.
 ;; The Sdd alternatives allow only r0 as register operand, even though on
 ;; SH2A any register could be allowed by switching to a 32 bit insn.
 ;; Generally sticking to the r0 is preferrable, since it generates smaller
 ;; code.  Obvious r0 reloads can then be eliminated with a peephole on SH2A.
 (define_insn "*mov"
   [(set (match_operand:QIHI 0 "general_movdst_operand"
- "=r,r,r,Snd,r,  Sdd,z,  r,l")
+ "=r,r,r,Sid,^zr,Ssd,r,  Sdd,z,  r,l")
(match_operand:QIHI 1 "general_movsrc_operand"
-  "Q,r,i,r,  Snd,z,  Sdd,l,r"))]
+  "Q,r,i,^zr,Sid,r,  Ssd,z,  Sdd,l,r"))]
   "TARGET_SH1
&& (arith_reg_operand (operands[0], mode)
|| arith_reg_operand (operands[1], mode))"
@@ -7453,9 +7453,11 @@ label:
mov.%1,%0
mov.%1,%0
mov.%1,%0
+   mov.%1,%0
+   mov.%1,%0
sts %1,%0
lds %1,%0"
-  [(set_attr "type" "pcload,move,movi8,store,load,store,load,prget,prset")
+  [(set_attr "type" 
"pcload,move,movi8,store,load,store,load,store,load,prget,prset")
(set (attr "length")
(cond [(and (match_operand 0 "displacement_mem_operand")
(not (match_operand 0 "short_displacement_mem_operand")))


[PATCH] PR fortran/66245 -- Check [derived] type spec

2015-06-05 Thread Steve Kargl
The attached patch checks that TYPE IS and CLASS IS
return a type spec or a derived type spec.  Regression 
tested without any new failures.  OK to commit?

2015-06-05  Steven G. Kargl  

* match.c (gfc_match_type_is, gfc_match_class_is):  Check if the
return type spec or derived type spec is validate.

2015-06-05  Steven G. Kargl  

* gfortran.dg/class_is_1.f90: New test.
* gfortran.dg/type_is_1.f90: Ditto.

-- 
Steve
Index: fortran/match.c
===
--- fortran/match.c	(revision 224174)
+++ fortran/match.c	(working copy)
@@ -5456,7 +5456,10 @@ gfc_match_type_is (void)
   c = gfc_get_case ();
   c->where = gfc_current_locus;
 
-  if (gfc_match_type_spec (&c->ts) == MATCH_ERROR)
+  m = gfc_match_type_spec (&c->ts);
+  if (m == MATCH_NO)
+goto syntax;
+  if (m == MATCH_ERROR)
 goto cleanup;
 
   if (gfc_match_char (')') != MATCH_YES)
@@ -5536,7 +5539,10 @@ gfc_match_class_is (void)
   c = gfc_get_case ();
   c->where = gfc_current_locus;
 
-  if (match_derived_type_spec (&c->ts) == MATCH_ERROR)
+  m = match_derived_type_spec (&c->ts);
+  if (m == MATCH_NO)
+goto syntax;
+  if (m == MATCH_ERROR)
 goto cleanup;
 
   if (c->ts.type == BT_DERIVED)
Index: testsuite/gfortran.dg/class_is_1.f90
===
--- testsuite/gfortran.dg/class_is_1.f90	(revision 0)
+++ testsuite/gfortran.dg/class_is_1.f90	(working copy)
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! PR fortran/66245
+! Original testcase by Gerhard Steinmetz
+! 
+program p
+   type t; end type
+   class(t), allocatable :: x
+   call s
+   contains
+  subroutine s
+ select type ( x )
+ class is ( )   ! { dg-error "error in CLASS IS" }
+ end select
+  end subroutine s
+end program p
Index: testsuite/gfortran.dg/type_is_1.f90
===
--- testsuite/gfortran.dg/type_is_1.f90	(revision 0)
+++ testsuite/gfortran.dg/type_is_1.f90	(working copy)
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! PR fortran/66245
+! Original testcase by Gerhard Steinmetz
+! 
+program p
+   type t; end type
+   class(t), allocatable :: x
+   call s
+   contains
+  subroutine s
+ select type ( x )
+ type is ( )   ! { dg-error "error in TYPE IS" }
+ end select
+  end subroutine s
+end program p


Re: [PATCH] PR fortran/66245 -- Check [derived] type spec

2015-06-05 Thread Jerry DeLisle
On 06/05/2015 04:55 PM, Steve Kargl wrote:
> The attached patch checks that TYPE IS and CLASS IS
> return a type spec or a derived type spec.  Regression 
> tested without any new failures.  OK to commit?
> 

OK, thanks,

Jerry


Re: [PR64164] drop copyrename, integrate into expand

2015-06-05 Thread Alexandre Oliva
On Apr 27, 2015, Richard Biener  wrote:

> This should also mention that is_gimple_reg vars do not have their
> address taken.

check

>> +static tree
>> +leader_merge (tree cur, tree next)

> Ick - presumably you can't use sth better than a TREE_LIST here?

The list was an experiment that never really worked, and when I tried to
make it work after the patch, it proved to be unworkable, so I dropped
it, and rewrote leader_merge to choose either of the params, preferring
anonymous over ignored over named, so as to reduce the likelihood of
misreading of debug dumps, since that's all they're used for.

>> static void
>> -expand_one_stack_var (tree var)
>> +expand_one_stack_var_1 (tree var)
>> {
>> HOST_WIDE_INT size, offset;
>> unsigned byte_align;
>> 
>> -  size = tree_to_uhwi (DECL_SIZE_UNIT (SSAVAR (var)));
>> -  byte_align = align_local_variable (SSAVAR (var));
>> +  if (TREE_CODE (var) != SSA_NAME || SSA_NAME_VAR (var))
>> +{
>> +  size = tree_to_uhwi (DECL_SIZE_UNIT (SSAVAR (var)));
>> +  byte_align = align_local_variable (SSAVAR (var));
>> +}
>> +  else

> I'd go here for all TREE_CODE (var) == SSA_NAME

Check

> (and get rid of the SSAVAR macro?)

There are remaining uses that don't seem worth dropping it for.

>> +/* Return the promoted mode for name.  If it is a named SSA_NAME, it
>> +   is the same as promote_decl_mode.  Otherwise, it is the promoted
>> +   mode of a temp decl of same type as the SSA_NAME, if we had created
>> +   one.  */
>> +
>> +machine_mode
>> +promote_ssa_mode (const_tree name, int *punsignedp)
>> +{
>> +  gcc_assert (TREE_CODE (name) == SSA_NAME);
>> +
>> +  if (SSA_NAME_VAR (name))
>> +return promote_decl_mode (SSA_NAME_VAR (name), punsignedp);

> As above I'd rather not have different paths for anonymous vs. non-anonymous
> vars (so just delete the above two lines).

Check

>> @@ -9668,6 +9678,11 @@ expand_expr_real_1 (tree exp, rtx target, 
>> machine_mode tmode,
>> pmode = promote_function_mode (type, mode, &unsignedp,
>> gimple_call_fntype (g),
>> 2);
>> + else if (!exp)
>> +   {
>> + gcc_assert (code == SSA_NAME);

> promote_ssa_mode should assert this.

>> + pmode = promote_ssa_mode (ssa_name, &unsignedp);

It does, so...  check.


>> @@ -2121,6 +2122,15 @@ aggregate_value_p (const_tree exp, const_tree fntype)
>> bool
>> use_register_for_decl (const_tree decl)
>> {
>> +  if (TREE_CODE (decl) == SSA_NAME)
>> +{
>> +  if (!SSA_NAME_VAR (decl))
>> +   return TYPE_MODE (TREE_TYPE (decl)) != BLKmode
>> + && !(flag_float_store && FLOAT_TYPE_P (TREE_TYPE (decl)));
>> +
>> +  decl = SSA_NAME_VAR (decl);

> See above.  Please drop the SSA_NAME_VAR != NULL path.

Check, then taken back, after a bootstrap failure and some debugging
made me realize this would be wrong.  Here are the nearly-added comments
that explain why:

  /* We often try to use the SSA_NAME, instead of its underlying
 decl, to get type information and guide decisions, to avoid
 differences of behavior between anonymous and named
 variables, but in this one case we have to go for the actual
 variable if there is one.  The main reason is that, at least
 at -O0, we want to place user variables on the stack, but we
 don't mind using pseudos for anonymous or ignored temps.
 Should we take the SSA_NAME, we'd conclude all SSA_NAMEs
 should go in pseudos, whereas their corresponding variables
 might have to go on the stack.  So, disregarding the decl
 here would negatively impact debug info at -O0, enable
 coalescing between SSA_NAMEs that ought to get different
 stack/pseudo assignments, and get the incoming argument
 processing thoroughly confused by PARM_DECLs expected to live
 in stack slots but assigned to pseudos.  */


>> +++ b/gcc/gimple-expr.h
>> +/* Defined in tree-ssa-coalesce.c.   */
>> +extern bool gimple_can_coalesce_p (tree, tree);

> Err, put it to tree-ssa-coalesce.h?

Check.  Lots of additional headers required to be able to include
tree-ssa-coalesce.h, though.


>> -  gcc_assert (src_mode == TYPE_MODE (TREE_TYPE (var)));
>> +  gcc_assert (src_mode == TYPE_MODE (TREE_TYPE (var ? var : name)));

> The TREE_TYPE of name and its SSA_NAME_VAR are always the same.  So just
> use TREE_TYPE (name) here.

Check

>> gcc_assert (!REG_P (dest_rtx)
>> - || dest_mode == promote_decl_mode (var, &unsignedp));
>> + || dest_mode == promote_ssa_mode (name, &unsignedp));
>> 
>> if (src_mode != dest_mode)
>> {
>> @@ -714,12 +715,12 @@ static rtx
>> get_temp_reg (tree name)
>> {
>> tree var = TREE_CODE (name) == SSA_NAME ? SSA_NAME_VAR (name) : name;
>> -  tree type = TREE_TYPE (var);
>> +  tree type = var ? TREE_TYPE (var) : TREE_TYPE (name);

> See above.

Check


Here's the revised patch, regstrapped on x86_64-linux-gnu and
i686-linux-gnu.  The first attempt failed to compile libjava on x86_64,
requ

pr64252.c: fix sizeof(int) assumption

2015-06-05 Thread DJ Delorie

On targets with 2 byte "int" the vectors are 16 values long, which
breaks the index count in __builtin_shuffle() using more than one
input vector.  Ok?

* gcc.dg/pr64252.c: Fix assumption about sizeof(int).

 2015-06-05  Thomas Koenig  
Index: gcc.dg/pr64252.c
===
--- gcc.dg/pr64252.c(revision 224181)
+++ gcc.dg/pr64252.c(working copy)
@@ -1,11 +1,11 @@
 /* PR target/64252 */
 /* { dg-do run } */
 /* { dg-options "-O2" } */
 
-typedef unsigned int V __attribute__((vector_size (32)));
+typedef unsigned int V __attribute__((vector_size (sizeof(unsigned long) * 
8)));
 
 __attribute__((noinline, noclone)) void
 foo (V *a, V *b, V *c, V *d, V *e)
 {
   V t = __builtin_shuffle (*a, *b, *c);
   V v = __builtin_shuffle (t, (V) { ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U }, 
(V) { 0, 1, 8, 3, 4, 5, 9, 7 });


[msp430] support sym+int and sym-sym

2015-06-05 Thread DJ Delorie

Because sizeof(void*) is 4 but POINTER_SIZE is 3, we have to handle
some things manually.  This is yet another one.  Committed.

* config/msp430/msp430.c (msp430_asm_integer): Support addition
and subtraction too.

Index: config/msp430/msp430.c
===
--- config/msp430/msp430.c  (revision 224181)
+++ config/msp430/msp430.c  (working copy)
@@ -973,13 +973,14 @@ msp430_asm_integer (rtx x, unsigned int 
   if (size == 3 && GET_MODE (x) == PSImode)
 size = 4;
 
   switch (size)
 {
 case 4:
-  if (c == SYMBOL_REF || c == CONST || c == LABEL_REF || c == CONST_INT)
+  if (c == SYMBOL_REF || c == CONST || c == LABEL_REF || c == CONST_INT
+ || c == PLUS || c == MINUS)
{
  fprintf (asm_out_file, "\t.long\t");
  output_addr_const (asm_out_file, x);
  fputc ('\n', asm_out_file);
  return true;
}


Re: [PATCH, RFC]: Next stage1, refactoring: propagating rtx subclasses

2015-06-05 Thread Mikhail Maltsev
09.05.2015 1:54, Jeff Law wrote:
> On 05/04/2015 02:18 PM, Mikhail Maltsev wrote:
[snip]
>> I'm trying to continue and the next patch (peep_split.patch,
>> peep_split.cl) is addressing the same task in some of the generated code
>> (namely, gen_peephole2_* and gen_split_* series of functions).
> And that looks good.  If it's bootstrapping and regression testing then
> it's good to go too.
> 
>>
>>> If you're going to continue this work, you should probably get
>>> write-after-approval access so that you can commit your own approved
>>> changes.
>> Is it OK to mention you as a maintainer who can approve my request for
>> write access?
> Yes, absolutely.  If you haven't already done so, go ahead and get this
> going because...
> 
> Both patches are approved.  Please install onto the trunk.
> 
> jeff
> 

Though this patch was approved about a month ago and I spent some time
while fixing the first patch related to rtx class hierarchy, I suppose
that it is still OK to apply it without additional approval.

I rebased the patch, and it required ~1 line change (which is rather
obvious). I also performed the complete test (bootstrapped and regtested
on x86_64-linux multilib, checked build of targets in
contrib/config-list.mk and ran regtests on several simulators: sh, mips
and arm).

Commited to trunk as r224183.

-- 
Regards,
Mikhail Maltsev
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c388eb5..5c8d6c4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,21 @@
+2015-06-06  Mikhail Maltsev  
+
+   * combine.c (combine_split_insns): Remove cast.
+   * config/bfin/bfin.c (hwloop_fail): Add cast in try_split call.
+   * config/sh/sh.c (sh_try_split_insn_simple): Remove cast.
+   * config/sh/sh_treg_combine.cc (sh_treg_combine::execute): Add cast.
+   * emit-rtl.c (try_split): Promote type of trial argument to rtx_insn.
+   * genemit.c (gen_split): Change return type of generated functions to
+   rtx_insn.
+   * genrecog.c (get_failure_return): Use NULL instead of NULL_RTX.
+   (print_subroutine_start): Promote rtx to rtx_insn in gen_split_* and
+   gen_peephole2_* functions.
+   (print_subroutine, main): Likewise.
+   * recog.c (peephole2_optimize): Remove cast.
+   (peep2_next_insn): Promote return type to rtx_insn.
+   * recog.h (peep2_next_insn): Fix prototype.
+   * rtl.h (try_split, split_insns): Likewise.
+
 2015-06-05  Kaz Kojima  
 
PR target/66410
diff --git a/gcc/combine.c b/gcc/combine.c
index 01f43b1..8a9ab7a 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -554,7 +554,7 @@ combine_split_insns (rtx pattern, rtx_insn *insn)
   rtx_insn *ret;
   unsigned int nregs;
 
-  ret = safe_as_a  (split_insns (pattern, insn));
+  ret = split_insns (pattern, insn);
   nregs = max_reg_num ();
   if (nregs > reg_stat.length ())
 reg_stat.safe_grow_cleared (nregs);
diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 914a024..7b570cd 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -3877,7 +3877,7 @@ hwloop_fail (hwloop_info loop)
   else
 {
   splitting_loops = 1;  
-  try_split (PATTERN (insn), insn, 1);
+  try_split (PATTERN (insn), safe_as_a  (insn), 1);
   splitting_loops = 0;
 }
 }
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index d77154c..3b63014 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -14236,7 +14236,7 @@ sh_try_split_insn_simple (rtx_insn* i, rtx_insn* 
curr_insn, int n = 0)
   fprintf (dump_file, "\n");
 }
 
-  rtx_insn* seq = safe_as_a (split_insns (PATTERN (i), curr_insn));
+  rtx_insn* seq = split_insns (PATTERN (i), curr_insn);
 
   if (seq == NULL)
 return std::make_pair (i, i);
diff --git a/gcc/config/sh/sh_treg_combine.cc b/gcc/config/sh/sh_treg_combine.cc
index 02e13e8..c09a4c3 100644
--- a/gcc/config/sh/sh_treg_combine.cc
+++ b/gcc/config/sh/sh_treg_combine.cc
@@ -1612,7 +1612,7 @@ sh_treg_combine::execute (function *fun)
log_msg ("trying to split insn:\n");
log_insn (*i);
log_msg ("\n");
-   try_split (PATTERN (*i), *i, 0);
+   try_split (PATTERN (*i), safe_as_a  (*i), 0);
   }
 
   m_touched_insns.clear ();
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c
index e632710..7bb2c77 100644
--- a/gcc/emit-rtl.c
+++ b/gcc/emit-rtl.c
@@ -3653,9 +3653,8 @@ mark_label_nuses (rtx x)
returns TRIAL.  If the insn to be returned can be split, it will be.  */
 
 rtx_insn *
-try_split (rtx pat, rtx uncast_trial, int last)
+try_split (rtx pat, rtx_insn *trial, int last)
 {
-  rtx_insn *trial = as_a  (uncast_trial);
   rtx_insn *before = PREV_INSN (trial);
   rtx_insn *after = NEXT_INSN (trial);
   rtx note;
@@ -3674,7 +3673,7 @@ try_split (rtx pat, rtx uncast_trial, int last)
 split_branch_probability = XINT (note, 0);
   probability = split_branch_probability;
 
-  seq = safe_as_a  (split_insns (pat, trial));
+  seq = split_insns (pat, trial);
 
   split_branch_probability = -1;
 
diff --git a/gcc/

Re: pr64252.c: fix sizeof(int) assumption

2015-06-05 Thread Marc Glisse

On Sat, 6 Jun 2015, DJ Delorie wrote:


On targets with 2 byte "int" the vectors are 16 values long, which
breaks the index count in __builtin_shuffle() using more than one
input vector.  Ok?

* gcc.dg/pr64252.c: Fix assumption about sizeof(int).

2015-06-05  Thomas Koenig  
Index: gcc.dg/pr64252.c
===
--- gcc.dg/pr64252.c(revision 224181)
+++ gcc.dg/pr64252.c(working copy)
@@ -1,11 +1,11 @@
/* PR target/64252 */
/* { dg-do run } */
/* { dg-options "-O2" } */

-typedef unsigned int V __attribute__((vector_size (32)));
+typedef unsigned int V __attribute__((vector_size (sizeof(unsigned long) * 
8)));


Why 'unsigned long' and not 'unsigned int'? Doesn't that break platforms 
where long and int have a different size?



__attribute__((noinline, noclone)) void
foo (V *a, V *b, V *c, V *d, V *e)
{
  V t = __builtin_shuffle (*a, *b, *c);
  V v = __builtin_shuffle (t, (V) { ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U, ~0U }, 
(V) { 0, 1, 8, 3, 4, 5, 9, 7 });


--
Marc Glisse


Re: pr64252.c: fix sizeof(int) assumption

2015-06-05 Thread DJ Delorie

Sorry, I meant unsigned int.