From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id A20E63858D37 for ; Mon, 16 Oct 2023 21:47:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A20E63858D37 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 A20E63858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697492827; cv=none; b=vUgl5AkjLY4ovZPrTmU2QCw+m5nhmedHLq2+AIZzjdWdvH4OOBTpH5MLjdeG60YF8VAvqB6lHu7MIWuVJZuAD80soDAfWlIeT7jt/QnCdWFU/V7OJHVkJoYTzaW4qTQKf21k9zItptZWnnwGN3JFom2WOno/Pf0J2zJE+TCDfaQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697492827; c=relaxed/simple; bh=rTU/YdqyVR/uDd5NSMiCLVRbF4X+8pi5jidrguKLZqA=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Su41GF/Clc5t8lagRivOdzHEa4UReFe6bLeWyyAO5RoCIIoNeSK2netquSy2NjnLNi9SLEVAqjcEXKFPo3Os6tkNB/FzhsQ9jfvbRv4eD8S9mXTCbzbjj24UkzljzvGY7DOhzWW1mTnUwJZZEKHiqX2jb0s8RmEa+y7yigF8j8o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-523100882f2so8410410a12.2 for ; Mon, 16 Oct 2023 14:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697492824; x=1698097624; 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=p3+k3z+tHQzRB4vbsIILerfgWrbBwy1jZVWQYMmFsSw=; b=kyc9SG630hDkhuJf8c31ZIPKjTtpAAyRLRvoCXkDbwhizjbSfj7bOnzZ+TNtFl4zD2 8nmr29Rnwf67I/BH+Yg5uwVcd2lupTqLpDbhg6NjBNoOXL/3RW5tKj3O7NnTadXMN5QK kB3VLTCr0Kn7U58Sz2u4NeEwtFMyDDUhxUmdwKXtbYtrplo/08aOC6I+X+f6vwmjPA/Y E51xq6JyG9iY1lsjpaOqzOdBXpaBMo6JesUb7cTLQVI6XyFhZlW+b1j8rl+BP/CKJyYX Ulje5TBfCNDLWwE8MdwDUW9RGpH0bZbT3Wz8UaURUWE7aH4HRwyA4mr8j5sh0PaGLiti KE5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697492824; x=1698097624; 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=p3+k3z+tHQzRB4vbsIILerfgWrbBwy1jZVWQYMmFsSw=; b=M874+vLVEbbTfh3tInezZrLUh3BpEqRJ5Y70BFr+n7IvSqXKLtjQJD1SRcXzbJwUOI eqTI8vKpqcUi8CzrTzHv4052jYGEseViaH6XlBz8BHNzs/JXI28K9aLnbBJO00n8mhLj g4ywAnbtjBIzejv099Hh1vxKTyhEYfcP0ZaILX+2cRjnwQBw+7agi/T0qIL3gza1noKl mwqH24Yxf+cTwD1G6yxrMZEmDmGXm6rL3k9Ojtvd71LBM4NeHwWLNULKLMsO5tJa92MC hUWfZaP+HRUCLHS4eYjw7GC9R2KOojL5aofz1KXjuJtSSJpyYQJCSHDrz4t/Tuu7eb0T fjgw== X-Gm-Message-State: AOJu0YzYimJW7QL4DJMfA/V8SjjrrlVBGuPIgb1zltLO3GS2qjIQSFTX sgoNNJ+ZTd3LkO3FPhUBBwB5IXC0U7jf2C99sIk= X-Google-Smtp-Source: AGHT+IEpFxF4Yk83NFug4OqTAOEayhIDwYQCGrgTOAMwUwLPNsp4lX1CgFsjOOsyJmalTtJny15+BNSXw+2x4xC60RA= X-Received: by 2002:a05:6402:348c:b0:53e:15be:9405 with SMTP id v12-20020a056402348c00b0053e15be9405mr389543edc.34.1697492824219; Mon, 16 Oct 2023 14:47:04 -0700 (PDT) MIME-Version: 1.0 References: <20230801195104.2183011-1-maskray@google.com> <20231016182447.bticawp4aps7tsso@google.com> In-Reply-To: From: Uros Bizjak Date: Mon, 16 Oct 2023 23:46:52 +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=-8.5 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 9:58=E2=80=AFPM Fangrui Song w= rote: > > On Mon, Oct 16, 2023 at 12:10=E2=80=AFPM Uros Bizjak = wrote: > > > > On Mon, Oct 16, 2023 at 8:24=E2=80=AFPM Fangrui Song wrote: > > > > > > 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 sectio= ns > > > >> (.lrodata, .ldata, .lbss and some variants). GNU ld and ld.lld 17= place > > > >> .l* sections into separate output sections. If small and medium c= ode > > > >> model object files are mixed, the .l* sections won't exert relocat= ion > > > >> overflow pressure on sections in object files built with -mcmodel= =3Dsmall. > > > >> > > > >> 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 objec= t files. > > > >> > > > >> This patch allows -mcmodel=3Dlarge to generate .l* sections and dr= ops 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-Ap= ril/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_PI= C) > > > >> + if (ix86_cmodel !=3D CM_MEDIUM && ix86_cmodel !=3D CM_MEDIUM_PI= C && > > > >> + 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 s= ize, > > > >> unsigned align) > > > >> { > > > >> - if ((ix86_cmodel =3D=3D CM_MEDIUM || ix86_cmodel =3D=3D CM_MEDI= UM_PIC) > > > >> - && size > (unsigned int)ix86_section_threshold) > > > >> + if ((ix86_cmodel =3D=3D CM_MEDIUM || ix86_cmodel =3D=3D CM_MEDI= UM_PIC || > > > >> + 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 alig= n) > > > >> { > > > >> - if ((ix86_cmodel =3D=3D CM_MEDIUM || ix86_cmodel =3D=3D CM_MEDI= UM_PIC) > > > >> - && 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_MEDI= UM_PIC || > > > >> + 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-Octobe= r/633153.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. > > It's so kind of you! Attached the ChangeLog: > > gcc/ > * config/i386/i386.cc (ix86_can_inline_p): > Handle CM_LARGE and CM_LARGE_PIC. > (x86_elf_aligned_decl_common): Ditto. > (x86_output_aligned_bss): Ditto. > * config/i386/i386.opt: Update doc for -mlarge-data-threshold=3D. > * doc/invoke.texi: Update doc for -mlarge-data-threshold=3D. > > gcc/testsuite/: > * gcc.target/i386/large-data.c: New test. Committed as [1]. [1] https://gcc.gnu.org/git/gitweb.cgi?p=3Dgcc.git;h=3D1a64156c7e25813afa8d= 4d8bbeb0590cad91cf55 Uros.