From patchwork Thu Mar 14 09:53:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Krebbel X-Patchwork-Id: 1912051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=GOsn0oWM; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TwN5602LSz1yWn for ; Thu, 14 Mar 2024 20:54:16 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B01783857C7D for ; Thu, 14 Mar 2024 09:54:13 +0000 (GMT) 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 A677A3858C31 for ; Thu, 14 Mar 2024 09:53:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A677A3858C31 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A677A3858C31 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710410027; cv=none; b=Gkdsut6NvziB2h1cO+4NnVFQb30VVvHJ3aMrbHgMl+doDZhAvj7BHQ8EQGMvkWDdOA4l2ugZ985Vv7LboL7aVdXehlKs0wqSFmB+crzvhu3ahJp4ZHPynHjmR65XIvzdZFTLaX+htZM4OacEd/K6tWGmj5tAdBthMJxE5F7FdBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710410027; c=relaxed/simple; bh=qhUJVI0VBz9jwXfpqplmwvczKGeXr6qWj7hoQlsBEOI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=vwkvTi5IW0vWo3Lp2ignkV4vLWK66J/7hGa6htlPksjTLnn7gYVtaVR48G4YZAFIPqjLj+2CM05J1RK9rRk5hg+kgn6xVhfA4vAkGHrVsiDqAyBI34TcMj7bF6py7F6qYORfui8YpAmWeVOiXNooELHC/hEC0USDZSUakQlEr2c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 42E9geeN008637 for ; Thu, 14 Mar 2024 09:53:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : subject : date : message-id : mime-version : content-transfer-encoding; s=pp1; bh=HyxBT6Fa49LhIqIiZx3kjE79Vd9fsIKjq1zXPrWUHp8=; b=GOsn0oWMeYyEFAy9pKMBHfGiDnoBdUdTaXYHmg3R5JfNA7pro12ueFEy2G4pAbTJ3Nvu wG7+J4wxa6XKf6oOjie/L2sBiXzU1a49ft0KIE4poDn1JOp1fJjc9Am+2xD/bo2RXyup r+J0UvDn6i9PB8k2fEbOg9Q9gZth9ev6R75/lW6eCef3o4zhnPNhsh8OhJa/Q/8WcM8U YccmuhRL1zEWINYmmUSPg+f/RL1gjrvZa+aCJga2h6ymyR/on73xPElFLNZZ5kpF7w4n YtaV398RIJTwp6zrDcwAaSUEWZDTUrz3GqvUB2VhywshAEWQ8BL5sQ2pDoaCCcjNMo4v hg== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3wuxua05y3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Mar 2024 09:53:43 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 42E7mV5r020446 for ; Thu, 14 Mar 2024 09:53:42 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3ws3kmbxv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 14 Mar 2024 09:53:41 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 42E9rbGv4457108 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 14 Mar 2024 09:53:40 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D8AF62005A for ; Thu, 14 Mar 2024 09:53:37 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B3DD52004F for ; Thu, 14 Mar 2024 09:53:37 +0000 (GMT) Received: from li-ecc9ffcc-3485-11b2-a85c-e633c5126265.boeblingen.de.ibm.com (unknown [9.152.224.146]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Thu, 14 Mar 2024 09:53:37 +0000 (GMT) From: Andreas Krebbel To: gcc-patches@gcc.gnu.org Subject: [Committed] IBM Z: Fix -munaligned-symbols Date: Thu, 14 Mar 2024 10:53:37 +0100 Message-ID: <20240314095337.10608-1-krebbel@linux.ibm.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: GXYBIK6BE7pr_bPSBnQZ5nFxDnJNYyZV X-Proofpoint-ORIG-GUID: GXYBIK6BE7pr_bPSBnQZ5nFxDnJNYyZV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-03-14_08,2024-03-13_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 bulkscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2403140069 X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_MSPIKE_H4, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org With this fix we make sure that only symbols with a natural alignment smaller than 2 are considered misaligned with -munaligned-symbols. Background is that -munaligned-symbols is only supposed to affect symbols whose natural alignment wouldn't be enough to fulfill our ABI requirement of having all symbols at even addresses. Because only these are the cases where we differ from other architectures. This fixes the unaligned-1 testcase, no regressions. Committed to mainline. gcc/ChangeLog: * config/s390/s390.cc (s390_encode_section_info): Adjust the check for misaligned symbols. * config/s390/s390.opt: Improve documentation. gcc/testsuite/ChangeLog: * gcc.target/s390/aligned-1.c: Add weak and void variables incorporating the cases from unaligned-2.c. * gcc.target/s390/unaligned-1.c: Likewise. * gcc.target/s390/unaligned-2.c: Removed. --- gcc/config/s390/s390.cc | 15 ++- gcc/config/s390/s390.opt | 7 +- gcc/testsuite/gcc.target/s390/aligned-1.c | 101 +++++++++++++++++-- gcc/testsuite/gcc.target/s390/unaligned-1.c | 103 ++++++++++++++++++-- gcc/testsuite/gcc.target/s390/unaligned-2.c | 16 --- 5 files changed, 201 insertions(+), 41 deletions(-) delete mode 100644 gcc/testsuite/gcc.target/s390/unaligned-2.c diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc index e63965578f1..372a2324403 100644 --- a/gcc/config/s390/s390.cc +++ b/gcc/config/s390/s390.cc @@ -13802,10 +13802,19 @@ s390_encode_section_info (tree decl, rtx rtl, int first) 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. This behavior can be - overridden for external symbols with the -munaligned-symbols - switch. */ + overridden for external and weak symbols with the + -munaligned-symbols switch. + For all external symbols without explicit alignment + DECL_ALIGN is already trimmed down to 8, however for weak + symbols this does not happen. These cases are catched by the + type size check. */ + const_tree size = TYPE_SIZE (TREE_TYPE (decl)); + unsigned HOST_WIDE_INT size_num = (tree_fits_uhwi_p (size) + ? tree_to_uhwi (size) : 0); if ((DECL_USER_ALIGN (decl) && DECL_ALIGN (decl) % 16) - || (s390_unaligned_symbols_p && !decl_binds_to_current_def_p (decl))) + || (s390_unaligned_symbols_p + && !decl_binds_to_current_def_p (decl) + && (DECL_USER_ALIGN (decl) ? DECL_ALIGN (decl) % 16 : size_num < 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/config/s390/s390.opt b/gcc/config/s390/s390.opt index 901ae4beb01..a5b5aa95a12 100644 --- a/gcc/config/s390/s390.opt +++ b/gcc/config/s390/s390.opt @@ -332,7 +332,8 @@ Store all argument registers on the stack. munaligned-symbols Target Var(s390_unaligned_symbols_p) Init(0) -Assume external symbols to be potentially unaligned. By default all -symbols without explicit alignment are assumed to reside on a 2 byte -boundary as mandated by the IBM Z ABI. +Assume external symbols, whose natural alignment would be 1, to be +potentially unaligned. By default all symbols without explicit +alignment are assumed to reside on a 2 byte boundary as mandated by +the IBM Z ABI. diff --git a/gcc/testsuite/gcc.target/s390/aligned-1.c b/gcc/testsuite/gcc.target/s390/aligned-1.c index 2dc99cf66bd..3f5a2611ef1 100644 --- a/gcc/testsuite/gcc.target/s390/aligned-1.c +++ b/gcc/testsuite/gcc.target/s390/aligned-1.c @@ -1,20 +1,103 @@ -/* Even symbols without explicite alignment are assumed to reside on a +/* Even symbols without explicit alignment are assumed to reside on a 2 byte boundary, as mandated by the IBM Z ELF ABI, and therefore can be accessed using the larl instruction. */ /* { dg-do compile } */ /* { dg-options "-O3 -march=z900 -fno-section-anchors" } */ -extern unsigned char extern_implicitly_aligned; -extern unsigned char extern_explicitly_aligned __attribute__((aligned(2))); -unsigned char aligned; +extern unsigned char extern_char; +extern unsigned char extern_explicitly_aligned_char __attribute__((aligned(2))); +extern unsigned char extern_explicitly_unaligned_char __attribute__((aligned(1))); +extern unsigned char __attribute__((weak)) extern_weak_char; +extern unsigned char extern_explicitly_aligned_weak_char __attribute__((weak,aligned(2))); +extern unsigned char extern_explicitly_unaligned_weak_char __attribute__((weak,aligned(1))); -unsigned char +unsigned char normal_char; +unsigned char explicitly_unaligned_char __attribute__((aligned(1))); +unsigned char __attribute__((weak)) weak_char = 0; +unsigned char explicitly_aligned_weak_char __attribute__((weak,aligned(2))); +unsigned char explicitly_unaligned_weak_char __attribute__((weak,aligned(1))); + +extern unsigned int extern_int; +extern unsigned int extern_explicitly_aligned_int __attribute__((aligned(4))); +extern unsigned int extern_explicitly_unaligned_int __attribute__((aligned(1))); +extern unsigned int __attribute__((weak)) extern_weak_int; +extern unsigned int extern_explicitly_aligned_weak_int __attribute__((weak,aligned(4))); +extern unsigned int extern_explicitly_unaligned_weak_int __attribute__((weak,aligned(1))); + +unsigned int normal_int; +unsigned int explicitly_unaligned_int __attribute__((aligned(1))); +unsigned int __attribute__((weak)) weak_int = 0; +unsigned int explicitly_aligned_weak_int __attribute__((weak,aligned(4))); +unsigned int explicitly_unaligned_weak_int __attribute__((weak,aligned(1))); + +extern const void extern_void; +extern const void extern_explicitly_aligned_void __attribute__((aligned(2))); +extern const void extern_explicitly_unaligned_void __attribute__((aligned(1))); +extern const void __attribute__((weak)) extern_weak_void; +extern const void extern_explicitly_aligned_weak_void __attribute__((weak,aligned(2))); +extern const void extern_explicitly_unaligned_weak_void __attribute__((weak,aligned(1))); + + +unsigned int foo () { - return extern_implicitly_aligned + extern_explicitly_aligned + aligned; + return extern_char + extern_explicitly_aligned_char + + extern_explicitly_unaligned_char + + extern_weak_char + extern_explicitly_aligned_weak_char + + extern_explicitly_unaligned_weak_char + + + normal_char + explicitly_unaligned_char + + weak_char + explicitly_aligned_weak_char + + explicitly_unaligned_weak_char + + + extern_int + extern_explicitly_aligned_int + + extern_explicitly_unaligned_int + + extern_weak_int + extern_explicitly_aligned_weak_int + + extern_explicitly_unaligned_weak_int + + + normal_int + explicitly_unaligned_int + + weak_int + explicitly_aligned_weak_int + + explicitly_unaligned_weak_int; } -/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_implicitly_aligned\n" 1 } } */ -/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned\n" 1 } } */ -/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,aligned\n" 1 } } */ +const void *f1(void) { return &extern_void; } +const void *f2(void) { return &extern_explicitly_aligned_void; } +const void *f3(void) { return &extern_explicitly_unaligned_void; } +const void *f4(void) { return &extern_weak_void; } +const void *f5(void) { return &extern_explicitly_aligned_weak_void; } +const void *f6(void) { return &extern_explicitly_unaligned_weak_void; } + + +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_char\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_weak_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_weak_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_weak_char\n" 0 } } */ + +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,normal_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_unaligned_char\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,weak_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_aligned_weak_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_unaligned_weak_char\n" 0 } } */ + +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_int\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_weak_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_weak_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_weak_int\n" 0 } } */ + +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,normal_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_unaligned_int\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,weak_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_aligned_weak_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_unaligned_weak_int\n" 0 } } */ + +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_void\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_void\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_void\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_weak_void\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_weak_void\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_weak_void\n" 0 } } */ diff --git a/gcc/testsuite/gcc.target/s390/unaligned-1.c b/gcc/testsuite/gcc.target/s390/unaligned-1.c index 421330aded1..47d77160266 100644 --- a/gcc/testsuite/gcc.target/s390/unaligned-1.c +++ b/gcc/testsuite/gcc.target/s390/unaligned-1.c @@ -1,20 +1,103 @@ -/* With the -munaligned-symbols option all external symbols without - explicite alignment are assumed to be potentially unaligned and - therefore cannot be accessed with larl. */ +/* With the -munaligned-symbols option all external and weak symbols + without explicit alignment are assumed to be potentially unaligned + and therefore cannot be accessed with larl. */ /* { dg-do compile } */ /* { dg-options "-O3 -march=z900 -fno-section-anchors -munaligned-symbols" } */ -extern unsigned char extern_unaligned; -extern unsigned char extern_explicitly_aligned __attribute__((aligned(2))); -unsigned char aligned; +extern unsigned char extern_char; +extern unsigned char extern_explicitly_aligned_char __attribute__((aligned(2))); +extern unsigned char extern_explicitly_unaligned_char __attribute__((aligned(1))); +extern unsigned char __attribute__((weak)) extern_weak_char; +extern unsigned char extern_explicitly_aligned_weak_char __attribute__((weak,aligned(2))); +extern unsigned char extern_explicitly_unaligned_weak_char __attribute__((weak,aligned(1))); + +unsigned char normal_char; +unsigned char explicitly_unaligned_char __attribute__((aligned(1))); +unsigned char __attribute__((weak)) weak_char = 0; +unsigned char explicitly_aligned_weak_char __attribute__((weak,aligned(2))); +unsigned char explicitly_unaligned_weak_char __attribute__((weak,aligned(1))); + +extern unsigned int extern_int; +extern unsigned int extern_explicitly_aligned_int __attribute__((aligned(4))); +extern unsigned int extern_explicitly_unaligned_int __attribute__((aligned(1))); +extern unsigned int __attribute__((weak)) extern_weak_int; +extern unsigned int extern_explicitly_aligned_weak_int __attribute__((weak,aligned(4))); +extern unsigned int extern_explicitly_unaligned_weak_int __attribute__((weak,aligned(1))); + +unsigned int normal_int; +unsigned int explicitly_unaligned_int __attribute__((aligned(1))); +unsigned int __attribute__((weak)) weak_int = 0; +unsigned int explicitly_aligned_weak_int __attribute__((weak,aligned(4))); +unsigned int explicitly_unaligned_weak_int __attribute__((weak,aligned(1))); + +extern const void extern_void; +extern const void extern_explicitly_aligned_void __attribute__((aligned(2))); +extern const void extern_explicitly_unaligned_void __attribute__((aligned(1))); +extern const void __attribute__((weak)) extern_weak_void; +extern const void extern_explicitly_aligned_weak_void __attribute__((weak,aligned(2))); +extern const void extern_explicitly_unaligned_weak_void __attribute__((weak,aligned(1))); + unsigned char foo () { - return extern_unaligned + extern_explicitly_aligned + aligned; + return extern_char + extern_explicitly_aligned_char + + extern_explicitly_unaligned_char + + extern_weak_char + extern_explicitly_aligned_weak_char + + extern_explicitly_unaligned_weak_char + + + normal_char + explicitly_unaligned_char + + weak_char + explicitly_aligned_weak_char + + explicitly_unaligned_weak_char + + + extern_int + extern_explicitly_aligned_int + + extern_explicitly_unaligned_int + + extern_weak_int + extern_explicitly_aligned_weak_int + + extern_explicitly_unaligned_weak_int + + + normal_int + explicitly_unaligned_int + + weak_int + explicitly_aligned_weak_int + + explicitly_unaligned_weak_int; } -/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_unaligned\n" 0 } } */ -/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned\n" 1 } } */ -/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,aligned\n" 1 } } */ +const void *f1(void) { return &extern_void; } +const void *f2(void) { return &extern_explicitly_aligned_void; } +const void *f3(void) { return &extern_explicitly_unaligned_void; } +const void *f4(void) { return &extern_weak_void; } +const void *f5(void) { return &extern_explicitly_aligned_weak_void; } +const void *f6(void) { return &extern_explicitly_unaligned_weak_void; } + + +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_char\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_char\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_weak_char\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_weak_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_weak_char\n" 0 } } */ + +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,normal_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_unaligned_char\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,weak_char\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_aligned_weak_char\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_unaligned_weak_char\n" 0 } } */ + +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_int\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_weak_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_weak_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_weak_int\n" 0 } } */ + +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,normal_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_unaligned_int\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,weak_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_aligned_weak_int\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,explicitly_unaligned_weak_int\n" 0 } } */ + +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_void\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_void\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_void\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_weak_void\n" 0 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_aligned_weak_void\n" 1 } } */ +/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,extern_explicitly_unaligned_weak_void\n" 0 } } */ diff --git a/gcc/testsuite/gcc.target/s390/unaligned-2.c b/gcc/testsuite/gcc.target/s390/unaligned-2.c deleted file mode 100644 index c1ece6d5935..00000000000 --- a/gcc/testsuite/gcc.target/s390/unaligned-2.c +++ /dev/null @@ -1,16 +0,0 @@ -/* weak symbols might get overridden in another module by symbols - which are not aligned on a 2-byte boundary. Although this violates - the zABI we try to handle this gracefully by not using larl on - these symbols if -munaligned-symbols has been specified. */ - -/* { dg-do compile } */ -/* { dg-options "-O3 -march=z900 -fno-section-anchors -munaligned-symbols" } */ -unsigned char __attribute__((weak)) weaksym = 0; - -unsigned char -foo () -{ - return weaksym; -} - -/* { dg-final { scan-assembler-times "larl\t%r\[0-9\]*,weaksym\n" 0 } } */