From patchwork Mon Oct 16 18:24:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fangrui Song X-Patchwork-Id: 153716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3646557vqb; Mon, 16 Oct 2023 11:25:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRlOKMJbS5SUhxTtZEPsgULIaYVn/cjSWjID/gmHYO3WyMvCRLUeoL3J0jOyUAyklruKz8 X-Received: by 2002:ac8:7d91:0:b0:419:82fa:7102 with SMTP id c17-20020ac87d91000000b0041982fa7102mr163214qtd.38.1697480723862; Mon, 16 Oct 2023 11:25:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697480723; cv=pass; d=google.com; s=arc-20160816; b=RlELl+CMoZ42/oj934R878lGvKGWoIhS58pPfhGVQ/nXdF0Xu+j1b5uL2JIs7zKI6k KSZU5oh87hQI1xSRNc69v4RQG6oB3yUPU7fjo7ibIaNK4Xf3ElPzr4FzwfY+51crDcEC Oox+Gzq3BZPmibRKaf8t7Uc9OgqKJIKxtNnsAkdu6NrWngLqt0rHq8l+lg6tdPc85gc2 wTKY++VcPBcrnuFUBKkGkTSq0hTlXY8qX+Ws+EgdKqf8eZVgQpowmQI5aYUVOx84WVy2 aQaU/P89b/fxedFNoUJiaeBSlxGNpWxLlKEVqUhhiWAnc/GV7QUIqBm+EOViscesou2B 0oGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=s4aVMXMDXOsEZzxKkpox7fateDXYm1GaqtAK7xRk+mQ=; fh=wDPLud1y9UatTgKAvzLczUTnzkyHnKdnDRWde9QDYBA=; b=ENNgDmaNtSdNbWlA/MbPQzFeY4ado3WOYcBvI0Hm7ep0JV9HHYzJBzpMkcHjVpOG7W 3lQNynLPN+Af8PIXns6tYn1MKGbzb7JQOpRDWd0TRZK4umY1qN9YHlNfUIWzRtTL9TKR 1+d+CNxDqIeH8nxbuIqTBKWV1cn3zyi/zqDn09QrDK8EL7rdPq63TaDtRd8zQQy8rZ5/ 88u9F8EzkGxOiaLLB6EGHHNA6mSh3Td098PsTTyCipn41D0n3w49Qxk6dG7xskIbx0fZ 1wJ4a1FwWXV2xIdbE5jplk284oUNx0pyF0aTV+/nLQpun126NDJg+83fgv7+g6n021Ve cMzQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=n0wJy+Pn; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d20-20020a05622a101400b0041980065908si5842261qte.506.2023.10.16.11.25.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 11:25:23 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=n0wJy+Pn; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9E6503857C71 for ; Mon, 16 Oct 2023 18:25:23 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by sourceware.org (Postfix) with ESMTPS id A12DD3857713 for ; Mon, 16 Oct 2023 18:24:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A12DD3857713 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 A12DD3857713 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697480696; cv=none; b=Lv3KQsmfP+ZQgEYyuk9qgflEsX6hAx54fkHfKDn2638ZwaurxrLvig2Ki2xEOTKqFD5gH5/WqYmx61UKrPC9rFSihLzcRSo8fbE03r0meRnvunIWxFMLmpD5Lwc8xnbmIf+6PiauF59hxoLneHNtkAAnvRz5lxl8K6KISl5C2kU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697480696; c=relaxed/simple; bh=r+4u2PlGMOS/wgjzQxQ1U5vUvDQuMMCHB/gjXUMwTLg=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=efyGnDU5MNbBnef5W6KJ2IPhfAa82/4Rie2cIjp+JPfeQOtQke1yw2e/9027KPm5SezeaEvZ5lMWNIo4wSiAeqWrnIh/atyrUKBLIYs5ePj8mXAsGRJybZg1J9aOLz/Bfh6praRnRCvJmZKznYNPoxs4VUzynbPYMTWHeA6rAeg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c9c496c114so29695ad.0 for ; Mon, 16 Oct 2023 11:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697480693; x=1698085493; darn=gcc.gnu.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=s4aVMXMDXOsEZzxKkpox7fateDXYm1GaqtAK7xRk+mQ=; b=n0wJy+Pnb6YN3KFx5/k6kxp3rBSv13yKdBHLoWW/OFEFEeSNH8MuMo6rN8s4PlInVn bAT9gH14nCvCd1TO1g3io+Hb2y8obIjrID4pJJ+Cqa1S7Fd5nvnIbOgi1eGKyHISJC8j 37ty6YuXFSIn7nMCSB1Z40OAz3Bf57BtF/nnDoz0lIGTTNeAbZ0rOfO3faRT0fLVB58H ZQwf5hzxM+hdKejbTrbwBZUOLi1jX68yCRoQzW7IFeWlN3E2bgzYkYzj+ZKq+ZXMD7l3 WZi8YF9HbDQNPV8k2M6J/MNzixvujFg5DRy587NXhHASzNK+4jUaAzu+lB0klIxBM7h/ eFtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697480693; x=1698085493; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=s4aVMXMDXOsEZzxKkpox7fateDXYm1GaqtAK7xRk+mQ=; b=E+j8fhagZCHaQDdedFIkPdHDrFy2xwBfBiGkydYs3EYCvsw1dgZHL8rbBeeU3AN0zL IB3uP/1bPkvu8izQ+Ow8BsY3sLyCaTXHNMkHu/3TRlzeVxhzkh21CxQN7oW4PdeA7L6X LREI6zgfpV3xfRE+Kzndh9MiHGJZKEQAVRQ6cDi4sAHmLUAlhGKzrgQ89KvAcBxnxAhl CyGE0vV5uJec/Z2M6hLAg9rDzqFIr5ALCcL1fSdLDVcj90XyyBq5N5yr7WB0sXyHTYUP Qf9pjT4Wq5RyZ3XjDjOJUpMfDpvKjiGaYwogYID2tMwjcQkOl3Km/VvrPt5vsRcEeExT jNWw== X-Gm-Message-State: AOJu0YxzHFYYt6vKq0KU0iW1ytJNWpkqd2ORmKkhZ8j5ep8r7eR9ECg9 a/PnDUCeXY8tFaC90xpeSBJ8JQ== X-Received: by 2002:a17:903:2a8e:b0:1c9:b5cf:6a78 with SMTP id lv14-20020a1709032a8e00b001c9b5cf6a78mr11182plb.27.1697480692275; Mon, 16 Oct 2023 11:24:52 -0700 (PDT) Received: from google.com ([2620:15c:2d3:205:1972:b984:359b:c069]) by smtp.gmail.com with ESMTPSA id x25-20020aa79ad9000000b006b2e07a6235sm209713pfp.136.2023.10.16.11.24.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 11:24:51 -0700 (PDT) Date: Mon, 16 Oct 2023 11:24:47 -0700 From: Fangrui Song To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org, Florian Weimer , "H.J. Lu" , Jan Beulich , Jan Hubicka , Michael Matz Subject: [PATCH v5] i386: Allow -mlarge-data-threshold with -mcmodel=large Message-ID: <20231016182447.bticawp4aps7tsso@google.com> References: <20230801195104.2183011-1-maskray@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-27.4 required=5.0 tests=BAYES_00, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773057624340347394 X-GMAIL-MSGID: 1779937547204119738 On 2023-10-16, Uros Bizjak wrote: >On Tue, Aug 1, 2023 at 9:51 PM Fangrui Song wrote: >> >> When using -mcmodel=medium, 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 place >> .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=small. >> >> However, when using -mcmodel=large, -mlarge-data-threshold doesn't >> apply. This means that the .rodata/.data/.bss sections may exert >> relocation overflow pressure on sections in -mcmodel=small object files. >> >> This patch allows -mcmodel=large 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 != CM_MEDIUM && ix86_cmodel != CM_MEDIUM_PIC) >> + if (ix86_cmodel != CM_MEDIUM && ix86_cmodel != CM_MEDIUM_PIC && >> + ix86_cmodel != CM_LARGE && ix86_cmodel != 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 == 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 == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC) >> - && size > (unsigned int)ix86_section_threshold) >> + if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC || >> + ix86_cmodel == CM_LARGE || ix86_cmodel == 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 == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC) >> - && size > (unsigned int)ix86_section_threshold) >> - switch_to_section (get_named_section (decl, ".lbss", 0)); >> + if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC || >> + ix86_cmodel == CM_LARGE || ix86_cmodel == 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/633153.html with the formatting. I don't have write access to the gcc repository:) (Hmmm... in emacs, C-c . gnu RET C-M-\ doesn't fix the && || formatting errors.) >> + switch_to_section(get_named_section(decl, ".lbss", 0)); >> else >> switch_to_section (bss_section); >> ASM_OUTPUT_ALIGN (file, floor_log2 (align / BITS_PER_UNIT)); >> diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt >> index 1cc8563477a..52fad492353 100644 >> --- a/gcc/config/i386/i386.opt >> +++ b/gcc/config/i386/i386.opt >> @@ -282,7 +282,7 @@ Branches are this expensive (arbitrary units). >> >> mlarge-data-threshold= >> Target RejectNegative Joined UInteger Var(ix86_section_threshold) Init(DEFAULT_LARGE_SECTION_THRESHOLD) >> --mlarge-data-threshold= Data greater than given threshold will go into .ldata section in x86-64 medium model. >> +-mlarge-data-threshold= Data greater than given threshold will go into a large data section in x86-64 medium and large code models. >> >> mcmodel= >> Target RejectNegative Joined Enum(cmodel) Var(ix86_cmodel) Init(CM_32) >> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi >> index 104766f446d..bf6fe3e1a20 100644 >> --- a/gcc/doc/invoke.texi >> +++ b/gcc/doc/invoke.texi >> @@ -33207,9 +33207,9 @@ the cache line size. @samp{compat} is the default. >> >> @opindex mlarge-data-threshold >> @item -mlarge-data-threshold=@var{threshold} >> -When @option{-mcmodel=medium} is specified, data objects larger than >> -@var{threshold} are placed in the large data section. This value must be the >> -same across all objects linked into the binary, and defaults to 65535. >> +When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data >> +objects larger than @var{threshold} are placed in large data sections. The >> +default is 65535. >> >> @opindex mrtd >> @item -mrtd >> diff --git a/gcc/testsuite/gcc.target/i386/large-data.c b/gcc/testsuite/gcc.target/i386/large-data.c >> new file mode 100644 >> index 00000000000..bdd4acd30b8 >> --- /dev/null >> +++ b/gcc/testsuite/gcc.target/i386/large-data.c >> @@ -0,0 +1,13 @@ >> +/* { dg-do compile } */ >> +/* { dg-require-effective-target lp64 } */ >> +/* { dg-options "-O2 -mcmodel=large -mlarge-data-threshold=4" } */ >> +/* { dg-final { scan-assembler {\.lbss} } } */ >> +/* { dg-final { scan-assembler {\.bss} } } */ >> +/* { dg-final { scan-assembler {\.ldata} } } */ >> +/* { dg-final { scan-assembler {\.data} } } */ >> +/* { dg-final { scan-assembler {\.lrodata} } } */ >> +/* { dg-final { scan-assembler {\.rodata} } } */ >> + >> +const char rodata_a[] = "abc", rodata_b[] = "abcd"; >> +char data_a[4] = {1}, data_b[5] = {1}; >> +char bss_a[4], bss_b[5]; >> -- >> 2.41.0.585.gd2178a4bd4-goog >> From da49445a50c57b583201e3fb48fa91781b9ec761 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 27 Apr 2023 12:29:31 -0700 Subject: [PATCH v5] i386: Allow -mlarge-data-threshold with -mcmodel=large When using -mcmodel=medium, 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 place .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=small. However, when using -mcmodel=large, -mlarge-data-threshold doesn't apply. This means that the .rodata/.data/.bss sections may exert relocation overflow pressure on sections in -mcmodel=small object files. This patch allows -mcmodel=large 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 . Changes from v4 (https://gcc.gnu.org/pipermail/gcc-patches/2023-October/633145.html) * "When you split an expression into multiple lines, split it before an operator, not after one." --- gcc/config/i386/i386.cc | 9 ++++++--- gcc/config/i386/i386.opt | 2 +- gcc/doc/invoke.texi | 6 +++--- gcc/testsuite/gcc.target/i386/large-data.c | 13 +++++++++++++ 4 files changed, 23 insertions(+), 7 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 8251b67e2d6..641e7680335 100644 --- a/gcc/config/i386/i386.cc +++ b/gcc/config/i386/i386.cc @@ -663,7 +663,8 @@ ix86_can_inline_p (tree caller, tree callee) static bool ix86_in_large_data_p (tree exp) { - if (ix86_cmodel != CM_MEDIUM && ix86_cmodel != CM_MEDIUM_PIC) + if (ix86_cmodel != CM_MEDIUM && ix86_cmodel != CM_MEDIUM_PIC + && ix86_cmodel != CM_LARGE && ix86_cmodel != CM_LARGE_PIC) return false; if (exp == NULL_TREE) @@ -874,7 +875,8 @@ x86_elf_aligned_decl_common (FILE *file, tree decl, const char *name, unsigned HOST_WIDE_INT size, unsigned align) { - if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC) + if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC + || ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC) && size > (unsigned int)ix86_section_threshold) { switch_to_section (get_named_section (decl, ".lbss", 0)); @@ -895,7 +897,8 @@ void x86_output_aligned_bss (FILE *file, tree decl, const char *name, unsigned HOST_WIDE_INT size, unsigned align) { - if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC) + if ((ix86_cmodel == CM_MEDIUM || ix86_cmodel == CM_MEDIUM_PIC + || ix86_cmodel == CM_LARGE || ix86_cmodel == CM_LARGE_PIC) && size > (unsigned int)ix86_section_threshold) switch_to_section (get_named_section (decl, ".lbss", 0)); else diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index b8382c48099..0c3b8f4b621 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -282,7 +282,7 @@ Branches are this expensive (arbitrary units). mlarge-data-threshold= Target RejectNegative Joined UInteger Var(ix86_section_threshold) Init(DEFAULT_LARGE_SECTION_THRESHOLD) --mlarge-data-threshold= Data greater than given threshold will go into .ldata section in x86-64 medium model. +-mlarge-data-threshold= Data greater than given threshold will go into a large data section in x86-64 medium and large code models. mcmodel= Target RejectNegative Joined Enum(cmodel) Var(ix86_cmodel) Init(CM_32) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index eb714d18511..50745a3a195 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -33390,9 +33390,9 @@ the cache line size. @samp{compat} is the default. @opindex mlarge-data-threshold @item -mlarge-data-threshold=@var{threshold} -When @option{-mcmodel=medium} is specified, data objects larger than -@var{threshold} are placed in the large data section. This value must be the -same across all objects linked into the binary, and defaults to 65535. +When @option{-mcmodel=medium} or @option{-mcmodel=large} is specified, data +objects larger than @var{threshold} are placed in large data sections. The +default is 65535. @opindex mrtd @item -mrtd diff --git a/gcc/testsuite/gcc.target/i386/large-data.c b/gcc/testsuite/gcc.target/i386/large-data.c new file mode 100644 index 00000000000..bdd4acd30b8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/large-data.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -mcmodel=large -mlarge-data-threshold=4" } */ +/* { dg-final { scan-assembler {\.lbss} } } */ +/* { dg-final { scan-assembler {\.bss} } } */ +/* { dg-final { scan-assembler {\.ldata} } } */ +/* { dg-final { scan-assembler {\.data} } } */ +/* { dg-final { scan-assembler {\.lrodata} } } */ +/* { dg-final { scan-assembler {\.rodata} } } */ + +const char rodata_a[] = "abc", rodata_b[] = "abcd"; +char data_a[4] = {1}, data_b[5] = {1}; +char bss_a[4], bss_b[5];