From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bat.birch.relay.mailchannels.net (bat.birch.relay.mailchannels.net [23.83.209.13]) by sourceware.org (Postfix) with ESMTPS id 296533858430 for ; Tue, 12 Oct 2021 14:22:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 296533858430 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 4349C682D0E; Tue, 12 Oct 2021 14:22:52 +0000 (UTC) Received: from pdx1-sub0-mail-a99.g.dreamhost.com (100-96-18-141.trex.outbound.svc.cluster.local [100.96.18.141]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id C283F682CE1; Tue, 12 Oct 2021 14:22:51 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a99.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.18.141 (trex/6.4.3); Tue, 12 Oct 2021 14:22:52 +0000 X-MC-Relay: Junk X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Shoe-Tank: 3fc6be1d39bc2102_1634048572036_2066270963 X-MC-Loop-Signature: 1634048572036:3369371176 X-MC-Ingress-Time: 1634048572036 Received: from pdx1-sub0-mail-a99.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a99.g.dreamhost.com (Postfix) with ESMTP id 225338117A; Tue, 12 Oct 2021 07:22:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gotplt.org; h=message-id :date:mime-version:subject:to:cc:references:from:in-reply-to :content-type:content-transfer-encoding; s=gotplt.org; bh=+Vk6Re Oxwz6Z5N+Bcgh3g1kAhio=; b=WXVCc41anLFfw+R3ZpOFAga4eas9AbcvunBr3l KnEK/8tDMnSWNF2QmY4YxkhE5aXYDVv1zAKQA+mRlyoMd6I9CS30aEXC/YPeyGQ1 CE/zMls5LXTi0Y1rABeQY3W1HdNxsQjqURRJD4FAHKOfG4AycTM/onopZgt81uhc t48m4= Received: from [192.168.1.174] (unknown [1.186.121.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a99.g.dreamhost.com (Postfix) with ESMTPSA id 19B627E097; Tue, 12 Oct 2021 07:22:47 -0700 (PDT) Message-ID: <95dad7ea-cd44-af4a-44ee-4391e4d4f457@gotplt.org> Date: Tue, 12 Oct 2021 19:52:42 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH 1/8] __builtin_dynamic_object_size: Recognize builtin name Content-Language: en-US To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: <20211007221432.1029249-1-siddhesh@gotplt.org> <20211007221432.1029249-2-siddhesh@gotplt.org> <20211012134228.GI304296@tucnak> X-DH-BACKEND: pdx1-sub0-mail-a99 From: Siddhesh Poyarekar In-Reply-To: <20211012134228.GI304296@tucnak> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3029.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SBL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Oct 2021 14:22:57 -0000 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