Re: [PATCH] Add macro DISABLE_COPY_AND_ASSIGN

2017-09-15 Thread Yao Qi
On Sat, Sep 9, 2017 at 1:27 PM, Ian Lance Taylor <i...@golang.org> wrote:
>
> The patch to include/ansidecl.h is basically OK.  Please add an
> example in the comment showing how to use it: after `private:`, and
> with a trailing semicolon.  Thanks.

Patch below is committed.  Thanks for the review.

>
> The patches to the other files will have to be approved by the
> relevant maintainers.
>

I'll split it and post them later.

-- 
Yao (齐尧)
From 753d12319d85876c2513029037af539c43717251 Mon Sep 17 00:00:00 2001
From: qiyao <qiyao@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 15 Sep 2017 15:40:50 +
Subject: [PATCH] [include] Add macro DISABLE_COPY_AND_ASSIGN

We have many classes that copy cotr and assignment operator are deleted
in different projects, gcc, gdb and gold.  So this patch adds a macro
to do this, and replace these existing mechanical code with macro
DISABLE_COPY_AND_ASSIGN.

The patch was posted in gdb-patches,
https://sourceware.org/ml/gdb-patches/2017-07/msg00254.html but we
think it is better to put this macro in include/ansidecl.h so that
other projects can use it too.

include:

2017-09-15  Yao Qi  <yao...@linaro.org>
	Pedro Alves  <pal...@redhat.com>

	* ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@252823 138bc75d-0d04-0410-961f-82ee72b054a4
---
 include/ChangeLog  |  5 +
 include/ansidecl.h | 26 ++
 2 files changed, 31 insertions(+)

diff --git a/include/ChangeLog b/include/ChangeLog
index 4703588..0221586 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-15  Yao Qi  <yao...@linaro.org>
+	Pedro Alves  <pal...@redhat.com>
+
+	* ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.
+
 2017-09-12  Jiong Wang  <jiong.w...@arm.com>
 
 	* dwarf2.def (DW_CFA_AARCH64_negate_ra_state): New DW_CFA_DUP.
diff --git a/include/ansidecl.h b/include/ansidecl.h
index ab3b895..450ce35 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -360,6 +360,32 @@ So instead we use the macro below and test it against specific values.  */
 # define FINAL
 #endif
 
+/* A macro to disable the copy constructor and assignment operator.
+   When building with C++11 and above, the methods are explicitly
+   deleted, causing a compile-time error if something tries to copy.
+   For C++03, this just declares the methods, causing a link-time
+   error if the methods end up called (assuming you don't
+   define them).  For C++03, for best results, place the macro
+   under the private: access specifier, like this,
+
+   class name_lookup
+   {
+ private:
+   DISABLE_COPY_AND_ASSIGN (name_lookup);
+   };
+
+   so that most attempts at copy are caught at compile-time.  */
+
+#if __cplusplus >= 201103
+#define DISABLE_COPY_AND_ASSIGN(TYPE)		\
+  TYPE (const TYPE&) = delete;			\
+  void operator= (const TYPE &) = delete
+  #else
+#define DISABLE_COPY_AND_ASSIGN(TYPE)		\
+  TYPE (const TYPE&);\
+  void operator= (const TYPE &)
+#endif /* __cplusplus >= 201103 */
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.9.1



Re: [PATCH] Add macro DISABLE_COPY_AND_ASSIGN

2017-09-09 Thread Yao Qi
On Fri, Aug 11, 2017 at 3:14 PM, Pedro Alves
> Yeah, this is a macro that lots of projects out there reinvent,
> can't imagine it being very controversial.
>
> I could have used this today in another spot in gdb.
>
> The patch as is touches areas with different maintainers, it
> may have fallen victim of diffusion of responsibility.
>
> Could we get at least the ansidecl.h change in, so we can
> start using it in gdb?  CCing Ian as a libiberty maintainer.

Hi Ian,
I just talked with you about this patch.  You are cc'ed.  Could you
take a look at the change in include/ansidecl.h?  Then, we can use it
in different
projects, gcc, gdb and gold.

-- 
Yao (齐尧)


Re: [PATCH] Add macro DISABLE_COPY_AND_ASSIGN

