public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@gotplt.org>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 1/8] __builtin_dynamic_object_size: Recognize builtin name
Date: Tue, 12 Oct 2021 19:52:42 +0530	[thread overview]
Message-ID: <95dad7ea-cd44-af4a-44ee-4391e4d4f457@gotplt.org> (raw)
In-Reply-To: <20211012134228.GI304296@tucnak>

On 10/12/21 19:12, Jakub Jelinek wrote:
> On Fri, Oct 08, 2021 at 03:44:25AM +0530, Siddhesh Poyarekar wrote:
>> --- a/gcc/builtins.c
>> +++ b/gcc/builtins.c
>> @@ -180,6 +180,7 @@ static rtx expand_builtin_memory_chk (tree, rtx, machine_mode,
>>   static void maybe_emit_chk_warning (tree, enum built_in_function);
>>   static void maybe_emit_sprintf_chk_warning (tree, enum built_in_function);
>>   static tree fold_builtin_object_size (tree, tree);
>> +static tree fold_builtin_dyn_object_size (tree, tree);
>>   
>>   unsigned HOST_WIDE_INT target_newline;
>>   unsigned HOST_WIDE_INT target_percent;
>> @@ -7910,6 +7911,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode,
>>         return const0_rtx;
>>   
>>       case BUILT_IN_OBJECT_SIZE:
>> +    case BUILT_IN_DYN_OBJECT_SIZE:
>>         return expand_builtin_object_size (exp);
> 
> I'd strongly prefer BUILT_IN_DYNAMIC_OBJECT_SIZE, we have even longer
> builtin enums and the abbreviation will only lead to confusion.
> 
>> +/* Fold a call to __builtin_dynamic_object_size with arguments PTR and OST,
>> +   if possible.  */
>> +
>> +static tree
>> +fold_builtin_dyn_object_size (tree ptr, tree ost)
> 
> Also please don't abbreviate.

Got it, will fix.

>> +{
>> +  int object_size_type;
>> +
>> +  if (!valid_object_size_args (ptr, ost, &object_size_type))
>> +    return NULL_TREE;
>> +
>> +  /* __builtin_dynamic_object_size doesn't evaluate side-effects in its
>> +     arguments; if there are any side-effects, it returns (size_t) -1 for types
>> +     0 and 1 and (size_t) 0 for types 2 and 3.  */
>> +  if (TREE_SIDE_EFFECTS (ptr))
>> +    return build_int_cst_type (size_type_node, object_size_type < 2 ? -1 : 0);
> 
> If we want to commit this patch separately, then the more natural stub
> implementation would be fold it into a __builtin_object_size call
> (or call fold_builtin_object_size and only if it returns NULL_TREE fold
> it into the builtin call).  But I assume we do not want to do that and
> want to commit the whole series at once, therefore even this is good enough.

Ideally, it would be great to have the whole series go in at once but if 
we're not able to build consensus soon enough, I'll post this one patch 
for inclusion.

Thanks,
Siddhesh

  reply	other threads:[~2021-10-12 14:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-07 22:14 [PATCH 0/8] __builtin_dynamic_object_size and more Siddhesh Poyarekar
2021-10-07 22:14 ` [PATCH 1/8] __builtin_dynamic_object_size: Recognize builtin name Siddhesh Poyarekar
2021-10-12 13:42   ` Jakub Jelinek
2021-10-12 14:22     ` Siddhesh Poyarekar [this message]
2021-10-07 22:14 ` [PATCH 2/8] tree-dynamic-object-size: New pass Siddhesh Poyarekar
2021-10-08  4:05   ` Siddhesh Poyarekar
2021-10-12 13:58   ` Jakub Jelinek
2021-10-12 14:28     ` Siddhesh Poyarekar
2021-10-07 22:14 ` [PATCH 3/8] tree-dynamic-object-size: Handle GIMPLE_PHI Siddhesh Poyarekar
2021-10-07 22:14 ` [PATCH 4/8] tree-dynamic-object-size: Support ADDR_EXPR Siddhesh Poyarekar
2021-10-07 22:14 ` [PATCH 5/8] tree-dynamic-object-size: Handle GIMPLE_ASSIGN Siddhesh Poyarekar
2021-10-07 22:14 ` [PATCH 6/8] tree-dynamic-object-size: Handle function parameters Siddhesh Poyarekar
2021-10-20 16:56   ` Martin Sebor
2021-10-20 16:59     ` Siddhesh Poyarekar
2021-10-07 22:14 ` [PATCH 7/8] tree-dynamic-object-size: Get subobject sizes Siddhesh Poyarekar
2021-10-07 22:14 ` [PATCH 8/8] tree-dynamic-object-size: Add test wrappers to extend testing Siddhesh Poyarekar
2021-10-08  4:50 ` [PATCH 0/8] __builtin_dynamic_object_size and more Siddhesh Poyarekar
2021-10-17 19:57   ` Jeff Law

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=95dad7ea-cd44-af4a-44ee-4391e4d4f457@gotplt.org \
    --to=siddhesh@gotplt.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.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).