From: Martin Jambor <mjambor@suse.cz>
To: Richard Biener <rguenther@suse.de>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>,
Richard Sandiford <richard.sandiford@arm.com>
Subject: Re: [PATCH 1/2] vec: Add array_slice constructors from non-const and gc vectors
Date: Fri, 26 Aug 2022 22:05:34 +0200 [thread overview]
Message-ID: <ri6fshi7ott.fsf@suse.cz> (raw)
In-Reply-To: <CA6349D6-10FC-4FDE-8BAC-5C58E6E58B7A@suse.de>
Hi,
On Fri, Aug 26 2022, Richard Biener wrote:
>> Am 26.08.2022 um 18:39 schrieb Martin Jambor <mjambor@suse.cz>:
>>
>> Hi,
>>
>> This patch adds constructors of array_slice that are required to
>> create them from non-const (heap or auto) vectors or from GC vectors.
>>
>> The use of non-const array_slices is somewhat limited, as creating one
>> from const vec<some_type> still leads to array_slice<const some_type>,
>> so I eventually also only resorted to having read-only array_slices.
>> But I do need the constructor from the gc vector.
>>
>> Bootstrapped and tested along code that actually uses it on
>> x86_64-linux. OK for trunk?
>>
>> Thanks,
>>
>> Martin
>>
>>
>> gcc/ChangeLog:
>>
>> 2022-08-08 Martin Jambor <mjambor@suse.cz>
>>
>> * vec.h (array_slice): Add constructors for non-const reference to
>> heap vector and pointers to heap vectors.
>> ---
>> gcc/vec.h | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/gcc/vec.h b/gcc/vec.h
>> index eed075addc9..b0477e1044c 100644
>> --- a/gcc/vec.h
>> +++ b/gcc/vec.h
>> @@ -2264,6 +2264,18 @@ public:
>> array_slice (const vec<OtherT> &v)
>> : m_base (v.address ()), m_size (v.length ()) {}
>>
>> + template<typename OtherT>
>> + array_slice (vec<OtherT> &v)
>> + : m_base (v.address ()), m_size (v.length ()) {}
>> +
>> + template<typename OtherT>
>> + array_slice (const vec<OtherT, va_gc> *v)
>> + : m_base (v ? v->address () : nullptr), m_size (v ? v->length () : 0) {}
>> +
>> + template<typename OtherT>
>> + array_slice (vec<OtherT, va_gc> *v)
>> + : m_base (v ? v->address () : nullptr), m_size (v ? v->length () : 0) {}
>> +
>
> I don’t quite understand why the generic ctor doesn’t cover the GC case. It looks more like reference vs pointer?
>
If you think that this should work:
vec<tree, va_gc> *heh = cfun->local_decls;
array_slice<tree> arr_slice (*heh);
then it does not:
/home/mjambor/gcc/mine/src/gcc/ipa-cp.cc:6693:36: error: no matching function for call to ‘array_slice<tree_node*>::array_slice(vec<tree_node*, va_gc>&)’
6693 | array_slice<tree> arr_slice (*heh);
| ^
In file included from /home/mjambor/gcc/mine/src/gcc/hash-table.h:248,
from /home/mjambor/gcc/mine/src/gcc/coretypes.h:486,
from /home/mjambor/gcc/mine/src/gcc/ipa-cp.cc:105:
/home/mjambor/gcc/mine/src/gcc/vec.h:2264:3: note: candidate: ‘template<class OtherT> array_slice<T>::array_slice(const vec<OtherT>&) [with T = tree_node*]’
2264 | array_slice (const vec<OtherT> &v)
| ^~~~~~~~~~~
/home/mjambor/gcc/mine/src/gcc/vec.h:2264:3: note: template argument deduction/substitution failed:
/home/mjambor/gcc/mine/src/gcc/ipa-cp.cc:6693:36: note: mismatched types ‘va_heap’ and ‘va_gc’
6693 | array_slice<tree> arr_slice (*heh);
| ^
[... I trimmed notes about all other candidates...]
Or did you mean something else?
Thanks,
Martin
next prev parent reply other threads:[~2022-08-26 20:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-26 16:38 Martin Jambor
2022-08-26 18:22 ` Richard Biener
2022-08-26 20:05 ` Martin Jambor [this message]
2022-08-29 8:09 ` Richard Biener
2022-08-29 8:09 ` Richard Biener
2022-08-29 8:31 ` Martin Jambor
2022-08-29 10:27 ` Martin Jambor
2022-08-29 11:26 ` Richard Biener
2022-08-29 11:26 ` Richard Biener
2022-08-29 11:50 ` Martin Jambor
2022-08-29 12:34 ` Richard Biener
2022-08-29 12:34 ` Richard Biener
2022-08-30 8:01 ` Richard Sandiford
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ri6fshi7ott.fsf@suse.cz \
--to=mjambor@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=rguenther@suse.de \
--cc=richard.sandiford@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).