Hi! On 2025-02-22T22:49:47+0100, I wrote: > On 2025-01-09T14:21:18+0100, I wrote: >> Pushed to trunk branch commit 3861d362ec7e3c50742fc43833fe9d8674f4070e >> "nvptx: PTX 'alloca' for '-mptx=7.3'+, '-march=sm_52'+ [PR65181]", >> [...] > >> --- a/gcc/testsuite/lib/target-supports.exp >> +++ b/gcc/testsuite/lib/target-supports.exp >> @@ -1009,9 +1009,37 @@ proc check_effective_target_alloca {} { >> [...] >> + # Find 'dg-do-what' in an outer frame. >> + set level 1 >> + while true { >> + upvar $level dg-do-what dg-do-what >> + if [info exists dg-do-what] then break >> + incr level >> + } >> + verbose "check_effective_target_alloca: found dg-do-what at level >> $level" 2 >> [...] > > Here, I'd duplicated code from 'check_effective_target_stack_size', boo. > Pushed to trunk branch commit f553b1aaa2b1b925c918e5dcf966290b045321c2 > "Refactor duplicated code into > 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what'",
... now really... > see attached. Grüße Thomas
>From f553b1aaa2b1b925c918e5dcf966290b045321c2 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tschwi...@baylibre.com> Date: Fri, 21 Feb 2025 19:42:28 +0100 Subject: [PATCH] Refactor duplicated code into 'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what' No change in behavior intended. gcc/testsuite/ * lib/gcc-dg.exp (proc find-dg-do-what): New. * lib/target-supports.exp (check_effective_target_stack_size) (check_effective_target_alloca): Use it. --- gcc/testsuite/lib/gcc-dg.exp | 16 ++++++++++++++++ gcc/testsuite/lib/target-supports.exp | 20 ++------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index 70be7a8d5fd..6e9a7b207ab 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -1369,3 +1369,19 @@ proc gcc-transform-out-of-tree { args } { set additional_prunes "" set dg_runtest_extra_prunes "" + +# Find the 'dg-do-what' variable living inside DejaGnu's 'dg-test' procedure, +# as a local variable. We start looking at the second-outer frame: this way, +# the caller of 'find-dg-do-what' may maintain a local 'dg-do-what' variable +# without interfering with this search. +proc find-dg-do-what { } { + set lookup_level 2 + while true { + upvar $lookup_level dg-do-what dg-do-what + if { [info exists dg-do-what] } { + verbose "find-dg-do-what: found 'dg-do-what' at level $lookup_level: ${dg-do-what}" 2 + return ${dg-do-what} + } + incr lookup_level + } +} diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 7eab76a7eb6..7b3172d55b4 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -652,15 +652,7 @@ proc check_effective_target_trampolines { } { proc check_effective_target_stack_size { } { # For nvptx target, stack size limits are relevant for execution only. if { [istarget nvptx-*-*] } { - # Find 'dg-do-what' in an outer frame. - set level 1 - while true { - upvar $level dg-do-what dg-do-what - if [info exists dg-do-what] then break - incr level - } - verbose "check_effective_target_stack_size: found dg-do-what at level $level" 2 - + set dg-do-what [find-dg-do-what] if { ![string equal [lindex ${dg-do-what} 0] run] } { return 0 } @@ -1021,15 +1013,7 @@ proc check_effective_target_alloca {} { return 0 } - # Find 'dg-do-what' in an outer frame. - set level 1 - while true { - upvar $level dg-do-what dg-do-what - if [info exists dg-do-what] then break - incr level - } - verbose "check_effective_target_alloca: found dg-do-what at level $level" 2 - + set dg-do-what [find-dg-do-what] if { [string equal [lindex ${dg-do-what} 0] run] } { # For 'dg-do run', it additionally depends on runtime support. # (If not supported, we don't try to demote 'run' to 'link', -- 2.34.1