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: 206120 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1745398dyb; Sun, 25 Feb 2024 13:15:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWgprzr+w30vQHVWS4rebT+NPAW+vUoHGA/ToNK6Ja5umQj5r3yNdN1WPZLBCflMgzp4ATrssfDrItcEui/PjmRrCPu4Q== X-Google-Smtp-Source: AGHT+IGnXP79kqb7SosIkCtECTigMipij+kGA6HikvgOoKLYqdZY3ahr0cGpFoP5uXwVHibfDSdP X-Received: by 2002:a05:6871:58f:b0:21e:b695:dff5 with SMTP id u15-20020a056871058f00b0021eb695dff5mr6362332oan.20.1708895736184; Sun, 25 Feb 2024 13:15:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708895736; cv=pass; d=google.com; s=arc-20160816; b=adjkJ2uJwznFTOMMLsn0pe5uXpddebs0WXEbJdo5d+gSrnJt4bgeTtzM1Yy4JqMujC wFu1yQJbND8TmNTln6+Erig7HgSTVHKWMyYYfJLqjelgFmNwJNxS2GrKm0WzjWiydOd0 PprsgOtGufh/YJmgaVM5LHZR/uKA5CmphbYkekhiGnpndGoXiwuQGz68IKWvnoPXT4re yRp42vXg4EG+RyztqSGRjd9hT8Prmr6ru4GV8xhyFvwTCAX8vfujSruWAW9rFP8xE+ZX Q1hSuUnURhuJ8An9TllS/eS4o8mbB9Km2s3VjxMVr/hJOMyaaQqHCV+XUo6VTLxUAu0A PKIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=Ci049eZALRaAy/6dI8zvIgX+8nJX3PhOIgOiwDh1qcQ=; fh=n8eNxIWSYJwy/CU3QSXzDvE/zeEoomCGojuOcYEQEyQ=; b=Cbzkh4sTji1l0jMsDPR5jGcl0ICmP8H2hjDmofcVsP/5Ut7OSX6hpnhV/8zLh+HWTH vZLuMrqiipgNmR3g0TbaARucBY4U1wZNee2f+NGXk7D0U66h84eO0GtWzXNGv/OPfGG7 9+6TFLxVnZStRMnDWLNcq7o/w0DNlfm5N84xpn+3BoQZPJC1jCnZneCkLJhQrjwWn1kw hqvN0R1vLOh/b/I91c+KpaFpDx4pNQB968gtpuCqCUaa6jq13WLqKg6Olo/ZX6oXqTY0 VVPygk4TgU5OKmJoY1+NVD/TQrTf+5L7//ECoDsbnxYIk4XoR3xbb0YpGsCU+6CSNS+a e+zw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=fT7qC8KI; arc=pass (i=1); 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id x13-20020a05620a098d00b0078776ed9eadsi3671533qkx.502.2024.02.25.13.15.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 13:15:36 -0800 (PST) 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=@gmail.com header.s=20230601 header.b=fT7qC8KI; arc=pass (i=1); 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DB1573858427 for ; Sun, 25 Feb 2024 21:15:35 +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-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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791887337840415109 X-GMAIL-MSGID: 1791907055073079333 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" } } */