* [i386] Fix couple of issues in large PIC model on x86-64/VxWorks
@ 2021-10-05 15:46 Eric Botcazou
2021-11-08 8:21 ` Uros Bizjak
0 siblings, 1 reply; 4+ messages in thread
From: Eric Botcazou @ 2021-10-05 15:46 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 717 bytes --]
Hi,
the first issue is that the !gotoff_operand path of legitimize_pic_address in
large PIC model does not make use of REG when it is available, which breaks
for thunks because new pseudo-registers can no longer be created. And the
second issue is that the system compiler (LLVM) generates @GOTOFF in large
model even for RTP, so we do the same.
Tested on x86-64/Linux and VxWorks, OK for the mainline?
2021-10-05 Eric Botcazou <ebotcazou@adacore.com>
* config/i386/i386.c (legitimize_pic_address): Adjust comment and
use the REG argument on the CM_LARGE_PIC code path as well.
* config/i386/predicates.md (gotoff_operand): Do not treat VxWorks
specially with the large code models.
--
Eric Botcazou
[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 2266 bytes --]
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a566d84a61e..a6784c4e9d6 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -11152,7 +11152,7 @@ legitimize_pic_address (rtx orig, rtx reg)
new_rtx = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new_rtx);
}
else if ((GET_CODE (addr) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (addr) == 0)
- /* We can't use @GOTOFF for text labels
+ /* We can't always use @GOTOFF for text labels
on VxWorks, see gotoff_operand. */
|| (TARGET_VXWORKS_RTP && GET_CODE (addr) == LABEL_REF))
{
@@ -11181,9 +11181,19 @@ legitimize_pic_address (rtx orig, rtx reg)
from the Global Offset Table (@GOT). */
new_rtx = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr), UNSPEC_GOT);
new_rtx = gen_rtx_CONST (Pmode, new_rtx);
+
if (TARGET_64BIT)
- new_rtx = force_reg (Pmode, new_rtx);
- new_rtx = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new_rtx);
+ new_rtx = copy_to_suggested_reg (new_rtx, reg, Pmode);
+
+ if (reg != 0)
+ {
+ gcc_assert (REG_P (reg));
+ new_rtx = expand_simple_binop (Pmode, PLUS, pic_offset_table_rtx,
+ new_rtx, reg, 1, OPTAB_DIRECT);
+ }
+ else
+ new_rtx = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, new_rtx);
+
new_rtx = gen_const_mem (Pmode, new_rtx);
set_mem_alias_set (new_rtx, ix86_GOT_alias_set ());
}
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index df5acb425d4..af2a573f3dd 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -617,9 +617,11 @@
;; use @GOTOFF unless we are absolutely sure that the symbol is in the
;; same segment as the GOT. Unfortunately, the flexibility of linker
;; scripts means that we can't be sure of that in general, so assume
-;; that @GOTOFF is never valid on VxWorks.
+;; @GOTOFF is not valid on VxWorks, except with the large code model.
(define_predicate "gotoff_operand"
- (and (not (match_test "TARGET_VXWORKS_RTP"))
+ (and (ior (not (match_test "TARGET_VXWORKS_RTP"))
+ (match_test "ix86_cmodel == CM_LARGE")
+ (match_test "ix86_cmodel == CM_LARGE_PIC"))
(match_operand 0 "local_symbolic_operand")))
;; Test for various thread-local symbols.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [i386] Fix couple of issues in large PIC model on x86-64/VxWorks
2021-10-05 15:46 [i386] Fix couple of issues in large PIC model on x86-64/VxWorks Eric Botcazou
@ 2021-11-08 8:21 ` Uros Bizjak
2021-11-08 8:27 ` Eric Botcazou
0 siblings, 1 reply; 4+ messages in thread
From: Uros Bizjak @ 2021-11-08 8:21 UTC (permalink / raw)
To: Eric Botcazou; +Cc: gcc-patches
On Tue, Oct 5, 2021 at 5:50 PM Eric Botcazou via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
>
> the first issue is that the !gotoff_operand path of legitimize_pic_address in
> large PIC model does not make use of REG when it is available, which breaks
> for thunks because new pseudo-registers can no longer be created. And the
> second issue is that the system compiler (LLVM) generates @GOTOFF in large
> model even for RTP, so we do the same.
>
> Tested on x86-64/Linux and VxWorks, OK for the mainline?
>
>
> 2021-10-05 Eric Botcazou <ebotcazou@adacore.com>
>
> * config/i386/i386.c (legitimize_pic_address): Adjust comment and
> use the REG argument on the CM_LARGE_PIC code path as well.
> * config/i386/predicates.md (gotoff_operand): Do not treat VxWorks
> specially with the large code models.
LGTM for the generic part, no idea for VxWorks.
Thanks,
Uros.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [i386] Fix couple of issues in large PIC model on x86-64/VxWorks
2021-11-08 8:21 ` Uros Bizjak
@ 2021-11-08 8:27 ` Eric Botcazou
2021-11-08 17:03 ` Olivier Hainque
0 siblings, 1 reply; 4+ messages in thread
From: Eric Botcazou @ 2021-11-08 8:27 UTC (permalink / raw)
To: Uros Bizjak; +Cc: gcc-patches, Olivier Hainque
> LGTM for the generic part, no idea for VxWorks.
Thanks. The VxWorks-specific hunk is needed to make GCC compatible with the
system compiler on this architecture (LLVM) and I have CCed Olivier.
--
Eric Botcazou
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [i386] Fix couple of issues in large PIC model on x86-64/VxWorks
2021-11-08 8:27 ` Eric Botcazou
@ 2021-11-08 17:03 ` Olivier Hainque
0 siblings, 0 replies; 4+ messages in thread
From: Olivier Hainque @ 2021-11-08 17:03 UTC (permalink / raw)
To: Eric Botcazou; +Cc: Olivier Hainque, Uros Bizjak, gcc-patches
> On 8 Nov 2021, at 09:27, Eric Botcazou <botcazou@adacore.com> wrote:
>
>> LGTM for the generic part, no idea for VxWorks.
>
> Thanks. The VxWorks-specific hunk is needed to make GCC compatible with the
> system compiler on this architecture (LLVM) and I have CCed Olivier.
Good for me, thanks Eric!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-11-08 17:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 15:46 [i386] Fix couple of issues in large PIC model on x86-64/VxWorks Eric Botcazou
2021-11-08 8:21 ` Uros Bizjak
2021-11-08 8:27 ` Eric Botcazou
2021-11-08 17:03 ` Olivier Hainque
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).