From e76254815c3adfff1c086beb6a4cfa46c49ac3b3 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Mon, 19 May 2008 15:39:55 -0400 Subject: Optimize away assignments in other contexts. --- testsuite/systemtap.base/optim_arridx.exp | 85 +++++++++++++++++++++++++++++++ testsuite/systemtap.base/optim_arridx.stp | 39 ++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 testsuite/systemtap.base/optim_arridx.exp create mode 100644 testsuite/systemtap.base/optim_arridx.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/optim_arridx.exp b/testsuite/systemtap.base/optim_arridx.exp new file mode 100644 index 00000000..447ad1f4 --- /dev/null +++ b/testsuite/systemtap.base/optim_arridx.exp @@ -0,0 +1,85 @@ +# test integer limits. Set and print variables and print constants. + +set test "optim_arridx" +set ::result_string {# globals +arr1:long [long, long] +arr2:long [long] +arr3:long [long] +# functions +fna:long (a:long) +return a +fnb:long (a:long, b:long) +return (a) + (b) +exit:unknown () +%{ + atomic_set (&session_state, STAP_SESSION_STOPPING); + _stp_exit (); +%} +# probes +begin /* <- begin */ + # locals + idx2:long + j:long + k:long + b:long + m:long + arr1:long [long] + arr2:long [long, long] + aa:long + bb:long + cc:long + dd:long + ee:long +{ +(arr2[(idx2) = (2)]) = (20) +(arr2[(j) = (4)]) = (40) +(arr1[fna((k) = (0)), k]) = (1) +(arr1[(b) = (1), b]) = (2) +fnb((arr3[0]) = (4), arr3[0]) +(m) = (1) +for (2; (m) <= (10); (m)++) ; +printf("%d %d %d %d\\n", arr1[0], arr2[0, 0], idx2, j) +(aa) = (fna(1)) +(bb) = (fnb((cc) = (1), 2)) +for (1; (bb) < (10); (bb)++) (cc) += (bb) +for ((dd) = (1); (dd) < (10); 1) (dd) += (1) +if (1) (ee) = (1) + +printf("%d %d %d %d %d", aa, bb, cc, dd, ee) +exit() +} +WARNING: eliding unused variable identifier 'elide_i' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:10:8 +WARNING: eliding unused variable identifier 'elide_c' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:14:8 +WARNING: eliding unused variable identifier 'elide_n' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:17:8 +WARNING: eliding unused variable identifier 'elide_aa' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:22:12 +WARNING: eliding unused variable identifier 'elide_bb' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:26:8 +WARNING: eliding unused variable identifier 'elide_ee' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:28:25 +WARNING: eliding unused variable identifier 'elide_ff' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:32:7 +WARNING: eliding unused variable identifier 'elide_idx1' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:1:26 +WARNING: eliding unused variable identifier 'elide_global_a' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:1:38 +WARNING: eliding unused variable identifier 'elide_global_b' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:1:54 +} + +proc optim_arridx_run { TEST_NAME args } { + # zap the srcdir prefix + set test_file_name $TEST_NAME + set TEST_NAME [regsub {.*/testsuite/} $TEST_NAME ""] + + set cmd [concat stap $args $test_file_name] + catch {eval exec $cmd} res + + set n 0 + set expected [split $::result_string "\n"] + foreach line [split $res "\n"] { + if {![string equal $line [lindex $expected $n]]} { + fail "$TEST_NAME" + send_log "line [expr $n + 1]: expected \"[lindex $expected $n]\"\n" + send_log "Got \"$line\"\n" + return + } + incr n + } + pass "$TEST_NAME" +} + +optim_arridx_run $srcdir/$subdir/$test.stp -p2 -v 2>/dev/null diff --git a/testsuite/systemtap.base/optim_arridx.stp b/testsuite/systemtap.base/optim_arridx.stp new file mode 100644 index 00000000..4551bb3e --- /dev/null +++ b/testsuite/systemtap.base/optim_arridx.stp @@ -0,0 +1,39 @@ +global arr1, arr2, arr3, elide_idx1, elide_global_a, elide_global_b + +function fna(a:long) {return a} +function fnb(a:long, b:long) {return a+b} + +probe begin { + // array indices + arr2[elide_idx1 = 1] = 10 + arr2[idx2 = 2] = 20 + arr2[elide_i=3] = 30 + arr2[j=4] = 40 + arr1[fna(k = 0), k] = 1 + arr1[b = 1, b] = 2 + arr1[elide_c = 2,2] = 3 + fnb(arr3[0] = 4, arr3[0]) + m = 1 + for (elide_n=2; m <= 10; m++) + arr2[m] = m * 10 + printf ("%d %d %d %d\n", arr1[0], arr2[0,0], idx2, j) + + // function args + aa = fna(elide_aa = 1) + bb = fnb(cc = 1, elide_global_a = 2) + + // loop + for (elide_bb = 1; bb < 10; bb++) + cc += bb + for (dd = 1; dd < 10; elide_ee = 1) + dd += 1 + + // conditional + if (elide_ff = 0) + elide_ff = 1 + if (elide_global_b = 1) + ee = 1 + + printf("%d %d %d %d %d", aa, bb, cc, dd, ee) + exit () +} -- cgit From c4c1558bbb72f56307d70661ac125544f1b88ffd Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 20 May 2008 00:12:25 +0200 Subject: PR6524: ctime() on bad values hangs system. --- testsuite/systemtap.base/ctime.exp | 18 +++++++++++++ testsuite/systemtap.base/ctime.stp | 55 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 testsuite/systemtap.base/ctime.exp create mode 100644 testsuite/systemtap.base/ctime.stp (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/ctime.exp b/testsuite/systemtap.base/ctime.exp new file mode 100644 index 00000000..f6db096a --- /dev/null +++ b/testsuite/systemtap.base/ctime.exp @@ -0,0 +1,18 @@ +set test "ctime" +set ::result_string {Thu Jan 1 00:00:00 1970 +Wed Dec 31 23:59:59 1969 +Thu Jan 1 00:00:01 1970 +Sat Mar 3 09:46:40 1973 +Fri Feb 13 23:31:30 2009 +Sat Jan 10 13:37:04 2004 +Fri Jul 13 11:01:20 2012 +a long, long time ago... +far far in the future... +Fri Dec 13 20:45:52 1901 +a long, long time ago... +Tue Jan 19 03:14:07 2038 +far far in the future... +a long, long time ago... +far far in the future... +} +stap_run2 $srcdir/$subdir/$test.stp diff --git a/testsuite/systemtap.base/ctime.stp b/testsuite/systemtap.base/ctime.stp new file mode 100644 index 00000000..680baff7 --- /dev/null +++ b/testsuite/systemtap.base/ctime.stp @@ -0,0 +1,55 @@ +probe begin +{ + // epoch + println(ctime(0)) + + // epoch - 1 + println(ctime(-1)) + + // epoch + 1 + println(ctime(1)) + + // Some funny numbers + println(ctime(100000000)) + println(ctime(1234567890)) + println(ctime(1073741824)) + println(ctime(0x50000000)) + + // some time really long ago + secspermin = 60 + minsperhour = 60 + hoursperday = 24 + secsperhour = secspermin * minsperhour + secsperday = secsperhour * hoursperday + epoch_year = 1970 + time = -1 * (epoch_year - 1000) * 365 * secsperday + println(ctime(time)) + + // some time in the far future + time = (9999 - epoch_year) * 365 * secsperday + println(ctime(time)) + + // min 32 bit + time = -2147483648 + println(ctime(time)) + + // over the edge, a long, long time ago... + time-- + println(ctime(time)) + + // max 32 bit + time = 2147483647 + println(ctime(time)) + + // over the edge, far far in the future... + time++ + println(ctime(time)) + + // min 64 bit + println(ctime(-9223372036854775808)) + + // max 64 bit + println(ctime(9223372036854775807)) + + exit() +} -- cgit From 2d6640ba82d5f243bcd3165fa11576a7cfee8c57 Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 20 May 2008 18:33:24 -0400 Subject: PR6538: testsuite changes --- testsuite/systemtap.base/warnings.exp | 2 +- testsuite/systemtap.base/warnings.stp | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/warnings.exp b/testsuite/systemtap.base/warnings.exp index 025bde89..6cff723d 100644 --- a/testsuite/systemtap.base/warnings.exp +++ b/testsuite/systemtap.base/warnings.exp @@ -9,7 +9,7 @@ expect { eof { } } wait -if {$ok == 9} { +if {$ok == 22} { pass $test } else { fail "$test ($ok)" diff --git a/testsuite/systemtap.base/warnings.stp b/testsuite/systemtap.base/warnings.stp index a0ce8d8d..a2ac5afc 100644 --- a/testsuite/systemtap.base/warnings.stp +++ b/testsuite/systemtap.base/warnings.stp @@ -1,9 +1,8 @@ -# PR 1119 +# PR 1119, 6538 global elide_me1 - function elide_me2 () {} - function foo:long () { elide_me3 = 1 } - +function bar() { print(elide+me1) ; ; ; } probe never { elide_me4 = 1; (elide_me5+5); print (foo()) } +probe never { print(elide+me1) bar () } -- cgit From fcc7aafa64338bdbac356dd509acd20f35563ef5 Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Wed, 21 May 2008 09:22:17 -0400 Subject: Optimize compound and binary expression assignments. --- testsuite/systemtap.base/optim_arridx.exp | 2 ++ testsuite/systemtap.base/optim_arridx.stp | 6 ++++++ 2 files changed, 8 insertions(+) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/optim_arridx.exp b/testsuite/systemtap.base/optim_arridx.exp index 447ad1f4..b7c5c360 100644 --- a/testsuite/systemtap.base/optim_arridx.exp +++ b/testsuite/systemtap.base/optim_arridx.exp @@ -45,6 +45,8 @@ for (1; (bb) < (10); (bb)++) (cc) += (bb) for ((dd) = (1); (dd) < (10); 1) (dd) += (1) if (1) (ee) = (1) +(cc) = ((dd) = (5)) +(cc) = ((4) + ((cc) = (1))) printf("%d %d %d %d %d", aa, bb, cc, dd, ee) exit() } diff --git a/testsuite/systemtap.base/optim_arridx.stp b/testsuite/systemtap.base/optim_arridx.stp index 4551bb3e..20710c7f 100644 --- a/testsuite/systemtap.base/optim_arridx.stp +++ b/testsuite/systemtap.base/optim_arridx.stp @@ -34,6 +34,12 @@ probe begin { if (elide_global_b = 1) ee = 1 + // compound assignment + cc = elide_gg=dd=5 + + // binary expression + cc = ((elide_hh = 4) + (cc = 1)) + printf("%d %d %d %d %d", aa, bb, cc, dd, ee) exit () } -- cgit From aa8a3b1797da54a14d04cd57758a65064056376e Mon Sep 17 00:00:00 2001 From: Stan Cox Date: Wed, 21 May 2008 12:47:29 -0400 Subject: Fix assignment optimization expected results. --- testsuite/systemtap.base/optim_arridx.exp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'testsuite/systemtap.base') diff --git a/testsuite/systemtap.base/optim_arridx.exp b/testsuite/systemtap.base/optim_arridx.exp index b7c5c360..0987dec6 100644 --- a/testsuite/systemtap.base/optim_arridx.exp +++ b/testsuite/systemtap.base/optim_arridx.exp @@ -50,16 +50,6 @@ if (1) (ee) = (1) printf("%d %d %d %d %d", aa, bb, cc, dd, ee) exit() } -WARNING: eliding unused variable identifier 'elide_i' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:10:8 -WARNING: eliding unused variable identifier 'elide_c' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:14:8 -WARNING: eliding unused variable identifier 'elide_n' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:17:8 -WARNING: eliding unused variable identifier 'elide_aa' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:22:12 -WARNING: eliding unused variable identifier 'elide_bb' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:26:8 -WARNING: eliding unused variable identifier 'elide_ee' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:28:25 -WARNING: eliding unused variable identifier 'elide_ff' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:32:7 -WARNING: eliding unused variable identifier 'elide_idx1' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:1:26 -WARNING: eliding unused variable identifier 'elide_global_a' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:1:38 -WARNING: eliding unused variable identifier 'elide_global_b' at /work/scox/systemtap/src/testsuite/systemtap.base/optim_arridx.stp:1:54 } proc optim_arridx_run { TEST_NAME args } { -- cgit