2017-08-02 Thread Yao Qi
On Wed, Jul 26, 2017 at 9:55 AM, Yao Qi <qiyao...@gmail.com> wrote:
> On 17-07-19 10:30:45, Yao Qi wrote:
>> We have many classes that copy cotr and assignment operator are deleted
>> in different projects, gcc, gdb and gold.  So this patch adds a macro
>> to do this, and replace these existing mechanical code with macro
>> DISABLE_COPY_AND_ASSIGN.
>>
>> The patch was posted in gdb-patches,
>> https://sourceware.org/ml/gdb-patches/2017-07/msg00254.html but we
>> think it is better to put this macro in include/ansidecl.h so that
>> other projects can use it too.
>>
>> Boostrapped on x86_64-linux-gnu.  Is it OK?
>>
>> include:
>>
>> 2017-07-19  Yao Qi  <yao...@linaro.org>
>>   Pedro Alves  <pal...@redhat.com>
>>
>>   * ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.
>>
>> gcc/cp:
>>
>> 2017-07-19  Yao Qi  <yao...@linaro.org>
>>
>>   * cp-tree.h (class ovl_iterator): Use DISABLE_COPY_AND_ASSIGN.
>>   * name-lookup.c (struct name_loopup): Likewise.
>>
>> gcc:
>>
>> 2017-07-19  Yao Qi  <yao...@linaro.org>
>>
>>   * tree-ssa-scopedtables.h (class avail_exprs_stack): Use
>>   DISABLE_COPY_AND_ASSIGN.
>>   (class const_and_copies): Likewise.
>
> Ping.
> https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01134.html
>

Ping.  It is a quite straightforward patch, can any one
take a look?

-- 
Yao (齐尧)


Re: [PATCH] Add macro DISABLE_COPY_AND_ASSIGN

2017-07-26 Thread Yao Qi
On 17-07-19 10:30:45, Yao Qi wrote:
> We have many classes that copy cotr and assignment operator are deleted
> in different projects, gcc, gdb and gold.  So this patch adds a macro
> to do this, and replace these existing mechanical code with macro
> DISABLE_COPY_AND_ASSIGN.
> 
> The patch was posted in gdb-patches,
> https://sourceware.org/ml/gdb-patches/2017-07/msg00254.html but we
> think it is better to put this macro in include/ansidecl.h so that
> other projects can use it too.
> 
> Boostrapped on x86_64-linux-gnu.  Is it OK?
> 
> include:
> 
> 2017-07-19  Yao Qi  <yao...@linaro.org>
>   Pedro Alves  <pal...@redhat.com>
> 
>   * ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.
> 
> gcc/cp:
> 
> 2017-07-19  Yao Qi  <yao...@linaro.org>
> 
>   * cp-tree.h (class ovl_iterator): Use DISABLE_COPY_AND_ASSIGN.
>   * name-lookup.c (struct name_loopup): Likewise.
> 
> gcc:
> 
> 2017-07-19  Yao Qi  <yao...@linaro.org>
> 
>   * tree-ssa-scopedtables.h (class avail_exprs_stack): Use
>   DISABLE_COPY_AND_ASSIGN.
>   (class const_and_copies): Likewise.

Ping.
https://gcc.gnu.org/ml/gcc-patches/2017-07/msg01134.html

-- 
Yao (齐尧)


[PATCH] Add macro DISABLE_COPY_AND_ASSIGN

2017-07-19 Thread Yao Qi
We have many classes that copy cotr and assignment operator are deleted
in different projects, gcc, gdb and gold.  So this patch adds a macro
to do this, and replace these existing mechanical code with macro
DISABLE_COPY_AND_ASSIGN.

The patch was posted in gdb-patches,
https://sourceware.org/ml/gdb-patches/2017-07/msg00254.html but we
think it is better to put this macro in include/ansidecl.h so that
other projects can use it too.

Boostrapped on x86_64-linux-gnu.  Is it OK?

include:

2017-07-19  Yao Qi  <yao...@linaro.org>
Pedro Alves  <pal...@redhat.com>

* ansidecl.h (DISABLE_COPY_AND_ASSIGN): New macro.

gcc/cp:

2017-07-19  Yao Qi  <yao...@linaro.org>

