From patchwork Fri Feb 8 00:43:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 1038400 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-495474-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="brX1u+nb"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Adco1IIw"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43wbzH1JkGz9sBZ for ; Fri, 8 Feb 2019 11:44:06 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=BGSbHT/dS0+MczieVxCOOiOkTZtqGX63SXkFBQADOzTZ9o99oW 0GlnF+FHStmqdUzO3OY74zavh2wU7j59fJdPAxyhId/O8M8EYm05u6M9y4pyXHS8 8Rzt6BRmd2XYOpqsXmjZzymMfq/iojwnTDJhFTUYh+0Af/Rm8rQ6/mrcE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=H76+2lIgwsarQIfZZgTnaahlnyI=; b=brX1u+nb2BR9I8nT30J4 R+ssicnAtOPePLhgbTzPhJ9kjcmNf0EB0smkZIa7BtShqLuyXSlSDE4S9sCRoJxz hNp9XvbFd7UCwXy9McglgJBwWmOxRuL1aVqbMH4g2I8GD8ehFJ8lAY8kZ0G9I1rU 9iN8Idvla+OrldEqem/MiTQ= Received: (qmail 16329 invoked by alias); 8 Feb 2019 00:43:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 16320 invoked by uid 89); 8 Feb 2019 00:43:58 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:488a X-HELO: mail-pg1-f171.google.com Received: from mail-pg1-f171.google.com (HELO mail-pg1-f171.google.com) (209.85.215.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Feb 2019 00:43:56 +0000 Received: by mail-pg1-f171.google.com with SMTP id c25so783338pgb.4 for ; Thu, 07 Feb 2019 16:43:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=U42VS4J2CCXiNjgwnfdB/HGi6vsQksaAsCzpqtKeWX0=; b=Adco1IIwkvJZn4ZyMEyB0zm6AzkPHEZ/Zydk3ARaZ+JgTUH4E9YuVGcdngCuQ0O6Et u94f98iMkDihRBZkCCdvGCMZLNRKVQCSVo0FwPMg2vV7D0X6eaZrdJscRJP6thojvtze yguXFAYx29mJPzAJL4/W7f8A/3Wv35vWv6ZbJV3lsr1E5yDVu6HMOytG590tiEPeRpG6 04pZGtF+1NmUozetruujuDMIPFCM1VaE+wH+E4+E9wlkM5hqjDQp/PUab7GhhxJ2cQPU crT5dbBMFJgClfTrWRtmPRICzF+JetH0zPBgUub90Ar4d3Lxc8IzRWtyZbehnco7Sdzq cRzQ== Received: from bubble.grove.modra.org ([58.175.241.133]) by smtp.gmail.com with ESMTPSA id m20sm358360pgb.56.2019.02.07.16.43.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Feb 2019 16:43:54 -0800 (PST) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id C3DC880573; Fri, 8 Feb 2019 11:13:50 +1030 (ACDT) Date: Fri, 8 Feb 2019 11:13:50 +1030 From: Alan Modra To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [RS6000] Correct save_reg_p Message-ID: <20190208004350.GD5398@bubble.grove.modra.org> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) X-IsSubscribed: yes Fixes lack of r30 save/restore on // -m32 -fpic -ftls-model=initial-exec __thread char* p; char** f1 (void) { return &p; } and // -m32 -fpic -msecure-plt extern int foo (int); int f1 (int x) { return foo (x); } These are both caused by save_reg_p returning false when the pic offset table reg (r30 for ABI_V4) was used, due to the logic not exactly matching that in rs6000_emit_prologue to set up r30. I've simplified the ABI_V4 logic down to df_regs_ever_live_p since that is obviously correct for all ABIs. I also noticed that save_reg_p isn't following the comment regarding calls_eh_return (since svn 267049, git 0edf78b1b2a0), and the comment needs tweaking too. For why the revised comment is correct, grep for saves_all_registers in lra.c, and yes, we do want to save the pic offset table reg for eh_return. Bootstrap and regression test on powerpc64-linux biarch in progress. OK assuming no regressions? Segher this patch supercedes https://gcc.gnu.org/ml/gcc-patches/2019-02/msg00307.html as there's no need to set crtl->uses_pic_offset_table for those cases now with the df_regs_ever_live_p test in save_reg_p. PR target/88343 * config/rs6000/rs6000.c (save_reg_p): Correct calls_eh_return case. Match logic in rs6000_emit_prologue emitting pic_offset_table setup, simplifying ABI_V4 case to df_regs_ever_live_p. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index cced90bb518..9933d4443f7 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -24013,18 +24013,26 @@ save_reg_p (int reg) if (reg == RS6000_PIC_OFFSET_TABLE_REGNUM && !TARGET_SINGLE_PIC_BASE) { + if (df_regs_ever_live_p (reg)) + return true; + /* When calling eh_return, we must return true for all the cases where conditional_register_usage marks the PIC offset reg - call used. */ + call used or fixed. */ + if (crtl->calls_eh_return + && ((DEFAULT_ABI == ABI_V4 && flag_pic) + || (DEFAULT_ABI == ABI_DARWIN && flag_pic) + || (TARGET_TOC && TARGET_MINIMAL_TOC))) + return true; + if (TARGET_TOC && TARGET_MINIMAL_TOC - && (crtl->calls_eh_return - || df_regs_ever_live_p (reg) - || !constant_pool_empty_p ())) + && !constant_pool_empty_p ()) return true; - if ((DEFAULT_ABI == ABI_V4 || DEFAULT_ABI == ABI_DARWIN) + if (DEFAULT_ABI == ABI_DARWIN && flag_pic && crtl->uses_pic_offset_table) return true; + return false; } return !call_used_regs[reg] && df_regs_ever_live_p (reg);