From patchwork Tue Nov 15 17:02:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej W. Rozycki" X-Patchwork-Id: 60656 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 B759F389EC5A for ; Tue, 15 Nov 2022 17:02:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by sourceware.org (Postfix) with ESMTPS id 7D1E6389EC57 for ; Tue, 15 Nov 2022 17:02:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7D1E6389EC57 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-lf1-x12a.google.com with SMTP id g12so25461551lfh.3 for ; Tue, 15 Nov 2022 09:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=mime-version:user-agent:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=qVA3wMHixDrjn9/wwzWd9kOpc11VymUi2rOh0qRSIqo=; b=F2jkk5NioIH5CbPsERF73PwIb8dzAkD0S7YgTouxukvJ+lMS/fLq5bjMYZCa+2F1HB 8jxf37hl1ceRMBBAO76XD8kcaOvmKMgufBE5xc+x0hy/2JbTE+RRnEVH7IKay2Tdw/JS nzRyHgoKYC9CV0rcDAhytkaKTpHjSNFtewXKcGL4CeUi26BACbkH9DL/V6zbk3kg9BlH ivQSPcStDJ/lsSG+HKfFaaCKFlLv52JgpLFhlwHENYysQccGtc4vom5DAb9YUSkib4rL nc07wlzpAg+MkgZ8e10CeN0JfsGqG62EgPKF6NXA5fBiNDMDakyerRfjUdNemQsttIBr U+fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qVA3wMHixDrjn9/wwzWd9kOpc11VymUi2rOh0qRSIqo=; b=NICBYWxIXuZpmBWXCR/BZAe8CKyCpTW8YB5dKLkfEMs0vRYWI01x+unUrCKQAcXOxu /9Hpo8cnCSLY6FV5na1kXS+3ki2CAITTSN0L2J0GIkuqx2cFD0T/p6Ncr1ASkotJG+Dy 8rnMKeF0D9Zsz3CS6GoKGBf84fA4H3MPEXe6dTWspA15vlH57IHbN3+eWzJidg7GC+JG bem6LbbSP1LN4XCnrB/zvH5sbVn/Ffcw1G3OY9NQ0qxA4bGXJECGiASmjrEZIK21dR29 aygpW2qocrFYpS31qL9OoVm23s826j7oNoB7kBtQGVOYuS/dQx+zmZYH1ok97IY2sYsx TA0Q== X-Gm-Message-State: ANoB5pmpWs/j2NAkns6wJ4HatCfFvw2k0FJ8u2x8Przfzf++7oAUF143 yJ6z4l2J3IXTbY3siO4wiw9cTFw5MeUu/j8/ X-Google-Smtp-Source: AA0mqf61E1HCSeDalkeOIDZKdd1q/etPdsQHqGYO6oLGFbJyoMCuJPtTqQc71+miGmPjOWkMXA9xiA== X-Received: by 2002:ac2:48b4:0:b0:497:ca2:4e74 with SMTP id u20-20020ac248b4000000b004970ca24e74mr6325373lfg.488.1668531738861; Tue, 15 Nov 2022 09:02:18 -0800 (PST) Received: from [192.168.219.3] ([78.8.192.131]) by smtp.gmail.com with ESMTPSA id y20-20020ac24214000000b004b384ae61absm2271928lfh.198.2022.11.15.09.02.16 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 15 Nov 2022 09:02:18 -0800 (PST) Date: Tue, 15 Nov 2022 17:02:13 +0000 (GMT) From: "Maciej W. Rozycki" To: gcc-patches@gcc.gnu.org cc: Rainer Orth , Mike Stump Subject: [PATCH] testsuite: Fix missing EFFECTIVE_TARGETS variable errors Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Permit running vector tests outside `check_vect_support_and_set_flags' environment, removing errors such as: ERROR: gcc.dg/analyzer/torture/pr93350.c -O0 : can't read "EFFECTIVE_TARGETS": no such variable for " dg-require-effective-target 1 vect_int " or: ERROR: gcc.dg/bic-bitmask-13.c: error executing dg-final: can't read "EFFECTIVE_TARGETS": no such variable with `mips-linux-gnu' target testing. The EFFECTIVE_TARGETS variable has originated from commit 9b7937cf8a06 ("Add support to run auto-vectorization tests for multiple effective targets."), where arrangements have been made to run vector tests run within `check_vect_support_and_set_flags' environment iteratively over all the vector unit variants available in the architecture using extra compilation flags regardless of whether the target environment arranged for a particular testsuite run has vector support enabled by default. So far this has been used for the MIPS target only. Vector tests have since been added though that run outside environment set up by `check_vect_support_and_set_flags' just using the current compilation environment with no extra flags added. This works for most targets, however causes problems with the MIPS target, because outside `check_vect_support_and_set_flags' environment the EFFECTIVE_TARGETS variable will not have been correctly set up even if it was added to the particular script invoking the test in question. Fix this by using just the current compilation environment whenever a vector feature is requested by `et-is-effective-target' in the absence of the EFFECTIVE_TARGETS variable. This required some modification to individual vector feature tests, which always added the compilation flags required for the determination of whether the given vector unit variant can be verified with the current testsuite run (except for the Loongson MMI variant). Now explicit flags are only passed in setting up EFFECTIVE_TARGETS and otherwise the current compilation environment will determine whether such a vector test is applicable. This changes how Loongson MMI is handled in that the `-mloongson-mmi' flag is explicitly passed for the determination of whether this vector unit variant can be verified, which I gather is how it was supposed to be arranged anyway because the flag is then added for testing the Loongson MMI variant. gcc/testsuite/ * lib/target-supports.exp (check_effective_target_mpaired_single): Add `args' argument and pass it to `check_no_compiler_messages' replacing `-mpaired-single'. (add_options_for_mips_loongson_mmi): Add `args' argument and pass it to `check_no_compiler_messages'. (check_effective_target_mips_msa): Add `args' argument and pass it to `check_no_compiler_messages' replacing `-mmsa'. (check_effective_target_mpaired_single_runtime) (add_options_for_mpaired_single): Pass `-mpaired-single' to `check_effective_target_mpaired_single'. (check_effective_target_mips_loongson_mmi_runtime) (add_options_for_mips_loongson_mmi): Pass `-mloongson-mmi' to `check_effective_target_mips_loongson_mmi'. (check_effective_target_mips_msa_runtime) (add_options_for_mips_msa): Pass `-mmsa' to `check_effective_target_mips_msa'. (et-is-effective-target): Verify that EFFECTIVE_TARGETS exists and if not, just check if the current compilation environment supports the target feature requested. (check_vect_support_and_set_flags): Pass `-mpaired-single', `-mloongson-mmi', and `-mmsa' to the respective target feature checks. --- Hi, This removes said errors and depending on the compilation flags used with a testsuite invocation may give scores such as: UNSUPPORTED: gcc.dg/analyzer/torture/pr93350.c -O0 or: PASS: gcc.dg/analyzer/torture/pr93350.c -O0 (test for excess errors) In some cases, including in particular Loongson MMI now enabled, it causes extra failures to appear, but my interpretation is they are preexisting issues either with the compiler or the respective test cases, which just did not previously show up simply because the test cases were not run. Therefore I conclude they are not issues with the test framework update proposed here. OK to apply then? Maciej --- gcc/testsuite/lib/target-supports.exp | 41 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) gcc-test-effective-targets.diff Index: gcc/gcc/testsuite/lib/target-supports.exp =================================================================== --- gcc.orig/gcc/testsuite/lib/target-supports.exp +++ gcc/gcc/testsuite/lib/target-supports.exp @@ -1329,10 +1329,10 @@ proc check_effective_target_pie { } { # Return true if the target supports -mpaired-single (as used on MIPS). -proc check_effective_target_mpaired_single { } { +proc check_effective_target_mpaired_single { args } { return [check_no_compiler_messages mpaired_single object { void foo (void) { } - } "-mpaired-single"] + } "$args"] } # Return true if the target has access to FPU instructions. @@ -2144,7 +2144,7 @@ proc check_mips_msa_hw_available { } { # executables, 0 otherwise. proc check_effective_target_mpaired_single_runtime { } { - if { [check_effective_target_mpaired_single] + if { [check_effective_target_mpaired_single "-mpaired-single"] && [check_mpaired_single_hw_available] } { return 1 } @@ -2154,7 +2154,7 @@ proc check_effective_target_mpaired_sing # Return 1 if the target supports running Loongson executables, 0 otherwise. proc check_effective_target_mips_loongson_mmi_runtime { } { - if { [check_effective_target_mips_loongson_mmi] + if { [check_effective_target_mips_loongson_mmi "-mloongson-mmi"] && [check_mips_loongson_mmi_hw_available] } { return 1 } @@ -2164,7 +2164,7 @@ proc check_effective_target_mips_loongso # Return 1 if the target supports running MIPS MSA executables, 0 otherwise. proc check_effective_target_mips_msa_runtime { } { - if { [check_effective_target_mips_msa] + if { [check_effective_target_mips_msa "-mmsa"] && [check_mips_msa_hw_available] } { return 1 } @@ -6095,7 +6095,7 @@ proc check_effective_target_arm_acq_rel # Add the options needed for MIPS Paired-Single. proc add_options_for_mpaired_single { flags } { - if { ! [check_effective_target_mpaired_single] } { + if { ! [check_effective_target_mpaired_single "-mpaired-single"] } { return "$flags" } return "$flags -mpaired-single" @@ -6104,7 +6104,7 @@ proc add_options_for_mpaired_single { fl # Add the options needed for MIPS SIMD Architecture. proc add_options_for_mips_msa { flags } { - if { ! [check_effective_target_mips_msa] } { + if { ! [check_effective_target_mips_msa "-mmsa"] } { return "$flags" } return "$flags -mmsa" @@ -6113,7 +6113,7 @@ proc add_options_for_mips_msa { flags } # Add the options needed for MIPS Loongson MMI Architecture. proc add_options_for_mips_loongson_mmi { flags } { - if { ! [check_effective_target_mips_loongson_mmi] } { + if { ! [check_effective_target_mips_loongson_mmi "-mloongson-mmi"] } { return "$flags" } return "$flags -mloongson-mmi" @@ -6123,7 +6123,7 @@ proc add_options_for_mips_loongson_mmi { # Return 1 if this a Loongson-2E or -2F target using an ABI that supports # the Loongson vector modes. -proc check_effective_target_mips_loongson_mmi { } { +proc check_effective_target_mips_loongson_mmi { args } { return [check_no_compiler_messages loongson assembly { #if !defined(__mips_loongson_mmi) #error !__mips_loongson_mmi @@ -6131,7 +6131,7 @@ proc check_effective_target_mips_loongso #if !defined(__mips_loongson_vector_rev) #error !__mips_loongson_vector_rev #endif - }] + } "$args"] } # Return 1 if this is a MIPS target that supports the legacy NAN. @@ -6145,7 +6145,7 @@ proc check_effective_target_mips_nanlega # Return 1 if an MSA program can be compiled to object -proc check_effective_target_mips_msa { } { +proc check_effective_target_mips_msa { args } { if ![check_effective_target_nomips16] { return 0 } @@ -6171,7 +6171,7 @@ proc check_effective_target_mips_msa { } return v[0]; } #endif - } "-mmsa" ] + } "$args"] } # Return 1 if this is an ARM target that adheres to the ABI for the ARM @@ -9049,11 +9049,16 @@ proc et-is-effective-target { target } { global EFFECTIVE_TARGETS global et_index - if { [llength $EFFECTIVE_TARGETS] > $et_index - && [lindex $EFFECTIVE_TARGETS $et_index] == $target } { + if { [info exists EFFECTIVE_TARGETS] } { + if { [llength $EFFECTIVE_TARGETS] > $et_index + && [lindex $EFFECTIVE_TARGETS $et_index] == $target } { return 1 + } else { + return 0 + } + } else { + return [check_effective_target_${target}] } - return 0 } # Return 1 if target default to short enums @@ -10647,13 +10652,13 @@ proc check_vect_support_and_set_flags { } } elseif { [istarget mips*-*-*] && [check_effective_target_nomips16] } { - if { [check_effective_target_mpaired_single] } { + if { [check_effective_target_mpaired_single "-mpaired-single"] } { lappend EFFECTIVE_TARGETS mpaired_single } - if { [check_effective_target_mips_loongson_mmi] } { + if { [check_effective_target_mips_loongson_mmi "-mloongson-mmi"] } { lappend EFFECTIVE_TARGETS mips_loongson_mmi } - if { [check_effective_target_mips_msa] } { + if { [check_effective_target_mips_msa "-mmsa"] } { lappend EFFECTIVE_TARGETS mips_msa } return [llength $EFFECTIVE_TARGETS]