From patchwork Thu Sep 30 08:50:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 45597 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 29FE03858C39 for ; Thu, 30 Sep 2021 08:52:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29FE03858C39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632991969; bh=gTxst+yQraz+SRe4XLt0XoIB6znJIND1avxmbfqM/mo=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=lQKFgDJXmqldWS/AbuvI4ddX+H50LdwR/jNgMDVdtoqajotd/oq5UeuyIp4dQPgoq fSzIBM2tZRf+Qg/hWoCRm8yILvgu4p8bafXSv24hRZYgLIomnkik3Grt5SsdwxuAap BAjYVemGv/+lLofNuwEelAAQndEWPzZHCcyKod8s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 994743857C63; Thu, 30 Sep 2021 08:50:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 994743857C63 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18U6VT8d000674; Thu, 30 Sep 2021 04:50:53 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0b-001b2d01.pphosted.com with ESMTP id 3bd81nk376-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Sep 2021 04:50:52 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18U8lHUG030109; Thu, 30 Sep 2021 08:50:51 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma06ams.nl.ibm.com with ESMTP id 3b9u1k1b66-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Sep 2021 08:50:50 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18U8okbi38338988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Sep 2021 08:50:46 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BFF514C070; Thu, 30 Sep 2021 08:50:46 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 873DE4C05C; Thu, 30 Sep 2021 08:50:46 +0000 (GMT) Received: from vm.lan (unknown [9.145.45.184]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 30 Sep 2021 08:50:46 +0000 (GMT) To: Andreas Krebbel Subject: [PATCH gcc-11 1/2] IBM Z: Define NO_PROFILE_COUNTERS Date: Thu, 30 Sep 2021 10:50:43 +0200 Message-Id: <20210930085044.358172-2-iii@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210930085044.358172-1-iii@linux.ibm.com> References: <20210930085044.358172-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: HmA_-keVE6NlpEgzlNsrsFR54X4EunW8 X-Proofpoint-ORIG-GUID: HmA_-keVE6NlpEgzlNsrsFR54X4EunW8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-30_02,2021-09-29_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 priorityscore=1501 malwarescore=0 adultscore=0 lowpriorityscore=0 bulkscore=0 clxscore=1015 suspectscore=0 impostorscore=0 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2109300051 X-Spam-Status: No, score=-11.0 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Ilya Leoshkevich via Gcc-patches From: Ilya Leoshkevich Reply-To: Ilya Leoshkevich Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" s390 glibc does not need counters in the .data section, since it stores edge hits in its own data structure. Therefore counters only waste space and confuse diffing tools (e.g. kpatch), so don't generate them. gcc/ChangeLog: * config/s390/s390.c (s390_function_profiler): Ignore labelno parameter. * config/s390/s390.h (NO_PROFILE_COUNTERS): Define. gcc/testsuite/ChangeLog: * gcc.target/s390/mnop-mcount-m31-mzarch.c: Adapt to the new prologue size. * gcc.target/s390/mnop-mcount-m64.c: Likewise. (cherry picked from commit a1c1b7a888a) --- gcc/config/s390/s390.c | 42 +++++++------------ gcc/config/s390/s390.h | 2 + .../gcc.target/s390/mnop-mcount-m31-mzarch.c | 2 +- .../gcc.target/s390/mnop-mcount-m64.c | 2 +- 4 files changed, 20 insertions(+), 28 deletions(-) diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index c5d4c439bcc..a863dfce9a2 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -13120,33 +13120,25 @@ output_asm_nops (const char *user, int hw) } } -/* Output assembler code to FILE to increment profiler label # LABELNO - for profiling a function entry. */ +/* Output assembler code to FILE to call a profiler hook. */ void -s390_function_profiler (FILE *file, int labelno) +s390_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) { - rtx op[8]; - - char label[128]; - ASM_GENERATE_INTERNAL_LABEL (label, "LP", labelno); + rtx op[4]; fprintf (file, "# function profiler \n"); op[0] = gen_rtx_REG (Pmode, RETURN_REGNUM); op[1] = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM); op[1] = gen_rtx_MEM (Pmode, plus_constant (Pmode, op[1], UNITS_PER_LONG)); - op[7] = GEN_INT (UNITS_PER_LONG); - - op[2] = gen_rtx_REG (Pmode, 1); - op[3] = gen_rtx_SYMBOL_REF (Pmode, label); - SYMBOL_REF_FLAGS (op[3]) = SYMBOL_FLAG_LOCAL; + op[3] = GEN_INT (UNITS_PER_LONG); - op[4] = gen_rtx_SYMBOL_REF (Pmode, flag_fentry ? "__fentry__" : "_mcount"); + op[2] = gen_rtx_SYMBOL_REF (Pmode, flag_fentry ? "__fentry__" : "_mcount"); if (flag_pic) { - op[4] = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op[4]), UNSPEC_PLT); - op[4] = gen_rtx_CONST (Pmode, op[4]); + op[2] = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op[2]), UNSPEC_PLT); + op[2] = gen_rtx_CONST (Pmode, op[2]); } if (flag_record_mcount) @@ -13160,20 +13152,19 @@ s390_function_profiler (FILE *file, int labelno) warning (OPT_Wcannot_profile, "nested functions cannot be profiled " "with %<-mfentry%> on s390"); else - output_asm_insn ("brasl\t0,%4", op); + output_asm_insn ("brasl\t0,%2", op); } else if (TARGET_64BIT) { if (flag_nop_mcount) - output_asm_nops ("-mnop-mcount", /* stg */ 3 + /* larl */ 3 + - /* brasl */ 3 + /* lg */ 3); + output_asm_nops ("-mnop-mcount", /* stg */ 3 + /* brasl */ 3 + + /* lg */ 3); else { output_asm_insn ("stg\t%0,%1", op); if (flag_dwarf2_cfi_asm) - output_asm_insn (".cfi_rel_offset\t%0,%7", op); - output_asm_insn ("larl\t%2,%3", op); - output_asm_insn ("brasl\t%0,%4", op); + output_asm_insn (".cfi_rel_offset\t%0,%3", op); + output_asm_insn ("brasl\t%0,%2", op); output_asm_insn ("lg\t%0,%1", op); if (flag_dwarf2_cfi_asm) output_asm_insn (".cfi_restore\t%0", op); @@ -13182,15 +13173,14 @@ s390_function_profiler (FILE *file, int labelno) else { if (flag_nop_mcount) - output_asm_nops ("-mnop-mcount", /* st */ 2 + /* larl */ 3 + - /* brasl */ 3 + /* l */ 2); + output_asm_nops ("-mnop-mcount", /* st */ 2 + /* brasl */ 3 + + /* l */ 2); else { output_asm_insn ("st\t%0,%1", op); if (flag_dwarf2_cfi_asm) - output_asm_insn (".cfi_rel_offset\t%0,%7", op); - output_asm_insn ("larl\t%2,%3", op); - output_asm_insn ("brasl\t%0,%4", op); + output_asm_insn (".cfi_rel_offset\t%0,%3", op); + output_asm_insn ("brasl\t%0,%2", op); output_asm_insn ("l\t%0,%1", op); if (flag_dwarf2_cfi_asm) output_asm_insn (".cfi_restore\t%0", op); diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h index 3b876160420..fb16a455a03 100644 --- a/gcc/config/s390/s390.h +++ b/gcc/config/s390/s390.h @@ -787,6 +787,8 @@ CUMULATIVE_ARGS; #define PROFILE_BEFORE_PROLOGUE 1 +#define NO_PROFILE_COUNTERS 1 + /* Trampolines for nested functions. */ diff --git a/gcc/testsuite/gcc.target/s390/mnop-mcount-m31-mzarch.c b/gcc/testsuite/gcc.target/s390/mnop-mcount-m31-mzarch.c index b2ad9f5bced..874ceb96fe8 100644 --- a/gcc/testsuite/gcc.target/s390/mnop-mcount-m31-mzarch.c +++ b/gcc/testsuite/gcc.target/s390/mnop-mcount-m31-mzarch.c @@ -4,5 +4,5 @@ void profileme (void) { - /* { dg-final { scan-assembler "NOPs for -mnop-mcount \\(10 halfwords\\)\n.*brcl\t0,0\n.*brcl\t0,0\n.*brcl\t0,0\n.*bcr\t0,0" } } */ + /* { dg-final { scan-assembler "NOPs for -mnop-mcount \\(7 halfwords\\)\n.*brcl\t0,0\n.*brcl\t0,0\n.*bcr\t0,0" } } */ } diff --git a/gcc/testsuite/gcc.target/s390/mnop-mcount-m64.c b/gcc/testsuite/gcc.target/s390/mnop-mcount-m64.c index c0e3c4e91b1..0d45834abdd 100644 --- a/gcc/testsuite/gcc.target/s390/mnop-mcount-m64.c +++ b/gcc/testsuite/gcc.target/s390/mnop-mcount-m64.c @@ -4,5 +4,5 @@ void profileme (void) { - /* { dg-final { scan-assembler "NOPs for -mnop-mcount \\(12 halfwords\\)\n.*brcl\t0,0\n.*brcl\t0,0\n.*brcl\t0,0\n.*brcl\t0,0" } } */ + /* { dg-final { scan-assembler "NOPs for -mnop-mcount \\(9 halfwords\\)\n.*brcl\t0,0\n.*brcl\t0,0\n.*brcl\t0,0" } } */ } From patchwork Thu Sep 30 08:50:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Leoshkevich X-Patchwork-Id: 45598 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EEDEC3858001 for ; Thu, 30 Sep 2021 08:53:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EEDEC3858001 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1632992033; bh=UxaB9+LL4/mx8Z6x4CPo3opfYVl2QOrgEqdrHKMtzy4=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=G4VQXR56MMge1lomqR5DSS8gHIv1YbfYy6sohinLS2tLNLYGsYeLGVFDWJcU5nxoz 5p9al9X3O5lS+kPvlzNcVlwx7/OscfDwSDb27mLX4q2YcWx3dHb3VXVOij54kAnFR9 xiJgll6LhUj/VdkVF9ahODfcSBhSzhZuKtAoPa6c= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id C6E493857C5B; Thu, 30 Sep 2021 08:50:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C6E493857C5B Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18U7UaNW011918; Thu, 30 Sep 2021 04:50:54 -0400 Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com with ESMTP id 3bd8wjhnx2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Sep 2021 04:50:53 -0400 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 18U8lFrp014565; Thu, 30 Sep 2021 08:50:52 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma06fra.de.ibm.com with ESMTP id 3b9u1kemas-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 30 Sep 2021 08:50:51 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 18U8jg1n39518488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 30 Sep 2021 08:45:42 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 629C04C04E; Thu, 30 Sep 2021 08:50:47 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 292A44C062; Thu, 30 Sep 2021 08:50:47 +0000 (GMT) Received: from vm.lan (unknown [9.145.45.184]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 30 Sep 2021 08:50:47 +0000 (GMT) To: Andreas Krebbel Subject: [PATCH gcc-11 2/2] IBM Z: Use @PLT symbols for local functions in 64-bit mode Date: Thu, 30 Sep 2021 10:50:44 +0200 Message-Id: <20210930085044.358172-3-iii@linux.ibm.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210930085044.358172-1-iii@linux.ibm.com> References: <20210930085044.358172-1-iii@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: sHO7JGK7-vlkfprKqdLt16WPz03Tdbzs X-Proofpoint-ORIG-GUID: sHO7JGK7-vlkfprKqdLt16WPz03Tdbzs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-30_02,2021-09-29_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 clxscore=1015 malwarescore=0 adultscore=0 spamscore=0 phishscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 suspectscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2109300051 X-Spam-Status: No, score=-11.0 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Ilya Leoshkevich via Gcc-patches From: Ilya Leoshkevich Reply-To: Ilya Leoshkevich Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This helps with generating code for kernel hotpatches, which contain individual functions and are loaded more than 2G away from vmlinux. This should not create performance regressions for the normal use cases, because for local functions ld replaces @PLT calls with direct calls. gcc/ChangeLog: * config/s390/predicates.md (bras_sym_operand): Accept all functions in 64-bit mode, use UNSPEC_PLT31. (larl_operand): Use UNSPEC_PLT31. * config/s390/s390.c (s390_loadrelative_operand_p): Likewise. (legitimize_pic_address): Likewise. (s390_emit_tls_call_insn): Mark __tls_get_offset as function, use UNSPEC_PLT31. (s390_delegitimize_address): Use UNSPEC_PLT31. (s390_output_addr_const_extra): Likewise. (print_operand): Add @PLT to TLS calls, handle %K. (s390_function_profiler): Mark __fentry__/_mcount as function, use %K, use UNSPEC_PLT31. (s390_output_mi_thunk): Use only UNSPEC_GOT, use %K. (s390_emit_call): Use UNSPEC_PLT31. (s390_emit_tpf_eh_return): Mark __tpf_eh_return as function. * config/s390/s390.md (UNSPEC_PLT31): Rename from UNSPEC_PLT. (*movdi_64): Use %K. (reload_base_64): Likewise. (*sibcall_brc): Likewise. (*sibcall_brcl): Likewise. (*sibcall_value_brc): Likewise. (*sibcall_value_brcl): Likewise. (*bras): Likewise. (*brasl): Likewise. (*bras_r): Likewise. (*brasl_r): Likewise. (*bras_tls): Likewise. (*brasl_tls): Likewise. (main_base_64): Likewise. (reload_base_64): Likewise. (@split_stack_call): Likewise. gcc/testsuite/ChangeLog: * g++.dg/ext/visibility/noPLT.C: Skip on s390x. * g++.target/s390/mi-thunk.C: New test. * gcc.target/s390/nodatarel-1.c: Move foostatic to the new tests. * gcc.target/s390/pr80080-4.c: Allow @PLT suffix. * gcc.target/s390/risbg-ll-3.c: Likewise. * gcc.target/s390/call.h: Common code for the new tests. * gcc.target/s390/call-z10-pic-nodatarel.c: New test. * gcc.target/s390/call-z10-pic.c: New test. * gcc.target/s390/call-z10.c: New test. * gcc.target/s390/call-z9-pic-nodatarel.c: New test. * gcc.target/s390/call-z9-pic.c: New test. * gcc.target/s390/call-z9.c: New test. * gcc.target/s390/mfentry-m64-pic.c: New test. * gcc.target/s390/tls.h: Common code for the new TLS tests. * gcc.target/s390/tls-pic.c: New test. * gcc.target/s390/tls.c: New test. (cherry picked from commit 0990d93dd8a) --- gcc/config/s390/predicates.md | 9 ++- gcc/config/s390/s390.c | 81 +++++++++++++------ gcc/config/s390/s390.md | 32 ++++---- gcc/testsuite/g++.dg/ext/visibility/noPLT.C | 2 +- gcc/testsuite/g++.target/s390/mi-thunk.C | 23 ++++++ .../gcc.target/s390/call-z10-pic-nodatarel.c | 20 +++++ gcc/testsuite/gcc.target/s390/call-z10-pic.c | 20 +++++ gcc/testsuite/gcc.target/s390/call-z10.c | 20 +++++ .../gcc.target/s390/call-z9-pic-nodatarel.c | 18 +++++ gcc/testsuite/gcc.target/s390/call-z9-pic.c | 18 +++++ gcc/testsuite/gcc.target/s390/call-z9.c | 20 +++++ gcc/testsuite/gcc.target/s390/call.h | 40 +++++++++ .../gcc.target/s390/mfentry-m64-pic.c | 9 +++ gcc/testsuite/gcc.target/s390/nodatarel-1.c | 26 +----- gcc/testsuite/gcc.target/s390/pr80080-4.c | 2 +- gcc/testsuite/gcc.target/s390/risbg-ll-3.c | 6 +- gcc/testsuite/gcc.target/s390/tls-pic.c | 14 ++++ gcc/testsuite/gcc.target/s390/tls.c | 10 +++ gcc/testsuite/gcc.target/s390/tls.h | 23 ++++++ 19 files changed, 320 insertions(+), 73 deletions(-) create mode 100644 gcc/testsuite/g++.target/s390/mi-thunk.C create mode 100644 gcc/testsuite/gcc.target/s390/call-z10-pic-nodatarel.c create mode 100644 gcc/testsuite/gcc.target/s390/call-z10-pic.c create mode 100644 gcc/testsuite/gcc.target/s390/call-z10.c create mode 100644 gcc/testsuite/gcc.target/s390/call-z9-pic-nodatarel.c create mode 100644 gcc/testsuite/gcc.target/s390/call-z9-pic.c create mode 100644 gcc/testsuite/gcc.target/s390/call-z9.c create mode 100644 gcc/testsuite/gcc.target/s390/call.h create mode 100644 gcc/testsuite/gcc.target/s390/mfentry-m64-pic.c create mode 100644 gcc/testsuite/gcc.target/s390/tls-pic.c create mode 100644 gcc/testsuite/gcc.target/s390/tls.c create mode 100644 gcc/testsuite/gcc.target/s390/tls.h diff --git a/gcc/config/s390/predicates.md b/gcc/config/s390/predicates.md index 15093cb4b30..99c343aa32c 100644 --- a/gcc/config/s390/predicates.md +++ b/gcc/config/s390/predicates.md @@ -101,10 +101,13 @@ (define_special_predicate "bras_sym_operand" (ior (and (match_code "symbol_ref") - (match_test "!flag_pic || SYMBOL_REF_LOCAL_P (op)")) + (ior (match_test "!flag_pic") + (match_test "SYMBOL_REF_LOCAL_P (op)") + (and (match_test "TARGET_64BIT") + (match_test "SYMBOL_REF_FUNCTION_P (op)")))) (and (match_code "const") (and (match_test "GET_CODE (XEXP (op, 0)) == UNSPEC") - (match_test "XINT (XEXP (op, 0), 1) == UNSPEC_PLT"))))) + (match_test "XINT (XEXP (op, 0), 1) == UNSPEC_PLT31"))))) ;; Return true if OP is a PLUS that is not a legitimate ;; operand for the LA instruction. @@ -197,7 +200,7 @@ && XINT (op, 1) == UNSPEC_GOTENT) return true; if (GET_CODE (op) == UNSPEC - && XINT (op, 1) == UNSPEC_PLT) + && XINT (op, 1) == UNSPEC_PLT31) return true; if (GET_CODE (op) == UNSPEC && XINT (op, 1) == UNSPEC_INDNTPOFF) diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index a863dfce9a2..8895dd7cc76 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -3291,7 +3291,7 @@ s390_loadrelative_operand_p (rtx addr, rtx *symref, HOST_WIDE_INT *addend) if (GET_CODE (addr) == SYMBOL_REF || (GET_CODE (addr) == UNSPEC && (XINT (addr, 1) == UNSPEC_GOTENT - || XINT (addr, 1) == UNSPEC_PLT))) + || XINT (addr, 1) == UNSPEC_PLT31))) { if (symref) *symref = addr; @@ -4964,7 +4964,7 @@ legitimize_pic_address (rtx orig, rtx reg) || (SYMBOL_REF_P (addr) && s390_rel_address_ok_p (addr)) || (GET_CODE (addr) == UNSPEC && (XINT (addr, 1) == UNSPEC_GOTENT - || XINT (addr, 1) == UNSPEC_PLT))) + || XINT (addr, 1) == UNSPEC_PLT31))) && GET_CODE (addend) == CONST_INT) { /* This can be locally addressed. */ @@ -5125,7 +5125,7 @@ legitimize_pic_address (rtx orig, rtx reg) /* For @PLT larl is used. This is handled like local symbol refs. */ - case UNSPEC_PLT: + case UNSPEC_PLT31: gcc_unreachable (); break; @@ -5191,7 +5191,10 @@ s390_emit_tls_call_insn (rtx result_reg, rtx tls_call) emit_insn (s390_load_got ()); if (!s390_tls_symbol) - s390_tls_symbol = gen_rtx_SYMBOL_REF (Pmode, "__tls_get_offset"); + { + s390_tls_symbol = gen_rtx_SYMBOL_REF (Pmode, "__tls_get_offset"); + SYMBOL_REF_FLAGS (s390_tls_symbol) |= SYMBOL_FLAG_FUNCTION; + } insn = s390_emit_call (s390_tls_symbol, tls_call, result_reg, gen_rtx_REG (Pmode, RETURN_REGNUM)); @@ -7606,7 +7609,7 @@ s390_delegitimize_address (rtx orig_x) y = XEXP (x, 0); if (GET_CODE (y) == UNSPEC && (XINT (y, 1) == UNSPEC_GOTENT - || XINT (y, 1) == UNSPEC_PLT)) + || XINT (y, 1) == UNSPEC_PLT31)) y = XVECEXP (y, 0, 0); else return orig_x; @@ -7859,7 +7862,7 @@ s390_output_addr_const_extra (FILE *file, rtx x) output_addr_const (file, XVECEXP (x, 0, 0)); fprintf (file, "@GOTOFF"); return true; - case UNSPEC_PLT: + case UNSPEC_PLT31: output_addr_const (file, XVECEXP (x, 0, 0)); fprintf (file, "@PLT"); return true; @@ -7953,6 +7956,7 @@ print_operand_address (FILE *file, rtx addr) 'E': print opcode suffix for branch on index instruction. 'G': print the size of the operand in bytes. 'J': print tls_load/tls_gdcall/tls_ldcall suffix + 'K': print @PLT suffix for call targets and load address values. 'M': print the second word of a TImode operand. 'N': print the second word of a DImode operand. 'O': print only the displacement of a memory reference or address. @@ -8139,6 +8143,29 @@ print_operand (FILE *file, rtx x, int code) case 'Y': print_shift_count_operand (file, x); return; + + case 'K': + /* Append @PLT to both local and non-local symbols in order to support + Linux Kernel livepatching: patches contain individual functions and + are loaded further than 2G away from vmlinux, and therefore they must + call even static functions via PLT. ld will optimize @PLT away for + normal code, and keep it for patches. + + Do not indiscriminately add @PLT in 31-bit mode due to the %r12 + restriction, use UNSPEC_PLT31 instead. + + @PLT only makes sense for functions, data is taken care of by + -mno-pic-data-is-text-relative. + + Adding @PLT interferes with handling of weak symbols in non-PIC code, + since their addresses are loaded with larl, which then always produces + a non-NULL result, so skip them here as well. */ + if (TARGET_64BIT + && GET_CODE (x) == SYMBOL_REF + && SYMBOL_REF_FUNCTION_P (x) + && !(SYMBOL_REF_WEAK (x) && !flag_pic)) + fprintf (file, "@PLT"); + return; } switch (GET_CODE (x)) @@ -13135,9 +13162,10 @@ s390_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) op[3] = GEN_INT (UNITS_PER_LONG); op[2] = gen_rtx_SYMBOL_REF (Pmode, flag_fentry ? "__fentry__" : "_mcount"); - if (flag_pic) + SYMBOL_REF_FLAGS (op[2]) |= SYMBOL_FLAG_FUNCTION; + if (flag_pic && !TARGET_64BIT) { - op[2] = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op[2]), UNSPEC_PLT); + op[2] = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op[2]), UNSPEC_PLT31); op[2] = gen_rtx_CONST (Pmode, op[2]); } @@ -13152,7 +13180,7 @@ s390_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) warning (OPT_Wcannot_profile, "nested functions cannot be profiled " "with %<-mfentry%> on s390"); else - output_asm_insn ("brasl\t0,%2", op); + output_asm_insn ("brasl\t0,%2%K2", op); } else if (TARGET_64BIT) { @@ -13164,7 +13192,7 @@ s390_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) output_asm_insn ("stg\t%0,%1", op); if (flag_dwarf2_cfi_asm) output_asm_insn (".cfi_rel_offset\t%0,%3", op); - output_asm_insn ("brasl\t%0,%2", op); + output_asm_insn ("brasl\t%0,%2%K2", op); output_asm_insn ("lg\t%0,%1", op); if (flag_dwarf2_cfi_asm) output_asm_insn (".cfi_restore\t%0", op); @@ -13180,7 +13208,7 @@ s390_function_profiler (FILE *file, int labelno ATTRIBUTE_UNUSED) output_asm_insn ("st\t%0,%1", op); if (flag_dwarf2_cfi_asm) output_asm_insn (".cfi_rel_offset\t%0,%3", op); - output_asm_insn ("brasl\t%0,%2", op); + output_asm_insn ("brasl\t%0,%2%K2", op); output_asm_insn ("l\t%0,%1", op); if (flag_dwarf2_cfi_asm) output_asm_insn (".cfi_restore\t%0", op); @@ -13256,9 +13284,11 @@ s390_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED, if (flag_pic && !SYMBOL_REF_LOCAL_P (op[0])) { nonlocal = 1; - op[0] = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op[0]), - TARGET_64BIT ? UNSPEC_PLT : UNSPEC_GOT); - op[0] = gen_rtx_CONST (Pmode, op[0]); + if (!TARGET_64BIT) + { + op[0] = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, op[0]), UNSPEC_GOT); + op[0] = gen_rtx_CONST (Pmode, op[0]); + } } /* Operand 1 is the 'this' pointer. */ @@ -13348,7 +13378,7 @@ s390_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED, } /* Jump to target. */ - output_asm_insn ("jg\t%0", op); + output_asm_insn ("jg\t%0%K0", op); /* Output literal pool if required. */ if (op[5]) @@ -13739,7 +13769,7 @@ rtx_insn * s390_emit_call (rtx addr_location, rtx tls_call, rtx result_reg, rtx retaddr_reg) { - bool plt_call = false; + bool plt31_call_p = false; rtx_insn *insn; rtx vec[4] = { NULL_RTX }; int elts = 0; @@ -13754,15 +13784,15 @@ s390_emit_call (rtx addr_location, rtx tls_call, rtx result_reg, { /* When calling a global routine in PIC mode, we must replace the symbol itself with the PLT stub. */ - if (flag_pic && !SYMBOL_REF_LOCAL_P (addr_location)) + if (flag_pic && !SYMBOL_REF_LOCAL_P (addr_location) && !TARGET_64BIT) { - if (TARGET_64BIT || retaddr_reg != NULL_RTX) + if (retaddr_reg != NULL_RTX) { addr_location = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, addr_location), - UNSPEC_PLT); + UNSPEC_PLT31); addr_location = gen_rtx_CONST (Pmode, addr_location); - plt_call = true; + plt31_call_p = true; } else /* For -fpic code the PLT entries might use r12 which is @@ -13783,7 +13813,7 @@ s390_emit_call (rtx addr_location, rtx tls_call, rtx result_reg, register 1. */ if (retaddr_reg == NULL_RTX && GET_CODE (addr_location) != SYMBOL_REF - && !plt_call) + && !plt31_call_p) { emit_move_insn (gen_rtx_REG (Pmode, SIBCALL_REGNUM), addr_location); addr_location = gen_rtx_REG (Pmode, SIBCALL_REGNUM); @@ -13791,7 +13821,7 @@ s390_emit_call (rtx addr_location, rtx tls_call, rtx result_reg, if (TARGET_INDIRECT_BRANCH_NOBP_CALL && GET_CODE (addr_location) != SYMBOL_REF - && !plt_call) + && !plt31_call_p) { /* Indirect branch thunks require the target to be a single GPR. */ addr_location = force_reg (Pmode, addr_location); @@ -13843,7 +13873,7 @@ s390_emit_call (rtx addr_location, rtx tls_call, rtx result_reg, insn = emit_call_insn (*call); /* 31-bit PLT stubs and tls calls use the GOT register implicitly. */ - if ((!TARGET_64BIT && plt_call) || tls_call != NULL_RTX) + if (plt31_call_p || tls_call != NULL_RTX) { /* s390_function_ok_for_sibcall should have denied sibcalls in this case. */ @@ -13899,7 +13929,10 @@ s390_emit_tpf_eh_return (rtx target) rtx reg, orig_ra; if (!s390_tpf_eh_return_symbol) - s390_tpf_eh_return_symbol = gen_rtx_SYMBOL_REF (Pmode, "__tpf_eh_return"); + { + s390_tpf_eh_return_symbol = gen_rtx_SYMBOL_REF (Pmode, "__tpf_eh_return"); + SYMBOL_REF_FLAGS (s390_tpf_eh_return_symbol) |= SYMBOL_FLAG_FUNCTION; + } reg = gen_rtx_REG (Pmode, 2); orig_ra = gen_rtx_REG (Pmode, 3); diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 7faf775fbf2..21f902b143c 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -79,7 +79,7 @@ UNSPEC_GOTENT UNSPEC_GOT UNSPEC_GOTOFF - UNSPEC_PLT + UNSPEC_PLT31 UNSPEC_PLTOFF ; Literal pool @@ -1906,7 +1906,7 @@ vlgvg\t%0,%v1,0 vleg\t%v0,%1,0 vsteg\t%v1,%0,0 - larl\t%0,%1" + larl\t%0,%1%K1" [(set_attr "op_type" "RI,RI,RI,RI,RI,RIL,RIL,RIL,RRE,RRE,RRE,RXY,RIL,RRE,RXY, RXY,RR,RX,RXY,RX,RXY,RIL,SIL,*,*,RS,RS,VRI,VRR,VRS,VRS, VRX,VRX,RIL") @@ -2180,7 +2180,7 @@ (match_operand:SI 1 "larl_operand" "X"))] "!TARGET_64BIT && !FP_REG_P (operands[0])" - "larl\t%0,%1" + "larl\t%0,%1%K1" [(set_attr "op_type" "RIL") (set_attr "type" "larl") (set_attr "z10prop" "z10_fwd_A1") @@ -10379,7 +10379,7 @@ [(call (mem:QI (match_operand 0 "bras_sym_operand" "X")) (match_operand 1 "const_int_operand" "n"))] "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC" - "j\t%0" + "j\t%0%K0" [(set_attr "op_type" "RI") (set_attr "type" "branch")]) @@ -10387,7 +10387,7 @@ [(call (mem:QI (match_operand 0 "bras_sym_operand" "X")) (match_operand 1 "const_int_operand" "n"))] "SIBLING_CALL_P (insn)" - "jg\t%0" + "jg\t%0%K0" [(set_attr "op_type" "RIL") (set_attr "type" "branch")]) @@ -10440,7 +10440,7 @@ (call (mem:QI (match_operand 1 "bras_sym_operand" "X")) (match_operand 2 "const_int_operand" "n")))] "SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC" - "j\t%1" + "j\t%1%K1" [(set_attr "op_type" "RI") (set_attr "type" "branch")]) @@ -10449,7 +10449,7 @@ (call (mem:QI (match_operand 1 "bras_sym_operand" "X")) (match_operand 2 "const_int_operand" "n")))] "SIBLING_CALL_P (insn)" - "jg\t%1" + "jg\t%1%K1" [(set_attr "op_type" "RIL") (set_attr "type" "branch")]) @@ -10476,7 +10476,7 @@ "!SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC && GET_MODE (operands[2]) == Pmode" - "bras\t%2,%0" + "bras\t%2,%0%K0" [(set_attr "op_type" "RI") (set_attr "type" "jsr") (set_attr "z196prop" "z196_cracked")]) @@ -10488,7 +10488,7 @@ "!SIBLING_CALL_P (insn) && GET_MODE (operands[2]) == Pmode" - "brasl\t%2,%0" + "brasl\t%2,%0%K0" [(set_attr "op_type" "RIL") (set_attr "type" "jsr") (set_attr "z196prop" "z196_cracked") @@ -10582,7 +10582,7 @@ "!SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC && GET_MODE (operands[3]) == Pmode" - "bras\t%3,%1" + "bras\t%3,%1%K1" [(set_attr "op_type" "RI") (set_attr "type" "jsr") (set_attr "z196prop" "z196_cracked")]) @@ -10595,7 +10595,7 @@ "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode" - "brasl\t%3,%1" + "brasl\t%3,%1%K1" [(set_attr "op_type" "RIL") (set_attr "type" "jsr") (set_attr "z196prop" "z196_cracked") @@ -10726,7 +10726,7 @@ "!SIBLING_CALL_P (insn) && TARGET_SMALL_EXEC && GET_MODE (operands[3]) == Pmode" - "bras\t%3,%1%J4" + "bras\t%3,%1%K1%J4" [(set_attr "op_type" "RI") (set_attr "type" "jsr") (set_attr "z196prop" "z196_cracked")]) @@ -10740,7 +10740,7 @@ "!SIBLING_CALL_P (insn) && GET_MODE (operands[3]) == Pmode" - "brasl\t%3,%1%J4" + "brasl\t%3,%1%K1%J4" [(set_attr "op_type" "RIL") (set_attr "type" "jsr") (set_attr "z196prop" "z196_cracked") @@ -11349,7 +11349,7 @@ [(set (match_operand 0 "register_operand" "=a") (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_MAIN_BASE))] "GET_MODE (operands[0]) == Pmode" - "larl\t%0,%1" + "larl\t%0,%1%K1" [(set_attr "op_type" "RIL") (set_attr "type" "larl") (set_attr "z10prop" "z10_fwd_A1") @@ -11369,7 +11369,7 @@ [(set (match_operand 0 "register_operand" "=a") (unspec [(label_ref (match_operand 1 "" ""))] UNSPEC_RELOAD_BASE))] "GET_MODE (operands[0]) == Pmode" - "larl\t%0,%1" + "larl\t%0,%1%K1" [(set_attr "op_type" "RIL") (set_attr "type" "larl") (set_attr "z10prop" "z10_fwd_A1")]) @@ -12226,7 +12226,7 @@ "" { s390_output_split_stack_data (operands[1], operands[2], operands[3], operands[4]); - return "jg\t%0"; + return "jg\t%0%K0"; } [(set_attr "op_type" "RIL") (set_attr "type" "branch")]) diff --git a/gcc/testsuite/g++.dg/ext/visibility/noPLT.C b/gcc/testsuite/g++.dg/ext/visibility/noPLT.C index 38af05fd6e3..b888303d56d 100644 --- a/gcc/testsuite/g++.dg/ext/visibility/noPLT.C +++ b/gcc/testsuite/g++.dg/ext/visibility/noPLT.C @@ -1,5 +1,5 @@ /* Test that -fvisibility=hidden prevents PLT. */ -/* { dg-do compile { target fpic } } */ +/* { dg-do compile { target { fpic && { ! s390x-*-* } } } } */ /* { dg-require-visibility "" } */ /* { dg-options "-fPIC -fvisibility=hidden" } */ /* { dg-final { scan-assembler-not "methodEv@PLT|indirect_symbol.*methodEv" } } */ diff --git a/gcc/testsuite/g++.target/s390/mi-thunk.C b/gcc/testsuite/g++.target/s390/mi-thunk.C new file mode 100644 index 00000000000..7c25dc04bba --- /dev/null +++ b/gcc/testsuite/g++.target/s390/mi-thunk.C @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -fPIC" } */ + +class A { +public: + virtual int a (void); +}; + +class B { +public: + virtual int b (void); +}; + +class C : public B, public A { +public: + virtual int a (void); +}; + +int C::a (void) { return b(); } + +/* { dg-final { scan-assembler {\n_ZThn8_N1C1aEv:\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {\n_ZThn4_N1C1aEv:\n} { target { ! lp64 } } } } */ +/* { dg-final { scan-assembler {\n\tjg\t.LTHUNK0@PLT\n} { target lp64 } } } */ diff --git a/gcc/testsuite/gcc.target/s390/call-z10-pic-nodatarel.c b/gcc/testsuite/gcc.target/s390/call-z10-pic-nodatarel.c new file mode 100644 index 00000000000..49984614bc6 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/call-z10-pic-nodatarel.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -march=z10 -mzarch -fPIC -mno-pic-data-is-text-relative" } */ + +#include "call.h" + +/* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} } } */ +/* { dg-final { scan-assembler {lgrl\t%r2,foo@GOTENT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {lrl\t%r2,foo@GOTENT\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,fooweak@PLT\n} } } */ +/* { dg-final { scan-assembler {lgrl\t%r2,fooweak@GOTENT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {lrl\t%r2,fooweak@GOTENT\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {foos:\n\t.quad\tfoo\n\t.quad\tfoostatic\n\t.quad\tfooweak\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {foos:\n\t.long\tfoo\n\t.long\tfoostatic\n\t.long\tfooweak\n} { target { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.target/s390/call-z10-pic.c b/gcc/testsuite/gcc.target/s390/call-z10-pic.c new file mode 100644 index 00000000000..210c56cc4ca --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/call-z10-pic.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -march=z10 -mzarch -fPIC" } */ + +#include "call.h" + +/* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} } } */ +/* { dg-final { scan-assembler {lgrl\t%r2,foo@GOTENT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {lrl\t%r2,foo@GOTENT\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,fooweak@PLT\n} } } */ +/* { dg-final { scan-assembler {lgrl\t%r2,fooweak@GOTENT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {lrl\t%r2,fooweak@GOTENT\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {foos:\n\t.quad\tfoo\n\t.quad\tfoostatic\n\t.quad\tfooweak\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {foos:\n\t.long\tfoo\n\t.long\tfoostatic\n\t.long\tfooweak\n} { target { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.target/s390/call-z10.c b/gcc/testsuite/gcc.target/s390/call-z10.c new file mode 100644 index 00000000000..2d7dc735df4 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/call-z10.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -march=z10 -mzarch" } */ + +#include "call.h" + +/* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,foo\n} { target { ! lp64 } } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foo@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foo\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,fooweak\n} } } */ +/* { dg-final { scan-assembler {larl\t%r2,fooweak\n} } } */ + +/* { dg-final { scan-assembler {foos:\n\t.quad\tfoo\n\t.quad\tfoostatic\n\t.quad\tfooweak\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {foos:\n\t.long\tfoo\n\t.long\tfoostatic\n\t.long\tfooweak\n} { target { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.target/s390/call-z9-pic-nodatarel.c b/gcc/testsuite/gcc.target/s390/call-z9-pic-nodatarel.c new file mode 100644 index 00000000000..b1ae318d3e9 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/call-z9-pic-nodatarel.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -march=z9-ec -fPIC -mno-pic-data-is-text-relative" } */ + +#include "call.h" + +/* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} } } */ +/* { dg-final { scan-assembler {larl\t%r\d+,foo@GOTENT\n} } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,fooweak@PLT\n} } } */ +/* { dg-final { scan-assembler {larl\t%r\d+,fooweak@GOTENT\n} } } */ + +/* { dg-final { scan-assembler {foos:\n\t.quad\tfoo\n\t.quad\tfoostatic\n\t.quad\tfooweak\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {foos:\n\t.long\tfoo\n\t.long\tfoostatic\n\t.long\tfooweak\n} { target { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.target/s390/call-z9-pic.c b/gcc/testsuite/gcc.target/s390/call-z9-pic.c new file mode 100644 index 00000000000..a89e78d8df8 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/call-z9-pic.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -march=z9-ec -fPIC" } */ + +#include "call.h" + +/* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} } } */ +/* { dg-final { scan-assembler {larl\t%r\d+,foo@GOTENT\n} } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,fooweak@PLT\n} } } */ +/* { dg-final { scan-assembler {larl\t%r\d+,fooweak@GOTENT\n} } } */ + +/* { dg-final { scan-assembler {foos:\n\t.quad\tfoo\n\t.quad\tfoostatic\n\t.quad\tfooweak\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {foos:\n\t.long\tfoo\n\t.long\tfoostatic\n\t.long\tfooweak\n} { target { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.target/s390/call-z9.c b/gcc/testsuite/gcc.target/s390/call-z9.c new file mode 100644 index 00000000000..21d035aecb6 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/call-z9.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -march=z9-ec" } */ + +#include "call.h" + +/* { dg-final { scan-assembler {brasl\t%r\d+,foo@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,foo\n} { target { ! lp64 } } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foo@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foo\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {brasl\t%r\d+,foostatic\n} { target { ! lp64 } } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic@PLT\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {larl\t%r2,foostatic\n} { target { ! lp64 } } } } */ + +/* { dg-final { scan-assembler {brasl\t%r\d+,fooweak\n} } } */ +/* { dg-final { scan-assembler {larl\t%r2,fooweak\n} } } */ + +/* { dg-final { scan-assembler {foos:\n\t.quad\tfoo\n\t.quad\tfoostatic\n\t.quad\tfooweak\n} { target lp64 } } } */ +/* { dg-final { scan-assembler {foos:\n\t.long\tfoo\n\t.long\tfoostatic\n\t.long\tfooweak\n} { target { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.target/s390/call.h b/gcc/testsuite/gcc.target/s390/call.h new file mode 100644 index 00000000000..059a6722887 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/call.h @@ -0,0 +1,40 @@ +/* Common code for testing the function call code generation. */ + +__attribute__ ((noipa)) void +foo (void) +{ + return; +} + +void * +usefoo (void) +{ + foo (); + return foo; +} + +__attribute__ ((noipa)) static void +foostatic (void) +{ + return; +} + +void * +usefoostatic (void) +{ + foostatic (); + return foostatic; +} + +__attribute__ ((weak)) void fooweak (void); + +void * +usefooweak (void) +{ + fooweak (); + return fooweak; +} + +__attribute__ ((__used__, section (".foos"), aligned (sizeof (void *)))) +static void +*foos[] = { foo, foostatic, fooweak }; diff --git a/gcc/testsuite/gcc.target/s390/mfentry-m64-pic.c b/gcc/testsuite/gcc.target/s390/mfentry-m64-pic.c new file mode 100644 index 00000000000..32d55ce2b75 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/mfentry-m64-pic.c @@ -0,0 +1,9 @@ +/* { dg-do compile { target { lp64 } } } */ +/* { dg-options "-pg -mfentry -fPIC" } */ + +void +profileme (void) +{ + /* __fentry__ must be referenced through PLT. */ + /* { dg-final { scan-assembler "brasl\t0,__fentry__@PLT\n" } } */ +} diff --git a/gcc/testsuite/gcc.target/s390/nodatarel-1.c b/gcc/testsuite/gcc.target/s390/nodatarel-1.c index f53332f901d..02e64c3eddf 100644 --- a/gcc/testsuite/gcc.target/s390/nodatarel-1.c +++ b/gcc/testsuite/gcc.target/s390/nodatarel-1.c @@ -15,12 +15,6 @@ foo () return a; } -static int __attribute__((noinline,noclone)) -foostatic (void) -{ - return a; -} - /* Just to make a potentially modified. */ void @@ -29,7 +23,7 @@ bar (int b) a = b; } -/* { dg-final { scan-assembler-times "\\.LANCHOR\\d+@GOTENT" 3 } } */ +/* { dg-final { scan-assembler-times "\\.LANCHOR\\d+@GOTENT" 2 } } */ /* The exrl target is a label_ref which should not be affected at all. */ @@ -63,21 +57,3 @@ fooptr () } /* { dg-final { scan-assembler-times "foo@GOTENT" 1 } } */ - - -/* A static function can be addressed relatively. */ - -int -callfoostatic () -{ - return foostatic (); -} - -void * -foostaticptr () -{ - return &foostatic; -} - - -/* { dg-final { scan-assembler-not "foostatic@" } } */ diff --git a/gcc/testsuite/gcc.target/s390/pr80080-4.c b/gcc/testsuite/gcc.target/s390/pr80080-4.c index 5fc6a558008..3f16a197764 100644 --- a/gcc/testsuite/gcc.target/s390/pr80080-4.c +++ b/gcc/testsuite/gcc.target/s390/pr80080-4.c @@ -13,4 +13,4 @@ void foo4(int *mem) } } -/* { dg-final { scan-assembler {(?n)\n\tlt\t.*\n\tjne\t(\.L\d+)\n(.*\n)*\tcs\t.*\n\tber\t%r14\n\1:\n\tjg\tbar\n} } } */ +/* { dg-final { scan-assembler {(?n)\n\tlt\t.*\n\tjne\t(\.L\d+)\n(.*\n)*\tcs\t.*\n\tber\t%r14\n\1:\n\tjg\tbar(@PLT)?\n} } } */ diff --git a/gcc/testsuite/gcc.target/s390/risbg-ll-3.c b/gcc/testsuite/gcc.target/s390/risbg-ll-3.c index 90d37f2c1ce..02f6e046eb9 100644 --- a/gcc/testsuite/gcc.target/s390/risbg-ll-3.c +++ b/gcc/testsuite/gcc.target/s390/risbg-ll-3.c @@ -23,7 +23,7 @@ i64 f1 (i64 v_a, i64 v_b) extern i64 f2_foo(); i64 f2 (i64 v_a, i64 v_b) { -/* { dg-final { scan-assembler "f2:\n\trisbg\t%r2,%r3,60,62,0\n\tbner\t%r14\n\tjg\tf2_foo\n" { target { lp64 } } } } */ +/* { dg-final { scan-assembler "f2:\n\trisbg\t%r2,%r3,60,62,0\n\tbner\t%r14\n\tjg\tf2_foo.*\n" { target { lp64 } } } } */ /* { dg-final { scan-assembler "f2:\n\trisbgn\t%r3,%r2,0,0\\\+32-1,64-0-32\n\trisbg\t%r3,%r5,60,62,0" { target { ! lp64 } } } } */ i64 v_anda = v_a & -15; i64 v_andb = v_b & 14; @@ -37,8 +37,8 @@ i64 f2 (i64 v_a, i64 v_b) void f2_bar (); void f2_cconly (i64 v_a, i64 v_b) { -/* { dg-final { scan-assembler "f2_cconly:\n\trisbg\t%r3,%r2,63,59,0\n\tber\t%r14\n\tjg\tf2_bar\n" { target { lp64 } } } } */ -/* { dg-final { scan-assembler "f2_cconly:\n\trisbgn\t%r3,%r2,0,0\\\+32-1,64-0-32\n\trisbg\t%r3,%r5,60,62,0\n\tber\t%r14\n\tjg\tf2_bar\n" { target { ! lp64 } } } } */ +/* { dg-final { scan-assembler "f2_cconly:\n\trisbg\t%r2,%r3,60,62,0\n\tber\t%r14\n\tjg\tf2_bar(@PLT)?\n" { target { lp64 } } } } */ +/* { dg-final { scan-assembler "f2_cconly:\n\trisbgn\t%r3,%r2,0,0\\\+32-1,64-0-32\n\trisbg\t%r3,%r5,60,62,0\n\tber\t%r14\n\tjg\tf2_bar(@PLT)?\n" { target { ! lp64 } } } } */ if ((v_a & -15) | (v_b & 14)) f2_bar(); } diff --git a/gcc/testsuite/gcc.target/s390/tls-pic.c b/gcc/testsuite/gcc.target/s390/tls-pic.c new file mode 100644 index 00000000000..17c5726be4f --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/tls-pic.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fPIC" } */ + +#include "tls.h" + +/* foo must use the global dynamic model. + __tls_get_offset must be referenced through PLT. */ + +/* { dg-final { scan-assembler-times {\tbrasl\t%r14,__tls_get_offset@PLT:tls_gdcall:foo\n} 1 } } */ + +/* foostatic must use the local dynamic model. + __tls_get_offset must be referenced through PLT. */ + +/* { dg-final { scan-assembler-times {\tbrasl\t%r14,__tls_get_offset@PLT:tls_ldcall} 1 } } */ diff --git a/gcc/testsuite/gcc.target/s390/tls.c b/gcc/testsuite/gcc.target/s390/tls.c new file mode 100644 index 00000000000..3d479d8e48f --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/tls.c @@ -0,0 +1,10 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +#include "tls.h" + +/* foo must use the initial-exec model, foostatic must use the local-exec + model. */ + +/* { dg-final { scan-assembler-times {\tear} 4 { target lp64 } } } */ +/* { dg-final { scan-assembler-times {\tear} 2 { target { ! lp64 } } } } */ diff --git a/gcc/testsuite/gcc.target/s390/tls.h b/gcc/testsuite/gcc.target/s390/tls.h new file mode 100644 index 00000000000..f639bd38c8d --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/tls.h @@ -0,0 +1,23 @@ +/* Common code for testing the TLS code generation. */ + +__thread int +foo; + +int +setfoo (int x) +{ + int result = foo; + foo = x; + return result; +} + +static __thread int +foostatic; + +int +setfoostatic (int x) +{ + int result = foostatic; + foostatic = x; + return result; +}