From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 6A62C385AC3A for ; Mon, 16 Oct 2023 19:58:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6A62C385AC3A Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=google.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6A62C385AC3A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697486316; cv=none; b=PY6z7B9X3UC3uKJfXmKXS12cOz8dRprzmnyjGcG7TRby36fF5r+DjevbyNvGhpzRc3Lj3P/oSRHGhQFXfvax8GljDlCQku7nPAiL36vz3rC9+X8hnGAlzCJM8YIehTWnj81Dbs7q/4J/NabKI/YyScoQiLKVq8GE7ETA65J97CI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697486316; c=relaxed/simple; bh=oXL3miI/XODF19NcWUtiVabv+YY9Zy6EHeln903AsZ4=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=RhhzlKcHyKuOI+kpWcFbcsuZw3i0GhsnsewR8gnl++6hGVcEChMhm3TXEJfSFPJmMf4caJACPVaor3al+lWGR82U42S3a30YOBqFrHjWgwxZELdzXlaaipxtD83UzkAgJTQzlPQ2I2ORXTYhP3jb0mxRfvxDns4pS4xbW8JlMzc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-405459d9a96so3135e9.0 for ; Mon, 16 Oct 2023 12:58:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697486312; x=1698091112; 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=YZ5GE8UasfMoTeuwpt3zheEvpet+H391VQcIXl2QJ+g=; b=noxorfcG+ZeyOWXRIYR0NmTCihAmX7LSzsQFp9wDGVEQQM52HQdICJC8Fp/IKaFLjY 4Oeuo58BasU6amOGHT8pH7ARI7gsuvQWy+sbUqLyYrjmA7dtfKk2zbbQ7IHTIj6l6OXA jZdGVDV7nrEiT8KFBgeGoAC2OZlnLvgntOF8Me4Sovv76Gmo4RlbVR7z85hr7LXC6cV6 4fk2ODF4T3oB7zvwauuB0FcjhD2irazD14VZMsoXw5YPcAe1YjDgRKcAO2f5JSEy90i3 kHhSBVibB7wph7Kq0jxyMUUXksEv9uJaGQG/Ph0QU2UX1ZJEkXHgXgaBaZsKnI1SqXJe /zjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697486312; x=1698091112; 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=YZ5GE8UasfMoTeuwpt3zheEvpet+H391VQcIXl2QJ+g=; b=P1bCfnXvNte4TYRTrmAVDOiGlf5QMg/909E0O6LP+K8Sd2uZjzWB1iqZ7H7X17Nph3 +PHqUZndnWSZoFI3MLG2/HVnN/V9uU++EeQ5PlvajJUWDQTP23GI0ukyKEgYu6orz1AL MH5r7a8Mn1sON6mBkn2zuqx6ayIZX1xgjZ3Zd7KfTiPgFWHmy2u0MKhVJJNAXA2fAZEP kg94sJKdUasxY00oJ1yxHuHqBBL1S7um6q8JNyFnp2tG+gN8GtjeamyxAyAux3mPisgN kjfUPVBEFnF38pI0T2joVki6sgZKbS9pGORRuaklPFncHxXEv0lPVv7Xyd/n+ALifsPN OP6g== X-Gm-Message-State: AOJu0Yy2TUabj4yKxG6clV/vc7ck7FfMCRNi6rj07dgCIboj7BaJ+Ifu XQJXv1poCo2e3A1+UH4gHi4zn+HaoX5C2L1/h9lj3Q== X-Google-Smtp-Source: AGHT+IHUXujYKrHIrQZOMCgu0T8LMKRNhLccReHk4JUT59JfPaCTnPxQm6PWGV7NDhD59nxZw3SHNguIqqAfxIAPaYo= X-Received: by 2002:a05:600c:4884:b0:400:c6de:6a20 with SMTP id j4-20020a05600c488400b00400c6de6a20mr25855wmp.3.1697486311891; Mon, 16 Oct 2023 12:58:31 -0700 (PDT) MIME-Version: 1.0 References: <20230801195104.2183011-1-maskray@google.com> <20231016182447.bticawp4aps7tsso@google.com> In-Reply-To: From: Fangrui Song Date: Mon, 16 Oct 2023 12:58:17 -0700 Message-ID: Subject: Re: [PATCH v5] i386: Allow -mlarge-data-threshold with -mcmodel=large To: Uros Bizjak 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=-23.8 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 12:10=E2=80=AFPM Uros Bizjak wr= ote: > > 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 sections > > >> (.lrodata, .ldata, .lbss and some variants). GNU ld and ld.lld 17 p= lace > > >> .l* sections into separate output sections. If small and medium cod= e > > >> model object files are mixed, the .l* sections won't exert relocatio= n > > >> overflow pressure on sections in object files built with -mcmodel=3D= small. > > >> > > >> 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 = files. > > >> > > >> This patch allows -mcmodel=3Dlarge to generate .l* sections and drop= s 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-Apri= l/616947.html): > > >> * Clarify commit message. Add link to https://groups.google.com/g/x8= 6-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 de= cl, > > >> const char *name, unsigned HOST_WIDE_INT siz= e, > > >> unsigned align) > > >> { > > >> - if ((ix86_cmodel =3D=3D CM_MEDIUM || ix86_cmodel =3D=3D CM_MEDIUM= _PIC) > > >> - && size > (unsigned int)ix86_section_threshold) > > >> + if ((ix86_cmodel =3D=3D CM_MEDIUM || ix86_cmodel =3D=3D CM_MEDIUM= _PIC || > > >> + ix86_cmodel =3D=3D CM_LARGE || ix86_cmodel =3D=3D CM_LARGE_PI= C) && > > >> + 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= _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_MEDIUM= _PIC || > > >> + ix86_cmodel =3D=3D CM_LARGE || ix86_cmodel =3D=3D CM_LARGE_P= IC) && > > >> + 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/= 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. --=20 =E5=AE=8B=E6=96=B9=E7=9D=BF