From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gcc.dg/guality/asm-1.c | 27 ++ gcc/testsuite/gcc.dg/guality/example.c | 138 ++++++++++ gcc/testsuite/gcc.dg/guality/guality.c | 28 ++ gcc/testsuite/gcc.dg/guality/guality.exp | 53 ++++ gcc/testsuite/gcc.dg/guality/guality.h | 377 +++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/guality/inline-params.c | 45 ++++ gcc/testsuite/gcc.dg/guality/nrv-1.c | 29 +++ gcc/testsuite/gcc.dg/guality/pr36728-1.c | 49 ++++ gcc/testsuite/gcc.dg/guality/pr36728-2.c | 49 ++++ gcc/testsuite/gcc.dg/guality/pr36977.c | 32 +++ gcc/testsuite/gcc.dg/guality/pr41353-1.c | 56 ++++ gcc/testsuite/gcc.dg/guality/pr41353-2.c | 24 ++ gcc/testsuite/gcc.dg/guality/pr41404-1.c | 41 +++ gcc/testsuite/gcc.dg/guality/pr41447-1.c | 26 ++ gcc/testsuite/gcc.dg/guality/pr41616-1.c | 20 ++ gcc/testsuite/gcc.dg/guality/pr42782.c | 24 ++ gcc/testsuite/gcc.dg/guality/pr43051-1.c | 57 ++++ gcc/testsuite/gcc.dg/guality/pr43077-1.c | 55 ++++ gcc/testsuite/gcc.dg/guality/pr43177.c | 36 +++ gcc/testsuite/gcc.dg/guality/pr43329-1.c | 52 ++++ gcc/testsuite/gcc.dg/guality/pr43479.c | 33 +++ gcc/testsuite/gcc.dg/guality/pr43593.c | 24 ++ gcc/testsuite/gcc.dg/guality/pr45003-1.c | 31 +++ gcc/testsuite/gcc.dg/guality/pr45003-2.c | 31 +++ gcc/testsuite/gcc.dg/guality/pr45003-3.c | 31 +++ gcc/testsuite/gcc.dg/guality/pr48466.c | 41 +++ gcc/testsuite/gcc.dg/guality/sra-1.c | 56 ++++ gcc/testsuite/gcc.dg/guality/vla-1.c | 36 +++ gcc/testsuite/gcc.dg/guality/vla-2.c | 55 ++++ 29 files changed, 1556 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/guality/asm-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/example.c create mode 100644 gcc/testsuite/gcc.dg/guality/guality.c create mode 100644 gcc/testsuite/gcc.dg/guality/guality.exp create mode 100644 gcc/testsuite/gcc.dg/guality/guality.h create mode 100644 gcc/testsuite/gcc.dg/guality/inline-params.c create mode 100644 gcc/testsuite/gcc.dg/guality/nrv-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr36728-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr36728-2.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr36977.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr41353-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr41353-2.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr41404-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr41447-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr41616-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr42782.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr43051-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr43077-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr43177.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr43329-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr43479.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr43593.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr45003-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr45003-2.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr45003-3.c create mode 100644 gcc/testsuite/gcc.dg/guality/pr48466.c create mode 100644 gcc/testsuite/gcc.dg/guality/sra-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/vla-1.c create mode 100644 gcc/testsuite/gcc.dg/guality/vla-2.c (limited to 'gcc/testsuite/gcc.dg/guality') diff --git a/gcc/testsuite/gcc.dg/guality/asm-1.c b/gcc/testsuite/gcc.dg/guality/asm-1.c new file mode 100644 index 000000000..e9cf4a167 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/asm-1.c @@ -0,0 +1,27 @@ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +struct A { int x; unsigned short y; char z[64]; }; + +void __attribute__((noinline)) +foo (struct A *p, char *q) +{ + int f = &p->z[p->y] - q; + asm volatile (NOP); + asm volatile (NOP : : "g" (f)); /* { dg-final { gdb-test 14 "f" "14" } } */ + asm volatile ("" : : "g" (p), "g" (q)); +} + +int +main () +{ + struct A a; + __builtin_memset (&a, 0, sizeof a); + a.y = 26; + a.x = 12; + asm volatile ("" : : "r" (&a) : "memory"); + foo (&a, &a.z[a.x]); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/example.c b/gcc/testsuite/gcc.dg/guality/example.c new file mode 100644 index 000000000..26d25c285 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/example.c @@ -0,0 +1,138 @@ +/* { dg-do run { xfail *-*-* } } */ +/* { dg-options "-g" } */ + +#define GUALITY_DONT_FORCE_LIVE_AFTER -1 + +#ifndef STATIC_INLINE +#define STATIC_INLINE /*static*/ +#endif + +#include "guality.h" + +#include + +/* Test the debug info for the functions used in the VTA + presentation at the GCC Summit 2008. */ + +typedef struct list { + struct list *n; + int v; +} elt, *node; + +STATIC_INLINE node +find_val (node c, int v, node e) +{ + while (c < e) + { + GUALCHK (c); + GUALCHK (v); + GUALCHK (e); + if (c->v == v) + return c; + GUALCHK (c); + GUALCHK (v); + GUALCHK (e); + c++; + } + return NULL; +} + +STATIC_INLINE node +find_prev (node c, node w) +{ + while (c) + { + node o = c; + c = c->n; + GUALCHK (c); + GUALCHK (o); + GUALCHK (w); + if (c == w) + return o; + GUALCHK (c); + GUALCHK (o); + GUALCHK (w); + } + return NULL; +} + +STATIC_INLINE node +check_arr (node c, node e) +{ + if (c == e) + return NULL; + e--; + while (c < e) + { + GUALCHK (c); + GUALCHK (e); + if (c->v > (c+1)->v) + return c; + GUALCHK (c); + GUALCHK (e); + c++; + } + return NULL; +} + +STATIC_INLINE node +check_list (node c, node t) +{ + while (c != t) + { + node n = c->n; + GUALCHK (c); + GUALCHK (n); + GUALCHK (t); + if (c->v > n->v) + return c; + GUALCHK (c); + GUALCHK (n); + GUALCHK (t); + c = n; + } + return NULL; +} + +struct list testme[] = { + { &testme[1], 2 }, + { &testme[2], 3 }, + { &testme[3], 5 }, + { &testme[4], 7 }, + { &testme[5], 11 }, + { NULL, 13 }, +}; + +int +main (int argc, char *argv[]) +{ + int n = sizeof (testme) / sizeof (*testme); + node first, last, begin, end, ret; + + GUALCHKXPR (n); + + begin = first = &testme[0]; + last = &testme[n-1]; + end = &testme[n]; + + GUALCHKXPR (first); + GUALCHKXPR (last); + GUALCHKXPR (begin); + GUALCHKXPR (end); + + ret = find_val (begin, 13, end); + GUALCHK (ret); + assert (ret == last); + + ret = find_prev (first, last); + GUALCHK (ret); + assert (ret == &testme[n-2]); + + ret = check_arr (begin, end); + GUALCHK (ret); + assert (!ret); + + ret = check_list (first, last); + GUALCHK (ret); + assert (!ret); +} diff --git a/gcc/testsuite/gcc.dg/guality/guality.c b/gcc/testsuite/gcc.dg/guality/guality.c new file mode 100644 index 000000000..d5d950fcd --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/guality.c @@ -0,0 +1,28 @@ +/* { dg-do run { xfail *-*-* } } */ +/* { dg-options "-g" } */ + +#include "guality.h" + +/* Some silly sanity checking. */ + +int +main (int argc, char *argv[]) +{ + int i = argc+1; + int j = argc-2; + int k = 5; + + GUALCHKXPR (argc); + GUALCHKXPR (i); + GUALCHKXPR (j); + GUALCHKXPR (k); + GUALCHKXPR (&i); + GUALCHKFLA (argc); + GUALCHKFLA (i); + GUALCHKFLA (j); + GUALCHKXPR (i); + GUALCHKXPR (j); + GUALCHKXPRVAL ("k", 5, 1); + GUALCHKXPRVAL ("0x40", 64, 0); + /* GUALCHKXPRVAL ("0", 0, 0); *//* XFAIL */ +} diff --git a/gcc/testsuite/gcc.dg/guality/guality.exp b/gcc/testsuite/gcc.dg/guality/guality.exp new file mode 100644 index 000000000..49e2ac5a5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/guality.exp @@ -0,0 +1,53 @@ +# This harness is for tests that should be run at all optimisation levels. + +load_lib gcc-dg.exp +load_lib gcc-gdb-test.exp + +# Disable on darwin until radr://7264615 is resolved. +if { [istarget *-*-darwin*] } { + return +} + +proc check_guality {args} { + set result [eval check_compile guality_check executable $args "-g -O0"] + set lines [lindex $result 0] + set output [lindex $result 1] + set ret 0 + if {[string match "" $lines]} { + set execout [gcc_load "./$output"] + set ret [string match "*1 PASS, 0 FAIL, 0 UNRESOLVED*" $execout] + } + remote_file build delete $output + return $ret +} + +dg-init + +global GDB +if ![info exists ::env(GUALITY_GDB_NAME)] { + if [info exists GDB] { + set guality_gdb_name "$GDB" + } else { + set guality_gdb_name "[transform gdb]" + } + setenv GUALITY_GDB_NAME "$guality_gdb_name" +} + +if {[check_guality " + #include \"$srcdir/$subdir/guality.h\" + volatile long int varl = 6; + int main (int argc, char *argv\[\]) + { + GUALCHKVAL (varl); + return 0; + } +"]} { + gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] "" + gcc-dg-runtest [lsort [glob $srcdir/c-c++-common/guality/*.c]] "-Wc++-compat" +} + +if [info exists guality_gdb_name] { + unsetenv GUALITY_GDB_NAME +} + +dg-finish diff --git a/gcc/testsuite/gcc.dg/guality/guality.h b/gcc/testsuite/gcc.dg/guality/guality.h new file mode 100644 index 000000000..8b657f29f --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/guality.h @@ -0,0 +1,377 @@ +/* Infrastructure to test the quality of debug information. + Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. + Contributed by Alexandre Oliva . + +This file is part of GCC. + +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GCC; see the file COPYING3. If not see +. */ + +#include +#include +#include +#include +#include + +/* This is a first cut at checking that debug information matches + run-time. The idea is to annotate programs with GUALCHK* macros + that guide the tests. + + In the current implementation, all of the macros expand to function + calls. On the one hand, this interferes with optimizations; on the + other hand, it establishes an optimization barrier and a clear + inspection point, where previous operations (as in the abstract + machine) should have been completed and have their effects visible, + and future operations shouldn't have started yet. + + In the current implementation of guality_check(), we fork a child + process that runs gdb, attaches to the parent process (the one that + called guality_check), moves up one stack frame (to the caller of + guality_check) and then examines the given expression. + + If it matches the expected value, we have a PASS. If it differs, + we have a FAILure. If it is missing, we'll have a FAIL or an + UNRESOLVED depending on whether the variable or expression might be + unavailable at that point, as indicated by the third argument. + + We envision a future alternate implementation with two compilation + and execution cycles, say one that runs the program and uses the + macros to log expressions and expected values, another in which the + macros expand to nothing and the logs are used to guide a debug + session that tests the values. How to identify the inspection + points in the second case is yet to be determined. It is + recommended that GUALCHK* macros be by themselves in source lines, + so that __FILE__ and __LINE__ will be usable to identify them. +*/ + +/* This is the type we use to pass values to guality_check. */ + +typedef intmax_t gualchk_t; + +/* Convert a pointer or integral type to the widest integral type, + as expected by guality_check. */ + +#ifndef __cplusplus +#define GUALCVT(val) \ + ((gualchk_t)__builtin_choose_expr \ + (__builtin_types_compatible_p (__typeof (val), gualchk_t), \ + (val), \ + __builtin_choose_expr \ + (__builtin_classify_type (val) \ + == __builtin_classify_type (&guality_skip), \ + (uintptr_t)(val),(intptr_t)(val)))) +#else +template +inline __attribute__((always_inline)) gualchk_t +gualcvt (T *val) +{ + return (uintptr_t) val; +} + +template +inline __attribute__((always_inline)) gualchk_t +gualcvt (T val) +{ + return (intptr_t) val; +} + +template <> +inline __attribute__((always_inline)) gualchk_t +gualcvt (gualchk_t val) +{ + return val; +} + +#define GUALCVT(val) gualcvt (val) +#endif + +/* Attach a debugger to the current process and verify that the string + EXPR, evaluated by the debugger, yields the gualchk_t number VAL. + If the debugger cannot compute the expression, say because the + variable is unavailable, this will count as an error, unless unkok + is nonzero. */ + +#define GUALCHKXPRVAL(expr, val, unkok) \ + guality_check ((expr), (val), (unkok)) + +/* Check that a debugger knows that EXPR evaluates to the run-time + value of EXPR. Unknown values are marked as acceptable, + considering that EXPR may die right after this call. This will + affect the generated code in that EXPR will be evaluated and forced + to remain live at least until right before the call to + guality_check, although not necessarily after the call. */ + +#define GUALCHKXPR(expr) \ + GUALCHKXPRVAL (#expr, GUALCVT (expr), 1) + +/* Same as GUALCHKXPR, but issue an error if the variable is optimized + away. */ + +#define GUALCHKVAL(expr) \ + GUALCHKXPRVAL (#expr, GUALCVT (expr), 0) + +/* Check that a debugger knows that EXPR evaluates to the run-time + value of EXPR. Unknown values are marked as errors, because the + value of EXPR is forced to be available right after the call, for a + range of at least one instruction. This will affect the generated + code, in that EXPR *will* be evaluated before and preserved until + after the call to guality_check. */ + +#define GUALCHKFLA(expr) do { \ + __typeof(expr) volatile __preserve_after; \ + __typeof(expr) __preserve_before = (expr); \ + GUALCHKXPRVAL (#expr, GUALCVT (__preserve_before), 0); \ + __preserve_after = __preserve_before; \ + asm ("" : : "m" (__preserve_after)); \ + } while (0) + +/* GUALCHK is the simplest way to assert that debug information for an + expression matches its run-time value. Whether to force the + expression live after the call, so as to flag incompleteness + errors, can be disabled by defining GUALITY_DONT_FORCE_LIVE_AFTER. + Setting it to -1, an error is issued for optimized out variables, + even though they are not forced live. */ + +#if ! GUALITY_DONT_FORCE_LIVE_AFTER +#define GUALCHK(var) GUALCHKFLA(var) +#elif GUALITY_DONT_FORCE_LIVE_AFTER < 0 +#define GUALCHK(var) GUALCHKVAL(var) +#else +#define GUALCHK(var) GUALCHKXPR(var) +#endif + +/* The name of the GDB program, with arguments to make it quiet. This + is GUALITY_GDB_DEFAULT GUALITY_GDB_ARGS by default, but it can be + overridden by setting the GUALITY_GDB environment variable, whereas + GUALITY_GDB_DEFAULT can be overridden by setting the + GUALITY_GDB_NAME environment variable. */ + +static const char *guality_gdb_command; +#define GUALITY_GDB_DEFAULT "gdb" +#if defined(__unix) +# define GUALITY_GDB_REDIRECT " > /dev/null 2>&1" +#elif defined (_WIN32) || defined (MSDOS) +# define GUALITY_GDB_REDIRECT " > nul" +#else +# define GUALITY_GDB_REDIRECT "" +#endif +#define GUALITY_GDB_ARGS " -nx -nw --quiet" GUALITY_GDB_REDIRECT + +/* Kinds of results communicated as exit status from child process + that runs gdb to the parent process that's being monitored. */ + +enum guality_counter { PASS, INCORRECT, INCOMPLETE }; + +/* Count of passes and errors. */ + +static int guality_count[INCOMPLETE+1]; + +/* If --guality-skip is given in the command line, all the monitoring, + forking and debugger-attaching action will be disabled. This is + useful to run the monitor program within a debugger. */ + +static int guality_skip; + +/* This is a file descriptor to which we'll issue gdb commands to + probe and test. */ +FILE *guality_gdb_input; + +/* This holds the line number where we're supposed to set a + breakpoint. */ +int guality_breakpoint_line; + +/* GDB should set this to true once it's connected. */ +int volatile guality_attached; + +/* This function is the main guality program. It may actually be + defined as main, because we #define main to it afterwards. Because + of this wrapping, guality_main may not have an empty argument + list. */ + +extern int guality_main (int argc, char *argv[]); + +static void __attribute__((noinline)) +guality_check (const char *name, gualchk_t value, int unknown_ok); + +/* Set things up, run guality_main, then print a summary and quit. */ + +int +main (int argc, char *argv[]) +{ + int i; + char *argv0 = argv[0]; + + guality_gdb_command = getenv ("GUALITY_GDB"); + if (!guality_gdb_command) + { + guality_gdb_command = getenv ("GUALITY_GDB_NAME"); + if (!guality_gdb_command) + guality_gdb_command = GUALITY_GDB_DEFAULT GUALITY_GDB_ARGS; + else + { + int len = strlen (guality_gdb_command) + sizeof (GUALITY_GDB_ARGS); + char *buf = (char *) __builtin_alloca (len); + strcpy (buf, guality_gdb_command); + strcat (buf, GUALITY_GDB_ARGS); + guality_gdb_command = buf; + } + } + + for (i = 1; i < argc; i++) + if (strcmp (argv[i], "--guality-skip") == 0) + guality_skip = 1; + else + break; + + if (!guality_skip) + { + guality_gdb_input = popen (guality_gdb_command, "w"); + /* This call sets guality_breakpoint_line. */ + guality_check (NULL, 0, 0); + if (!guality_gdb_input + || fprintf (guality_gdb_input, "\ +set height 0\n\ +attach %i\n\ +set guality_attached = 1\n\ +b %i\n\ +continue\n\ +", (int)getpid (), guality_breakpoint_line) <= 0 + || fflush (guality_gdb_input)) + { + perror ("gdb"); + abort (); + } + } + + argv[--i] = argv0; + + guality_main (argc - i, argv + i); + + i = guality_count[INCORRECT]; + + fprintf (stderr, "%s: %i PASS, %i FAIL, %i UNRESOLVED\n", + i ? "FAIL" : "PASS", + guality_count[PASS], guality_count[INCORRECT], + guality_count[INCOMPLETE]); + + return i; +} + +#define main guality_main + +/* Tell the GDB child process to evaluate NAME in the caller. If it + matches VALUE, we have a PASS; if it's unknown and UNKNOWN_OK, we + have an UNRESOLVED. Otherwise, it's a FAIL. */ + +static void __attribute__((noinline)) +guality_check (const char *name, gualchk_t value, int unknown_ok) +{ + int result; + + if (guality_skip) + return; + + { + volatile gualchk_t xvalue = -1; + volatile int unavailable = 0; + if (name) + { + /* The sequence below cannot distinguish an optimized away + variable from one mapped to a non-lvalue zero. */ + if (fprintf (guality_gdb_input, "\ +up\n\ +set $value1 = 0\n\ +set $value1 = (%s)\n\ +set $value2 = -1\n\ +set $value2 = (%s)\n\ +set $value3 = $value1 - 1\n\ +set $value4 = $value1 + 1\n\ +set $value3 = (%s)++\n\ +set $value4 = --(%s)\n\ +down\n\ +set xvalue = $value1\n\ +set unavailable = $value1 != $value2 ? -1 : $value3 != $value4 ? 1 : 0\n\ +continue\n\ +", name, name, name, name) <= 0 + || fflush (guality_gdb_input)) + { + perror ("gdb"); + abort (); + } + else if (!guality_attached) + { + unsigned int timeout = 0; + + /* Give GDB some more time to attach. Wrapping around a + 32-bit counter takes some seconds, it should be plenty + of time for GDB to get a chance to start up and attach, + but not long enough that, if GDB is unavailable or + broken, we'll take far too long to give up. */ + while (--timeout && !guality_attached) + ; + if (!timeout && !guality_attached) + { + fprintf (stderr, "gdb: took too long to attach\n"); + abort (); + } + } + } + else + { + guality_breakpoint_line = __LINE__ + 5; + return; + } + /* Do NOT add lines between the __LINE__ above and the line below, + without also adjusting the added constant to match. */ + if (!unavailable || (unavailable > 0 && xvalue)) + { + if (xvalue == value) + result = PASS; + else + result = INCORRECT; + } + else + result = INCOMPLETE; + asm ("" : : "X" (name), "X" (value), "X" (unknown_ok), "m" (xvalue)); + switch (result) + { + case PASS: + fprintf (stderr, "PASS: %s is %lli\n", name, value); + break; + case INCORRECT: + fprintf (stderr, "FAIL: %s is %lli, not %lli\n", name, xvalue, value); + break; + case INCOMPLETE: + fprintf (stderr, "%s: %s is %s, expected %lli\n", + unknown_ok ? "UNRESOLVED" : "FAIL", name, + unavailable < 0 ? "not computable" : "optimized away", value); + result = unknown_ok ? INCOMPLETE : INCORRECT; + break; + default: + abort (); + } + } + + switch (result) + { + case PASS: + case INCORRECT: + case INCOMPLETE: + ++guality_count[result]; + break; + + default: + abort (); + } +} diff --git a/gcc/testsuite/gcc.dg/guality/inline-params.c b/gcc/testsuite/gcc.dg/guality/inline-params.c new file mode 100644 index 000000000..f4c5f1509 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/inline-params.c @@ -0,0 +1,45 @@ +/* { dg-do run } */ +/* IPA-SRA removes the arguments as dead, so we don't see their values, early + inlining inlines the functions too early to test the real IPA passes (such + as IPA-CP). */ +/* { dg-options "-g -fno-early-inlining -fno-ipa-sra" } */ +/* { dg-xfail-run-if "" { "*-*-*" } { "-O2" "-O3" "-Os" } } */ + +#define GUALITY_DONT_FORCE_LIVE_AFTER -1 + +#ifndef STATIC_INLINE +#define STATIC_INLINE /*static*/ +#endif + + +#include "guality.h" + +struct a{ + struct b {int a;} b; + struct c{ int a;} c; +}; + +__attribute__ ((always_inline)) static inline void +t1 (struct b *ab, int b) +{ + GUALCHKXPRVAL ("b", 0xbbb, 0); + GUALCHKVAL (ab); +} +__attribute__ ((always_inline)) static inline void +t2 (struct c *ac, char *msg) +{ + GUALCHKVAL (ac); + GUALCHKVAL (msg); +} +__attribute__ ((always_inline)) static inline void +t3 (struct a *a) +{ + t1(&a->b, 0xbbb); + t2(&a->c, "test"); +} +struct a a={{0},{1}}; +int +main (int argc, char *argv[]) +{ + t3(&a); +} diff --git a/gcc/testsuite/gcc.dg/guality/nrv-1.c b/gcc/testsuite/gcc.dg/guality/nrv-1.c new file mode 100644 index 000000000..6e70050ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/nrv-1.c @@ -0,0 +1,29 @@ +/* { dg-do run } */ +/* { dg-options "-g -fno-tree-sra" } */ + +void abort (void); + +struct A +{ + int i[100]; +}; + +struct A a1, a3; + +__attribute__((noinline)) struct A +f () +{ + struct A a2; + a2.i[0] = 42; + if (a3.i[0] != 0) + abort (); + a2.i[4] = 7; /* { dg-final { gdb-test 20 "a2.i\[0\]" "42" } } */ + return a2; +} + +int +main () +{ + a1 = f (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr36728-1.c b/gcc/testsuite/gcc.dg/guality/pr36728-1.c new file mode 100644 index 000000000..c4ad564e1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr36728-1.c @@ -0,0 +1,49 @@ +/* PR debug/36728 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +int __attribute__((noinline)) +foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7) +{ + char *x = __builtin_alloca (arg7); + int __attribute__ ((aligned(32))) y; + + y = 2; + asm volatile ("" : "=m" (y) : "m" (y)); + x[0] = 25; + asm volatile ("" : "=m" (x[0]) : "m" (x[0])); + return y; +} + +/* On s390(x) r2 and r3 are (depending on the optimization level) used + when adjusting the addresses in order to meet the alignment + requirements above. They usually hold the function arguments arg1 + and arg2. So it is expected that these values are unavailable in + some of these tests. */ + +/* { dg-final { gdb-test 12 "arg1" "1" { target { ! "s390*-*-*" } } } }*/ +/* { dg-final { gdb-test 12 "arg2" "2" { target { ! "s390*-*-*" } } } }*/ +/* { dg-final { gdb-test 12 "arg3" "3" } } */ +/* { dg-final { gdb-test 12 "arg4" "4" } } */ +/* { dg-final { gdb-test 12 "arg5" "5" } } */ +/* { dg-final { gdb-test 12 "arg6" "6" } } */ +/* { dg-final { gdb-test 12 "arg7" "30" } } */ +/* { dg-final { gdb-test 12 "y" "2" } } */ +/* { dg-final { gdb-test 14 "arg1" "1" { target { ! "s390*-*-*" } } } }*/ +/* { dg-final { gdb-test 14 "arg2" "2" { target { ! "s390*-*-*" } } } }*/ +/* { dg-final { gdb-test 14 "arg3" "3" } } */ +/* { dg-final { gdb-test 14 "arg4" "4" } } */ +/* { dg-final { gdb-test 14 "arg5" "5" } } */ +/* { dg-final { gdb-test 14 "arg6" "6" } } */ +/* { dg-final { gdb-test 14 "arg7" "30" } } */ +/* { dg-final { gdb-test 14 "*x" "(char) 25" } } */ +/* { dg-final { gdb-test 14 "y" "2" } } */ + +int +main () +{ + int l = 0; + asm volatile ("" : "=r" (l) : "0" (l)); + foo (l + 1, l + 2, l + 3, l + 4, l + 5, l + 6, l + 30); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr36728-2.c b/gcc/testsuite/gcc.dg/guality/pr36728-2.c new file mode 100644 index 000000000..a7c2de747 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr36728-2.c @@ -0,0 +1,49 @@ +/* PR debug/36728 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +int __attribute__((noinline)) +foo (int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7) +{ + char x[30]; + int __attribute__ ((aligned(32))) y; + + y = 2; + asm volatile ("" : "=m" (y) : "m" (y)); + x[0] = 25; + asm volatile ("" : "=m" (x[0]) : "m" (x[0])); + return y; +} + +/* On s390(x) r2 and r3 are (depending on the optimization level) used + when adjusting the addresses in order to meet the alignment + requirements above. They usually hold the function arguments arg1 + and arg2. So it is expected that these values are unavailable in + some of these tests. */ + +/* { dg-final { gdb-test 12 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 12 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 12 "arg3" "3" } } */ +/* { dg-final { gdb-test 12 "arg4" "4" } } */ +/* { dg-final { gdb-test 12 "arg5" "5" } } */ +/* { dg-final { gdb-test 12 "arg6" "6" } } */ +/* { dg-final { gdb-test 12 "arg7" "30" } } */ +/* { dg-final { gdb-test 12 "y" "2" } } */ +/* { dg-final { gdb-test 14 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 14 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 14 "arg3" "3" } } */ +/* { dg-final { gdb-test 14 "arg4" "4" } } */ +/* { dg-final { gdb-test 14 "arg5" "5" } } */ +/* { dg-final { gdb-test 14 "arg6" "6" } } */ +/* { dg-final { gdb-test 14 "arg7" "30" } } */ +/* { dg-final { gdb-test 14 "*x" "(char) 25" } } */ +/* { dg-final { gdb-test 14 "y" "2" } } */ + +int +main () +{ + int l = 0; + asm volatile ("" : "=r" (l) : "0" (l)); + foo (l + 1, l + 2, l + 3, l + 4, l + 5, l + 6, l + 30); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr36977.c b/gcc/testsuite/gcc.dg/guality/pr36977.c new file mode 100644 index 000000000..3689fae8c --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr36977.c @@ -0,0 +1,32 @@ +/* PR debug/36977 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ + +void +foo () +{ +} + +int +main () +{ + struct { char c[100]; } cbig; + struct { int i[800]; } ibig; + struct { long l[900]; } lbig; + struct { float f[200]; } fbig; + struct { double d[300]; } dbig; + struct { short s[400]; } sbig; + + ibig.i[0] = 55; /* { dg-final { gdb-test 30 "ibig.i\[0\]" "55" } } */ + ibig.i[100] = 5; /* { dg-final { gdb-test 30 "ibig.i\[100\]" "5" } } */ + cbig.c[0] = '\0'; /* { dg-final { gdb-test 30 "cbig.c\[0\]" "'\\0'" } } */ + cbig.c[99] = 'A'; /* { dg-final { gdb-test 30 "cbig.c\[99\]" "'A'" } } */ + fbig.f[100] = 11.0; /* { dg-final { gdb-test 30 "fbig.f\[100\]" "11" } } */ + dbig.d[202] = 9.0; /* { dg-final { gdb-test 30 "dbig.d\[202\]" "9" } } */ + sbig.s[90] = 255; /* { dg-final { gdb-test 30 "sbig.s\[90\]" "255" } } */ + lbig.l[333] = 999; /* { dg-final { gdb-test 30 "lbig.l\[333\]" "999" } } */ + + foo (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr41353-1.c b/gcc/testsuite/gcc.dg/guality/pr41353-1.c new file mode 100644 index 000000000..1d2cca787 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr41353-1.c @@ -0,0 +1,56 @@ +/* PR debug/41353 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +int vari __attribute__((used)) = 17, varj; + +__attribute__((noinline)) int +f1 (void) +{ + /* { dg-final { gdb-test 17 "vari" "17" } } */ + int vari1 = 2 * vari; /* { dg-final { gdb-test 17 "vari1" "2 * 17" } } */ + int vari2 = 3 * vari; /* { dg-final { gdb-test 17 "vari2" "3 * 17" } } */ + int vari3 = 2 * vari; /* { dg-final { gdb-test 17 "vari3" "2 * 17" } } */ + int vari4 = 3 * vari; /* { dg-final { gdb-test 17 "vari4" "3 * 17" } } */ + int vari5 = 4 * vari; /* { dg-final { gdb-test 17 "vari5" "4 * 17" } } */ + int vari6 = 5 * vari; /* { dg-final { gdb-test 17 "vari6" "5 * 17" } } */ + return varj; +} + +__attribute__((noinline)) int +f2 (int i, int j) +{ + j += i; + /* { dg-final { gdb-test 28 "i" "37" } } */ + /* { dg-final { gdb-test 28 "j" "28 + 37" { xfail *-*-* } } } */ + int i1 = 2 * i; /* { dg-final { gdb-test 28 "i1" "2 * 37" } } */ + int i2 = 3 * i; /* { dg-final { gdb-test 28 "i2" "3 * 37" } } */ + return j; +} + +__attribute__((noinline)) int +f3 (int i) +{ + asm volatile ("" : "+r" (i)); + /* { dg-final { gdb-test 39 "i" "12" } } */ + int i1 = 2 * i; /* { dg-final { gdb-test 39 "i1" "2 * 12" } } */ + int i2 = 2 * i; /* { dg-final { gdb-test 39 "i2" "2 * 12" } } */ + int i3 = 3 * i; /* { dg-final { gdb-test 39 "i3" "3 * 12" } } */ + return i; +} + +int (*volatile fnp1) (void) = f1; +int (*volatile fnp2) (int, int) = f2; +int (*volatile fnp3) (int) = f3; + +int +main (int argc, char *argv[]) +{ + asm volatile ("" : : "r" (&fnp1) : "memory"); + asm volatile ("" : : "r" (&fnp2) : "memory"); + asm volatile ("" : : "r" (&fnp3) : "memory"); + fnp1 (); + fnp2 (37, 28); + fnp3 (12); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr41353-2.c b/gcc/testsuite/gcc.dg/guality/pr41353-2.c new file mode 100644 index 000000000..0983bf4ab --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr41353-2.c @@ -0,0 +1,24 @@ +/* PR debug/41353 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +int varh; +int vari __attribute__((used)) = 17, varj; + +__attribute__((noinline)) int +f1 (void) +{ + int vari1 = 2 * vari; /* { dg-final { gdb-test 13 "vari1" "2 * 17" } } */ + int vari2 = 3 * vari; /* { dg-final { gdb-test 13 "vari2" "3 * 17" } } */ + return varj; +} + +int (*volatile fnp1) (void) = f1; + +int +main (int argc, char *argv[]) +{ + asm volatile ("" : : "r" (&fnp1) : "memory"); + fnp1 (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr41404-1.c b/gcc/testsuite/gcc.dg/guality/pr41404-1.c new file mode 100644 index 000000000..59a8293e6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr41404-1.c @@ -0,0 +1,41 @@ +/* PR debug/41404 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +__attribute__ ((noinline)) +int bar1 (int i) +{ + const char *foo = "foo"; + asm volatile ("" : "+r" (i) : : "memory"); + i++; /* { dg-final { gdb-test 10 "*foo" "'f'" } } */ + asm volatile ("" : "+r" (i) : : "memory"); + foo = "bar"; + asm volatile ("" : "+r" (i) : : "memory"); + i++; /* { dg-final { gdb-test 14 "*foo" "'b'" } } */ + asm volatile ("" : "+r" (i) : : "memory"); + return i; +} + +__attribute__ ((noinline)) +int bar2 (int i) +{ + const char *foo = "foo"; + asm volatile ("" : "+r" (i) : : "memory"); + i++; /* { dg-final { gdb-test 24 "*foo" "'f'" } } */ + asm volatile ("" : "+r" (i) : : "memory"); + return i; +} + +__attribute__ ((noinline)) +const char *baz (int i) +{ + return i ? "foo" : "bar"; +} + +int +main (void) +{ + bar1 (6); + bar2 (6); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr41447-1.c b/gcc/testsuite/gcc.dg/guality/pr41447-1.c new file mode 100644 index 000000000..9bb28abe3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr41447-1.c @@ -0,0 +1,26 @@ +/* { dg-do run { xfail *-*-* } } */ +/* { dg-options "-g" } */ + +#include "guality.h" + +int a; + +int +main (int argc, char *argv[]) +{ + int tmp = a; + int tmp2 = a; + int tmp3; + int res; + GUALCHKVAL (a); + GUALCHKVAL (tmp); + GUALCHKVAL (tmp2); + a = 0; + tmp3 = tmp2; + GUALCHKVAL (a); + GUALCHKVAL (tmp); + GUALCHKVAL (tmp2); + GUALCHKVAL (tmp3); + res = tmp - tmp2 + 1; + return res; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr41616-1.c b/gcc/testsuite/gcc.dg/guality/pr41616-1.c new file mode 100644 index 000000000..24f64ab08 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr41616-1.c @@ -0,0 +1,20 @@ +/* { dg-do run { xfail *-*-* } } */ +/* { dg-options "-g" } */ + +#include "guality.h" + +inline int f(int *a) +{ + return *a; +} + +int +main(int argc, char *argv[]) +{ + int b = -1; + GUALCHKVAL (b); + if (argc > 0) + b = -f(&b); + GUALCHKVAL (b); + return b; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr42782.c b/gcc/testsuite/gcc.dg/guality/pr42782.c new file mode 100644 index 000000000..6a880814a --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr42782.c @@ -0,0 +1,24 @@ +/* { dg-options "-g" } */ + +#include "guality.h" + +void __attribute__ ((__noinline__)) +g (void) +{ + asm volatile (""); +} + +int +f (int a) +{ + g (); + GUALCHKVAL (a); + return a; +} + +int +main (int argc, char *argv[]) +{ + f (argc + 2); + f (argc + 5); +} diff --git a/gcc/testsuite/gcc.dg/guality/pr43051-1.c b/gcc/testsuite/gcc.dg/guality/pr43051-1.c new file mode 100644 index 000000000..77325c97e --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr43051-1.c @@ -0,0 +1,57 @@ +/* PR debug/43051 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +extern void abort (void); + +static void __attribute__ ((noinline)) +foo (const char *x, long long y, int z) +{ + asm volatile ("" : : "r" (x), "r" ((int) y), "r" (z) : "memory"); +} + +struct S +{ + struct S *n; + int v; +}; + +struct S a[10]; + +struct S * __attribute__ ((noinline)) +bar (struct S *c, int v, struct S *e) +{ +#ifdef __i386__ + register int si asm ("esi"), di asm ("edi"), bx +# if !defined (__pic__) && !defined (__APPLE__) + asm ("ebx") +# endif + ; + asm volatile ("" : "=r" (si), "=r" (di), "=r" (bx)); +#endif + while (c < e) + { + foo ("c", (__UINTPTR_TYPE__) c, 0); /* { dg-final { gdb-test 34 "c" "\&a\[0\]" } } */ + foo ("v", v, 1); /* { dg-final { gdb-test 35 "v" "1" } } */ + foo ("e", (__UINTPTR_TYPE__) e, 2); /* { dg-final { gdb-test 36 "e" "\&a\[1\]" } } */ + if (c->v == v) + return c; + foo ("c", (__UINTPTR_TYPE__) c, 3); /* { dg-final { gdb-test 39 "c" "\&a\[0\]" } } */ + foo ("v", v, 4); /* { dg-final { gdb-test 40 "v" "1" } } */ + foo ("e", (__UINTPTR_TYPE__) e, 5); /* { dg-final { gdb-test 41 "e" "\&a\[1\]" } } */ + c++; + } +#ifdef __i386__ + asm volatile ("" : : "r" (si), "r" (di), "r" (bx)); +#endif + return 0; +} + +int +main () +{ + asm volatile ("" : : "r" (&a[0]) : "memory"); + if (bar (&a[a[0].v], a[0].v + 1, &a[a[0].v + 1])) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr43077-1.c b/gcc/testsuite/gcc.dg/guality/pr43077-1.c new file mode 100644 index 000000000..d8d5eebe0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr43077-1.c @@ -0,0 +1,55 @@ +/* PR debug/43077 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +int varb; + +int __attribute__((noinline)) +fn1 (void) +{ + int vara = (varb == 3); /* { dg-final { gdb-test 11 "vara" "0" } } */ + asm volatile ("" : : "g" (vara)); /* { dg-final { gdb-test 11 "varb" "2" } } */ + return 0; +} + +int __attribute__((noinline)) +fn2 (void) +{ + int vara = (varb == 3); /* { dg-final { gdb-test 19 "vara" "1" } } */ + asm volatile ("" : : "g" (vara)); /* { dg-final { gdb-test 19 "varb" "3" } } */ + return 0; +} + +int __attribute__((noinline)) +foo (unsigned long *p, unsigned long *q) +{ + int ret; + asm volatile ("" : "=r" (ret), "=r" (*p), "=r" (*q) : "0" (1), "1" (2), "2" (3)); + return ret; +} + +int __attribute__((noinline)) +fn3 (void) +{ + unsigned long a = 0, b = 0, c = 0; + a = foo (&b, &c); + /* { dg-final { gdb-test 42 "a" "1" } } */ + /* { dg-final { gdb-test 42 "b" "2" } } */ + /* { dg-final { gdb-test 42 "c" "3" } } */ + unsigned long vara = a; /* { dg-final { gdb-test 42 "vara" "1" } } */ + unsigned long varb = b; /* { dg-final { gdb-test 42 "varb" "2" } } */ + unsigned long varc = c; /* { dg-final { gdb-test 42 "varc" "3" } } */ + asm volatile ("" : : "g" (vara), "g" (varb), "g" (varc)); + return a; +} + +int +main (void) +{ + asm volatile ("" : "=r" (varb) : "0" (2)); + fn1 (); + asm volatile ("" : "=r" (varb) : "0" (3)); + fn2 (); + fn3 (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr43177.c b/gcc/testsuite/gcc.dg/guality/pr43177.c new file mode 100644 index 000000000..563835b63 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr43177.c @@ -0,0 +1,36 @@ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +void __attribute__((noinline)) +bar (long x) +{ + asm volatile ("" : : "r" (x) : "memory"); +} + +long __attribute__((noinline)) +foo (long x) +{ + long l = x + 3; + bar (l);/* { dg-final { gdb-test 15 "l" "10" } } */ + bar (l);/* { dg-final { gdb-test 15 "x" "7" } } */ + return l; +} + +long __attribute__((noinline)) +baz (int x) +{ + long l = x + 3; + bar (l);/* { dg-final { gdb-test 24 "l" "10" } } */ + bar (l);/* { dg-final { gdb-test 24 "x" "7" } } */ + return l; +} + +int +main (void) +{ + int i; + asm volatile ("" : "=r" (i) : "0" (7)); + foo (i); + baz (i); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr43329-1.c b/gcc/testsuite/gcc.dg/guality/pr43329-1.c new file mode 100644 index 000000000..5e27adfca --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr43329-1.c @@ -0,0 +1,52 @@ +/* PR debug/43329 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +static inline void +foo (int argx) +{ + int varx = argx; + __asm__ volatile (NOP); /* { dg-final { gdb-test 12 "argx" "25" } } */ + __asm__ volatile (NOP : : "g" (varx)); /* { dg-final { gdb-test 12 "varx" "25" } } */ +} + +int i; + +__attribute__((noinline)) +void baz (int x) +{ + asm volatile ("" : : "r" (x) : "memory"); +} + +static inline void +bar (void) +{ + foo (25); + i = i + 2; + i = i * 2; + i = i - 4; + baz (i); + i = i * 2; + i = i >> 1; + i = i << 6; + baz (i); + i = i + 2; + i = i * 2; + i = i - 4; + baz (i); + i = i * 2; + i = i >> 6; + i = i << 1; + baz (i); +} + +int +main (void) +{ + __asm__ volatile ("" : "=r" (i) : "0" (0)); + bar (); + bar (); + return i; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr43479.c b/gcc/testsuite/gcc.dg/guality/pr43479.c new file mode 100644 index 000000000..e0bc246cd --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr43479.c @@ -0,0 +1,33 @@ +/* PR debug/43479 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +__attribute__((noinline)) void +foo (int k, int l, int m, int n) +{ + l++; + { + int h = n; + { + int i = k; + k++; /* { dg-final { gdb-test 13 "i" "6" } } */ + } /* { dg-final { gdb-test 13 "h" "9" } } */ + /* { dg-final { gdb-test 13 "n" "9" } } */ + { + int j = m; + m++; /* { dg-final { gdb-test 18 "j" "8" } } */ + } /* { dg-final { gdb-test 18 "h" "9" } } */ + /* { dg-final { gdb-test 12 "n" "9" } } */ + } + asm volatile ("" : : "r" (k), "r" (l)); + asm volatile ("" : : "r" (m), "r" (n)); +} + +int +main (void) +{ + int q = 6; + asm ("" : "+r" (q)); + foo (q, q + 1, q + 2, q + 3); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr43593.c b/gcc/testsuite/gcc.dg/guality/pr43593.c new file mode 100644 index 000000000..d8cc41359 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr43593.c @@ -0,0 +1,24 @@ +/* PR debug/43593 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +void __attribute__((noinline)) +bar (int *p) +{ + asm volatile ("" : : "r" (p) : "memory"); +} + +int __attribute__((noinline)) +foo (void) +{ + int i, *j = &i; + bar (j); + return 6 + i; /* { dg-final { gdb-test 16 "j" "&i" } } */ +} + +int +main (void) +{ + foo (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr45003-1.c b/gcc/testsuite/gcc.dg/guality/pr45003-1.c new file mode 100644 index 000000000..7cef8f628 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr45003-1.c @@ -0,0 +1,31 @@ +/* PR debug/45003 */ +/* { dg-do run { target { x86_64-*-* && lp64 } } } */ +/* { dg-options "-g" } */ + +int __attribute__((noinline)) +foo (unsigned short *p) +{ + int a = *p; + asm volatile ("nop"); + asm volatile ("nop" : : "D" (a)); /* { dg-final { gdb-test 10 "a" "0x8078" } } */ + return 0; +} + +int __attribute__((noinline)) +bar (short *p) +{ + unsigned int a = *p; + asm volatile ("nop"); + asm volatile ("nop" : : "D" (a)); /* { dg-final { gdb-test 19 "a" "0xffff8078" } } */ + return 0; +} + +int +main () +{ + unsigned short us = 0x8078; + foo (&us); + short s = -32648; + bar (&s); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr45003-2.c b/gcc/testsuite/gcc.dg/guality/pr45003-2.c new file mode 100644 index 000000000..dcdba237f --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr45003-2.c @@ -0,0 +1,31 @@ +/* PR debug/45003 */ +/* { dg-do run { target { x86_64-*-* && lp64 } } } */ +/* { dg-options "-g" } */ + +int __attribute__((noinline)) +foo (unsigned short *p) +{ + int a = *p; + asm volatile ("nop" : : "D" ((int) *p)); + asm volatile ("nop" : : "D" ((int) *p)); /* { dg-final { gdb-test 10 "a" "0x8078" } } */ + return 0; +} + +int __attribute__((noinline)) +bar (short *p) +{ + unsigned int a = *p; + asm volatile ("nop" : : "D" ((unsigned int) *p)); + asm volatile ("nop" : : "D" ((unsigned int) *p)); /* { dg-final { gdb-test 19 "a" "0xffff8078" } } */ + return 0; +} + +int +main () +{ + unsigned short us = 0x8078; + foo (&us); + short s = -32648; + bar (&s); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr45003-3.c b/gcc/testsuite/gcc.dg/guality/pr45003-3.c new file mode 100644 index 000000000..3adc4f238 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr45003-3.c @@ -0,0 +1,31 @@ +/* PR debug/45003 */ +/* { dg-do run { target { x86_64-*-* && lp64 } } } */ +/* { dg-options "-g" } */ + +int __attribute__((noinline)) +foo (unsigned short *p) +{ + int a = (short) *p; + asm volatile ("nop" : : "D" ((int) *p)); + asm volatile ("nop" : : "D" ((int) *p)); /* { dg-final { gdb-test 10 "a" "-32648" } } */ + return 0; +} + +int __attribute__((noinline)) +bar (short *p) +{ + unsigned int a = (unsigned short) *p; + asm volatile ("nop" : : "D" ((unsigned int) *p)); + asm volatile ("nop" : : "D" ((unsigned int) *p)); /* { dg-final { gdb-test 19 "a" "0x8078" } } */ + return 0; +} + +int +main () +{ + unsigned short us = 0x8078; + foo (&us); + short s = -32648; + bar (&s); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/pr48466.c b/gcc/testsuite/gcc.dg/guality/pr48466.c new file mode 100644 index 000000000..8d5426a99 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/pr48466.c @@ -0,0 +1,41 @@ +/* PR debug/48466 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ + +struct S { unsigned int a; unsigned int *b; }; +struct T { struct S a; struct S b; }; +struct U { const char *u; }; +int n[10]; +volatile int v; + +struct U +foo (const char *s) +{ + struct U r; + r.u = s; + return r; +} + +void +bar (struct T *s, int a, int b) +{ + s->a.a = a; + s->a.b = &s->a.a; + s->b.a = b; + s->b.b = &s->b.a; +} + +int +main () +{ + struct T t; + struct U x = foo ("this is x"); + struct S y, z; + y.b = n; /* { dg-final { gdb-test 38 "t.a.a" "17" } } */ + y.a = 0; /* { dg-final { gdb-test 38 "*t.a.b" "17" } } */ + bar (&t, 17, 21); /* { dg-final { gdb-test 38 "t.b.a" "21" } } */ + v++; /* { dg-final { gdb-test 38 "*t.b.b" "21" } } */ + z = y; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/sra-1.c b/gcc/testsuite/gcc.dg/guality/sra-1.c new file mode 100644 index 000000000..e779d7ac8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/sra-1.c @@ -0,0 +1,56 @@ +/* PR debug/43983 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +struct A { int i; int j; }; +struct B { int : 4; int i : 12; int j : 12; int : 4; }; + +__attribute__((noinline)) void +bar (int x) +{ + asm volatile ("" : : "r" (x) : "memory"); +} + +__attribute__((noinline)) int +f1 (int k) +{ + struct A a = { 4, k + 6 }; + asm ("" : "+r" (a.i)); + a.j++; + bar (a.i); /* { dg-final { gdb-test 21 "a.i" "4" } } */ + bar (a.j); /* { dg-final { gdb-test 21 "a.j" "14" } } */ + return a.i + a.j; +} + +__attribute__((noinline)) int +f2 (int k) +{ + int a[2] = { 4, k + 6 }; + asm ("" : "+r" (a[0])); + a[1]++; + bar (a[0]); /* { dg-final { gdb-test 32 "a\[0\]" "4" } } */ + bar (a[1]); /* { dg-final { gdb-test 32 "a\[1\]" "14" } } */ + return a[0] + a[1]; +} + +__attribute__((noinline)) int +f3 (int k) +{ + struct B a = { 4, k + 6 }; + asm ("" : "+r" (a.i)); + a.j++; + bar (a.i); /* { dg-final { gdb-test 43 "a.i" "4" } } */ + bar (a.j); /* { dg-final { gdb-test 43 "a.j" "14" } } */ + return a.i + a.j; +} + +int +main (void) +{ + int k; + asm ("" : "=r" (k) : "0" (7)); + f1 (k); + f2 (k); + f3 (k); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/vla-1.c b/gcc/testsuite/gcc.dg/guality/vla-1.c new file mode 100644 index 000000000..2db1c29ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/vla-1.c @@ -0,0 +1,36 @@ +/* PR debug/43150 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +void __attribute__((noinline)) +bar (short *p) +{ + __builtin_memset (p, '\0', 17 * sizeof (*p)); + asm volatile ("" : : "r" (p) : "memory"); +} + +int __attribute__((noinline)) +f1 (int i) +{ + char a[i + 1]; + a[0] = 5; /* { dg-final { gdb-test 17 "i" "5" } } */ + return a[0]; /* { dg-final { gdb-test 17 "sizeof (a)" "6" } } */ +} + +int __attribute__((noinline)) +f2 (int i) +{ + short a[i * 2 + 7]; /* { dg-final { gdb-test 24 "i" "5" } } */ + bar (a); /* { dg-final { gdb-test 24 "sizeof (a)" "17 * sizeof (short)" } } */ + return a[i + 4]; +} + +int +main () +{ + int i = 5; + asm volatile ("" : "=r" (i) : "0" (i)); + f1 (i); + f2 (i); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/guality/vla-2.c b/gcc/testsuite/gcc.dg/guality/vla-2.c new file mode 100644 index 000000000..6773775b9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/guality/vla-2.c @@ -0,0 +1,55 @@ +/* PR debug/42801 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +void __attribute__((noinline)) +fn1 (int *x, int y) +{ + asm volatile ("" : : "rm" (x), "rm" (y) : "memory"); +} + +static inline __attribute__((always_inline)) int +fn2 (int i) +{ + int a[i]; + fn1 (a, i); + fn1 (a, i); /* { dg-final { gdb-test 16 "sizeof (a)" "5 * sizeof (int)" } } */ + return i; +} + +static inline __attribute__((always_inline)) int +fn3 (int i) +{ + int a[i]; + fn1 (a, i); + fn1 (a, i); /* { dg-final { gdb-test 25 "sizeof (a)" "6 * sizeof (int)" } } */ + return i; +} + +static inline __attribute__((always_inline)) int +fn4 (int i) +{ + return fn3 (i); +} + +int __attribute__((noinline)) +fn5 (void) +{ + return fn2 (5) + 1; +} + +int __attribute__((noinline)) +fn6 (int i) +{ + return fn2 (i + 1) + fn4 (i + 2) + fn4 (i + 2) + 1; +} + +int +main (void) +{ + int x = 4; + asm volatile ("" : "+r" (x)); + fn5 (); + fn6 (x); + return 0; +} -- cgit v1.2.3