* cp-tree.h (class ovl_iterator): Use DISABLE_COPY_AND_ASSIGN.
* name-lookup.c (struct name_loopup): Likewise.

gcc:

2017-07-19  Yao Qi  <yao...@linaro.org>

* tree-ssa-scopedtables.h (class avail_exprs_stack): Use
DISABLE_COPY_AND_ASSIGN.
(class const_and_copies): Likewise.
---
 gcc/cp/cp-tree.h|  4 +---
 gcc/cp/name-lookup.c|  3 +--
 gcc/tree-ssa-scopedtables.h |  6 ++
 include/ansidecl.h  | 19 +++
 4 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index abc9b65..9a45680 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -718,9 +718,7 @@ class ovl_iterator
   }
 
  private:
-  /* Do not duplicate.  */
-  ovl_iterator = (const ovl_iterator &);
-  ovl_iterator (const ovl_iterator &);
+  DISABLE_COPY_AND_ASSIGN (ovl_iterator);
 
  public:
   operator bool () const
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index cd7428a..f80958d 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -194,8 +194,7 @@ public:
   }
 
 private: /* Uncopyable, unmovable, unassignable. I am a rock. */
-  name_lookup (const name_lookup &);
-  name_lookup = (const name_lookup &);
+  DISABLE_COPY_AND_ASSIGN (name_lookup);
 
 protected:
   static bool seen_p (tree scope)
diff --git a/gcc/tree-ssa-scopedtables.h b/gcc/tree-ssa-scopedtables.h
index df304ae..692da8a 100644
--- a/gcc/tree-ssa-scopedtables.h
+++ b/gcc/tree-ssa-scopedtables.h
@@ -158,8 +158,7 @@ class avail_exprs_stack
 
   /* We do not allow copying this object or initializing one
  from another.  */
-  avail_exprs_stack& operator= (const avail_exprs_stack&);
-  avail_exprs_stack (class avail_exprs_stack &);
+  DISABLE_COPY_AND_ASSIGN (avail_exprs_stack);
 };
 
 /* This class defines an unwindable const/copy equivalence table
@@ -197,8 +196,7 @@ class const_and_copies
 
  private:
   vec m_stack;
-  const_and_copies& operator= (const const_and_copies&);
-  const_and_copies (class const_and_copies &);
+  DISABLE_COPY_AND_ASSIGN (const_and_copies);
 };
 
 void initialize_expr_from_cond (tree cond, struct hashable_expr *expr);
diff --git a/include/ansidecl.h b/include/ansidecl.h
index f6e1761..796f744 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -354,6 +354,25 @@ So instead we use the macro below and test it against 
specific values.  */
 # define FINAL
 #endif
 
+/* A macro to disable the copy constructor and assignment operator.
+   When building with C++11 and above, the methods are explicitly
+   deleted, causing a compile-time error if something tries to copy.
+   For C++03, this just declares the methods, causing a link-time
+   error if the methods end up called (assuming you don't
+   define them).  For C++03, for best results, place the macro
+   under the private: access specifier, so that most attempts at
+   copy are caught at compile-time.  */
+
+#if __cplusplus >= 201103
+#define DISABLE_COPY_AND_ASSIGN(TYPE)  \
+  TYPE (const TYPE&) = delete; \
+  void operator= (const TYPE &) = delete
+  #else
+#define DISABLE_COPY_AND_ASSIGN(TYPE)  \
+  TYPE (const TYPE&);  \
+  void operator= (const TYPE &)
+#endif /* __cplusplus >= 201103 */
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.9.1



Re: [1/9][RFC][DWARF] Reserve three DW_OP numbers in vendor extension space

2016-11-30 Thread Yao Qi
On Wed, Nov 30, 2016 at 11:15:22AM +, Jiong Wang wrote:
> 
> Hi GDB, Binutils maintainer:
> 
>   OK on this proposal and install this patch to binutils-gdb master?
>

This proposal is good to GDB, as long as you add a gdbarch hook and move
the code handling DW_CFA_GNU_window_save in
gdb/dwarf2-frame.c:execute_cfa_program to sparc-tdep.c or/and
sparc64-tdep.c.

-- 
Yao (齐尧)


Re: [C++ PATCH] RFC: implement P0386R2 - C++17 inline variables

