From patchwork Sun Nov 3 22:22:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lewis Hyatt X-Patchwork-Id: 2005826 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=m8rO+piG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; 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 [8.43.85.97]) (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 4XhThC6CNdz1xwV for ; Mon, 4 Nov 2024 09:25:47 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 138C7385843F for ; Sun, 3 Nov 2024 22:25:46 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by sourceware.org (Postfix) with ESMTPS id 4DEB0385782C for ; Sun, 3 Nov 2024 22:23:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4DEB0385782C 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 4DEB0385782C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::f30 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730672596; cv=none; b=uuuvSKGAUBPXq4IVY6VGJ7KIwxrwRSVpCNyoq/MCWUdsPF6aIar7/App5KS+mXwexXl3dRxT/4zhp7zBXsm/fXznI7cR0ddZG0YDPfZjGGEn6f1Wk3fimKrssaKhrRLSvJuV+MhH9CPPH5PJVjfPgN26OHQwk1/F/up6ItK+dKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730672596; c=relaxed/simple; bh=93mo04Y5MdhgVdOS2qA/rxUdFfXp3rLP8/u+ZWoYEAM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Kxc5B6QdlaRf4046YwVnIRQEGPKJQXlv1flaO5KD0NfI0g1W6JUUwwLv8ngcRdTVQ7jGtcbHJ7HS/wm2nhUPS8oXTNtPwyh3F1Zw3j3g61WRdtOsNDbfvTuR6XYsq7VQA/A4JcPRTkcSGQTb3G4lYDsKf2Gd1/Wc6g/Ym3fVlhM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-6cbe9914487so26860786d6.1 for ; Sun, 03 Nov 2024 14:23:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730672582; x=1731277382; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yjavlwy73Qcmjvc90z0/4Dq7kOFgTWsxoGo4U+aly+I=; b=m8rO+piGRm6dFGuRwkGBfdvK9JF6PbQowpn/YhI9dbkFMqA9orboEoD+gDsrbZwdm5 YD8fZDTRp7Wu7GJp5x75zws7w1uoyc5vrfz0z1ZGOO5FwhWIQT5k3ox0AxUebf7Bv7bJ 1lODLNGbZHNX6ShevtrM+uXoEwKLdljEQ7jA/lDExAqUHsxuINDTlPSShrYKqxlFFIzE 7wQb8zRy6KTK9TEtnvl4S8RLIiKNu4aNbRh8/4O9dK3U0PmLDG4EEMHnNxslsGW3ri45 MBjn6StJviQ0MxI3uDYE0uPoJMusRyXnMdoCa0K+qQkXX6gfWh/r6PhTWGtj9X5QjQaV gAyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730672582; x=1731277382; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yjavlwy73Qcmjvc90z0/4Dq7kOFgTWsxoGo4U+aly+I=; b=dLXpnGqwTOsTETTl7t1JGNEj+1Qu+aOoha2l3JEumX2ohpxOKLXO35jtl1EOJomzIk wJu18eEgJByDfGGxRmTBgdaSWij7I9eiKP8a3MgZU1Sf86o/5ond0rZOsA0VWTZAfqde djDKlTJFpb/qugpuB4BjvGAzA4IPuDtvDN2hbOTmIPiUcUwYL9pLy3jg7SPCP/8gIZmQ CR+RJGlcJjI044/RfCdydQUqw+mSA6mlxJQwm2O7Rr5UvyD+KP517qAKYOIRyx9WwK4w Y/175+FRIZoF5lAAR8ZDIw2GKZVc9l5Xa/Ny3jvvWPylAcYWfC+rUygnhrxiWjWw0rwo ar2w== X-Gm-Message-State: AOJu0YyUigj4mZu0UK+/JoNSN7FKn8Hz/ZfCIhk4jwZoHboPgbjtN26a XkQmbGfwmy7iE0ef7MFciyUiPALEOEFQCy/M0gdDjbnzs+vo1gro5ClDiA== X-Google-Smtp-Source: AGHT+IFEU6wdfJ/Paw2/DQrr1g7SLdaZJkx90K0kFEFNK3v0xc3lAA8fa3Xknsp0w0uzJMoVxmfMiA== X-Received: by 2002:a05:6214:3f88:b0:6cb:e952:8096 with SMTP id 6a1803df08f44-6d351b35b82mr199741316d6.50.1730672581624; Sun, 03 Nov 2024 14:23:01 -0800 (PST) Received: from localhost.localdomain ([173.54.240.58]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d35415b2fesm42025866d6.92.2024.11.03.14.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 14:23:01 -0800 (PST) From: Lewis Hyatt To: gcc-patches@gcc.gnu.org Cc: Lewis Hyatt Subject: [PATCH 14/15] Support for 64-bit location_t: Testsuite parts Date: Sun, 3 Nov 2024 17:22:19 -0500 Message-Id: <20241103222220.933471-15-lhyatt@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241103222220.933471-1-lhyatt@gmail.com> References: <20241103222220.933471-1-lhyatt@gmail.com> MIME-Version: 1.0 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 Add support to the testsuite for effective target "large_location_t" indicating if 64-bit location support has been configured. Adjust the tests that are sensitive to location_t internals so they can test large locations too. gcc/testsuite/ChangeLog: * lib/target-supports.exp (check_no_compiler_messages_nocache): Refactor the code for retrieving compiler messages to... (get_compiler_messages_nocache) ...here. New function. (get_compiler_messages): New function. (check_effective_target_large_location_t): New function. * g++.dg/diagnostic/pr77949.C: Adapt the test for 64-bit location_t, when the expected failure doesn't actually happen. * g++.dg/modules/loc-prune-4.C: Adjust the expected output for the 64-bit location_t case * gcc.dg/plugin/expensive_selftests_plugin.c: Don't try to test the maximum supported column number in 64-bit location_t mode. * gcc.dg/plugin/location_overflow_plugin.c: Adjust the base_location so it can effectively test 64-bit location_t as well. --- gcc/testsuite/g++.dg/diagnostic/pr77949.C | 5 ++- gcc/testsuite/g++.dg/modules/loc-prune-4.C | 11 ++++-- .../plugin/expensive_selftests_plugin.c | 7 ++-- .../gcc.dg/plugin/location_overflow_plugin.c | 7 ++++ gcc/testsuite/lib/target-supports.exp | 34 +++++++++++++++++-- 5 files changed, 55 insertions(+), 9 deletions(-) diff --git a/gcc/testsuite/g++.dg/diagnostic/pr77949.C b/gcc/testsuite/g++.dg/diagnostic/pr77949.C index b81d6e2bb46..35922e9bb23 100644 --- a/gcc/testsuite/g++.dg/diagnostic/pr77949.C +++ b/gcc/testsuite/g++.dg/diagnostic/pr77949.C @@ -1,7 +1,10 @@ -// Ensure that no fix-it hints are emitted +// Ensure that no fix-it hints are emitted unless large locations are available. // { dg-options "-fdiagnostics-parseable-fixits" } /* Very long line, where a missing semicolon would be suggested for insertion at column 4097. */ class test { } // { dg-error "-: expected .;. after class definition" "" { target *-*-* } .-1 } +/* { dg-begin-multiline-output "" } +fix-it: +{ dg-end-multiline-output "" { target large_location_t } } */ diff --git a/gcc/testsuite/g++.dg/modules/loc-prune-4.C b/gcc/testsuite/g++.dg/modules/loc-prune-4.C index aa8f248b52b..a6c62a3385c 100644 --- a/gcc/testsuite/g++.dg/modules/loc-prune-4.C +++ b/gcc/testsuite/g++.dg/modules/loc-prune-4.C @@ -16,7 +16,12 @@ int bar (int); // merge lines int baz (int); -// { dg-final { scan-lang-dump {Ordinary maps:2 locs:12288 range_bits:5} module } } // { dg-final { scan-lang-dump { 1 source file names\n Source file...=[^\n]*loc-prune-4.C\n} module } } -// { dg-final { scan-lang-dump { Span:0 ordinary \[[0-9]+\+12288,\+4096\)->\[0,\+4096\)} module } } -// { dg-final { scan-lang-dump { Span:1 ordinary \[[0-9]+\+40960,\+8192\)->\[4096,\+8192\)} module } } + +// { dg-final { scan-lang-dump {Ordinary maps:2 locs:12288 range_bits:5} module { target { ! large_location_t } } } } +// { dg-final { scan-lang-dump { Span:0 ordinary \[[0-9]+\+12288,\+4096\)->\[0,\+4096\)} module { target { ! large_location_t } } } } +// { dg-final { scan-lang-dump { Span:1 ordinary \[[0-9]+\+40960,\+8192\)->\[4096,\+8192\)} module { target { ! large_location_t } } } } + +// { dg-final { scan-lang-dump {Ordinary maps:2 locs:49152 range_bits:7} module { target large_location_t } } } +// { dg-final { scan-lang-dump { Span:0 ordinary \[[0-9]+\+49152,\+16384\)->\[0,\+16384\)} module { target large_location_t } } } +// { dg-final { scan-lang-dump { Span:1 ordinary \[[0-9]+\+163840,\+32768\)->\[16384,\+32768\)} module { target large_location_t } } } diff --git a/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.c b/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.c index e96efe0bed5..1b487ad63b6 100644 --- a/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.c +++ b/gcc/testsuite/gcc.dg/plugin/expensive_selftests_plugin.c @@ -63,17 +63,20 @@ test_richloc (rich_location *richloc) static void test_fixit_on_very_long_line (const line_table_case &case_) { - /* Various interesting column/line-width values, to try to tickle - out bugs. */ + /* Various interesting column/line-width values, to try to tickle out bugs. In + 64-bit location mode, we can't test the max because the maximum supported + column is unreasonably large. */ const int VERY_LONG_LINE = 8192; const int columns[] = {0, 1, 80, +#ifndef ENABLE_LARGE_SOURCE_LOCATIONS LINE_MAP_MAX_COLUMN_NUMBER - 2, LINE_MAP_MAX_COLUMN_NUMBER - 1, LINE_MAP_MAX_COLUMN_NUMBER, LINE_MAP_MAX_COLUMN_NUMBER + 1, LINE_MAP_MAX_COLUMN_NUMBER + 2, +#endif VERY_LONG_LINE, VERY_LONG_LINE + 5}; for (unsigned int width_idx = 0; width_idx < ARRAY_SIZE (columns); diff --git a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c index 45a01b5f917..f7d7ca4b57c 100644 --- a/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c +++ b/gcc/testsuite/gcc.dg/plugin/location_overflow_plugin.c @@ -84,6 +84,13 @@ plugin_init (struct plugin_name_args *plugin_info, if (!base_location) error_at (UNKNOWN_LOCATION, "missing plugin argument"); + /* With 64-bit sources, the thresholds are larger, so shift the base + location argument accordingly. */ +#ifdef ENABLE_LARGE_SOURCE_LOCATIONS + gcc_assert (sizeof (location_t) == sizeof (uint64_t)); + base_location = 1 + ((base_location - 1) << 31); +#endif + register_callback (plugin_info->base_name, PLUGIN_PRAGMAS, on_pragma_registration, diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 75703ddca60..f92dda583b1 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -180,13 +180,27 @@ proc clear_effective_target_cache { } { array unset et_cache } -# Like check_compile, but delete the output file and return true if the -# compiler printed no messages. -proc check_no_compiler_messages_nocache {args} { +# Like check_compile, but delete the output file and return just the +# compiler output as a string. +proc get_compiler_messages_nocache {args} { set result [eval check_compile $args] set lines [lindex $result 0] set output [lindex $result 1] remote_file build delete $output + return $lines +} + +# And the cached version. +proc get_compiler_messages {prop args} { + return [check_cached_effective_target $prop { + eval [list get_compiler_messages_nocache $prop] $args + }] +} + +# Like check_compile, but delete the output file and return true if the +# compiler printed no messages. +proc check_no_compiler_messages_nocache {args} { + set lines [eval get_compiler_messages_nocache $args ] return [string match "" $lines] } @@ -13939,3 +13953,17 @@ proc add_options_for_nvptx_alias_ptx { flags } { return $flags } + + +# Return 1 if GCC was configured with large (64-bit) location_t. + +proc check_effective_target_large_location_t { } { + set lines [get_compiler_messages large_location_t assembly ";" "-fdump-internal-locations" ] + if ![ regexp {\nMAX_LOCATION_T\s*location_t interval: (\d*)} $lines dummy max_loc ] { + verbose "Could not parse output of -fdump-internal-locations. Assuming small location_t." 2 + return 0 + } + # No need to rely on 64-bit capable TCL here. The max for 32-bit locations + # is 2147483647, which is 10 characters long. + return [ expr { [string length $max_loc] > 10 } ] +}