From patchwork Fri Sep 27 17:35:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 1168676 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-509720-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=golang.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="cPWV3ky4"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=golang-org.20150623.gappssmtp.com header.i=@golang-org.20150623.gappssmtp.com header.b="qk3iQjxJ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46fzTX4pkRz9sP3 for ; Sat, 28 Sep 2019 03:35:28 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=ZEqYyvalKzAUJ7pya+rUY25Qg8Rq4bDXxevCjw1NVOBlQu XO0dabmd3MjVmqbuRNbSwi+cR3Si4Pazq1tU6yfbD+WDmGvwN+d6/lYDA6MvQor/ Z9z9VJtJdGoU4cqGh3/dbrRZ55tcB6bsWUqgNi9ETJGlPxNr4mVE+mqvQ+69M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=VIK+mU8lAmamA+RnBQfHRgR853k=; b=cPWV3ky4kUdb/ZmT+OrW WJ8wIqnNrDgIR5iLwRiHYkvUXYM+drEKO+T0mXwXJrC2v+ILYVxg0G2DBZXYhDfG xYWKXjrPdXGOrX0Uej7zmkSyEcdqIeqJjm3o9w8BK137U/4z3xNK5bL6bJwAVZTL 7wKhns9gbY8jGiO5CwyGqp8= Received: (qmail 61667 invoked by alias); 27 Sep 2019 17:35:21 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 61455 invoked by uid 89); 27 Sep 2019 17:35:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=pt, HX-Received:5109, Bootstrapped, HX-Languages-Length:2045 X-HELO: mail-ed1-f51.google.com Received: from mail-ed1-f51.google.com (HELO mail-ed1-f51.google.com) (209.85.208.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 27 Sep 2019 17:35:20 +0000 Received: by mail-ed1-f51.google.com with SMTP id t3so3017387edw.13 for ; Fri, 27 Sep 2019 10:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golang-org.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=pmCFbKhtaixycsetGceylrl773UHazGfsKlDJ8rm/x0=; b=qk3iQjxJ01XnaWWEB7kpMaIZUsypbj00IgKoMKtS/hA0ogO8vOxvtVE98kVMEF5sMy KvLO7vDi2cRH8e36A8KkCeQ61cWhfmUAi8p0iK53PyItfnyGwOa6bn5nJQj1rd8KoiMa 3wNF3gZ77NAeUw+4n1v/uAd4priYtmnKscR0MHrJ4USVuaeQAAajawI1uNwXXES3HSJ7 IdUdQQsQ4WQySKHSeK2vCp6Iog/aIPZyd5c37kAN++A8EW5gx/51eQqlqRHbdMBIlDI2 A1Dv/tsWFFuifxqVI2uu8LlXwhkdFLg+imlLun6X4bj3+eX3wplehEvZfxIKNwUDqGwM PTlQ== MIME-Version: 1.0 From: Ian Lance Taylor Date: Fri, 27 Sep 2019 10:35:06 -0700 Message-ID: Subject: Go patch committed: Only check whether struct/array types are big To: gcc-patches , gofrontend-dev This patch changes the Go frontend escape analysis test for a big type to only fetch the size if it might matter. Fetching the size of a type typically involves a hash table lookup, and is generally non-trivial. The escape analysis code calls is_big more than one might expect. So only fetch the size if we need it. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 276186) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -d1fa6c34e56eade6fb5b6291f0a727b1a12bf6f1 +27d1f3031197428b5745d09c167f982d638b8776 The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: gcc/go/gofrontend/escape.cc =================================================================== --- gcc/go/gofrontend/escape.cc (revision 275698) +++ gcc/go/gofrontend/escape.cc (working copy) @@ -511,16 +511,28 @@ Node::is_big(Escape_context* context) co || t->is_abstract()) return false; - int64_t size; - bool ok = t->backend_type_size(context->gogo(), &size); - bool big = ok && (size < 0 || size > 10 * 1024 * 1024); + bool big = false; + if (t->struct_type() != NULL + || (t->array_type() != NULL && !t->is_slice_type())) + { + int64_t size; + bool ok = t->backend_type_size(context->gogo(), &size); + big = ok && (size < 0 || size > 10 * 1024 * 1024); + } if (this->expr() != NULL) { if (this->expr()->allocation_expression() != NULL) { - ok = t->deref()->backend_type_size(context->gogo(), &size); - big = big || size <= 0 || size >= (1 << 16); + Type* pt = t->deref(); + if (pt->struct_type() != NULL + || (pt->array_type() != NULL && !pt->is_slice_type())) + { + int64_t size; + bool ok = pt->backend_type_size(context->gogo(), &size); + if (ok) + big = big || size <= 0 || size >= (1 << 16); + } } else if (this->expr()->call_expression() != NULL) {