2016-10-26 Thread Yao Qi
On Tue, Oct 25, 2016 at 7:06 PM, Jakub Jelinek  wrote:
>
> I think this patch should fix it, will bootstrap/regtest it now:
>

Yes, the fails in gdb.cp/member-ptr.exp go away with the patched g++.
I run gdb.cp/member-ptr.exp with three different c++ variations,

Schedule of variations:
unix/-std=c++03
unix/-std=c++11
unix/-std=c++1z

Thanks for the fix.

-- 
Yao (齐尧)


Re: [C++ PATCH] RFC: implement P0386R2 - C++17 inline variables

2016-10-21 Thread Yao Qi
Hi Jakub,

On Thu, Oct 20, 2016 at 5:21 PM, Andre Vieira (lists)
 wrote:
>  <2><8f5>: Abbrev Number: 38 (DW_TAG_member)
> <8f6>   DW_AT_specification: <0x8be>
> <8fa>   DW_AT_linkage_name: (indirect string, offset: 0x4a0):
> _ZN6BANANA1sE
> <8fe>   DW_AT_location: 5 byte block: 3 64 bf 1 0
> (DW_OP_addr: 1bf64)
>
> I haven't tested it on other targets.

I can reproduce it on x86_64 as well.

 <1><328>: Abbrev Number: 20 (DW_TAG_class_type)
<329>   DW_AT_name: A
<32b>   DW_AT_byte_size   : 24
<32c>   DW_AT_decl_file   : 1
<32d>   DW_AT_decl_line   : 23
<32e>   DW_AT_containing_type: <0x328>
<332>   DW_AT_sibling : <0x458>

 <2><336>: Abbrev Number: 19 (DW_TAG_member)
<337>   DW_AT_name: s
<339>   DW_AT_decl_file   : 1
<33a>   DW_AT_decl_line   : 40
<33b>   DW_AT_type: <0x5e>
<33f>   DW_AT_external: 1
<33f>   DW_AT_accessibility: 1  (public)
<340>   DW_AT_declaration : 1
 <2><36d>: Abbrev Number: 23 (DW_TAG_member)
<36e>   DW_AT_specification: <0x336>
<372>   DW_AT_linkage_name: (indirect string, offset: 0x447): _ZN1A1sE
<376>   DW_AT_location: 9 byte block: 3 10 15 60 0 0 0 0 0
 (DW_OP_addr: 601510)

We have two DIEs for member 's'.  GDB adds both of them as two fields,
the first one as static member (because of DW_AT_declaration), and the
second one as a non-static member.  GDB doesn't understand the
relationship between these two DIEs by DW_AT_specification.

Is attribute DW_AT_specification applicable to DW_TAG_member?
This is not documented in DWARF5 Appendix A "Attribute by Tage Value",
Page 258.

-- 
Yao (齐尧)


Re: [AArch64] Handle HFAs of float16 types properly

2016-08-05 Thread Yao Qi
On Tue, Jul 26, 2016 at 2:55 PM, James Greenhalgh
 wrote:
>
> OK? As this is an ABI break, I'm not proposing for it to go back to GCC 6,
> though it will apply cleanly there if the maintainers support that.
>

What do you mean by "ABI break"?  AFAICS, with this patch, it conforms to
AAPCS.

The subject leads me thinking about the handling of HVA of float16.

-- 
Yao (齐尧)


Re: [ARM] Fix PR middle-end/65958

2015-10-07 Thread Yao Qi

Hi Eric,

On 06/10/15 11:11, Eric Botcazou wrote:

Here's the implementation for aarch64, very similar but simpler since there is
no shortage of scratch registers; the only thing to note is the new blockage
pattern.  This was tested on real hardware but not with Linux, instead with
Darwin (experimental port of the toolchain to iOS) and makes it possible to
pass ACATS (Ada conformance testsuite which requires stack checking).

There is also a couple of tweaks for the ARM implementation: a cosmetic one
for the probe_stack pattern and one for the output_probe_stack_range loop.


I assume that this patch (and arm patch) will change the instruction
sequences in prologue.  If so, do you have some examples about how
prologue is changed with this patch?  I need to adapt GDB prologue
analyser to these new instruction sequences.

--
Yao (齐尧)


