From patchwork Sun Feb 25 21:14:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1903979 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=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=fT7qC8KI; 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 4Tjc320fDwz23cm for ; Mon, 26 Feb 2024 08:15:09 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E82C13858C24 for ; Sun, 25 Feb 2024 21:15:07 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id 948883858D3C for ; Sun, 25 Feb 2024 21:14:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 948883858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 948883858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708895684; cv=none; b=kP/dHHE5IlQHPNjNc33E2iRz4K+ULDwzbTh7+DhAszdgeh7SOWep7Cra5yphGhIhq0CWJLXZNzTCVpQiex6g+SMM4zVLLaTeksrtCVV3xrJWi6ZZOv+YbC6+QOlqGbqeUe4f2CsLZ3JdJT9bLj+cpqpGpAjYGQcvcJ1ZUs6MeP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708895684; c=relaxed/simple; bh=Yh86ysARS4DGqSL53dw71eHukYfw8Z6tvFc4FFsuCjU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=GnVhRhdcQKeEk8nehG+DL3W4X9Zr8gOkenTMDmBkuJM747Pv6cGJcvcTprvT8QF12o8o1KbgbTfzB2WsEWkflmn8MurDJjuY0AQmijiQ7GvppGK1CvBA938BJEQBePzO7n9bTSNTQK0bkecpo2/QoxNEGRBhxrT2Zml4e3pXKjI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-5dbf7b74402so2017014a12.0 for ; Sun, 25 Feb 2024 13:14:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708895681; x=1709500481; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ci049eZALRaAy/6dI8zvIgX+8nJX3PhOIgOiwDh1qcQ=; b=fT7qC8KIZez+8GmsYdwLsbyMrzu2d8NHya1IL0cm4M17+0kgafQwMEl8YEO6NYM11e oQOIOqYvFt64my48plDXKBmHFfWeBpT6YnFBqGA+krCD2CaEteRB37O/naZe//OGS7hy zLS05SdROoFH1pjKUHzrWlIYG+j72IG8eYhGx3an2o7P2io+yH7mPJXYTNTn/pfVPfJu wxYsc7I6fd9Neyp86SZVjzehjCkqFFdR66dEwgL04vKjykYm6iaKRbeZL+y3rnSeHOzR 1kEtmOIvQUKhN42x8DgWpXQBNQ4pR5cZHeNKRoFEVsBmx+ajHvSVRJEV9yWqVRwskp+f ugxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708895681; x=1709500481; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ci049eZALRaAy/6dI8zvIgX+8nJX3PhOIgOiwDh1qcQ=; b=AuucE/wBiq53buyaSQuxZABGzZSfhjasxE8ONlZn0ARhnjEd1ApYN+lZWUuTrO52n3 qmffiAoX5s14paiU1BZZWgu211H/vom2N87cNl3xqPNt5zrwpS6DkPuD29amQUpQCXCl GVsC5X5XChQfp4aehAj4loL4veZEdGmwKIOcyBibdzV/cpN6kOkrDc3k7TP+XigY0OOi kWhvqNro1SMCzv/xHI+3sk7Aio1E8JEmxzUd0ctJJxl1H+5mWG0Jd2I8ePiHGutXFUdS 27dftQpSzpjTRES/IiqqlMXDMoZU6IDd9E32SzhQp35tnzSWcKsiOmRT67bZJw9hfnrK 6JtA== X-Gm-Message-State: AOJu0YyRDR+u4e70DTCrb1xoSSBx9tLFCe1fEiN9Ah/rUqmjRcFIA2f/ XH5McrPwPasgh3F23DMxo6KsqPO6SztvUwRDWdY9LLcolo7PY5S4eIYwoy9Q X-Google-Smtp-Source: AGHT+IFrD6ipqQolTGLwKOaLaiVQHTHafXe77ZZJwd0PW2VOOPRb0GKDG4OISstgEyDPoKxSWMJksQ== X-Received: by 2002:a05:6a21:2d8c:b0:1a0:f096:4ece with SMTP id ty12-20020a056a212d8c00b001a0f0964ecemr2771296pzb.2.1708895681064; Sun, 25 Feb 2024 13:14:41 -0800 (PST) Received: from gnu-cfl-3.localdomain ([172.58.89.72]) by smtp.gmail.com with ESMTPSA id v4-20020a1709028d8400b001dc90b62393sm1465854plo.216.2024.02.25.13.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 13:14:40 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 846857403EB; Sun, 25 Feb 2024 13:14:39 -0800 (PST) From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: ubizjak@gmail.com, hongtao.liu@intel.com Subject: [PATCH v2] x86: Check interrupt instead of noreturn attribute Date: Sun, 25 Feb 2024 13:14:39 -0800 Message-ID: <20240225211439.3553007-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Spam-Status: No, score=-3021.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, 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 ix86_set_func_type checks noreturn attribute to avoid incompatible attribute error in LTO1 on interrupt functions. Since TREE_THIS_VOLATILE is set also for _Noreturn without noreturn attribute, check interrupt attribute for interrupt functions instead. gcc/ PR target/114097 * config/i386/i386-options.cc (ix86_set_func_type): Check interrupt instead of noreturn attribute. gcc/testsuite/ PR target/114097 * gcc.target/i386/pr114097-1.c: New test. --- gcc/config/i386/i386-options.cc | 8 ++++--- gcc/testsuite/gcc.target/i386/pr114097-1.c | 26 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr114097-1.c diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc index 93a01146db7..1301f6b913e 100644 --- a/gcc/config/i386/i386-options.cc +++ b/gcc/config/i386/i386-options.cc @@ -3391,11 +3391,13 @@ ix86_set_func_type (tree fndecl) into a noreturn function by setting TREE_THIS_VOLATILE. Normally the local-pure-const pass is run after ix86_set_func_type is called. When the local-pure-const pass is enabled for LTO, the interrupt - function is marked as noreturn in the IR output, which leads the - incompatible attribute error in LTO1. */ + function is marked with TREE_THIS_VOLATILE in the IR output, which + leads to the incompatible attribute error in LTO1. Ignore the + interrupt function in this case. */ bool has_no_callee_saved_registers = ((TREE_THIS_VOLATILE (fndecl) - && lookup_attribute ("noreturn", DECL_ATTRIBUTES (fndecl)) + && !lookup_attribute ("interrupt", + TYPE_ATTRIBUTES (TREE_TYPE (fndecl))) && optimize && !optimize_debug && (TREE_NOTHROW (fndecl) || !flag_exceptions)) diff --git a/gcc/testsuite/gcc.target/i386/pr114097-1.c b/gcc/testsuite/gcc.target/i386/pr114097-1.c new file mode 100644 index 00000000000..b14c7b6214d --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr114097-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mtune-ctrl=^prologue_using_move,^epilogue_using_move -fomit-frame-pointer" } */ + +#define ARRAY_SIZE 256 + +extern int array[ARRAY_SIZE][ARRAY_SIZE][ARRAY_SIZE]; +extern int value (int, int, int) +#ifndef __x86_64__ +__attribute__ ((regparm(3))) +#endif +; + +void +_Noreturn +no_return_to_caller (void) +{ + unsigned i, j, k; + for (i = ARRAY_SIZE; i > 0; --i) + for (j = ARRAY_SIZE; j > 0; --j) + for (k = ARRAY_SIZE; k > 0; --k) + array[i - 1][j - 1][k - 1] = value (i, j, k); + while (1); +} + +/* { dg-final { scan-assembler-not "push" } } */ +/* { dg-final { scan-assembler-not "pop" } } */