Re: [PATCH] c++: Implement DR2303 [PR97453]

2020-11-02 Thread kamlesh kumar via Gcc-patches
>>Do you see a reason this wouldn't work?
No, I do not see any.This is good.
>>so it's probably simplest to go ahead with mine.
Yes, thank you.

On Mon, Nov 2, 2020 at 9:48 PM Jason Merrill  wrote:
>
> On 11/2/20 10:10 AM, kamlesh kumar wrote:
> > addressed jason comments.
> > no regression due to this, tested on x86_64 linux.
> >
> > On Tue, Oct 27, 2020 at 11:09 PM Jason Merrill  wrote:
> >>
> >> On 10/22/20 1:31 PM, kamlesh kumar wrote:
> >>> Attaching the patch file.
> >>>
> >>>   >>Instead of building a hash table, would it work to handle ambiguity by
> >>>   >>checking whether one of the classes is a base of the other?
> >>
> >>> Fixing for cases like: struct B: A,A may not be cleaner
> >>> this way.
> >>
> >> Why not?  Your patch does extra work even when there's no ambiguity.
> >>
> >>> On Thu, Oct 22, 2020 at 3:23 AM Jason Merrill  >>> > wrote:
> >>>   >
> >>>   > On 10/21/20 6:32 AM, kamlesh kumar wrote:
> >>>   > > gcc/cp/ChangeLog
> >>>   > > ---
> >>>   > >
> >>>   > > 2020-10-21  Kamlesh Kumar   >>> >
> >>>   > >
> >>>   > > PR c++/97453
> >>>   > > * pt.c (get_template_base): Implement DR2303,
> >>>   > > Consider closest base while template
> >>>   > > deduction when base of base also matches.
> >>>   > >
> >>>   > > gcc/testsuite/ChangeLog
> >>>   > > --
> >>>   > >
> >>>   > > 2020-10-21  Kamlesh Kumar   >>> >
> >>>   > >
> >>>   > > * g++.dg/Drs/dr2303.C: New Test
> >>>   > >
> >>>   > > --
> >>>   > >
> >>>   > > As part of this patch I Implemented fix for below defect report in 
> >>> cwg
> >>>   > > https://wg21.cmeerw.net/cwg/issue2303 .
> >>>   >
> >>>   > Thanks!
> >>>   >
> >>>   > Please see https://gcc.gnu.org/contribute.html for guidance on email
> >>>   > subject lines; for this patch I'd think something like
> >>>   >
> >>>   > [PATCH] c++: Implement DR2303 [PR97453]
> >>>   >
> >>>   > Also, your patch was corrupted by word wrap; the easiest way to avoid
> >>>   > that is probably to attach the file rather than copy it into the 
> >>> message.
> >>>   >
> >>>   > > Reg tested on x86_64 and did not found any failure.
> >>>   > > Patch summary: Remove base of base from list of bases
> >>>   > >
> >>>   > > created a hash_set from list of bases and then iterate over each
> >>>   > > element of hash_set and find its  list of bases and remove this from
> >>>   > > hash_set if present.
> >>>   > > and finally, deduction succeeds if in hash_set remains only single
> >>>   > > element or it's empty.
> >>>   > > otherwise deduction is ambiguous.
> >>>   >
> >>>   > Instead of building a hash table, would it work to handle ambiguity by
> >>>   > checking whether one of the classes is a base of the other?
>
> This is what I had in mind; it seems clearer to me.  Do you see a reason
> this wouldn't work?
>
> Also, I notice that you still don't seem to have a copyright assignment
> on file with the FSF.  I and Jonathan Wakely both asked about it last
> year; has there been any progress on that?  Your patch is too large to
> go in without a copyright assignment, so it's probably simplest to go
> ahead with mine.
>
> Thanks,
> Jason


Re: [PATCH] c++: Implement DR2303 [PR97453]

2020-11-02 Thread kamlesh kumar via Gcc-patches
addressed jason comments.
no regression due to this, tested on x86_64 linux.