Re: [ARM] Fix PR middle-end/65958

2015-10-07 Thread Yao Qi

Hi Eric,
Thanks for the examples.  I am able to map these instructions in your
examples back to RTX in your patch.

On 07/10/15 10:09, Eric Botcazou wrote:

Yes, it will generate either individual probes or a probing loop before the
frame is established when -fstack-check is passed.  For aarch64, a probe is a
store based on x9 of the form:

str xzr, [x9, #offset]

with preceding instructions to compute x9 from sp, typically:

sub x9, sp, #16384



If I read aarch64_emit_probe_stack_range correctly, these two
instructions are generated when (size <= PROBE_INTERVAL).  If
size <= 4 * PROBE_INTERVAL, more instructions are generated,

sub x9, sp, #16384
str xzr, [x9]

sub x9, x9, #PROBE_INTERVAL
str xzr, [x9]
... /* At most two instances of these two insn. */

either
sub x9, x9, #PROBE_INTERVAL
str xzr, [x9, #offset]
or
str xzr, [x9, -16]


A probing loop uses both x9 and x10:

sub x9, sp, #12288
sub x10, sp, #36864
LPSRL0:
sub x9, x9, 4096
str xzr, [x9]
cmp x9, x10
b.neLPSRL0



The probing loop is used when size > 4 * PROBE_INTERVAL


with an optional last probe:

str xzr, [x10,#-16]


and there can be an optional instruction before the probe,

sub x10, x10, #PROBE_INTERVAL

Let me know if my understanding above is wrong.

When I read the examples and your patch, I happen to see a
nit in ChangeLog entry,


2015-10-06  Tristan Gingold  
Eric Botcazou  

PR middle-end/65958
* config/aarch64/aarch64-protos.h (aarch64_output_probe_stack-range):
Declare.


s/aarch64_output_probe_stack-range/aarch64_output_probe_stack_range

--
Yao (齐尧)


Re: [PATCH][1/n] dwarf2out refactoring for early (LTO) debug

2015-08-19 Thread Yao Qi

On 18/08/15 20:32, Aldy Hernandez wrote:

Aldyh, what other testing did you usually do for changes?  Run
the gdb testsuite against the new compiler?  Anything else?


gdb testsuite, and make sure you test GCC with
--enable-languages=all,go,ada, though the latter is mostly useful while
you iron out bugs initially.  I found that ultimately, the best test was
C++.


FWIW, it would be nice to run gdb testsuite with different dwarf
versions (3, 4, and 5).

--
Yao (齐尧)


[RFA 1/8] New port: TI C6x: Remove gdb from noconfigdirs in configure.ac

2011-07-19 Thread Yao Qi
This patch is one of patch set to add a new port (TI C6x) in gdb.  In
this patch, gdb is removed from noconfigdirs in top-level configure.ac.

OK for gcc and binutils?

-- 
Yao (齐尧)
From 321345017e27e908539502a3f08bc604c5f60c66 Mon Sep 17 00:00:00 2001
From: Yao Qi y...@codesourcery.com
Date: Mon, 11 Jul 2011 01:30:03 -0700
Subject: [PATCH 01/14] remove gdb from noconfigdirs

2011-07-19  Yao Qi  y...@codesourcery.com

	* configure.ac (noconfigdirs): Remove gdb.
	* configure: Regenerate.
---
 configure|2 +-
 configure.ac |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index 9f7055d..11ea09b 100755
--- a/configure
+++ b/configure
@@ -3606,7 +3606,7 @@ case ${target} in
 fi
 ;;
   tic6x-*-*)
-noconfigdirs=$noconfigdirs gdb sim
+noconfigdirs=$noconfigdirs sim
 ;;
   tilepro-*-* | tilegx-*-*)
 noconfigdirs=$noconfigdirs sim
diff --git a/configure.ac b/configure.ac
index 98705a1..80a0fca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1052,7 +1052,7 @@ case ${target} in
 fi
 ;;
   tic6x-*-*)
-noconfigdirs=$noconfigdirs gdb sim
+noconfigdirs=$noconfigdirs sim
 ;;
   tilepro-*-* | tilegx-*-*)
 noconfigdirs=$noconfigdirs sim
-- 
1.7.0.4