From patchwork Sat Dec 18 12:35:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 49085 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0BF7F385800B for ; Sat, 18 Dec 2021 12:35:40 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from antelope.elm.relay.mailchannels.net (antelope.elm.relay.mailchannels.net [23.83.212.4]) by sourceware.org (Postfix) with ESMTPS id 2BEF33858D28 for ; Sat, 18 Dec 2021 12:35:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2BEF33858D28 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 B1CA68813C9; Sat, 18 Dec 2021 12:35:23 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 42D97881C21; Sat, 18 Dec 2021 12:35:23 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.105.57.85 (trex/6.4.3); Sat, 18 Dec 2021 12:35:23 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Invention-Society: 42753571532c350c_1639830923330_4202473514 X-MC-Loop-Signature: 1639830923330:2194771539 X-MC-Ingress-Time: 1639830923330 Received: from rhbox.redhat.com (unknown [1.6.40.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4JGQL15mfCz18t; Sat, 18 Dec 2021 04:35:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gotplt.org; s=gotplt.org; t=1639830923; bh=dZAp6nppeB3/e+HhHDFc1aSBE9E=; h=From:To:Cc:Subject:Date:Content-Transfer-Encoding; b=uXi7nTteK2CvkowVndmBassZN9UpiYLSEfFID/MJimIzg/q+Dzz7Qvna63AwRf016 Z1NgUVDKGNbnJCCy9uHePmIGz55cVA8oz+Zc6XNV5yqFjUuad6mA0MamOePyvyCNU9 ikKHnODy+8pJdWUcDJwB/GKNZ1aYSytXF9DRXSi0= From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org Subject: [PATCH v5 0/4] __builtin_dynamic_object_size Date: Sat, 18 Dec 2021 18:05:07 +0530 Message-Id: <20211218123511.139456-1-siddhesh@gotplt.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211109190137.1107736-1-siddhesh@gotplt.org> References: <20211109190137.1107736-1-siddhesh@gotplt.org> MIME-Version: 1.0 X-Spam-Status: No, score=-3032.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham 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: , Cc: jakub@redhat.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This patchset enhances the __builtin_dynamic_object_size builtin to produce dynamic expressions for object sizes to improve coverage of _FORTIFY_SOURCE. Testing: -------- This series has been tested with build and test for i686, bootstrap with ubsan and full bootstrap and test with x86_64. I also tested the toolchain with a glibc build and testsuite run for x86_64 and i686 with _FORTIFY_SOURCE=3 enabled for gcc12. Additional testing plans (i.e. I've already started to do some of this): - Build packages to compare values returned by __builtin_object_size with the older pass and this new one. Also compare with __builtin_dynamic_object_size. - Expand the list of packages to get more coverage metrics. - Explore performance impact on applications on building with _FORTIFY_SOURCE=3. Siddhesh Poyarekar (4): tree-object-size: Support dynamic sizes in conditions tree-object-size: Handle function parameters tree-object-size: Handle GIMPLE_CALL tree-object-size: Dynamic sizes for ADDR_EXPR gcc/builtins.c | 6 +- .../gcc.dg/builtin-dynamic-object-size-0.c | 495 +++++++++++++ .../gcc.dg/builtin-dynamic-object-size-10.c | 2 + .../builtin-dynamic-object-size-5-main.c | 32 + .../gcc.dg/builtin-dynamic-object-size-5.c | 7 +- gcc/testsuite/gcc.dg/builtin-object-size-1.c | 154 +++- gcc/testsuite/gcc.dg/builtin-object-size-2.c | 133 ++++ gcc/testsuite/gcc.dg/builtin-object-size-3.c | 151 ++++ gcc/testsuite/gcc.dg/builtin-object-size-4.c | 93 +++ gcc/testsuite/gcc.dg/builtin-object-size-5.c | 22 +- gcc/tree-object-size.c | 670 +++++++++++++++--- 11 files changed, 1677 insertions(+), 88 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c create mode 100644 gcc/testsuite/gcc.dg/builtin-dynamic-object-size-5-main.c