From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by sourceware.org (Postfix) with ESMTPS id 5FD873858C54 for ; Mon, 16 Oct 2023 19:10:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5FD873858C54 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5FD873858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::132 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697483440; cv=none; b=DfB86yKt7oSNmfC5df6RyUNcddqvJdaSrFLZtXZ4t9ctglVDai8pk/sK04tB5NdOaEflckJwAiv946VAZh5W55wubCxhB1PqRUMP4DlAish1yTNCK7MlzTbCwxzkFWuU34q+564CII0Fmh/zlYyncr6wTXv/hXPHeGfsRDDOGYU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697483440; c=relaxed/simple; bh=ArIaYK3Nnnk6N4auhHIlday3s98NkmyWW4Rsu7E3Klo=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=GycReBQITRR5MT96Qwq99akRayr7/tKd2/QEnEgH2a7OwXTt3gfvKJsNFXlUZafcYY5NaYf91d6dKOljhWjxtsxQGxJ539WJwCq4j1DGepwmaceCpNth3kwO//p6TpETxtiv3zVdYXWIVJFB5XIiMhcofSVavJ/gmzGc1IqFeUg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-507a29c7eefso2850603e87.1 for ; Mon, 16 Oct 2023 12:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697483436; x=1698088236; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=BXvTKmZ/QqareX9ZoyXIUiuOJpvrKNfdFDANStbJZ+Y=; b=YVqp9fVcxtac8aFRQJYLNJpDTcN4imad7Qg/j7XZU5Lmc495J810j6+vIDpcpmZl2Z 0rqT67z/b2UX1XBmEECu3DZW7MmT0unvnXlo+hfTKU1sXENZgAIaU58OluZV7w/WWoMw RiNiX2ZHBERzqA/Z6T96q8f+B1V+QI10h0RNRxJqrjK7kCNMwFieBWcA755up2qlsq3b tvJMFd0teh8N501dZA8TRfMe5vrND4iu3iV+uoCSsE7AOEc0J5c2bVC1vkGSdaIC5Zcx AskmjMJm7P9HpeX0ioe7mU4dpPNiqiXDqrzHsmMsE1OconAPrV+c7w6fW6P7s/xOxVsh N3mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697483436; x=1698088236; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BXvTKmZ/QqareX9ZoyXIUiuOJpvrKNfdFDANStbJZ+Y=; b=ZrdMA7dIJXPbyjjskA6gC3Wu2aKgbbEN0IPghpMNu1vDTCjmD0BQsO14ROoKwvy+yT zvOo5lvXEkxrxndfnj0z+AVU2VEYj01paB+40luBWn9/KjEsoSBxCmwyu1/LU3XHbS8/ mI7iIfLKMh/opuwmwoVMf6NA1uffy18SfZqIblotZcnB37G7awEeM/bwxJ656B+vvADT FIqnZXNddLNKe23DHU2ScG7I5zDcHZ7kPX60HlUKQ/BYKnnifjz/eEBblHZdj7SzpthH 1nFMzUtBJH0vHoRvJyIQe9Tb1ENdJVXnnv5dO/U5PqUDCZ2u4UZcY4DGcg3yK56DyWIh WV0Q== X-Gm-Message-State: AOJu0YyxVsLiOnsgviblgdPsyuVEVLF1UW8Y1EayRwk2A/zSQTkgldhs L80qIZzijWy+usILPHsv1c1LrkXmTW0c1etvvDU= X-Google-Smtp-Source: AGHT+IGDeaudIsZHMZ0TkxJdFQXztY8PiVQg5KTVtSZ2eISFnp84QmaCDowxCBR9gocaeo0MEdmcIIQAkPv1FcdVcm4= X-Received: by 2002:a19:6904:0:b0:507:9e56:5b1c with SMTP id e4-20020a196904000000b005079e565b1cmr131674lfc.13.1697483435445; Mon, 16 Oct 2023 12:10:35 -0700 (PDT) MIME-Version: 1.0 References: <20230801195104.2183011-1-maskray@google.com> <20231016182447.bticawp4aps7tsso@google.com> In-Reply-To: <20231016182447.bticawp4aps7tsso@google.com> From: Uros Bizjak Date: Mon, 16 Oct 2023 21:10:24 +0200 Message-ID: Subject: Re: [PATCH v5] i386: Allow -mlarge-data-threshold with -mcmodel=large To: Fangrui Song Cc: gcc-patches@gcc.gnu.org, Florian Weimer , "H.J. Lu" , Jan Beulich , Jan Hubicka , Michael Matz Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, Oct 16, 2023 at 8:24=E2=80=AFPM Fangrui Song w= rote: > > On 2023-10-16, Uros Bizjak wrote: > >On Tue, Aug 1, 2023 at 9:51=E2=80=AFPM Fangrui Song = wrote: > >> > >> When using -mcmodel=3Dmedium, large data objects larger than the > >> -mlarge-data-threshold threshold are placed into large data sections > >> (.lrodata, .ldata, .lbss and some variants). GNU ld and ld.lld 17 pla= ce > >> .l* sections into separate output sections. If small and medium code > >> model object files are mixed, the .l* sections won't exert relocation > >> overflow pressure on sections in object files built with -mcmodel=3Dsm= all. > >> > >> However, when using -mcmodel=3Dlarge, -mlarge-data-threshold doesn't > >> apply. This means that the .rodata/.data/.bss sections may exert > >> relocation overflow pressure on sections in -mcmodel=3Dsmall object fi= les. > >> > >> This patch allows -mcmodel=3Dlarge to generate .l* sections and drops = an > >> unneeded documentation restriction that the value must be the same. > >> > >> Link: https://groups.google.com/g/x86-64-abi/c/jnQdJeabxiU > >> ("Large data sections for the large code model") > >> > >> Signed-off-by: Fangrui Song > >> > >> --- > >> Changes from v1 (https://gcc.gnu.org/pipermail/gcc-patches/2023-April/= 616947.html): > >> * Clarify commit message. Add link to https://groups.google.com/g/x86-= 64-abi/c/jnQdJeabxiU > >> > >> Changes from v2 > >> * Drop an uneeded limitation in the documentation. > >> > >> Changes from v3 > >> * Change scan-assembler directives to use \. to match literal . > >> --- > >> gcc/config/i386/i386.cc | 15 +++++++++------ > >> gcc/config/i386/i386.opt | 2 +- > >> gcc/doc/invoke.texi | 6 +++--- > >> gcc/testsuite/gcc.target/i386/large-data.c | 13 +++++++++++++ > >> 4 files changed, 26 insertions(+), 10 deletions(-) > >> create mode 100644 gcc/testsuite/gcc.target/i386/large-data.c > >> > >> diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc > >> index eabc70011ea..37e810cc741 100644 > >> --- a/gcc/config/i386/i386.cc > >> +++ b/gcc/config/i386/i386.cc > >> @@ -647,7 +647,8 @@ ix86_can_inline_p (tree caller, tree callee) > >> static bool > >> ix86_in_large_data_p (tree exp) > >> { > >> - if (ix86_cmodel !=3D CM_MEDIUM && ix86_cmodel !=3D CM_MEDIUM_PIC) > >> + if (ix86_cmodel !=3D CM_MEDIUM && ix86_cmodel !=3D CM_MEDIUM_PIC && > >> + ix86_cmodel !=3D CM_LARGE && ix86_cmodel !=3D CM_LARGE_PIC) > > > >Please split multi-line expression before the operator, not after it, > >as instructed in GNU Coding Standards [1] ... > > > >[1] https://www.gnu.org/prep/standards/html_node/Formatting.html > > > >> return false; > >> > >> if (exp =3D=3D NULL_TREE) > >> @@ -858,8 +859,9 @@ x86_elf_aligned_decl_common (FILE *file, tree decl= , > >> const char *name, unsigned HOST_WIDE_INT size, > >> unsigned align) > >> { > >> - if ((ix86_cmodel =3D=3D CM_MEDIUM || ix86_cmodel =3D=3D CM_MEDIUM_P= IC) > >> - && size > (unsigned int)ix86_section_threshold) > >> + if ((ix86_cmodel =3D=3D CM_MEDIUM || ix86_cmodel =3D=3D CM_MEDIUM_P= IC || > >> + ix86_cmodel =3D=3D CM_LARGE || ix86_cmodel =3D=3D CM_LARGE_PIC)= && > >> + size > (unsigned int)ix86_section_threshold) > > > >... also here ... > > > >> { > >> switch_to_section (get_named_section (decl, ".lbss", 0)); > >> fputs (LARGECOMM_SECTION_ASM_OP, file); > >> @@ -879,9 +881,10 @@ void > >> x86_output_aligned_bss (FILE *file, tree decl, const char *name, > >> unsigned HOST_WIDE_INT size, unsigned align) > >> { > >> - if ((ix86_cmodel =3D=3D CM_MEDIUM || ix86_cmodel =3D=3D CM_MEDIUM_P= IC) > >> - && size > (unsigned int)ix86_section_threshold) > >> - switch_to_section (get_named_section (decl, ".lbss", 0)); > >> + if ((ix86_cmodel =3D=3D CM_MEDIUM || ix86_cmodel =3D=3D CM_MEDIUM_P= IC || > >> + ix86_cmodel =3D=3D CM_LARGE || ix86_cmodel =3D=3D CM_LARGE_PIC= ) && > >> + size > (unsigned int)ix86_section_threshold) > > > >... and here. > > > >OK with these formatting changes. > > > >Thanks, > >Uros. > > Thank you for the review! > Posted PATCH v5 https://gcc.gnu.org/pipermail/gcc-patches/2023-October/63= 3153.html > with the formatting. > > I don't have write access to the gcc repository:) Please provide the ChangeLog entry (see [1,2]) and I'll commit the patch for you. [1] https://gcc.gnu.org/contribute.html [2] https://gcc.gnu.org/codingconventions.html#ChangeLogs Thanks, Uros.