aboutsummaryrefslogtreecommitdiff
path: root/gcc/config/i386/i386.cc
diff options
context:
space:
mode:
authorUros Bizjak <ubizjak@gmail.com>2023-10-16 22:22:28 +0200
committerUros Bizjak <ubizjak@gmail.com>2023-10-16 23:44:23 +0200
commit1a64156c7e25813afa8d4d8bbeb0590cad91cf55 (patch)
tree175ab4690a19f33d8867dbc8aa34146c5cf7dfb7 /gcc/config/i386/i386.cc
parent328745607c5d403a1c7b6bc2ecaa1574ee42122f (diff)
downloadgcc-1a64156c7e25813afa8d4d8bbeb0590cad91cf55.zip
gcc-1a64156c7e25813afa8d4d8bbeb0590cad91cf55.tar.gz
gcc-1a64156c7e25813afa8d4d8bbeb0590cad91cf55.tar.bz2
i386: Allow -mlarge-data-threshold with -mcmodel=large
From: Fangrui Song <maskray@google.com> 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 <maskray@google.com> gcc/ChangeLog: * 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/ChangeLog: * gcc.target/i386/large-data.c: New test.
Diffstat (limited to 'gcc/config/i386/i386.cc')
-rw-r--r--gcc/config/i386/i386.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 8251b67..641e768 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