This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC PATCH, i386]: Use %r15 for REAL_PIC_OFFSET_TABLE_REGNUM on x86_64


In the case of cpuid, the code is hardly performance sensitive, and probably runs only at startup. An alternative solution for the broken code here is to move the result from rbx to another register, and to save/restore rbx. Currently, this is the only place in libgcc and newlib affected by this problem.

Leif Ekblad

----- Original Message ----- From: "Andi Kleen" <andi@firstfloor.org>
To: "Uros Bizjak" <ubizjak@gmail.com>
Cc: <gcc-patches@gcc.gnu.org>; "Richard Henderson" <rth@redhat.com>; "Jakub Jelinek" <jakub@redhat.com>; <jh@suse.cz>; "H.J. Lu" <hjl.tools@gmail.com>
Sent: Monday, December 24, 2012 10:32 PM
Subject: Re: [RFC PATCH, i386]: Use %r15 for REAL_PIC_OFFSET_TABLE_REGNUM on x86_64



Uros Bizjak <ubizjak@gmail.com> writes:

Hello!

Currently, we use %rbx as REAL_PIC_OFFSET_TABLE_REGNUM on x86_64.
Since this register gets marked as fixed reg in
ix86_conditional_register_usage, we get into troubles with insns that
use %rbx (cmpxchg, cpuid). According to x86_64 psABI, we are free to
use any register, so attached patch changes %rbx with %r15 (also
following the example in the psABI). This patch has no implications on
small code model (that doesn't use REAL_PIC_OFFSET_TABLE_REGNUM
anyway), but on medium and large code model fixes usage of cpuid.h
(please see PR 55712 [1]) and avoids a pair of xchgs around cmpxchg or
cpuid instructions.

So everyone who worked around this and use r15 now broke.


It would be probably better to just teach the register allocator
to spill those registers as needed, to handle some asm() statement.
Not sure how hard that would be.

-Andi

--
ak@linux.intel.com -- Speaking for myself only


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]