From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70432 invoked by alias); 26 Aug 2016 15:03:18 -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 70417 invoked by uid 89); 26 Aug 2016 15:03:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=BAYES_40,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=outgoing, dijkstra, sk:wdijkst, U*wdijkstr X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Aug 2016 15:03:07 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 84C3828; Fri, 26 Aug 2016 08:04:46 -0700 (PDT) Received: from e104437-lin (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A68993F220; Fri, 26 Aug 2016 08:03:04 -0700 (PDT) References: From: Jiong Wang To: Wilco Dijkstra Cc: GCC Patches , nd Subject: Re: [PATCH][AArch64 - v2] Simplify eh_return implementation Date: Fri, 26 Aug 2016 15:03:00 -0000 In-reply-to: Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-IsSubscribed: yes X-SW-Source: 2016-08/txt/msg01868.txt.bz2 Wilco Dijkstra writes: > Ping > > I noticed it would still be a good idea to add an extra barrier in the epilog as the > scheduler doesn't appear to handle aliases of frame accesses properly. > > This patch simplifies the handling of the EH return value. We force the use of the > frame pointer so the return location is always at FP + 8. This means we can emit > a simple volatile access in EH_RETURN_HANDLER_RTX without needing md > patterns, splitters and frame offset calculations. The new implementation also > fixes various bugs in aarch64_final_eh_return_addr, which does not work with > -fomit-frame-pointer, alloca or outgoing arguments. The -fomit-frame-pointer is really broken on aarch64_find_eh_return_addr - return gen_frame_mem (DImode, - plus_constant (Pmode, - stack_pointer_rtx, - fp_offset - + cfun->machine->frame.saved_regs_size - - 2 * UNITS_PER_WORD)); the saved_regs_size includes both general and vector register saving area, while LR should be saved on top of general register area. Meanwhile saved_regs_size contains alignment amount. Given EH unwind code will invoke __builtin_unwind_init which pushes all callee-saved, both general and vector, the current function will always get wrong offset. I think the correct offset when -fomit-frame-pointer should be: "cfun->machine->frame.reg_offset[LR_REGNUM]" I have done a quick check on _Unwind_RaiseException which is the only code affected by this change. Without frame pointer, the exception handler's address is installed in different, thus wrong, stack slot. ... str x30, [sp, 112] ... str x19, [sp, 176] This approach used in this patch looks good to me. > 2016-08-10 Wilco Dijkstra > gcc/ > * config/aarch64/aarch64.md (eh_return): Remove pattern and splitter. > * config/aarch64/aarch64.h (AARCH64_EH_STACKADJ_REGNUM): Remove. > (EH_RETURN_HANDLER_RTX): New define. > * config/aarch64/aarch64.c (aarch64_frame_pointer_required): > Force frame pointer in EH return functions. > (aarch64_expand_epilogue): Add barrier for eh_return. > (aarch64_final_eh_return_addr): Remove. > (aarch64_eh_return_handler_rtx): New function. > * config/aarch64/aarch64-protos.h (aarch64_final_eh_return_addr): > Remove. > (aarch64_eh_return_handler_rtx): New prototype. -- Regards, Jiong