From patchwork Mon Jun 26 16:45:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Krebbel X-Patchwork-Id: 113050 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7615009vqr; Mon, 26 Jun 2023 09:48:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5KdEc1pYc27jF0gqw2G8rM0X9e0nBP8Yqd8yqErEXN7L6snzGrr4zsidmchOEGubQcBV28 X-Received: by 2002:a05:6402:29a:b0:514:945c:6cea with SMTP id l26-20020a056402029a00b00514945c6ceamr18946546edv.37.1687798086257; Mon, 26 Jun 2023 09:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687798086; cv=none; d=google.com; s=arc-20160816; b=yg/Hm9/qHEoE/Mc13VQ7fajiNXV60/qcwMgDAMPIFR92fS3QJPwemHrE3UA8Blm/pq h4tzW3t475CCzGt+0C2h0zVKWCf4nxkF6zn6Vj5s4EGS1rS9olCfUjZnSKX4G9xbtwIl vFrlDLrPsD9lcXTQxaIDrrbxDAnj1aPhMQH4TB9gCZDmPK7NkGu4OrH05h4Vz7aiepSS NIqRtoEvqgjEHotxgX2IaxSz/6lXqCzpnjmJRvbcCATKHcZOeUVwQAvmFurFKquaHDap EmPFvLhVNEsoEKWjj6o+drOmVzx7ncMRDRNxPYgag11G7I3yT6HQ7GQooRukF+LRjeMe ur2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=ArpurbxzHGgx3zWVbEGza5nRaNgNWJHO4iAwBmBpU2E=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=qJ8nA2em2ArLHr7LwFBKXWJWLOzsc3pA8AtEjr0HQ6B60/OX0Fjr1doYMfFJsk++b0 4neJLstP2eew59iMUXI5Rmzdh+aROY3bDpNYVDQCAP6qo3AkDxNSp/5fijZ0HQzlBtY3 vW8n7vvfSNOFrGcWF7I/TLq5lkaepJQPlEYu3B0rNQ5E+jfOYEtbc42rB89VWnngG+0O wOgVDpK84ZC8tx8X9UvkxOAMnQh/MDEqNrfw58HEsfVUAV/3DWEwsxkC6/mSkGf8+Y2U 2cXbAm9g9jr0tzjt0/WyQJacGCXVhUkYMNgQRGH3g16eHhf8jfZv65baQsuRhTc2LeV/ TEsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qpbkKJim; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id m24-20020a056402051800b0051a5a8f03d8si2822329edv.15.2023.06.26.09.48.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 09:48:06 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qpbkKJim; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A7583858028 for ; Mon, 26 Jun 2023 16:46:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A7583858028 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687797965; bh=ArpurbxzHGgx3zWVbEGza5nRaNgNWJHO4iAwBmBpU2E=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qpbkKJimyRNmCYdDWgbeW9t31MSdS/GUizNuJpkxMaEU+KVuzzUJWw5rhaRD3UzPH RNBYHQJsVtr5+cBvqAncXoA+LE8RTxcOdb9xQNDPqkF8rKFroKr7WtmUKsuz/K2qmG tKrNbdxOqeCo6Ijd0K2kP63wArOsRzYHAwz9D8IY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id EEDEC3857722 for ; Mon, 26 Jun 2023 16:45:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EEDEC3857722 Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35QGH3Pu013376 for ; Mon, 26 Jun 2023 16:45:18 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3rfe298n95-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 26 Jun 2023 16:45:17 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 35Q5GD25002662 for ; Mon, 26 Jun 2023 16:45:15 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3rdr4511pw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 26 Jun 2023 16:45:15 +0000 Received: from smtpav03.fra02v.mail.ibm.com (smtpav03.fra02v.mail.ibm.com [10.20.54.102]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 35QGjCTp6292132 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 26 Jun 2023 16:45:12 GMT Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B74E020043 for ; Mon, 26 Jun 2023 16:45:12 +0000 (GMT) Received: from smtpav03.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8226420040 for ; Mon, 26 Jun 2023 16:45:12 +0000 (GMT) Received: from li-ecc9ffcc-3485-11b2-a85c-e633c5126265.fritz.box (unknown [9.171.59.85]) by smtpav03.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Mon, 26 Jun 2023 16:45:12 +0000 (GMT) To: gcc-patches@gcc.gnu.org Subject: [Committed] IBM zSystems: Assume symbols without explicit alignment to be ok Date: Mon, 26 Jun 2023 18:45:12 +0200 Message-ID: <20230626164512.11512-1-krebbel@linux.ibm.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: OfhC9gFbN1ot9AQVSNT9-eIS2U5-cMdv X-Proofpoint-ORIG-GUID: OfhC9gFbN1ot9AQVSNT9-eIS2U5-cMdv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-26_14,2023-06-26_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 lowpriorityscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 suspectscore=0 impostorscore=0 mlxlogscore=999 spamscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306260151 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andreas Krebbel via Gcc-patches From: Andreas Krebbel Reply-To: Andreas Krebbel Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769784566171182864?= X-GMAIL-MSGID: =?utf-8?q?1769784566171182864?= A change we have committed back in 2015 relies on the backend requested ABI alignment to be applied to ALL symbols by the middle-end. However, this does not appear to be the case for external symbols. With this commit we assume all symbols without explicit alignment to be aligned according to the ABI. That's the behavior we had before. This fixes a performance regression caused by the 2015 patch. Since then the address of external char type symbols have been pushed to the literal pool, although it is safe to access them with larl (which requires symbols to reside at even addresses). Bootstrapped and regression tested on s390x. gcc/ * config/s390/s390.cc (s390_encode_section_info): Set SYMBOL_FLAG_SET_NOTALIGN2 only if the symbol has explicitely been misaligned. gcc/testsuite/ * gcc.target/s390/larl-1.c: New test. --- gcc/config/s390/s390.cc | 6 +++-- gcc/testsuite/gcc.target/s390/larl-1.c | 32 ++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/s390/larl-1.c diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index 9284477396d..d9f10542473 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -13706,8 +13706,10 @@ s390_encode_section_info (tree decl, rtx rtl, int first) { /* Store the alignment to be able to check if we can use a larl/load-relative instruction. We only handle the cases - that can go wrong (i.e. no FUNC_DECLs). */ - if (DECL_ALIGN (decl) == 0 || DECL_ALIGN (decl) % 16) + that can go wrong (i.e. no FUNC_DECLs). + All symbols without an explicit alignment are assumed to be 2 + byte aligned as mandated by our ABI. */ + if (DECL_USER_ALIGN (decl) && DECL_ALIGN (decl) % 16) SYMBOL_FLAG_SET_NOTALIGN2 (XEXP (rtl, 0)); else if (DECL_ALIGN (decl) % 32) SYMBOL_FLAG_SET_NOTALIGN4 (XEXP (rtl, 0)); diff --git a/gcc/testsuite/gcc.target/s390/larl-1.c b/gcc/testsuite/gcc.target/s390/larl-1.c new file mode 100644 index 00000000000..5ef2ef63f82 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/larl-1.c @@ -0,0 +1,32 @@ +/* Check if load-address-relative instructions are created */ + +/* { dg-do compile { target { s390*-*-* } } } */ +/* { dg-options "-O2 -march=z10 -mzarch -fno-section-anchors" } */ + +/* An explicitely misaligned symbol. This symbol is NOT aligned as + mandated by our ABI. However, the back-end needs to handle that in + order to make things like __attribute__((packed)) work. The symbol + address is expected to be loaded from literal pool. */ +/* { dg-final { scan-assembler "lgrl\t%r2," { target { lp64 } } } } */ +/* { dg-final { scan-assembler "lrl\t%r2," { target { ! lp64 } } } } */ +extern char align1 __attribute__((aligned(1))); + +/* { dg-final { scan-assembler "larl\t%r2,align2" } } */ +extern char align2 __attribute__((aligned(2))); + +/* { dg-final { scan-assembler "larl\t%r2,align4" } } */ +extern char align4 __attribute__((aligned(4))); + +/* An external char symbol without explicit alignment has a DECL_ALIGN + of just 8. In contrast to local definitions DATA_ABI_ALIGNMENT is + NOT applied to DECL_ALIGN in that case. Make sure the backend + still assumes this symbol to be aligned according to ABI + requirements. */ +/* { dg-final { scan-assembler "larl\t%r2,align_default" } } */ +extern char align_default; + +char * foo1 () { return &align1; } +char * foo2 () { return &align2; } +char * foo3 () { return &align4; } +char * foo4 () { return &align_default; } +