From patchwork Mon Nov 28 08:46:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 26582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5519486wrr; Mon, 28 Nov 2022 00:47:29 -0800 (PST) X-Google-Smtp-Source: AA0mqf5KASoj5oytgjKjW4a24sL9ycVpInFmFcQ+hp7Wn6JfEIk017baKDpM82lZt3HPycNx+oLX X-Received: by 2002:a17:906:4997:b0:7ae:ec5c:a99e with SMTP id p23-20020a170906499700b007aeec5ca99emr25145367eju.219.1669625249229; Mon, 28 Nov 2022 00:47:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669625249; cv=none; d=google.com; s=arc-20160816; b=xWWxMcKmOf4y9RUjoSIA2DZr7XGjcfAQk3kE5TNrKg8ptQOjjPor9y8Xa6ejYfQYKK 8Bk4x4Vv8qi+Uhap3uXW87JAN+IydvDjCLhh8I7iNWzVyJt+RWAzAUIPGn6CFVp7rWBs NFHZ2fDMG8/0SojBGqSMCyv5QeqgIca744pP6iyjBvdBV8rqGGGvLzBoprGbvsxVAaih xjbKEMr9OUQdwM3pgNlHKlB1y079vQGPGRk+fPqwSs8/QRbf48dk4sWRg8EOmBEQeM5e ssw8EoIbyezO4HMRsQiFEpwP0TglMOGpx+eoFT8QyvnNvyeBekt23I5SLbquU/Mer5/F oUuQ== 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-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=vwOfMcpReKMUoC4mHVmaVWkSAAVK6rkz1vk0DQeOcnU=; b=UB/el/us0rMRM1qn/BXYE7IdAO/hm4463GaJ5uxoEzTaZPqLjanPZ5ZmhEGd5FMXFL EKZpp46hQq4lm7u/4qo7tL5LZhiy+75McbhSCCgDTFeVbiEw4IeWnykL4hiQLeprWS+P QQs8NLY+Ygb+fsgKWmJ2LBOdmqQXMathiPjFlgwFTSHJYlHlQ9uny3uD/WnaSMdwBfKo KeyWgi6a56XZmfziBUaxwd6yK45bkexcORm9p4KnPQcIuoEDZeHoszRWZBCD06aLv1IW /dMxqAalta8KO6O2bTbbewSJ46Sb8hJOU4+1Lkq/RmKAD7ikktn0TNAbYcmCtHp5Afit +4wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=SC6u8OTQ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id f8-20020a056402068800b004534c6c4bd7si8781413edy.433.2022.11.28.00.47.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 00:47:29 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=SC6u8OTQ; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 003073858426 for ; Mon, 28 Nov 2022 08:47:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 003073858426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669625248; bh=vwOfMcpReKMUoC4mHVmaVWkSAAVK6rkz1vk0DQeOcnU=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=SC6u8OTQ46gT1+/cxOQ0zAvil+cli5mZHkeqb+LaESlzfyQRMB9UpD8JlpWAm190D c/RTF6WKkUc9VaU2PL2Gyi1dDq5unkPCiNgaTNKhzXgmAkv/L1nl1bkWgh8E5W47OR b1Vc7gAPqB1S8Q0NDfbk4mcH1m5NElDch7ZKahZU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 325AF3858D3C for ; Mon, 28 Nov 2022 08:46:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 325AF3858D3C Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-486-toXvnEP1OBGPu_ApBzK1cA-1; Mon, 28 Nov 2022 03:46:41 -0500 X-MC-Unique: toXvnEP1OBGPu_ApBzK1cA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C0203833AF8; Mon, 28 Nov 2022 08:46:40 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.202]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D8EA112132C; Mon, 28 Nov 2022 08:46:40 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2AS8kZjg2252612 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 28 Nov 2022 09:46:36 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2AS8kZxa2252611; Mon, 28 Nov 2022 09:46:35 +0100 Date: Mon, 28 Nov 2022 09:46:34 +0100 To: Uros Bizjak Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] i386: Fix up ix86_abi handling [PR106875] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek 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?1750728965369116111?= X-GMAIL-MSGID: =?utf-8?q?1750728965369116111?= Hi! The following testcase fails since my changes to make also opts_set saved/restored upon function target/optimization changes (before it has been acting as "has this option be ever explicit anywhere?"). The problem is that for ix86_abi we depend on the opts_set value for it in ix86_option_override_internal: SET_OPTION_IF_UNSET (opts, opts_set, ix86_abi, DEFAULT_ABI); but as it is a TargetSave, the backend code is required to save/restore it manually (it does that) and since gcc 11 also to save/restore the opts_set bit for it (which isn't done). We don't do that for various other TargetSave which ix86_function_specific_{save,restore} saves/restores, but as long as we never test opts_set for it, it doesn't really matter. One possible fix would be to introduce some new TargetSave into which ix86_function_specific_{save,restore} would save/restore a bitmask of the opts_set bits. The following patch uses an easier fix, by making it a TargetVariable instead the saving/restoring is handled by the generated code. The differences in options.h are just slight movements on where *ix86_abi stuff appears in it, ditto for options.cc, the real differences are just in options-save.cc, where cl_target_option_save gets: + ptr->x_ix86_abi = opts->x_ix86_abi; ... + if (opts_set->x_ix86_abi) mask |= HOST_WIDE_INT_1U << 3; (plus movements of following TargetVariables mask related stuff), cl_target_option_restore gets: + opts->x_ix86_abi = ptr->x_ix86_abi; ... + opts_set->x_ix86_abi = static_cast((mask & 1) != 0); + mask >>= 1; plus the movements in other functions too. So, by it being a TargetVariable, the only thing that changed is that we don't need to handle it manually in ix86_function_specific_{save,restore} because it is handled automatically including the opts_set stuff. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2022-11-28 Jakub Jelinek PR target/106875 * config/i386/i386.opt (x_ix86_abi): Remove TargetSave. (ix86_abi): Replace it with TargetVariable. * config/i386/i386-options.cc (ix86_function_specific_save, ix86_function_specific_restore): Don't save and restore x_ix86_abi. * g++.target/i386/pr106875.C: New test. Jakub --- gcc/config/i386/i386.opt.jj 2022-11-14 13:35:46.818988464 +0100 +++ gcc/config/i386/i386.opt 2022-11-25 17:33:33.325176813 +0100 @@ -109,8 +109,8 @@ TargetVariable enum cmodel ix86_cmodel = CM_32 ;; -mabi= -TargetSave -enum calling_abi x_ix86_abi +TargetVariable +enum calling_abi ix86_abi = SYSV_ABI ;; -masm= TargetSave --- gcc/config/i386/i386-options.cc.jj 2022-11-24 10:29:02.965586934 +0100 +++ gcc/config/i386/i386-options.cc 2022-11-25 17:31:11.803222733 +0100 @@ -687,7 +687,6 @@ ix86_function_specific_save (struct cl_t ptr->x_recip_mask_explicit = opts->x_recip_mask_explicit; ptr->x_ix86_arch_string = opts->x_ix86_arch_string; ptr->x_ix86_tune_string = opts->x_ix86_tune_string; - ptr->x_ix86_abi = opts->x_ix86_abi; ptr->x_ix86_asm_dialect = opts->x_ix86_asm_dialect; ptr->x_ix86_branch_cost = opts->x_ix86_branch_cost; ptr->x_ix86_dump_tunes = opts->x_ix86_dump_tunes; @@ -823,7 +822,6 @@ ix86_function_specific_restore (struct g opts->x_recip_mask_explicit = ptr->x_recip_mask_explicit; opts->x_ix86_arch_string = ptr->x_ix86_arch_string; opts->x_ix86_tune_string = ptr->x_ix86_tune_string; - opts->x_ix86_abi = ptr->x_ix86_abi; opts->x_ix86_asm_dialect = ptr->x_ix86_asm_dialect; opts->x_ix86_branch_cost = ptr->x_ix86_branch_cost; opts->x_ix86_dump_tunes = ptr->x_ix86_dump_tunes; --- gcc/testsuite/g++.target/i386/pr106875.C.jj 2022-11-25 17:40:06.680490251 +0100 +++ gcc/testsuite/g++.target/i386/pr106875.C 2022-11-25 17:39:53.236684603 +0100 @@ -0,0 +1,5 @@ +// PR target/106875 +// { dg-do compile { target { c++11 && lp64 } } } +// { dg-options "-O0 -mabi=ms -fabi-version=3 -mcall-ms2sysv-xlogues" } + +#include "pr101180.C"