From patchwork Fri Apr 1 13:48:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 64860 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp747386lbc; Fri, 1 Apr 2016 06:49:03 -0700 (PDT) X-Received: by 10.66.132.73 with SMTP id os9mr31011882pab.27.1459518543609; Fri, 01 Apr 2016 06:49:03 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g78si21516919pfd.130.2016.04.01.06.49.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Apr 2016 06:49:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-424191-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-424191-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-424191-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org 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:date:message-id:subject:from:to:content-type; q= dns; s=default; b=hd6ikkQkl6agc0DGK/DoWdAPmuQT+3nCQPMx+9diWl89mf BIVYvk3MyZQyw2SvxPB6v50I30azr/oQRfXHJNOmdRo4WhHQZ0gUqr1qNolVYcaQ lP6SDXhnuIxOye+XdZX/lQrskp2XCTnFweq6ZaViDvXR4sQ1ZYS860HTEi9R8= 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:date:message-id:subject:from:to:content-type; s= default; bh=ZDomYfScAizw3BCbwNc4Imbtua8=; b=NyGMBjBUV7/dNxzAgvRz w0ovEvjUfxSyEShrJaEUW6TBMgsuu4Af177AiTh28EiEKiDegNyvnuDij32LZgXO lbl4JTn8st0WBLoArpkgBriJVRP4+sZXNflmITvIG2T/NgDzXMyld5e3Y9XK9Npw RBw8mL25FTJp3JLujKxE//o= Received: (qmail 11627 invoked by alias); 1 Apr 2016 13:48:51 -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 11580 invoked by uid 89); 1 Apr 2016 13:48:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=thumbs, arms, exceeds, H*c:sk:089e015 X-HELO: mail-ig0-f177.google.com Received: from mail-ig0-f177.google.com (HELO mail-ig0-f177.google.com) (209.85.213.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 01 Apr 2016 13:48:37 +0000 Received: by mail-ig0-f177.google.com with SMTP id cl4so12829745igb.0 for ; Fri, 01 Apr 2016 06:48:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=HKUGJjkVIrOnr+cxO6twgPkaN6ej8QS481/hAzZsIZM=; b=dYS4YipVWkXglVHCabDJIGE3a4KkZb+1MZlrQwXmKxPsfcXCXNN34ah8uKv5mJdddM XbTT5Ea8KJKdluWE0vEg7Tc+BDY0nVx/PPSaF/8n0LxDKrJjHS11cfY+E+KdvVlIAsEy ibUDjJW/M5I7h6fQBrE2/pdx/AxTRZQ1wnm05/3w5jhSor3KzrGsB0gTgI8ZxCAw5dYZ hO/FAMOEBuZmoGSf061VyKt561a8Wy831G6qVbNXt3dxr0DYyCwEalK96sNv4p7t2ZpJ ijaSfmilWh5pVhsTEOQNb0yGSuYuACFaav/FOKcm4js+IumOFZ5pE0O+EdSo5b3PGGsz tJIA== X-Gm-Message-State: AD7BkJIP9Id6X0Dg20veyq01PJ76yP9ecD8C5T94/7YL0y4WVDPXLnaiu+Db4s8xBZyG+8KtfOWtfWeReg0zyMYy MIME-Version: 1.0 X-Received: by 10.50.136.136 with SMTP id qa8mr3444635igb.39.1459518515591; Fri, 01 Apr 2016 06:48:35 -0700 (PDT) Received: by 10.36.196.5 with HTTP; Fri, 1 Apr 2016 06:48:35 -0700 (PDT) Date: Fri, 1 Apr 2016 19:18:35 +0530 Message-ID: Subject: [RFC] introduce --param max-lto-partition for having an upper bound on partition size From: Prathamesh Kulkarni To: gcc Patches , Richard Biener , Ramana Radhakrishnan , Jan Hubicka X-IsSubscribed: yes Hi, The attached patch introduces param max-lto-partition which creates an upper bound for partition size. My primary motivation for this patch is to fix building chromium for arm with -flto-partition=one. Chromium fails to build with -flto-partition={none, one} with assembler error: "branch out of range error" because in both these cases LTO creates a single text section of 18 mb which exceeds thumb's limit of 16 mb and arm backend emits a short call if caller and callee are in same section. This is binutils PR18625: https://sourceware.org/bugzilla/show_bug.cgi?id=18625 With patch, chromium builds for -flto-partition=one (by creating more than one but minimal number of partitions to honor 16 mb limit). I haven't tested with -flto-partition=none but I suppose the build will still fail for none, because it won't involve partitioning? I am not sure how to fix for none case. As suggested by Jim in binutils PR18625, the proper fix would be to implement branch relaxation in arm's port of gas, however I suppose only LTO will realistically create such large sections, and implementing branch relaxation appears to be quite complicated and probably too much of an effort for this single use case, so this patch serves as a work-around to the issue. I am looking into fine-tuning the param value for ARM backend to roughly match limit of 16 mb. AFAIU, this would change semantics of --param n_lto_partitions (or -flto-partition=one) from "exactly n_lto_partitions" to "at-least n_lto_partitions". If that's not desirable maybe we could add another param/option ? Cross-tested on arm*-*-*. Would this patch be OK for stage-1 (after getting param value right for ARM target) ? Thanks, Prathamesh diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index c868490..f734d56 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3459,6 +3459,11 @@ arm_option_override (void) /* Init initial mode for testing. */ thumb_flipper = TARGET_THUMB; + + maybe_set_param_value (MAX_PARTITION_SIZE, + 10000, /* FIXME: fine-tune this value to roughly match 16 mb limit. */ + global_options.x_param_values, + global_options_set.x_param_values); } static void diff --git a/gcc/lto/lto-partition.c b/gcc/lto/lto-partition.c index 9eb63c2..bc0c612 100644 --- a/gcc/lto/lto-partition.c +++ b/gcc/lto/lto-partition.c @@ -511,9 +511,20 @@ lto_balanced_map (int n_lto_partitions) varpool_order.qsort (varpool_node_cmp); /* Compute partition size and create the first partition. */ + if (PARAM_VALUE (MIN_PARTITION_SIZE) > PARAM_VALUE (MAX_PARTITION_SIZE)) + fatal_error (input_location, "min partition size cannot be greater than max partition size"); + partition_size = total_size / n_lto_partitions; if (partition_size < PARAM_VALUE (MIN_PARTITION_SIZE)) partition_size = PARAM_VALUE (MIN_PARTITION_SIZE); + else if (partition_size > PARAM_VALUE (MAX_PARTITION_SIZE)) + { + n_lto_partitions = total_size / PARAM_VALUE (MAX_PARTITION_SIZE); + if (total_size % PARAM_VALUE (MAX_PARTITION_SIZE)) + n_lto_partitions++; + partition_size = total_size / n_lto_partitions; + } + npartitions = 1; partition = new_partition (""); if (symtab->dump_file) diff --git a/gcc/params.def b/gcc/params.def index 9362c15..b6055ff 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -1029,6 +1029,11 @@ DEFPARAM (MIN_PARTITION_SIZE, "Minimal size of a partition for LTO (in estimated instructions).", 1000, 0, 0) +DEFPARAM (MAX_PARTITION_SIZE, + "lto-max-partition", + "Maximal size of a partition for LTO (in estimated instructions).", + INT_MAX, 0, INT_MAX) + /* Diagnostic parameters. */ DEFPARAM (CXX_MAX_NAMESPACES_FOR_DIAGNOSTIC_HELP,