On Tue, Oct 27, 2020 at 11:09 PM Jason Merrill  wrote:
>
> On 10/22/20 1:31 PM, kamlesh kumar wrote:
> > Attaching the patch file.
> >
> >  >>Instead of building a hash table, would it work to handle ambiguity by
> >  >>checking whether one of the classes is a base of the other?
>
> > Fixing for cases like: struct B: A,A may not be cleaner
> > this way.
>
> Why not?  Your patch does extra work even when there's no ambiguity.
>
> > On Thu, Oct 22, 2020 at 3:23 AM Jason Merrill  > > wrote:
> >  >
> >  > On 10/21/20 6:32 AM, kamlesh kumar wrote:
> >  > > gcc/cp/ChangeLog
> >  > > ---
> >  > >
> >  > > 2020-10-21  Kamlesh Kumar   > >
> >  > >
> >  > > PR c++/97453
> >  > > * pt.c (get_template_base): Implement DR2303,
> >  > > Consider closest base while template
> >  > > deduction when base of base also matches.
> >  > >
> >  > > gcc/testsuite/ChangeLog
> >  > > --
> >  > >
> >  > > 2020-10-21  Kamlesh Kumar   > >
> >  > >
> >  > > * g++.dg/Drs/dr2303.C: New Test
> >  > >
> >  > > --
> >  > >
> >  > > As part of this patch I Implemented fix for below defect report in cwg
> >  > > https://wg21.cmeerw.net/cwg/issue2303 .
> >  >
> >  > Thanks!
> >  >
> >  > Please see https://gcc.gnu.org/contribute.html for guidance on email
> >  > subject lines; for this patch I'd think something like
> >  >
> >  > [PATCH] c++: Implement DR2303 [PR97453]
> >  >
> >  > Also, your patch was corrupted by word wrap; the easiest way to avoid
> >  > that is probably to attach the file rather than copy it into the message.
> >  >
> >  > > Reg tested on x86_64 and did not found any failure.
> >  > > Patch summary: Remove base of base from list of bases
> >  > >
> >  > > created a hash_set from list of bases and then iterate over each
> >  > > element of hash_set and find its  list of bases and remove this from
> >  > > hash_set if present.
> >  > > and finally, deduction succeeds if in hash_set remains only single
> >  > > element or it's empty.
> >  > > otherwise deduction is ambiguous.
> >  >
> >  > Instead of building a hash table, would it work to handle ambiguity by
> >  > checking whether one of the classes is a base of the other?
> >  >
> >  > > ---
> >  > > diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> >  > > index dc664ec3798..7adf461e108 100644
> >  > > --- a/gcc/cp/pt.c
> >  > > +++ b/gcc/cp/pt.c
> >  > > @@ -22643,8 +22643,9 @@ static enum template_base_result
> >  > >   get_template_base (tree tparms, tree targs, tree parm, tree arg,
> >  > >   bool explain_p, tree *result)
> >  > >   {
> >  > > -  tree rval = NULL_TREE;
> >  > > +  *result = NULL_TREE;
> >  > > tree binfo;
> >  > > +  hash_set binfo_set;
> >  > >
> >  > > gcc_assert (RECORD_OR_UNION_CODE_P (TREE_CODE (arg)));
> >  > >
> >  > > @@ -22659,31 +22660,51 @@ get_template_base (tree tparms, tree targs,
> >  > > tree parm, tree arg,
> >  > > /* Walk in inheritance graph order.  The search order is not
> >  > >important, and this avoids multiple walks of virtual bases.  */
> >  > > for (binfo = TREE_CHAIN (binfo); binfo; binfo = TREE_CHAIN (binfo))
> >  > > -{
> >  > > -  tree r = try_class_unification (tparms, targs, parm,
> >  > > -   BINFO_TYPE (binfo), explain_p);
> >  > > -
> >  > > -  if (r)
> >  > > - {
> >  > > -   /* If there is more than one satisfactory baseclass, then:
> >  > > -
> >  > > -[temp.deduct.call]
> >  > > + {
> >  > > +   tree r = try_class_unification (tparms, targs, parm,
> >  > > +   BINFO_TYPE (binfo), explain_p);
> >  > > +   if (r)
> >  > > + {
> >  > > +   binfo_set.add(r);
> >  > > + }
> >  > > + }
> >  > >
> >  > > -   If they yield more than one possible deduced A, the type
> >  > > -   deduction fails.
> >  > > +  /* If there is more than one satisfactory baseclass, then:
> >  > > + [temp.deduct.call]
> >  > > +  If they yield more than one possible deduced A, the type
> >  > > +  deduction fails.
> >  > > + However, if there is a class C that is a (direct or indirect)
> >  > > base class of
> >  > > + D and derived (directly or indirectly) from a class B and
> > that would be a
> >  > > + valid deduced A, the deduced A cannot be B or pointer to B,
> >  > > respectively.  */
> >  > > +  for (hash_set::iterator it = binfo_set.begin();
> >  > > +it != binfo_set.end(); ++it)
> >  > > +{
> >  > > +  binfo = TYPE_BINFO (*it);
> >  > > +  for (binfo = TREE_CHAIN (binfo); binfo; binfo = TREE_CHAIN
> > (binfo))
> >  > > +{
> >  > > +  tree r = try_class_unification (tparms, targs, parm,
> >  > > + 

[PATCH] c++: Implement DR2303 [PR97453]

2020-10-22 Thread kamlesh kumar via Gcc-patches
Attaching the patch file.

>>Instead of building a hash table, would it work to handle ambiguity by
>>checking whether one of the classes is a base of the other?
Fixing for cases like: struct B: A,A may not be cleaner this
way.

On Thu, Oct 22, 2020 at 3:23 AM Jason Merrill  wrote:
>
> On 10/21/20 6:32 AM, kamlesh kumar wrote:
> > gcc/cp/ChangeLog
> > ---
> >
> > 2020-10-21  Kamlesh Kumar  
> >
> > PR c++/97453
> > * pt.c (get_template_base): Implement DR2303,
> > Consider closest base while template
> > deduction when base of base also matches.
> >
> > gcc/testsuite/ChangeLog
> > --
> >
> > 2020-10-21  Kamlesh Kumar  
> >
> > * g++.dg/Drs/dr2303.C: New Test
> >
> > --
> >
> > As part of this patch I Implemented fix for below defect report in cwg
> > https://wg21.cmeerw.net/cwg/issue2303 .
>
> Thanks!
>
> Please see https://gcc.gnu.org/contribute.html for guidance on email
> subject lines; for this patch I'd think something like
>
> [PATCH] c++: Implement DR2303 [PR97453]
>
> Also, your patch was corrupted by word wrap; the easiest way to avoid
> that is probably to attach the file rather than copy it into the message.
>
> > Reg tested on x86_64 and did not found any failure.
> > Patch summary: Remove base of base from list of bases
> >
> > created a hash_set from list of bases and then iterate over each
> > element of hash_set and find its  list of bases and remove this from
> > hash_set if present.
> > and finally, deduction succeeds if in hash_set remains only single
> > element or it's empty.
> > otherwise deduction is ambiguous.
>
> Instead of building a hash table, would it work to handle ambiguity by
> checking whether one of the classes is a base of the other?
>
> > ---
> > diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> > index dc664ec3798..7adf461e108 100644
> > --- a/gcc/cp/pt.c
> > +++ b/gcc/cp/pt.c
> > @@ -22643,8 +22643,9 @@ static enum template_base_result
> >   get_template_base (tree tparms, tree targs, tree parm, tree arg,
> >   bool explain_p, tree *result)
> >   {
> > -  tree rval = NULL_TREE;
> > +  *result = NULL_TREE;
> > tree binfo;
> > +  hash_set binfo_set;
> >
> > gcc_assert (RECORD_OR_UNION_CODE_P (TREE_CODE (arg)));
> >
> > @@ -22659,31 +22660,51 @@ get_template_base (tree tparms, tree targs,
> > tree parm, tree arg,
> > /* Walk in inheritance graph order.  The search order is not
> >important, and this avoids multiple walks of virtual bases.  */
> > for (binfo = TREE_CHAIN (binfo); binfo; binfo = TREE_CHAIN (binfo))
> > -{
> > -  tree r = try_class_unification (tparms, targs, parm,
> > -   BINFO_TYPE (binfo), explain_p);
> > -
> > -  if (r)
> > - {
> > -   /* If there is more than one satisfactory baseclass, then:
> > -
> > -[temp.deduct.call]
> > + {
> > +   tree r = try_class_unification (tparms, targs, parm,
> > +   BINFO_TYPE (binfo), explain_p);
> > +   if (r)
> > + {
> > +   binfo_set.add(r);
> > + }
> > + }
> >
> > -   If they yield more than one possible deduced A, the type
> > -   deduction fails.
> > +  /* If there is more than one satisfactory baseclass, then:
> > + [temp.deduct.call]
> > +  If they yield more than one possible deduced A, the type
> > +  deduction fails.
> > + However, if there is a class C that is a (direct or indirect)
> > base class of
> > + D and derived (directly or indirectly) from a class B and that
would be a
> > + valid deduced A, the deduced A cannot be B or pointer to B,
> > respectively.  */
> > +  for (hash_set::iterator it = binfo_set.begin();
> > +it != binfo_set.end(); ++it)
> > +{
> > +  binfo = TYPE_BINFO (*it);
> > +  for (binfo = TREE_CHAIN (binfo); binfo; binfo = TREE_CHAIN
(binfo))
> > +{
> > +  tree r = try_class_unification (tparms, targs, parm,
> > +  BINFO_TYPE (binfo), explain_p);
> > +  if (r && binfo_set.contains(r))
> > +{
> > +  binfo_set.remove(r);
> > +}
> > +}
> > +}
> >
> > -  applies.  */
> > -   if (rval && !same_type_p (r, rval))
> > - {
> > -   *result = NULL_TREE;
> > -   return tbr_ambiguous_baseclass;
> > - }
> > +  if (binfo_set.elements() > 1)
> > +{
> > +  return tbr_ambiguous_baseclass;
> > +}
> >
> > -   rval = r;
> > - }
> > +  if (binfo_set.is_empty())
> > +{
> > +  return tbr_success;
> >   }
> >
> > -  *result = rval;
> > +  if (binfo_set.elements() == 1)
> > +{
> > +  *result = *binfo_set.begin();
> > +}
> > return tbr_success;
> >   }
> >
> > diff --git a/gcc/testsuite/g++.dg/DRs/dr2303.C
> > b/gcc/testsuite/g++.dg/DRs/dr2303.C
> > new file mode 100644
> > index 000..b4c23332358
> 

PATCH [DR2303][PR97453]

2020-10-21 Thread kamlesh kumar via Gcc-patches
gcc/cp/ChangeLog
---

2020-10-21  Kamlesh Kumar  

PR c++/97453
* pt.c (get_template_base): Implement DR2303,
Consider closest base while template
deduction when base of base also matches.

gcc/testsuite/ChangeLog
--

2020-10-21  Kamlesh Kumar  

* g++.dg/Drs/dr2303.C: New Test

--

As part of this patch I Implemented fix for below defect report in cwg
https://wg21.cmeerw.net/cwg/issue2303 .
Reg tested on x86_64 and did not found any failure.
Patch summary: Remove base of base from list of bases

created a hash_set from list of bases and then iterate over each
element of hash_set and find its  list of bases and remove this from
hash_set if present.
and finally, deduction succeeds if in hash_set remains only single
element or it's empty.
otherwise deduction is ambiguous.
---
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index dc664ec3798..7adf461e108 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -22643,8 +22643,9 @@ static enum template_base_result
 get_template_base (tree tparms, tree targs, tree parm, tree arg,
 bool explain_p, tree *result)
 {
-  tree rval = NULL_TREE;
+  *result = NULL_TREE;
   tree binfo;
+  hash_set binfo_set;

   gcc_assert (RECORD_OR_UNION_CODE_P (TREE_CODE (arg)));

@@ -22659,31 +22660,51 @@ get_template_base (tree tparms, tree targs,
tree parm, tree arg,
   /* Walk in inheritance graph order.  The search order is not
  important, and this avoids multiple walks of virtual bases.  */
   for (binfo = TREE_CHAIN (binfo); binfo; binfo = TREE_CHAIN (binfo))
-{
-  tree r = try_class_unification (tparms, targs, parm,
-   BINFO_TYPE (binfo), explain_p);
-
-  if (r)
- {
-   /* If there is more than one satisfactory baseclass, then:
-
-[temp.deduct.call]
+ {
+   tree r = try_class_unification (tparms, targs, parm,
+   BINFO_TYPE (binfo), explain_p);
+   if (r)
+ {
+   binfo_set.add(r);
+ }
+ }

-   If they yield more than one possible deduced A, the type
-   deduction fails.
+  /* If there is more than one satisfactory baseclass, then:
+ [temp.deduct.call]
+  If they yield more than one possible deduced A, the type
+  deduction fails.
+ However, if there is a class C that is a (direct or indirect)
base class of
+ D and derived (directly or indirectly) from a class B and that would be a
+ valid deduced A, the deduced A cannot be B or pointer to B,
respectively.  */
+  for (hash_set::iterator it = binfo_set.begin();
+it != binfo_set.end(); ++it)
+{
+  binfo = TYPE_BINFO (*it);
+  for (binfo = TREE_CHAIN (binfo); binfo; binfo = TREE_CHAIN (binfo))
+{
+  tree r = try_class_unification (tparms, targs, parm,
+  BINFO_TYPE (binfo), explain_p);
+  if (r && binfo_set.contains(r))
+{
+  binfo_set.remove(r);
+}
+}
+}

-  applies.  */
-   if (rval && !same_type_p (r, rval))
- {
-   *result = NULL_TREE;
-   return tbr_ambiguous_baseclass;
- }
+  if (binfo_set.elements() > 1)
+{
+  return tbr_ambiguous_baseclass;
+}

-   rval = r;
- }
+  if (binfo_set.is_empty())
+{
+  return tbr_success;
 }

-  *result = rval;
+  if (binfo_set.elements() == 1)
+{
+  *result = *binfo_set.begin();
+}
   return tbr_success;
 }

diff --git a/gcc/testsuite/g++.dg/DRs/dr2303.C
b/gcc/testsuite/g++.dg/DRs/dr2303.C
new file mode 100644
index 000..b4c23332358
--- /dev/null
+++ b/gcc/testsuite/g++.dg/DRs/dr2303.C
@@ -0,0 +1,20 @@
+// DR 2303
+// PR c++/97453
+// { dg-do compile { target c++11 } }
+
+template 
+struct A;
+template <>
+struct A<> {};
+template 
+struct A : A {};
+struct B : A {};
+
+template 
+void f(const A &) {
+  static_assert(sizeof...(T) == 2, "it should duduce to A");
+}
+
+void g() {
+  f(B{});
+}


./kamlesh


Re: [PATCH] Defined libcall_arg_t

2020-06-16 Thread Kamlesh Kumar via Gcc-patches

thanks Richard,

addressed your concern.

diff --git a/gcc/rtl.h b/gcc/rtl.h
index 0872cc4..7206c8a 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2238,6 +2238,16 @@ struct address_info {
   enum rtx_code base_outer_code;
 };

+/* This is used for passing args in emit_library_* functions */
+struct libcall_arg {
+  rtx value;
+  machine_mode mode;
+  bool unsigned_p;
+  constexpr
+  libcall_arg (rtx v, machine_mode m, bool u) : value(v), mode(m),
+    unsigned_p(u) {}
+};
+
 /* This is used to bundle an rtx and a mode together so that the pair
    can be used with the wi:: routines.  If we ever put modes into rtx
    integer constants, this should go away and then just pass an rtx 
in.  */


On 16/06/20 2:34 pm, Richard Sandiford wrote:

Thanks for doing this.

Kamlesh Kumar via Gcc-patches  writes:

diff --git a/gcc/rtl.h b/gcc/rtl.h
index 0872cc4..c023ff0 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2238,6 +2238,18 @@ struct address_info {
enum rtx_code base_outer_code;
  };
  
+/* This is used for passing args in emit_library_* functions */

+typedef struct libcall_arg {

There's not really any need for a typedef here.  We should just
use “libcall_arg” directly.


+  rtx value;
+  machine_mode mode;
+  bool unsigned_p;
+  libcall_arg (rtx v, machine_mode m, bool u) {
+value = v;
+mode = m;
+unsigned_p = u;
+  }

Please use member initialisation for the fields instead.

Now that we're C++11, the constructor might as well be constexpr.

Thanks,
Richard


+} libcall_arg_t;
+
  /* This is used to bundle an rtx and a mode together so that the pair
 can be used with the wi:: routines.  If we ever put modes into rtx
 integer constants, this should go away and then just pass an rtx in.  */


Re: [PATCH v1 1/2][PPC64] [PR88877]

2020-06-13 Thread kamlesh kumar via Gcc-patches
Thank you all for the suggestions.
This is first patch where I have just defined a struct libcall_arg_t
which contains
three member rtx, machine_mode and a boolean unsigned_p and will be
used in passing args in
emit_library_[call/value] functions.

Once this patch is approved then i will create second patch in which
arg type libcall_arg_t will be
propogated on all instances needed.
Then final patch which will fix the actual problem reported in PR88877.

ChangeLog Entry:

2020-06-13  Kamlesh Kumar  

   * rtl.h (libcall_arg_t): Defined.


---
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 0872cc4..c023ff0 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2238,6 +2238,18 @@ struct address_info {
   enum rtx_code base_outer_code;
 };

+/* This is used for passing args in emit_library_* functions */
+typedef struct libcall_arg {
+  rtx value;
+  machine_mode mode;
+  bool unsigned_p;
+  libcall_arg (rtx v, machine_mode m, bool u) {
+value = v;
+mode = m;
+unsigned_p = u;
+  }
+} libcall_arg_t;
+
 /* This is used to bundle an rtx and a mode together so that the pair
can be used with the wi:: routines.  If we ever put modes into rtx
integer constants, this should go away and then just pass an rtx in.  */
--
2.7.4

On Fri, Jun 12, 2020 at 4:43 AM Segher Boessenkool
 wrote:
>
> On Tue, Jun 09, 2020 at 02:29:13PM -0600, Jeff Law wrote:
> > On Sun, 2020-05-24 at 11:22 -0500, Segher Boessenkool wrote:
> > > OTOH, you don't need to name Tuple at all...  It should not *have* a
> > > constructor, since you declared it as class...  But you can just use
> > > std::tuple here?
> > >
> > > > (emit_library_call): Added default arg unsigned_p.
> > > > (emit_library_call_value): Added default arg unsigned_p.
> > >
> > > Yeah, eww.  Default arguments have all the problems you had before,
> > > except now it is hidden and much more surprising.
> > >
> > > Those functions really should take rtx_mode_t arguments?
> > >
> > > Thanks again for working on this,
> > ISTM that using std::tuple would be better than defining our own types.
>
> Yeah.  But as Jakub an Iain said, not using a container type (but a more
> concrete type, instead) is much better anyway :-)
>
> > I'd rather see the argument be explicit rather than using default arguments 
> > too.
> > While I have ack'd some patches with default arguments, I still don't like 
> > 'em.
>
> Default arguments have their place (but it's not here :-) )
>
> > I do like the approach of getting the infrastructure in place without 
> > changing
> > behavior, then having the behavior fix as a distinct change.
>
> With Git, commits are easy and cheap, and massaging a patch series into
> shape is easy and cheap as well.  If you develop using Git in the first
> place (and you should!), you should naturally end up with many patches
> in your series, and the preparatory patches first (after you reshuffle
> things a bit, if you are like me and your foresight is severly limited).
>
> So you have this separate *anyway* (or should have).  Since it helps
> reviewing a lot, and also later bisecting, it is good to keep it.
>
>
> Segher


[PATCH] Defined libcall_arg_t

2020-06-13 Thread Kamlesh Kumar via Gcc-patches
This is first patch where I have just defined a struct libcall_arg_t which 
contains
three member rtx, machine_mode and a boolean unsigned_p and will be used in 
passing args in
emit_library_[call/value] functions.

Once this patch is approved then i will create second patch in which arg type 
libcall_arg_t will be
propogated on all instances needed.
Then final patch which will fix the actual problem reported in PR88877.

ChangeLog Entry:

2020-06-13  Kamlesh Kumar  

   * rtl.h (libcall_arg_t): Defined.


---
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 0872cc4..c023ff0 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2238,6 +2238,18 @@ struct address_info {
   enum rtx_code base_outer_code;
 };
 
+/* This is used for passing args in emit_library_* functions */
+typedef struct libcall_arg {
+  rtx value;
+  machine_mode mode;
+  bool unsigned_p;
+  libcall_arg (rtx v, machine_mode m, bool u) {
+value = v;
+mode = m;
+unsigned_p = u;
+  }
+} libcall_arg_t;
+
 /* This is used to bundle an rtx and a mode together so that the pair
can be used with the wi:: routines.  If we ever put modes into rtx
integer constants, this should go away and then just pass an rtx in.  */
-- 
2.7.4



[PATCH] Defined libcall_arg_t

2020-06-13 Thread Kamlesh Kumar via Gcc-patches
This is first patch where I have just defined a struct libcall_arg_t which 
contains
three member rtx, machine_mode and a boolean unsigned_p and will be used in 
passing args in
emit_library_[call/value] functions.

Once this patch is approved then i will create second patch in which arg type 
libcall_arg_t will be
propogated on all instances needed.
Then final patch which will fix the actual problem reported in PR88877.

ChangeLog Entry:

2020-06-13  Kamlesh Kumar  

   * rtl.h (libcall_arg_t): Defined.


---
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 0872cc4..c023ff0 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2238,6 +2238,18 @@ struct address_info {
   enum rtx_code base_outer_code;
 };
 
+/* This is used for passing args in emit_library_* functions */
+typedef struct libcall_arg {
+  rtx value;
+  machine_mode mode;
+  bool unsigned_p;
+  libcall_arg (rtx v, machine_mode m, bool u) {
+value = v;
+mode = m;
+unsigned_p = u;
+  }
+} libcall_arg_t;
+
 /* This is used to bundle an rtx and a mode together so that the pair
can be used with the wi:: routines.  If we ever put modes into rtx
integer constants, this should go away and then just pass an rtx in.  */
-- 
2.7.4



Re: [PATCH v1 1/2][PPC64] [PR88877]

2020-05-25 Thread kamlesh kumar via Gcc-patches
> OTOH, you don't need to name Tuple at all...  It should not *have* a
> constructor, since you declared it as class...  But you can just use
> std::tuple here?

I thought of using std::tuple  but it requires c++11 support.
I am not sure we always build gcc with c++11?

>
> > (emit_library_call): Added default arg unsigned_p.
> > (emit_library_call_value): Added default arg unsigned_p.
>
> Yeah, eww.  Default arguments have all the problems you had before,
> except now it is hidden and much more surprising.
>
> Those functions really should take rtx_mode_t arguments?

I was thinking the same. will incorporate this.

./kamlesh


[PATCH v1 1/2][PPC64] [PR88877]

2020-05-24 Thread Kamlesh Kumar via Gcc-patches
Here is a discussion we did some time ago regarding the defect.
https://gcc.gnu.org/pipermail/gcc/2019-January/227834.html
please see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88877 for testcase
behavior.

We incorporating below Jakub's suggestion in this patch series.

Jakub wrote:
""
Yeah, all the callers of emit_library_call* would need to be changed to pass
triplets rtx, machine_mode, int/bool /*unsignedp*/, instead of just
rtx_mode_t pair.
""


In this patch series trying to address same by creating a struct Tuple
which bundles existing rtx and machine_mode and added one more
bool member which store unsigned_p which by default is false.
This patch does not change underlying behavior yet. This will be done in
follow up patches.

ChangeLog Entry:

2020-05-24 Kamlesh Kumar 

* rtl.h (Tuple): Defined and typedefed to rtx_mode_t.
(emit_library_call): Added default arg unsigned_p.
(emit_library_call_value): Added default arg unsigned_p.
---
 gcc/rtl.h | 26 ++
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/gcc/rtl.h b/gcc/rtl.h
index b0b1aac..ee42de7 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2238,10 +2238,20 @@ struct address_info {
   enum rtx_code base_outer_code;
 };
 
-/* This is used to bundle an rtx and a mode together so that the pair
-   can be used with the wi:: routines.  If we ever put modes into rtx
-   integer constants, this should go away and then just pass an rtx in.  */
-typedef std::pair  rtx_mode_t;
+/* This is used to bundle an rtx and a mode and unsignedness together so
+   that the tuple can be used with the wi:: routines.  If we ever put modes
+   into rtx integer constants, this should go away and then just pass an rtx 
in.  */
+typedef struct Tuple {
+  rtx first;
+  machine_mode second;
+  /* unsigned_p  */
+  bool third;
+  Tuple (rtx f, machine_mode s, bool t = false) {
+first = f;
+second = s;
+third = t;
+  }
+} rtx_mode_t;
 
 namespace wi
 {
@@ -4176,9 +4186,9 @@ emit_library_call (rtx fun, libcall_type fn_type, 
machine_mode outmode)
 
 inline void
 emit_library_call (rtx fun, libcall_type fn_type, machine_mode outmode,
-  rtx arg1, machine_mode arg1_mode)
+  rtx arg1, machine_mode arg1_mode, bool unsigned_p = false)
 {
-  rtx_mode_t args[] = { rtx_mode_t (arg1, arg1_mode) };
+  rtx_mode_t args[] = { rtx_mode_t (arg1, arg1_mode, unsigned_p) };
   emit_library_call_value_1 (0, fun, NULL_RTX, fn_type, outmode, 1, args);
 }
 
@@ -4238,9 +4248,9 @@ emit_library_call_value (rtx fun, rtx value, libcall_type 
fn_type,
 inline rtx
 emit_library_call_value (rtx fun, rtx value, libcall_type fn_type,
 machine_mode outmode,
-rtx arg1, machine_mode arg1_mode)
+rtx arg1, machine_mode arg1_mode, bool unsigned_p = 
false)
 {
-  rtx_mode_t args[] = { rtx_mode_t (arg1, arg1_mode) };
+  rtx_mode_t args[] = { rtx_mode_t (arg1, arg1_mode, unsigned_p) };
   return emit_library_call_value_1 (1, fun, value, fn_type, outmode, 1, args);
 }
 
-- 
2.7.4



Re: [PATCH][PPC64] [PR88877]

2020-05-22 Thread kamlesh kumar via Gcc-patches
ping?

On Tue, May 19, 2020 at 5:32 PM kamlesh kumar 
wrote:

> can someone look at the patch, please?
>
>
> On Wed, Apr 8, 2020 at 9:29 PM Jeff Law  wrote:
>
>> On Mon, 2020-04-06 at 14:58 +0530, kamlesh kumar via Gcc-patches wrote:
>> > Hi Richard,
>> > Here is a discussion we did some time ago
>> > https://gcc.gnu.org/pipermail/gcc/2019-January/227834.html
>> > please see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88877 for more
>> > info regarding the bug.
>> >
>> > We incorporated below Jakub's suggestion in this patch.
>> >
>> > Jakub wrote:
>> > ""
>> > Yeah, all the callers of emit_library_call* would need to be changed to
>> pass
>> > triplets rtx, machine_mode, int/bool /*unsignedp*/, instead of just
>> > rtx_mode_t pair.
>> > Jakub
>> > ""
>> I think you're generally on the right track here, but I'm deferring this
>> to gcc11
>> (other maintainers are, of course, welcome to push it for gcc10 as it's a
>> code
>> correctness issue).
>>
>> Jeff
>> >
>>
>>


Re: [PATCH][PPC64] [PR88877]

2020-05-19 Thread kamlesh kumar via Gcc-patches
can someone look at the patch, please?


On Wed, Apr 8, 2020 at 9:29 PM Jeff Law  wrote:

> On Mon, 2020-04-06 at 14:58 +0530, kamlesh kumar via Gcc-patches wrote:
> > Hi Richard,
> > Here is a discussion we did some time ago
> > https://gcc.gnu.org/pipermail/gcc/2019-January/227834.html
> > please see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88877 for more
> > info regarding the bug.
> >
> > We incorporated below Jakub's suggestion in this patch.
> >
> > Jakub wrote:
> > ""
> > Yeah, all the callers of emit_library_call* would need to be changed to
> pass
> > triplets rtx, machine_mode, int/bool /*unsignedp*/, instead of just
> > rtx_mode_t pair.
> > Jakub
> > ""
> I think you're generally on the right track here, but I'm deferring this
> to gcc11
> (other maintainers are, of course, welcome to push it for gcc10 as it's a
> code
> correctness issue).
>
> Jeff
> >
>
>


Re: [PATCH][libstd++][PR92156]

2020-04-21 Thread kamlesh kumar via Gcc-patches
added VERIFY in test and changed the template parameter naming.

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 6b7e68f0e63..d350d0b2575 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -176,36 +176,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   typename __any_constructible::type;

 /// Construct with a copy of @p __value as the contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  __any_constructible_t<_Tp, _ValueType&&> = true,
-  enable_if_t::value, bool> = true>
-  any(_ValueType&& __value)
+template ,
+  typename _Mgr = _Manager<_VTp>,
+  enable_if_t::value &&
+  !__is_in_place_type<_VTp>::value, bool> = true>
+  any(_Tp&& __value)
   : _M_manager(&_Mgr::_S_manage)
   {
-_Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value));
-  }
-
-/// Construct with a copy of @p __value as the contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  enable_if_t<__and_v,
-  __not_>,
-  __not_<__is_in_place_type<_Tp>>>,
-  bool> = false>
-  any(_ValueType&& __value)
-  : _M_manager(&_Mgr::_S_manage)
-  {
-_Mgr::_S_create(_M_storage, __value);
+_Mgr::_S_create(_M_storage, std::forward<_Tp>(__value));
   }

 /// Construct with an object created from @p __args as the
contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  __any_constructible_t<_Tp, _Args&&...> = false>
+template ,
+  typename _Mgr = _Manager<_VTp>,
+  __any_constructible_t<_VTp, _Args&&...> = false>
   explicit
-  any(in_place_type_t<_ValueType>, _Args&&... __args)
+  any(in_place_type_t<_Tp>, _Args&&... __args)
   : _M_manager(&_Mgr::_S_manage)
   {
 _Mgr::_S_create(_M_storage, std::forward<_Args>(__args)...);
@@ -213,13 +200,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION

 /// Construct with an object created from @p __il and @p __args as
 /// the contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  __any_constructible_t<_Tp, initializer_list<_Up>,
+template ,
+  typename _Mgr = _Manager<_VTp>,
+  __any_constructible_t<_VTp, initializer_list<_Up>,
 _Args&&...> = false>
   explicit
-  any(in_place_type_t<_ValueType>,
+  any(in_place_type_t<_Tp>,
   initializer_list<_Up> __il, _Args&&... __args)
   : _M_manager(&_Mgr::_S_manage)
   {
@@ -258,40 +245,43 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 }

 /// Store a copy of @p __rhs as the contained object.
-template
-  enable_if_t>::value, any&>
-  operator=(_ValueType&& __rhs)
+template
+  enable_if_t>::value, any&>
+  operator=(_Tp&& __rhs)
   {
- *this = any(std::forward<_ValueType>(__rhs));
+ *this = any(std::forward<_Tp>(__rhs));
  return *this;
   }

 /// Emplace with an object created from @p __args as the contained object.
-template 
-  typename __any_constructible<_Decay<_ValueType>&,
-   _Decay<_ValueType>, _Args&&...>::type
+template >
+  typename __any_constructible<_VTp&,
+   _VTp, _Args&&...>::type
   emplace(_Args&&... __args)
   {
- __do_emplace<_Decay<_ValueType>>(std::forward<_Args>(__args)...);
+ __do_emplace<_VTp>(std::forward<_Args>(__args)...);
  any::_Arg __arg;
  this->_M_manager(any::_Op_access, this, &__arg);
- return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
+ return *static_cast<_VTp*>(__arg._M_obj);
   }

 /// Emplace with an object created from @p __il and @p __args as
 /// the contained object.
-template 
-  typename __any_constructible<_Decay<_ValueType>&,
-   _Decay<_ValueType>,
+template >
+  typename __any_constructible<_VTp&,
+   _VTp,
initializer_list<_Up>,
_Args&&...>::type
   emplace(initializer_list<_Up> __il, _Args&&... __args)
   {
- __do_emplace<_Decay<_ValueType>, _Up>(__il,
+ __do_emplace<_VTp, _Up>(__il,
   std::forward<_Args>(__args)...);
  any::_Arg __arg;
  this->_M_manager(any::_Op_access, this, &__arg);
- return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
+ return *static_cast<_VTp*>(__arg._M_obj);
   }

 // modifiers
diff --git a/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
new file mode 100644
index 000..df6c9deff1b
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
@@ -0,0 +1,39 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2014-2020 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 that it will be 

Re: [PATCH][libstd++][PR92156]

2020-04-21 Thread kamlesh kumar via Gcc-patches
Added the fix for emplace.

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 6b7e68f0e63..f35d90e548d 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -178,30 +178,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 /// Construct with a copy of @p __value as the contained object.
 template ,
   typename _Mgr = _Manager<_Tp>,
-  __any_constructible_t<_Tp, _ValueType&&> = true,
-  enable_if_t::value, bool> = true>
+  enable_if_t::value &&
+  !__is_in_place_type<_Tp>::value, bool> = true>
   any(_ValueType&& __value)
   : _M_manager(&_Mgr::_S_manage)
   {
 _Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value));
   }

-/// Construct with a copy of @p __value as the contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  enable_if_t<__and_v,
-  __not_>,
-  __not_<__is_in_place_type<_Tp>>>,
-  bool> = false>
-  any(_ValueType&& __value)
-  : _M_manager(&_Mgr::_S_manage)
-  {
-_Mgr::_S_create(_M_storage, __value);
-  }
-
 /// Construct with an object created from @p __args as the contained
object.
 template ,
+  typename _Tp = decay_t<_ValueType>,
   typename _Mgr = _Manager<_Tp>,
   __any_constructible_t<_Tp, _Args&&...> = false>
   explicit
@@ -214,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 /// Construct with an object created from @p __il and @p __args as
 /// the contained object.
 template ,
+  typename _Tp = decay_t<_ValueType>,
   typename _Mgr = _Manager<_Tp>,
   __any_constructible_t<_Tp, initializer_list<_Up>,
 _Args&&...> = false>
@@ -267,31 +254,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   }

 /// Emplace with an object created from @p __args as the contained
object.
-template 
-  typename __any_constructible<_Decay<_ValueType>&,
-   _Decay<_ValueType>, _Args&&...>::type
+template >
+  typename __any_constructible<_Tp&,
+   _Tp, _Args&&...>::type
   emplace(_Args&&... __args)
   {
- __do_emplace<_Decay<_ValueType>>(std::forward<_Args>(__args)...);
+ __do_emplace<_Tp>(std::forward<_Args>(__args)...);
  any::_Arg __arg;
  this->_M_manager(any::_Op_access, this, &__arg);
- return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
+ return *static_cast<_Tp*>(__arg._M_obj);
   }

 /// Emplace with an object created from @p __il and @p __args as
 /// the contained object.
-template 
-  typename __any_constructible<_Decay<_ValueType>&,
-   _Decay<_ValueType>,
+template >
+  typename __any_constructible<_Tp&,
+   _Tp,
initializer_list<_Up>,
_Args&&...>::type
   emplace(initializer_list<_Up> __il, _Args&&... __args)
   {
- __do_emplace<_Decay<_ValueType>, _Up>(__il,
+ __do_emplace<_Tp, _Up>(__il,
   std::forward<_Args>(__args)...);
  any::_Arg __arg;
  this->_M_manager(any::_Op_access, this, &__arg);
- return *static_cast<_Decay<_ValueType>*>(__arg._M_obj);
+ return *static_cast<_Tp*>(__arg._M_obj);
   }

 // modifiers
diff --git a/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
new file mode 100644
index 000..c4f1ed55aee
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2014-2020 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 that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+#include 
+#include 
+#include 
+
+int main() {
+auto a = std::any(std::in_place_type, 5);
+auto b = std::any(std::in_place_type, {1});
+std::any p = std::pair(1, 1);
+(void)p;
+std::any t = std::tuple(1);
+(void)t;
+return 0;
+}
+

thanks,


On Tue, Apr 21, 2020 at 12:09 PM Ville Voutilainen <
ville.voutilai...@gmail.com> wrote:

> On Tue, 21 Apr 2020 at 09:11, Ville Voutilainen
>  wrote:
> >
> > On Tue, 21 Apr 2020 at 04:10, kamlesh kumar 
> wrote:
> > >
> > > Thank you for reviewing.
> > > without  _Decay to decay_t in the constructor which takes
> inplace_type_t,
> > > cases like this fails
> > > auto a = std::any(std::in_place_type, 5);
> > >
> > > for these constructors, standard does not say anything about
> > > not-sameness checks with any.
> > > 

Re: [PATCH][libstd++][PR92156]

2020-04-20 Thread kamlesh kumar via Gcc-patches
Thank you for reviewing.
without  _Decay to decay_t in the constructor which takes inplace_type_t,
cases like this fails
auto a = std::any(std::in_place_type, 5);

for these constructors, standard does not say anything about
not-sameness checks with any.
https://en.cppreference.com/w/cpp/utility/any/any.

./kamlesh


On Mon, Apr 20, 2020 at 11:54 PM Ville Voutilainen
 wrote:
>
> On Mon, 20 Apr 2020 at 21:09, Ville Voutilainen
>  wrote:
> >
> > On Sat, 18 Apr 2020 at 03:35, kamlesh kumar via Libstdc++
> >  wrote:
> > >
> > > On Fri, Apr 17, 2020, 10:59 PM kamlesh kumar 
> > > wrote:
> > >
> > > > Fixes all this.
> > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92156
> > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91630
> > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90415
> > > >
> > > > On Fri, Apr 17, 2020 at 10:45 PM kamlesh kumar 
> > > > wrote:
> > > > >
> > > > > This patch corrects the requirement  of 4,5 and 6th constructor
> > > > > As per https://en.cppreference.com/w/cpp/utility/any/any.
> >
> > The patch looks correct to me. We have some old cruft there, like the
> > overload your patch removes, it was
> > there to support copy-only types, but LWG issues axed that bit. This
> > constructor indeed should not check is_constructible,
> > because it'll end up instantiating this constructor itself, and
> > compute its constraints, and instantiate itself.
> > The in_place constructor doesn't have that problem, because it won't
> > instantiate itself.
>
> ..except the change from _Decay to decay_t looks wrong. _Decay also
> checks the non-sameness with
> any. That change shouldn't be made.


Re: [PATCH][libstd++][PR92156]

2020-04-17 Thread kamlesh kumar via Gcc-patches
On Fri, Apr 17, 2020, 10:59 PM kamlesh kumar 
wrote:

> Fixes all this.
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92156
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91630
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90415
>
> On Fri, Apr 17, 2020 at 10:45 PM kamlesh kumar 
> wrote:
> >
> > This patch corrects the requirement  of 4,5 and 6th constructor
> > As per https://en.cppreference.com/w/cpp/utility/any/any.
> >
> > ChangeLog:
> > 2020-04-17  Kamlesh Kumar  
> >
> > PR libstdc++/92156
> > * include/std/any (ans::any(_ValueType &&):: Remove
> is_constructible.
> > (any::any(in_place_type_t<_ValueType>, _Args&&...)): Use decay_t.
> > (any::any(in_place_type_t<_ValueType>,initializer_list<_Up>,
> _Args&&...)):
> > Use decay_t.
> >  * testsuite/20_util/any/misc/92156.cc: New Test.
> >
> > diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
> > index 6b7e68f0e63..fb212eb2231 100644
> > --- a/libstdc++-v3/include/std/any
> > +++ b/libstdc++-v3/include/std/any
> > @@ -178,30 +178,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >  /// Construct with a copy of @p __value as the contained object.
> >  template ,
> >typename _Mgr = _Manager<_Tp>,
> > -  __any_constructible_t<_Tp, _ValueType&&> = true,
> > -  enable_if_t::value, bool> = true>
> > +  enable_if_t::value &&
> > +  !__is_in_place_type<_Tp>::value, bool> = true>
> >any(_ValueType&& __value)
> >: _M_manager(&_Mgr::_S_manage)
> >{
> >  _Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value));
> >}
> >
> > -/// Construct with a copy of @p __value as the contained object.
> > -template ,
> > -  typename _Mgr = _Manager<_Tp>,
> > -  enable_if_t<__and_v,
> > -  __not_>,
> > -  __not_<__is_in_place_type<_Tp>>>,
> > -  bool> = false>
> > -  any(_ValueType&& __value)
> > -  : _M_manager(&_Mgr::_S_manage)
> > -  {
> > -_Mgr::_S_create(_M_storage, __value);
> > -  }
> > -
> >  /// Construct with an object created from @p __args as the
> contained object.
> >  template  > -  typename _Tp = _Decay<_ValueType>,
> > +  typename _Tp = decay_t<_ValueType>,
> >typename _Mgr = _Manager<_Tp>,
> >__any_constructible_t<_Tp, _Args&&...> = false>
> >explicit
> > @@ -214,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >  /// Construct with an object created from @p __il and @p __args as
> >  /// the contained object.
> >  template  > -  typename _Tp = _Decay<_ValueType>,
> > +  typename _Tp = decay_t<_ValueType>,
> >typename _Mgr = _Manager<_Tp>,
> >__any_constructible_t<_Tp, initializer_list<_Up>,
> >  _Args&&...> = false>
> > diff --git a/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
> b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
> > new file mode 100644
> > index 000..c4f1ed55aee
> > --- /dev/null
> > +++ b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
> > @@ -0,0 +1,34 @@
> > +// { dg-options "-std=gnu++17" }
> > +// { dg-do compile }
> > +
> > +// Copyright (C) 2014-2020 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 that it will be useful,
> > +// but WITHOUT ANY WARRANTY; without even the implied warranty of
> > +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> > +// GNU General Public License for more details.
> > +
> > +// You should have received a copy of the GNU General Public License
> along
> > +// with this library; see the file COPYING3.  If not see
> > +// .
> > +
> > +#include 
> > +#include 
> > +#include 
> > +
> > +int main() {
> > +auto a = std::any(std::in_place_type, 5);
> > +auto b = std::any(std::in_place_type, {1});
> > +std::any p = std::pair(1, 1);
> > +(void)p;
> > +std::any t = std::tuple(1);
> > +(void)t;
> > +return 0;
> > +}
> > +
> >
> > Regtested on X86_64-linux.
> >
> > Thanks,
> >
>


Re: [PATCH][libstd++][PR92156]

2020-04-17 Thread kamlesh kumar via Gcc-patches
Fixes all this.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92156
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91630
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90415

On Fri, Apr 17, 2020 at 10:45 PM kamlesh kumar  wrote:
>
> This patch corrects the requirement  of 4,5 and 6th constructor
> As per https://en.cppreference.com/w/cpp/utility/any/any.
>
> ChangeLog:
> 2020-04-17  Kamlesh Kumar  
>
> PR libstdc++/92156
> * include/std/any (ans::any(_ValueType &&):: Remove is_constructible.
> (any::any(in_place_type_t<_ValueType>, _Args&&...)): Use decay_t.
> (any::any(in_place_type_t<_ValueType>,initializer_list<_Up>, 
> _Args&&...)):
> Use decay_t.
>  * testsuite/20_util/any/misc/92156.cc: New Test.
>
> diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
> index 6b7e68f0e63..fb212eb2231 100644
> --- a/libstdc++-v3/include/std/any
> +++ b/libstdc++-v3/include/std/any
> @@ -178,30 +178,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>  /// Construct with a copy of @p __value as the contained object.
>  template ,
>typename _Mgr = _Manager<_Tp>,
> -  __any_constructible_t<_Tp, _ValueType&&> = true,
> -  enable_if_t::value, bool> = true>
> +  enable_if_t::value &&
> +  !__is_in_place_type<_Tp>::value, bool> = true>
>any(_ValueType&& __value)
>: _M_manager(&_Mgr::_S_manage)
>{
>  _Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value));
>}
>
> -/// Construct with a copy of @p __value as the contained object.
> -template ,
> -  typename _Mgr = _Manager<_Tp>,
> -  enable_if_t<__and_v,
> -  __not_>,
> -  __not_<__is_in_place_type<_Tp>>>,
> -  bool> = false>
> -  any(_ValueType&& __value)
> -  : _M_manager(&_Mgr::_S_manage)
> -  {
> -_Mgr::_S_create(_M_storage, __value);
> -  }
> -
>  /// Construct with an object created from @p __args as the contained 
> object.
>  template  -  typename _Tp = _Decay<_ValueType>,
> +  typename _Tp = decay_t<_ValueType>,
>typename _Mgr = _Manager<_Tp>,
>__any_constructible_t<_Tp, _Args&&...> = false>
>explicit
> @@ -214,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>  /// Construct with an object created from @p __il and @p __args as
>  /// the contained object.
>  template  -  typename _Tp = _Decay<_ValueType>,
> +  typename _Tp = decay_t<_ValueType>,
>typename _Mgr = _Manager<_Tp>,
>__any_constructible_t<_Tp, initializer_list<_Up>,
>  _Args&&...> = false>
> diff --git a/libstdc++-v3/testsuite/20_util/any/misc/92156.cc 
> b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
> new file mode 100644
> index 000..c4f1ed55aee
> --- /dev/null
> +++ b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
> @@ -0,0 +1,34 @@
> +// { dg-options "-std=gnu++17" }
> +// { dg-do compile }
> +
> +// Copyright (C) 2014-2020 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 that it will be useful,
> +// but WITHOUT ANY WARRANTY; without even the implied warranty of
> +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +// GNU General Public License for more details.
> +
> +// You should have received a copy of the GNU General Public License along
> +// with this library; see the file COPYING3.  If not see
> +// .
> +
> +#include 
> +#include 
> +#include 
> +
> +int main() {
> +auto a = std::any(std::in_place_type, 5);
> +auto b = std::any(std::in_place_type, {1});
> +std::any p = std::pair(1, 1);
> +(void)p;
> +std::any t = std::tuple(1);
> +(void)t;
> +return 0;
> +}
> +
>
> Regtested on X86_64-linux.
>
> Thanks,
>


[PATCH][libstd++][PR92156]

2020-04-17 Thread kamlesh kumar via Gcc-patches
This patch corrects the requirement  of 4,5 and 6th constructor
As per https://en.cppreference.com/w/cpp/utility/any/any.

ChangeLog:
2020-04-17  Kamlesh Kumar  

PR libstdc++/92156
* include/std/any (ans::any(_ValueType &&):: Remove
is_constructible.
(any::any(in_place_type_t<_ValueType>, _Args&&...)): Use decay_t.
(any::any(in_place_type_t<_ValueType>,initializer_list<_Up>,
_Args&&...)):
Use decay_t.
 * testsuite/20_util/any/misc/92156.cc: New Test.

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 6b7e68f0e63..fb212eb2231 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -178,30 +178,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 /// Construct with a copy of @p __value as the contained object.
 template ,
   typename _Mgr = _Manager<_Tp>,
-  __any_constructible_t<_Tp, _ValueType&&> = true,
-  enable_if_t::value, bool> = true>
+  enable_if_t::value &&
+  !__is_in_place_type<_Tp>::value, bool> = true>
   any(_ValueType&& __value)
   : _M_manager(&_Mgr::_S_manage)
   {
 _Mgr::_S_create(_M_storage, std::forward<_ValueType>(__value));
   }

-/// Construct with a copy of @p __value as the contained object.
-template ,
-  typename _Mgr = _Manager<_Tp>,
-  enable_if_t<__and_v,
-  __not_>,
-  __not_<__is_in_place_type<_Tp>>>,
-  bool> = false>
-  any(_ValueType&& __value)
-  : _M_manager(&_Mgr::_S_manage)
-  {
-_Mgr::_S_create(_M_storage, __value);
-  }
-
 /// Construct with an object created from @p __args as the contained
object.
 template ,
+  typename _Tp = decay_t<_ValueType>,
   typename _Mgr = _Manager<_Tp>,
   __any_constructible_t<_Tp, _Args&&...> = false>
   explicit
@@ -214,7 +201,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 /// Construct with an object created from @p __il and @p __args as
 /// the contained object.
 template ,
+  typename _Tp = decay_t<_ValueType>,
   typename _Mgr = _Manager<_Tp>,
   __any_constructible_t<_Tp, initializer_list<_Up>,
 _Args&&...> = false>
diff --git a/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
new file mode 100644
index 000..c4f1ed55aee
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/any/misc/92156.cc
@@ -0,0 +1,34 @@
+// { dg-options "-std=gnu++17" }
+// { dg-do compile }
+
+// Copyright (C) 2014-2020 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 that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// .
+
+#include 
+#include 
+#include 
+
+int main() {
+auto a = std::any(std::in_place_type, 5);
+auto b = std::any(std::in_place_type, {1});
+std::any p = std::pair(1, 1);
+(void)p;
+std::any t = std::tuple(1);
+(void)t;
+return 0;
+}
+

Regtested on X86_64-linux.

Thanks,


Re: [PATCH][PPC64] [PR88877]

2020-04-06 Thread kamlesh kumar via Gcc-patches
Hi Richard,
Here is a discussion we did some time ago
https://gcc.gnu.org/pipermail/gcc/2019-January/227834.html
please see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88877 for more
info regarding the bug.

We incorporated below Jakub's suggestion in this patch.

Jakub wrote:
""
Yeah, all the callers of emit_library_call* would need to be changed to pass
triplets rtx, machine_mode, int/bool /*unsignedp*/, instead of just
rtx_mode_t pair.
Jakub
""

On Mon, Apr 6, 2020 at 2:47 PM Richard Biener  wrote:
>
> On Mon, 6 Apr 2020, kamlesh kumar wrote:
>
> > Segher,
> > Please provide your suggestion/thought on the fix.
>
> There is not a single line of explanation what the change does so what
> do you expect?
>
> Richard.
>
> > On Mon, Mar 23, 2020 at 8:16 PM kamlesh kumar  
> > wrote:
> > >
> > > Attached patch fixes.
> > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88877.
> > > ChangeLog Entry.
> > >
> > > 2020-03-23  Kamlesh Kumar  
> > >
> > > * rtl.h : Defined Tuple for bundling rtx, mode and
> > > unsignedness default as 0
> > > Added Extra argument (unsignedp) in emit_library_call and
> > > emit_library_call_value.
> > > * except.c : Likewise.
> > > * explow.c : Likewise.
> > > * expmed.c : Likewise.
> > > * expr.c : Likewise.
> > > * optabs.c : Likewise.
> > > * asan.c : Likewise.
> > > * builtins.c : Likewise.
> > > * calls.c : Likewise.
> > > * cfgexpand.c : Likewise.
> > > * config/aarch64/aarch64.c : Likewise.
> > > * config/aarch64/aarch64.h : Likewise.
> > > * config/aarch64/atomics.md : Likewise.
> > > * config/alpha/alpha.c : Likewise.
> > > * config/arc/arc.c : Likewise.
> > > * config/arc/elf.h : Likewise.
> > > * config/arc/linux.h : Likewise.
> > > * config/arm/arm.c : Likewise.
> > > * config/bfin/bfin.md : Likewise.
> > > * config/c6x/c6x.c : Likewise.
> > > * config/csky/csky.c : Likewise.
> > > * config/frv/frv.c : Likewise.
> > > * config/i386/i386-expand.c : Likewise.
> > > * config/i386/i386.c : Likewise.
> > > * config/ia64/ia64.c : Likewise.
> > > * config/ia64/ia64.md : Likewise.
> > > * config/m32r/m32r.c : Likewise.
> > > * config/m68k/linux.h : Likewise.
> > > * config/m68k/m68k.c : Likewise.
> > > * config/microblaze/microblaze.c : Likewise.
> > > * config/mips/mips.h : Likewise.
> > > * config/mips/sdemtk.h : Likewise.
> > > * config/nds32/nds32.h : Likewise.
> > > * config/nios2/nios2.c : Likewise.
> > > * config/or1k/or1k.c : Likewise.
> > > * config/pa/pa.c : Likewise.
> > > * config/pa/pa.md : Likewise.
> > > * config/pru/pru.c : Likewise.
> > > * config/riscv/riscv.h : Likewise.
> > > * config/riscv/riscv.md : Likewise.
> > > * config/rl78/rl78.c : Likewise.
> > > * config/rs6000/rs6000-string.c : Likewise.
> > > * config/rs6000/rs6000.c : Likewise.
> > > * config/rs6000/rs6000.md : Likewise.
> > > * config/rs6000/vsx.md : Likewise.
> > > * config/sh/sh.c : Likewise.
> > > * config/sparc/sparc.c : Likewise.
> > > * config/tilegx/tilegx.c : Likewise.
> > > * config/tilepro/tilepro.c : Likewise.
> > > * config/visium/visium.c : Likewise.
> > > * config/xtensa/xtensa.c : Likewise.
> > > * testsuite/gcc.target/powerpc/pr88877.c : Newtest
> >
>
> --
> Richard Biener 
> SUSE Software Solutions Germany GmbH, Maxfeldstrasse 5, 90409 Nuernberg,
> Germany; GF: Felix Imendörffer; HRB 36809 (AG Nuernberg)


Re: [PATCH][PPC64] [PR88877]

2020-04-06 Thread kamlesh kumar via Gcc-patches
Segher,
Please provide your suggestion/thought on the fix.

On Mon, Mar 23, 2020 at 8:16 PM kamlesh kumar  wrote:
>
> Attached patch fixes.
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88877.
> ChangeLog Entry.
>
> 2020-03-23  Kamlesh Kumar  
>
> * rtl.h : Defined Tuple for bundling rtx, mode and
> unsignedness default as 0
> Added Extra argument (unsignedp) in emit_library_call and
> emit_library_call_value.
> * except.c : Likewise.
> * explow.c : Likewise.
> * expmed.c : Likewise.
> * expr.c : Likewise.
> * optabs.c : Likewise.
> * asan.c : Likewise.
> * builtins.c : Likewise.
> * calls.c : Likewise.
> * cfgexpand.c : Likewise.
> * config/aarch64/aarch64.c : Likewise.
> * config/aarch64/aarch64.h : Likewise.
> * config/aarch64/atomics.md : Likewise.
> * config/alpha/alpha.c : Likewise.
> * config/arc/arc.c : Likewise.
> * config/arc/elf.h : Likewise.
> * config/arc/linux.h : Likewise.
> * config/arm/arm.c : Likewise.
> * config/bfin/bfin.md : Likewise.
> * config/c6x/c6x.c : Likewise.
> * config/csky/csky.c : Likewise.
> * config/frv/frv.c : Likewise.
> * config/i386/i386-expand.c : Likewise.
> * config/i386/i386.c : Likewise.
> * config/ia64/ia64.c : Likewise.
> * config/ia64/ia64.md : Likewise.
> * config/m32r/m32r.c : Likewise.
> * config/m68k/linux.h : Likewise.
> * config/m68k/m68k.c : Likewise.
> * config/microblaze/microblaze.c : Likewise.
> * config/mips/mips.h : Likewise.
> * config/mips/sdemtk.h : Likewise.
> * config/nds32/nds32.h : Likewise.
> * config/nios2/nios2.c : Likewise.
> * config/or1k/or1k.c : Likewise.
> * config/pa/pa.c : Likewise.
> * config/pa/pa.md : Likewise.
> * config/pru/pru.c : Likewise.
> * config/riscv/riscv.h : Likewise.
> * config/riscv/riscv.md : Likewise.
> * config/rl78/rl78.c : Likewise.
> * config/rs6000/rs6000-string.c : Likewise.
> * config/rs6000/rs6000.c : Likewise.
> * config/rs6000/rs6000.md : Likewise.
> * config/rs6000/vsx.md : Likewise.
> * config/sh/sh.c : Likewise.
> * config/sparc/sparc.c : Likewise.
> * config/tilegx/tilegx.c : Likewise.
> * config/tilepro/tilepro.c : Likewise.
> * config/visium/visium.c : Likewise.
> * config/xtensa/xtensa.c : Likewise.
> * testsuite/gcc.target/powerpc/pr88877.c : Newtest


Re: [PATCH][PPC64] [PR88877]

2020-03-24 Thread kamlesh kumar via Gcc-patches
Thanks Hans-Peter for reviewing.
Here is Formatted ChangeLog Entry.

2020-03-24  Kamlesh Kumar  

* rtl.h: Defined Tuple for bundling rtx, mode and unsignedness
(default as 0), Added Extra argument (unsignedp)
in emit_library_call and emit_library_call_value.
* except.c: Likewise.
* explow.c: Likewise.
* expmed.c: Likewise.
* expr.c: Likewise.
* optabs.c: Likewise.
* asan.c: Likewise.
* builtins.c: Likewise.
* calls.c: Likewise.
* cfgexpand.c: Likewise.
* config/aarch64/aarch64.c: Likewise.
* config/aarch64/aarch64.h: Likewise.
* config/aarch64/atomics.md: Likewise.
* config/alpha/alpha.c: Likewise.
* config/arc/arc.c: Likewise.
* config/arc/elf.h: Likewise.
* config/arc/linux.h: Likewise.
* config/arm/arm.c: Likewise.
* config/bfin/bfin.md: Likewise.
* config/c6x/c6x.c: Likewise.
* config/csky/csky.c: Likewise.
* config/frv/frv.c: Likewise.
* config/i386/i386-expand.c: Likewise.
* config/i386/i386.c: Likewise.
* config/ia64/ia64.c: Likewise.
* config/ia64/ia64.md: Likewise.
* config/m32r/m32r.c: Likewise.
* config/m68k/linux.h: Likewise.
* config/m68k/m68k.c: Likewise.
* config/microblaze/microblaze.c: Likewise.
* config/mips/mips.h: Likewise.
* config/mips/sdemtk.h: Likewise.
* config/nds32/nds32.h: Likewise.
* config/nios2/nios2.c: Likewise.
* config/or1k/or1k.c: Likewise.
* config/pa/pa.c: Likewise.
* config/pa/pa.md: Likewise.
* config/pru/pru.c: Likewise.
* config/riscv/riscv.h: Likewise.
* config/riscv/riscv.md: Likewise.
* config/rl78/rl78.c: Likewise.
* config/rs6000/rs6000-string.c: Likewise.
* config/rs6000/rs6000.c: Likewise.
* config/rs6000/rs6000.md: Likewise.
* config/rs6000/vsx.md: Likewise.
* config/sh/sh.c: Likewise.
* config/sparc/sparc.c: Likewise.
* config/tilegx/tilegx.c: Likewise.
* config/tilepro/tilepro.c: Likewise.
* config/visium/visium.c: Likewise.
* config/xtensa/xtensa.c: Likewise.
* testsuite/gcc.target/powerpc/pr88877.c: Newtest

./kamlesh


On Tue, Mar 24, 2020 at 10:54 PM Hans-Peter Nilsson  wrote:
>
>
> On Tue, 24 Mar 2020, Hans-Peter Nilsson wrote:
> > The new argument is default 0, so make use of that: do not patch
> > all those files where 0 is fine.
>
> Oops, I was tricked by the comment; it's not actually "default 0"
> in the C++ sense.  And you have an overloaded function with
> different numbers of parameters; I don't know if you can get
> away cheaper than all those files you patched.  Sorry for the
> noise in that part; the ChangeLog formatting comment still
> applies.
>
> brgds, H-P


[PATCH][PPC64] [PR88877]

2020-03-23 Thread kamlesh kumar via Gcc-patches
Attached patch fixes.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88877.
ChangeLog Entry.

2020-03-23  Kamlesh Kumar  

* rtl.h : Defined Tuple for bundling rtx, mode and
unsignedness default as 0
Added Extra argument (unsignedp) in emit_library_call and
emit_library_call_value.
* except.c : Likewise.
* explow.c : Likewise.
* expmed.c : Likewise.
* expr.c : Likewise.
* optabs.c : Likewise.
* asan.c : Likewise.
* builtins.c : Likewise.
* calls.c : Likewise.
* cfgexpand.c : Likewise.
* config/aarch64/aarch64.c : Likewise.
* config/aarch64/aarch64.h : Likewise.
* config/aarch64/atomics.md : Likewise.
* config/alpha/alpha.c : Likewise.
* config/arc/arc.c : Likewise.
* config/arc/elf.h : Likewise.
* config/arc/linux.h : Likewise.
* config/arm/arm.c : Likewise.
* config/bfin/bfin.md : Likewise.
* config/c6x/c6x.c : Likewise.
* config/csky/csky.c : Likewise.
* config/frv/frv.c : Likewise.
* config/i386/i386-expand.c : Likewise.
* config/i386/i386.c : Likewise.
* config/ia64/ia64.c : Likewise.
* config/ia64/ia64.md : Likewise.
* config/m32r/m32r.c : Likewise.
* config/m68k/linux.h : Likewise.
* config/m68k/m68k.c : Likewise.
* config/microblaze/microblaze.c : Likewise.
* config/mips/mips.h : Likewise.
* config/mips/sdemtk.h : Likewise.
* config/nds32/nds32.h : Likewise.
* config/nios2/nios2.c : Likewise.
* config/or1k/or1k.c : Likewise.
* config/pa/pa.c : Likewise.
* config/pa/pa.md : Likewise.
* config/pru/pru.c : Likewise.
* config/riscv/riscv.h : Likewise.
* config/riscv/riscv.md : Likewise.
* config/rl78/rl78.c : Likewise.
* config/rs6000/rs6000-string.c : Likewise.
* config/rs6000/rs6000.c : Likewise.
* config/rs6000/rs6000.md : Likewise.
* config/rs6000/vsx.md : Likewise.
* config/sh/sh.c : Likewise.
* config/sparc/sparc.c : Likewise.
* config/tilegx/tilegx.c : Likewise.
* config/tilepro/tilepro.c : Likewise.
* config/visium/visium.c : Likewise.
* config/xtensa/xtensa.c : Likewise.
* testsuite/gcc.target/powerpc/pr88877.c : Newtest
diff --git a/gcc/asan.c b/gcc/asan.c
index cc8f9122e3d..ec4d6bdc161 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -1488,7 +1488,7 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb,
   ret = emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode,
  GEN_INT (asan_frame_size
 	  + base_align_bias),
- TYPE_MODE (pointer_sized_int_node));
+ TYPE_MODE (pointer_sized_int_node), 0);
   /* __asan_stack_malloc_[n] returns a pointer to fake stack if succeeded
 	 and NULL otherwise.  Check RET value is NULL here and jump over the
 	 BASE reassignment in this case.  Otherwise, reassign BASE to RET.  */
@@ -1615,7 +1615,7 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb,
 	  emit_library_call (ret, LCT_NORMAL, ptr_mode, addr, ptr_mode,
 			 GEN_INT (asan_frame_size + base_align_bias),
 			 TYPE_MODE (pointer_sized_int_node),
-			 orig_addr, ptr_mode);
+			 orig_addr, ptr_mode, 0);
 	}
   lab = gen_label_rtx ();
   emit_jump (lab);
@@ -1715,7 +1715,7 @@ asan_emit_allocas_unpoison (rtx top, rtx bot, rtx_insn *before)
   top = convert_memory_address (ptr_mode, top);
   bot = convert_memory_address (ptr_mode, bot);
   emit_library_call (ret, LCT_NORMAL, ptr_mode,
-		 top, ptr_mode, bot, ptr_mode);
+		 top, ptr_mode, bot, ptr_mode, 0);
 
   do_pending_stack_adjust ();
   rtx_insn *insns = get_insns ();
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 53bae599d3e..99fa50bd515 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -2979,7 +2979,7 @@ expand_builtin_powi (tree exp, rtx target)
 
   target = emit_library_call_value (optab_libfunc (powi_optab, mode),
 target, LCT_CONST, mode,
-op0, mode, op1, mode2);
+op0, mode, op1, mode2, 0);
 
   return target;
 }
@@ -5858,7 +5858,7 @@ expand_asan_emit_allocas_unpoison (tree exp)
 			 OPTAB_LIB_WIDEN);
   rtx ret = init_one_libfunc ("__asan_allocas_unpoison");
   ret = emit_library_call_value (ret, NULL_RTX, LCT_NORMAL, ptr_mode,
- top, ptr_mode, bot, ptr_mode);
+ top, ptr_mode, bot, ptr_mode, 0);
   return ret;
 }
 
diff --git a/gcc/calls.c b/gcc/calls.c
index 4c3a8f3c215..20324ff6f04 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -5247,7 +5247,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
 {
   rtx val = args[i].first;
   function_arg_info arg (args[i].second, /*named=*/true);
-  int unsigned_p = 0;
+  int unsigned_p = GET_THIRD(args[i]);
 
   /* We cannot convert the arg value to the mode the library wants here;
 	 must do it earlier