From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1383) id 954BF3847818; Fri, 3 Sep 2021 21:05:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 954BF3847818 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Segher Boessenkool To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3353] rs6000: Don't use r12 for CR save on ELFv2 (PR102107) X-Act-Checkin: gcc X-Git-Author: Segher Boessenkool X-Git-Refname: refs/heads/master X-Git-Oldrev: addf167a23f61c0ec97f6e71577a0623f3fc13e7 X-Git-Newrev: 2484f7a4b0f52e6ed04754be336f1fa6fde47f6b Message-Id: <20210903210540.954BF3847818@sourceware.org> Date: Fri, 3 Sep 2021 21:05:40 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Sep 2021 21:05:40 -0000 https://gcc.gnu.org/g:2484f7a4b0f52e6ed04754be336f1fa6fde47f6b commit r12-3353-g2484f7a4b0f52e6ed04754be336f1fa6fde47f6b Author: Segher Boessenkool Date: Thu Sep 2 16:38:24 2021 +0000 rs6000: Don't use r12 for CR save on ELFv2 (PR102107) CR is saved and/or restored on some paths where GPR12 is already live since it has a meaning in the calling convention in the ELFv2 ABI. It is not completely clear to me that we can always use r11 here, but it does seem save, there is checking code (to detect conflicts here), and it is stage 1. So here goes. 2021-09-03 Segher Boessenkool PR target/102107 * config/rs6000/rs6000-logue.c (rs6000_emit_prologue): On ELFv2 use r11 instead of r12 for CR save, in all cases. Diff: --- gcc/config/rs6000/rs6000-logue.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gcc/config/rs6000/rs6000-logue.c b/gcc/config/rs6000/rs6000-logue.c index 07337c4836a..e363d56ecec 100644 --- a/gcc/config/rs6000/rs6000-logue.c +++ b/gcc/config/rs6000/rs6000-logue.c @@ -3293,10 +3293,13 @@ rs6000_emit_prologue (void) /* If we need to save CR, put it into r12 or r11. Choose r12 except when r12 will be needed by out-of-line gpr save. */ - cr_save_regno = ((DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) - && !(strategy & (SAVE_INLINE_GPRS - | SAVE_NOINLINE_GPRS_SAVES_LR)) - ? 11 : 12); + if (DEFAULT_ABI == ABI_AIX + && !(strategy & (SAVE_INLINE_GPRS | SAVE_NOINLINE_GPRS_SAVES_LR))) + cr_save_regno = 11; + else if (DEFAULT_ABI == ABI_ELFv2) + cr_save_regno = 11; + else + cr_save_regno = 12; if (!WORLD_SAVE_P (info) && info->cr_save_p && REGNO (frame_reg_rtx) != cr_save_regno