From patchwork Wed Oct 28 22:48:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Gra=C5=BEvydas_Ignotas?= X-Patchwork-Id: 537587 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 E6BAA140787 for ; Thu, 29 Oct 2015 09:49:12 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=W7AReJHg; dkim-atps=neutral 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; q=dns; s=default; b=YekXrlBwdtip mHRPano70XFgWVnodxr7zftp6zH55p+iaRinf0cuOe4d2fuudHmfB2WBRkIZlh8U gA7IAU7L3ljubz2If9zX31EtBcCS3Cw2bV0u9kGMbjE9Z0CHXBqPHj/73woXtCPs yx2ZVYZtrZxUhHnYHks/2UU/q33pJck= 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; s=default; bh=uDeUwbsr6MEYIqGS6T RjYmQeFIw=; b=W7AReJHgMtOBDiwHJJJ/P+i1kc/o2/PyizZWKDnxc4S20Dg9Nk EArGISEna8xh4JT7IJMi9TL0/DWdLrfiU9aLsacxYjzgVK4NnikJhLD907EqBfnL I5c2ob3kQAfaBycSL7+Dn/U25bo2qempVViIuNyPNmT1UpXYIhv8285vE= Received: (qmail 1831 invoked by alias); 28 Oct 2015 22:49:05 -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 1818 invoked by uid 89); 28 Oct 2015 22:49:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wi0-f178.google.com Received: from mail-wi0-f178.google.com (HELO mail-wi0-f178.google.com) (209.85.212.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 28 Oct 2015 22:49:03 +0000 Received: by wijp11 with SMTP id p11so271954727wij.0 for ; Wed, 28 Oct 2015 15:49:00 -0700 (PDT) X-Received: by 10.194.184.44 with SMTP id er12mr48192519wjc.58.1446072540263; Wed, 28 Oct 2015 15:49:00 -0700 (PDT) Received: from localhost.localdomain ([5.20.220.27]) by smtp.gmail.com with ESMTPSA id v191sm6063269wmd.24.2015.10.28.15.48.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Oct 2015 15:48:59 -0700 (PDT) From: Grazvydas Ignotas To: gcc-patches@gcc.gnu.org Cc: Bernd Edlinger , Grazvydas Ignotas Subject: [PATCH][4.9/5 Backport] PR rtl-optimization/67037 Use copy_rtx when necessary Date: Thu, 29 Oct 2015 00:48:44 +0200 Message-Id: <1446072524-17431-1-git-send-email-notasas@gmail.com> Hi, This is the 4.9 and GCC 5 backport of patch from PR67037 that's already in trunk. I've build it on 4.9 and confirmed that it works. Grazvydas Backport from mainline 2015-09-30 Bernd Edlinger PR rtl-optimization/67037 * lra-constraints.c (process_addr_reg): Use copy_rtx when necessary. testsuite: 2015-09-30 Bernd Edlinger PR rtl-optimization/67037 * gcc.c-torture/execute/pr67037.c: New test. --- gcc/lra-constraints.c | 2 +- gcc/testsuite/gcc.c-torture/execute/pr67037.c | 49 +++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr67037.c diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index ae8f3cd..919b127 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -1203,7 +1203,7 @@ process_addr_reg (rtx *loc, rtx *before, rtx *after, enum reg_class cl) if (after != NULL) { start_sequence (); - lra_emit_move (reg, new_reg); + lra_emit_move (before_p ? copy_rtx (reg) : reg, new_reg); emit_insn (*after); *after = get_insns (); end_sequence (); diff --git a/gcc/testsuite/gcc.c-torture/execute/pr67037.c b/gcc/testsuite/gcc.c-torture/execute/pr67037.c new file mode 100644 index 0000000..3119d32 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr67037.c @@ -0,0 +1,49 @@ +long (*extfunc)(); + +static inline void lstrcpynW( short *d, const short *s, int n ) +{ + unsigned int count = n; + + while ((count > 1) && *s) + { + count--; + *d++ = *s++; + } + if (count) *d = 0; +} + +int __attribute__((noinline,noclone)) +badfunc(int u0, int u1, int u2, int u3, + short *fsname, unsigned int fsname_len) +{ + static const short ntfsW[] = {'N','T','F','S',0}; + char superblock[2048+3300]; + int ret = 0; + short *p; + + if (extfunc()) + return 0; + p = (void *)extfunc(); + if (p != 0) + goto done; + + extfunc(superblock); + + lstrcpynW(fsname, ntfsW, fsname_len); + + ret = 1; +done: + return ret; +} + +static long f() +{ + return 0; +} + +int main() +{ + short buf[6]; + extfunc = f; + return !badfunc(0, 0, 0, 0, buf, 6); +}