From patchwork Tue Nov 27 16:17:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 1003913 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-491005-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sandoe.co.uk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="qDrGq29R"; 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 43488d1CNRz9s3C for ; Wed, 28 Nov 2018 03:18:08 +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:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:cc:to; q=dns; s=default; b=yDhIb+K8i4R6mgDUPdfA 13MuIIc4K4HahF0CQ9Tz78+p2uCSczUGB/VoQjuYUNrrUhRRoZENb4QOLVhRazZ3 rU8zPqOf9N5xcpJ2OAVUywQqRA1KaQDzi+39YBXYsCrbTH0DTly1ozmUMsiDLIja SLLhxcoVy+eLOMOlp144zyE= 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:from :content-type:content-transfer-encoding:mime-version:subject :message-id:date:cc:to; s=default; bh=rt0KEhfo0R7/yc9Z/TAJoOB+Uu k=; b=qDrGq29Raq7soPZPxoHTjwJvymjdgBq5tTGx76McOXt46d/pcxVgDwo42C 78oNydqIof4OnHsWuSVjuDnYKqni0Je7mtx4JZk1dKJ9EoE0ro3k1AFeD2GT2EWT pdFEyIB00ubjkRJhudvnoD8N1TCTFRa0hwwCACZX+XHL9gFNk= Received: (qmail 75271 invoked by alias); 27 Nov 2018 16:18:00 -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 75235 invoked by uid 89); 27 Nov 2018 16:17:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_COUK, KAM_LAZY_DOMAIN_SECURITY autolearn=ham version=3.3.2 spammy=sites, Hx-spam-relays-external:ESMTPA X-HELO: smtp2.wavenetuk.net Received: from smtp2.wavenetuk.net (HELO smtp2.wavenetuk.net) (195.26.37.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Nov 2018 16:17:57 +0000 Received: from euterpe-sie.home (host81-138-1-83.in-addr.btopenworld.com [81.138.1.83]) by smtp2.wavenetuk.net (Postfix) with ESMTPA id 82ECC600136; Tue, 27 Nov 2018 16:17:55 +0000 (GMT) From: Iain Sandoe Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH] Fix PR78444. Message-Id: Date: Tue, 27 Nov 2018 16:17:52 +0000 Cc: Uros Bizjak To: GCC-patches Hi, As described in comment #4/5 in the PR, there are [corner] cases where the the compiler incorrectly concludes that only 64b alignment is needed at a call site. This is caught by Darwin’s dynamic linker which enforces the ABI requirement for 128b alignment, causing the exe be aborted. With this fix, we no longer need the work-around that was applied when profiling was on, so we can remove the special-casing there. The attached patch has been tested on x86_64-darwin and x86_64-linux-gnu. The problem exists on all open branches, OK for trunk? Backports? thanks Iain gcc/ * config/i386/darwin.h (STACK_BOUNDARY): Remove macro. * config/i386/i386.c (ix86_compute_frame_layout): Ensure at least 128b stack alignment in non-leaf functions. From e199bce63f952ae1c3f6bffcdc20360aaf4deae8 Mon Sep 17 00:00:00 2001 From: Iain Sandoe Date: Fri, 16 Nov 2018 16:25:47 +0000 Subject: [PATCH] [patch] Fix PR78444, update stack alignment for non-leaf functions. --- gcc/config/i386/darwin.h | 3 --- gcc/config/i386/i386.c | 10 ++++++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h index 735abeddb2..64133aa8dc 100644 --- a/gcc/config/i386/darwin.h +++ b/gcc/config/i386/darwin.h @@ -85,9 +85,6 @@ extern int darwin_emit_branch_islands; /* On Darwin, the stack is 128-bit aligned at the point of every call. Failure to ensure this will lead to a crash in the system libraries or dynamic loader. */ -#undef STACK_BOUNDARY -#define STACK_BOUNDARY \ - ((profile_flag || TARGET_64BIT_MS_ABI) ? 128 : BITS_PER_WORD) #undef MAIN_STACK_BOUNDARY #define MAIN_STACK_BOUNDARY 128 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index ef58533344..c88617e3c1 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -11161,10 +11161,16 @@ ix86_compute_frame_layout (void) /* 64-bit MS ABI seem to require stack alignment to be always 16, except for function prologues, leaf functions and when the defult incoming stack boundary is overriden at command line or via - force_align_arg_pointer attribute. */ - if ((TARGET_64BIT_MS_ABI && crtl->preferred_stack_boundary < 128) + force_align_arg_pointer attribute. + + Darwin's ABI specifies 128b alignment for both 32 and 64 bit variants + at call sites, including profile function calls. + */ + if (((TARGET_64BIT_MS_ABI || TARGET_MACHO) + && crtl->preferred_stack_boundary < 128) && (!crtl->is_leaf || cfun->calls_alloca != 0 || ix86_current_function_calls_tls_descriptor + || (TARGET_MACHO && crtl->profile) || ix86_incoming_stack_boundary < 128)) { crtl->preferred_stack_boundary = 128;