public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/redhat/heads/gcc-8-branch)] x86_64: Fix up -fpic -mcmodel=large -fno-plt [PR98063] Date: Fri, 23 Apr 2021 10:51:52 +0000 (GMT) [thread overview] Message-ID: <20210423105152.03679394343E@sourceware.org> (raw) https://gcc.gnu.org/g:07de0596cc0ffb88bcc9e8e1ac14e16286db2478 commit 07de0596cc0ffb88bcc9e8e1ac14e16286db2478 Author: Jakub Jelinek <jakub@redhat.com> Date: Tue Dec 1 10:44:40 2020 +0100 x86_64: Fix up -fpic -mcmodel=large -fno-plt [PR98063] On the following testcase with -fpic -mcmodel=large -fno-plt we emit call puts@GOTPCREL(%rip) but that is not really appropriate for CM_LARGE_PIC, the .text can be larger than 2GB in that case and the .got slot further away from %rip than what can fit into the signed 32-bit immediate. The following patch computes the address of the .got slot the way it is computed for that model for function pointer loads, and calls that. 2020-12-01 Jakub Jelinek <jakub@redhat.com> PR target/98063 * config/i386/i386.c (ix86_expand_call): Handle non-plt CM_LARGE_PIC calls. * gcc.target/i386/pr98063.c: New test. (cherry picked from commit ebc8606a9408623e2fa2a02a5526b882ffd0e7a8) Diff: --- gcc/config/i386/i386.c | 12 +++++++++++- gcc/testsuite/gcc.target/i386/pr98063.c | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index d97d5c0f0fe..31502774ef3 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -28517,7 +28517,17 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1, } else if (!TARGET_PECOFF && !TARGET_MACHO) { - if (TARGET_64BIT) + if (TARGET_64BIT + && ix86_cmodel == CM_LARGE_PIC + && DEFAULT_ABI != MS_ABI) + { + fnaddr = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), + UNSPEC_GOT); + fnaddr = gen_rtx_CONST (Pmode, fnaddr); + fnaddr = force_reg (Pmode, fnaddr); + fnaddr = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, fnaddr); + } + else if (TARGET_64BIT) { fnaddr = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), diff --git a/gcc/testsuite/gcc.target/i386/pr98063.c b/gcc/testsuite/gcc.target/i386/pr98063.c new file mode 100644 index 00000000000..f76435a7194 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr98063.c @@ -0,0 +1,13 @@ +/* PR target/98063 */ +/* { dg-do run { target { i?86-*-linux* x86_64-*-linux* } } } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-require-effective-target fpic } */ +/* { dg-options "-O2 -fpic -mcmodel=large -fno-plt -save-temps" } */ +/* { dg-final { scan-assembler-not "puts@GOTPCREL" } } */ + +int +main () +{ + __builtin_puts ("Hello, world!"); + return 0; +}
reply other threads:[~2021-04-23 10:51 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210423105152.03679394343E@sourceware.org \ --to=jakub@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).