On Mon, Oct 16, 2023 at 9:58 PM Fangrui Song <mask...@google.com> wrote: > > On Mon, Oct 16, 2023 at 12:10 PM Uros Bizjak <ubiz...@gmail.com> wrote: > > > > On Mon, Oct 16, 2023 at 8:24 PM Fangrui Song <mask...@google.com> wrote: > > > > > > On 2023-10-16, Uros Bizjak wrote: > > > >On Tue, Aug 1, 2023 at 9:51 PM Fangrui Song <mask...@google.com> 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 <mask...@google.com> > > > >> > > > >> --- > > > >> 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:) > > > > 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=. > * doc/invoke.texi: Update doc for -mlarge-data-threshold=. > > gcc/testsuite/: > * gcc.target/i386/large-data.c: New test.
Committed as [1]. [1] https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=1a64156c7e25813afa8d4d8bbeb0590cad91cf55 Uros.