From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23286 invoked by alias); 17 Dec 2015 21:59:34 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 23271 invoked by uid 89); 17 Dec 2015 21:59:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=ubizjak@gmail.com, ubizjakgmailcom, Hx-languages-length:4126, our X-HELO: mail-qg0-f44.google.com Received: from mail-qg0-f44.google.com (HELO mail-qg0-f44.google.com) (209.85.192.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 17 Dec 2015 21:59:32 +0000 Received: by mail-qg0-f44.google.com with SMTP id k90so39933490qge.0 for ; Thu, 17 Dec 2015 13:59:32 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.141.6.9 with SMTP id i9mr189252qhd.68.1450389570508; Thu, 17 Dec 2015 13:59:30 -0800 (PST) Received: by 10.55.181.70 with HTTP; Thu, 17 Dec 2015 13:59:30 -0800 (PST) In-Reply-To: References: <20151216232951.GA17976@intel.com> Date: Thu, 17 Dec 2015 21:59:00 -0000 Message-ID: Subject: Re: [PATCH] PR target/68937: i686: -fno-plt produces wrong code (maybe only with tailcall From: "H.J. Lu" To: Uros Bizjak Cc: "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg01831.txt.bz2 On Thu, Dec 17, 2015 at 1:21 PM, Uros Bizjak wrote: > On Thu, Dec 17, 2015 at 7:09 PM, H.J. Lu wrote: >> On Thu, Dec 17, 2015 at 8:11 AM, H.J. Lu wrote: >>> On Thu, Dec 17, 2015 at 7:50 AM, H.J. Lu wrote: >>>> On Thu, Dec 17, 2015 at 5:42 AM, Uros Bizjak wrote: >>>>> On Thu, Dec 17, 2015 at 2:00 PM, H.J. Lu wrote: >>>>>> On Thu, Dec 17, 2015 at 2:04 AM, Uros Bizjak wrote: >>>>>>> On Thu, Dec 17, 2015 at 12:29 AM, H.J. Lu wrote: >>>>>>>> Since sibcall never returns, we can only use call-clobbered register >>>>>>>> as GOT base. Otherwise, callee-saved register used as GOT base won't >>>>>>>> be properly restored. >>>>>>>> >>>>>>>> Tested on x86-64 with -m32. OK for trunk? >>>>>>> >>>>>>> You don't have to add explicit clobber for members of "CLOBBERED_REGS" >>>>>>> class, and register_no_elim_operand predicate should be used with "U" >>>>>>> constraint. Also, please introduce new predicate, similar to how >>>>>>> GOT_memory_operand is defined and handled. >>>>>>> >>>>>> >>>>>> Here is the updated patch. There is a predicate already, >>>>>> sibcall_memory_operand. It allows any registers to >>>>>> be as GOT base, which is the root of our problem. >>>>>> This patch removes GOT slot from it and handles >>>>>> sibcall over GOT slot with *sibcall_GOT_32 and >>>>>> *sibcall_value_GOT_32 patterns. Since I need to >>>>>> expose constraints on GOT base register to RA, >>>>>> I have to use 2 operands, GOT base and function >>>>>> symbol, to describe sibcall over 32-bit GOT slot. >>>>> >>>>> Please use >>>>> >>>>> (mem:SI (plus:SI >>>>> (match_operand:SI 0 "register_no_elim_operand" "U") >>>>> (match_operand:SI 1 "GOT32_symbol_operand"))) >>>>> ... >>>>> >>>>> to avoid manual rebuild of the operand. >>>>> >>>> >>>> Is this OK? >>>> >>> >>> An updated patch to allow sibcall_memory_operand for RTL >>> expansion. OK for trunk if there is no regression? >>> >> >> There is no regressions on x86-64 with -m32. OK for trunk? > > OK for mainline, with a following change: > > @@ -597,11 +597,17 @@ > (match_operand 0 "memory_operand")))) > > ;; Return true if OP is a memory operands that can be used in sibcalls. > +;; Since sibcall never returns, we can only use call-clobbered register > +;; as GOT base. Allow GOT slot here only with pseudo register as GOT > +;; base. Properly handle sibcall over GOT slot with *sibcall_GOT_32 > +;; and *sibcall_value_GOT_32 patterns. > (define_predicate "sibcall_memory_operand" > (and (match_operand 0 "memory_operand") > (match_test "CONSTANT_P (XEXP (op, 0)) > || (GET_CODE (XEXP (op, 0)) == PLUS > && REG_P (XEXP (XEXP (op, 0), 0)) > + && (REGNO (XEXP (XEXP (op, 0), 0)) > + >= FIRST_PSEUDO_REGISTER) > && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST > && GET_CODE (XEXP (XEXP (XEXP (op, 0), 1), 0)) == UNSPEC > && XINT (XEXP (XEXP (XEXP (op, 0), 1), 0), 1) == UNSPEC_GOT)"))) > > You can use (!HARD_REGISTER_NUM_P (...) || call_used_regs[...]) here. > Call-used hard regs are still allowed here. > > Can you please also rewrite this horrible match_test as a block of C > code using GOT32_symbol_operand predicate? > I am retesting the patch with ;; Return true if OP is a memory operands that can be used in sibcalls. ;; Since sibcall never returns, we can only use call-clobbered register ;; as GOT base. Allow GOT slot here only with pseudo register as GOT ;; base. Properly handle sibcall over GOT slot with *sibcall_GOT_32 ;; and *sibcall_value_GOT_32 patterns. (define_predicate "sibcall_memory_operand" (match_operand 0 "memory_operand") { op = XEXP (op, 0); if (CONSTANT_P (op)) return true; if (GET_CODE (op) == PLUS && REG_P (XEXP (op, 0))) { int regno = REGNO (XEXP (op, 0)); if (!HARD_REGISTER_NUM_P (regno) || call_used_regs[regno]) { op = XEXP (op, 1); if (GOT32_symbol_operand (op, VOIDmode)) return true; } } return false; }) I will check it in if there is no regression. Thanks. -- H.J.