From patchwork Tue Sep 19 19:22:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Qing Zhao X-Patchwork-Id: 815791 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-462521-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ffm1zQQd"; 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 3xxXnf5qclz9sNr for ; Wed, 20 Sep 2017 05:22:29 +1000 (AEST) 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:to; q=dns; s=default; b=jM5gcd5V1CN6zqg63Y+45tH QGuqFYGO3DLCJwQvCec5EOiMBswW1jVMsuZ8eTRG2IsNWYVlDc+r2SlFvvV4YNik 2Bgm0yY7RTt/94GRIxvfBwEIa4lG6aIhjoQY5l+BB1ft2BDoH7LA59+D2WQsjkat 5FBGbDka7FbiCiNjkils= 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:to; s=default; bh=xWFNjzTgfqOYxJpMNS4RTplyHcw=; b= ffm1zQQdszxZGhi7Et1VaVKCkndFOVpiN9NgObcqn70rK/j1fav3KcFEdPxPwr/u anPuJk5Ze3FIgKJ8pA2TjZBxTQ05ZsbCr1glq6aiMeir6vERzutZRSmhfk2zcLk1 GWvGECGTTstb9F7/nRlpLkzS4s2T3Uaf/5YC6FjYxHY= Received: (qmail 10679 invoked by alias); 19 Sep 2017 19:22:22 -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 10483 invoked by uid 89); 19 Sep 2017 19:22:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy=H*r:Gateway X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Sep 2017 19:22:20 +0000 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v8JJMIvL032148 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Sep 2017 19:22:19 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id v8JJMILq007958 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 19 Sep 2017 19:22:18 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v8JJMHaH029952 for ; Tue, 19 Sep 2017 19:22:18 GMT Received: from dhcp-amer-vpn-adc-anyconnect-10-154-155-87.vpn.oracle.com (/10.154.155.87) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 19 Sep 2017 12:22:17 -0700 From: Qing Zhao Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH] Fix PR81422[aarch64] internal compiler error: in update_equiv_regs, at ira.c:3425 Message-Id: <0EC213FB-C1C3-4E10-83EB-AAC8412D7074@oracle.com> Date: Tue, 19 Sep 2017 14:22:16 -0500 To: gcc-patches@gcc.gnu.org X-IsSubscribed: yes Hi, This patch fixes the aarch64 bug 81422 https://gcc.gnu.org/PR81422 Before adding REG_EQUIV notes in the TLS symbol handling code, we should check whether the "dest" is a REG or NOT (sometimes, it's a SUBREG as in this bug). Only when the “dest” is a REG, the note will be added. a new small testing case is added. this change has been tested on aarch64-unknown-linux-gnu with no regression. Thanks! Qing =============== gcc/ChangeLog: * config/aarch64/aarch64.c (aarch64_load_symref_appropriately): check whether the dest is REG before adding REG_EQUIV note. gcc/testsuite/ChangeLog: PR target/81422 * gcc.target/aarch64/pr81422.C: New test. --- gcc/config/aarch64/aarch64.c | 12 ++++++++---- gcc/testsuite/gcc.target/aarch64/pr81422.C | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/pr81422.C diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index a2ecd7a..6c3ef76 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -1480,7 +1480,8 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm, tp = gen_lowpart (mode, tp); emit_insn (gen_rtx_SET (dest, gen_rtx_PLUS (mode, tp, x0))); - set_unique_reg_note (get_last_insn (), REG_EQUIV, imm); + if (REG_P (dest)) + set_unique_reg_note (get_last_insn (), REG_EQUIV, imm); return; } @@ -1514,7 +1515,8 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm, } emit_insn (gen_rtx_SET (dest, gen_rtx_PLUS (mode, tp, tmp_reg))); - set_unique_reg_note (get_last_insn (), REG_EQUIV, imm); + if (REG_P (dest)) + set_unique_reg_note (get_last_insn (), REG_EQUIV, imm); return; } @@ -1555,7 +1557,8 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm, gcc_unreachable (); } - set_unique_reg_note (get_last_insn (), REG_EQUIV, imm); + if (REG_P (dest)) + set_unique_reg_note (get_last_insn (), REG_EQUIV, imm); return; } @@ -1584,7 +1587,8 @@ aarch64_load_symref_appropriately (rtx dest, rtx imm, emit_insn (gen_tlsie_tiny_sidi (dest, imm, tp)); } - set_unique_reg_note (get_last_insn (), REG_EQUIV, imm); + if (REG_P (dest)) + set_unique_reg_note (get_last_insn (), REG_EQUIV, imm); return; } diff --git a/gcc/testsuite/gcc.target/aarch64/pr81422.C b/gcc/testsuite/gcc.target/aarch64/pr81422.C new file mode 100644 index 0000000..5bcc948 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr81422.C @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O0" } */ + +struct DArray +{ + __SIZE_TYPE__ length; + int* ptr; +}; + +void foo35(DArray) +{ + static __thread int x[5]; + foo35({5, (int*)&x}); +} +