From patchwork Wed Sep 17 14:43:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 390422 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 CCEC4140077 for ; Thu, 18 Sep 2014 00:43:35 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=ur/A/kly26i84QZU EYYXGXGXBcP0SFfhSPP+vteVl3pIpqFNDdubKExrI2fthEEr6pibXU5++iWha3KB 8egs8l/GR/LOYhImzI3R+8/XknC5N/COoU1JvWACxRFqJSmjAZeT3MwHTp2wZgbB r2W9sWH0x2MtVokHSTA2dhyVoBE= 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 :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=F0CnJzA3AWfX3oyUKGqbRb QXer8=; b=ka8gNzy2/RLxK5LzgOJYslsTfT11toBTldDEQdHfDsa9tyN++ub+Cc BVR6/vRMKGfFl9866YdWClOBlLPU+fIK268/xyjl39Tm5I11QRbbCD/mQZZIR5eA hCLh4TDmmIN2m3fjoSjAozUmDxKioLGLl1rYlVCq8dIrh69FxpG5w= Received: (qmail 17640 invoked by alias); 17 Sep 2014 14:43:28 -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 17629 invoked by uid 89); 17 Sep 2014 14:43:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 17 Sep 2014 14:43:25 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 17 Sep 2014 15:43:22 +0100 Received: from e106375-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 17 Sep 2014 15:43:20 +0100 From: James Greenhalgh To: gcc-patches@gcc.gnu.org Cc: richard.earnshaw@arm.com, marcus.shawcroft@arm.com, venkataramanan.kumar@linaro.org, steve.mcintyre@linaro.org, patch@linaro.org, pinskia@gmail.com Subject: Re: [PATCH AArch64]: Add constraint letter for stack_protect_test pattern) Date: Wed, 17 Sep 2014 15:43:01 +0100 Message-Id: <1410964981-32412-1-git-send-email-james.greenhalgh@arm.com> In-Reply-To: <541946A7.8080407@arm.com> References: <541946A7.8080407@arm.com> MIME-Version: 1.0 X-MC-Unique: 114091715432200201 X-IsSubscribed: yes On Wed, Sep 17, 2014 at 09:30:31AM +0100, Richard Earnshaw wrote: > "=&r" is correct for an early-clobbered scratch. > > R. In that case... How is the attached patch for trunk? I've bootstrapped it on AArch64 with -fstack-protector-strong and -frename-registers in the BOOT_CFLAGS without seeing any issues. OK? Thanks, James --- gcc/ 2014-09-15 James Greenhalgh * config/aarch64/aarch64.md (stack_protect_test_): Mark scratch register as an output to placate register renaming. gcc/testsuite/ 2014-09-15 James Greenhalgh * gcc.target/aarch64/stack_protector_set_1.c: New. * gcc.target/aarch64/stack_protector_set_2.c: Likewise. diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index c60038a9015d614f40f6d9e3fd228ad3e2b247a8..f15a516bb0559c86bea7512f91d60dc179ec9149 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -4031,7 +4031,7 @@ (define_insn "stack_protect_test_" (unspec:PTR [(match_operand:PTR 1 "memory_operand" "m") (match_operand:PTR 2 "memory_operand" "m")] UNSPEC_SP_TEST)) - (clobber (match_scratch:PTR 3 "&r"))] + (clobber (match_scratch:PTR 3 "=&r"))] "" "ldr\t%3, %x1\;ldr\t%0, %x2\;eor\t%0, %3, %0" [(set_attr "length" "12") diff --git a/gcc/testsuite/gcc.target/aarch64/stack_protector_set_1.c b/gcc/testsuite/gcc.target/aarch64/stack_protector_set_1.c new file mode 100644 index 0000000..df0d26b --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/stack_protector_set_1.c @@ -0,0 +1,15 @@ +/* { dg-do assemble } */ +/* { dg-options "-fstack-protector-strong -O1 -frename-registers" } */ + +extern int bar (const char *s, int *argc); +extern int baz (const char *s); + +char +foo (const char *s) +{ + int argc; + int ret; + if ( !bar (s, &argc)) + ret = baz (s); + return *s; +} diff --git a/gcc/testsuite/gcc.target/aarch64/stack_protector_set_2.c b/gcc/testsuite/gcc.target/aarch64/stack_protector_set_2.c new file mode 100644 index 0000000..b94a2d6 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/stack_protector_set_2.c @@ -0,0 +1,17 @@ +/* { dg-do assemble } */ +/* { dg-options "-fstack-protector-strong -O1 -frename-registers" } */ + +typedef unsigned int uint32_t; +struct ctx +{ + uint32_t A; +}; + +void * +buffer_copy (const struct ctx *ctx, void *resbuf) +{ + uint32_t buffer[4]; + buffer[0] = (ctx->A); + __builtin_memcpy (resbuf, buffer, 16); + return resbuf; +}