diff options
author | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2014-03-25 22:37:19 -0700 |
commit | 1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch) | |
tree | c607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.dg/guality | |
parent | 283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff) | |
download | toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2 toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip |
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/guality')
67 files changed, 2908 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/asm-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/asm-1.c new file mode 100644 index 000000000..e9cf4a167 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/bswaptest.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/bswaptest.c new file mode 100644 index 000000000..38b9d981c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/bswaptest.c @@ -0,0 +1,32 @@ +/* { dg-do run { target { x86_64-*-* && lp64 } } } */ +/* { dg-options "-g" } */ + +volatile int vv; + +__attribute__((noclone, noinline)) long +foo (long x) +{ + long f = __builtin_bswap64 (x); + long g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 12 "g" "f" } } */ + return f; +} + +__attribute__((noclone, noinline)) int +bar (int x) +{ + int f = __builtin_bswap32 (x); + int g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 22 "g" "f" } } */ + return f; +} + +int +main () +{ + foo (0x123456789abcde0fUL); + bar (0x12345678); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/clztest.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/clztest.c new file mode 100644 index 000000000..9428be30b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/clztest.c @@ -0,0 +1,33 @@ +/* { dg-do run { target { x86_64-*-* && lp64 } } } */ +/* { dg-options "-g" } */ + +volatile int vv; + +__attribute__((noinline, noclone)) long +foo (long x) +{ + long f = __builtin_clzl (x); + long g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 12 "g" "f" } } */ + return f; +} + +__attribute__((noinline, noclone)) long +bar (long x) +{ + long f = __builtin_clzl (x); + long g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 22 "g" "f" } } */ + return f; +} + +int +main () +{ + long x = vv; + foo (x + 0x123456UL); + bar (x + 0x7fffffffUL); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/csttest.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/csttest.c new file mode 100644 index 000000000..4480c715e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/csttest.c @@ -0,0 +1,63 @@ +/* PR debug/49676 */ +/* { dg-do run { target lp64 } } */ +/* { dg-options "-g" } */ + +volatile int v; + +__attribute__((noinline, noclone)) +unsigned long long +foo (unsigned long long x) +{ + unsigned long long a = x * (0x17ULL << 31); /* { dg-final { gdb-test 29 "a" "(0x17ULL << 31)" } } */ + unsigned long long b = x * (0x7ULL << 33); /* { dg-final { gdb-test 29 "b" "(0x7ULL << 33)" } } */ + unsigned long long c = x * (0x1ULL << 35); /* { dg-final { gdb-test 29 "c" "(0x1ULL << 35)" } } */ + unsigned long long d = x * (0x17ULL << 15); /* { dg-final { gdb-test 29 "d" "(0x17ULL << 15)" } } */ + unsigned long long e = x * (0x17ULL << 50); /* { dg-final { gdb-test 29 "e" "(0x17ULL << 50)" } } */ + unsigned long long f = x * (0x37ULL << 31); /* { dg-final { gdb-test 29 "f" "(0x37ULL << 31)" } } */ + unsigned long long g = x * (0x37ULL << 50); /* { dg-final { gdb-test 29 "g" "(0x37ULL << 50)" } } */ + unsigned long long h = x * (0x1efULL << 33); /* { dg-final { gdb-test 29 "h" "(0x1efULL << 33)" } } */ + unsigned long long i = x * (0x1efULL << 50); /* { dg-final { gdb-test 29 "i" "(0x1efULL << 50)" } } */ + unsigned long long j = x * -(0x17ULL << 31); /* { dg-final { gdb-test 29 "j" "-(0x17ULL << 31)" } } */ + unsigned long long k = x * -(0x7ULL << 33); /* { dg-final { gdb-test 29 "k" "-(0x7ULL << 33)" } } */ + unsigned long long l = x * -(0x1ULL << 35); /* { dg-final { gdb-test 29 "l" "-(0x1ULL << 35)" } } */ + unsigned long long m = x * -(0x17ULL << 15); /* { dg-final { gdb-test 29 "m" "-(0x17ULL << 15)" } } */ + unsigned long long n = x * -(0x17ULL << 50); /* { dg-final { gdb-test 29 "n" "-(0x17ULL << 50)" } } */ + unsigned long long o = x * -(0x37ULL << 31); /* { dg-final { gdb-test 29 "o" "-(0x37ULL << 31)" } } */ + unsigned long long p = x * -(0x37ULL << 50); /* { dg-final { gdb-test 29 "p" "-(0x37ULL << 50)" } } */ + unsigned long long q = x * -(0x1efULL << 33); /* { dg-final { gdb-test 29 "q" "-(0x1efULL << 33)" } } */ + unsigned long long r = x * -(0x1efULL << 50); /* { dg-final { gdb-test 29 "r" "-(0x1efULL << 50)" } } */ + v++; + return x; +} + +__attribute__((noinline, noclone)) +unsigned long long +bar (unsigned long long x) +{ + unsigned long long a = (x & 255) + (0x17ULL << 31); /* { dg-final { gdb-test 55 "a" "(0x17ULL << 31)" } } */ + unsigned long long b = (x & 255) + (0x7ULL << 33); /* { dg-final { gdb-test 55 "b" "(0x7ULL << 33)" } } */ + unsigned long long c = (x & 255) + (0x1ULL << 35); /* { dg-final { gdb-test 55 "c" "(0x1ULL << 35)" } } */ + unsigned long long d = (x & 255) + (0x17ULL << 15); /* { dg-final { gdb-test 55 "d" "(0x17ULL << 15)" } } */ + unsigned long long e = (x & 255) + (0x17ULL << 50); /* { dg-final { gdb-test 55 "e" "(0x17ULL << 50)" } } */ + unsigned long long f = (x & 255) + (0x37ULL << 31); /* { dg-final { gdb-test 55 "f" "(0x37ULL << 31)" } } */ + unsigned long long g = (x & 255) + (0x37ULL << 50); /* { dg-final { gdb-test 55 "g" "(0x37ULL << 50)" } } */ + unsigned long long h = (x & 255) + (0x1efULL << 33); /* { dg-final { gdb-test 55 "h" "(0x1efULL << 33)" } } */ + unsigned long long i = (x & 255) + (0x1efULL << 50); /* { dg-final { gdb-test 55 "i" "(0x1efULL << 50)" } } */ + unsigned long long j = (x & 255) + -(0x17ULL << 31); /* { dg-final { gdb-test 55 "j" "-(0x17ULL << 31)" } } */ + unsigned long long k = (x & 255) + -(0x7ULL << 33); /* { dg-final { gdb-test 55 "k" "-(0x7ULL << 33)" } } */ + unsigned long long l = (x & 255) + -(0x1ULL << 35); /* { dg-final { gdb-test 55 "l" "-(0x1ULL << 35)" } } */ + unsigned long long m = (x & 255) + -(0x17ULL << 15); /* { dg-final { gdb-test 55 "m" "-(0x17ULL << 15)" } } */ + unsigned long long n = (x & 255) + -(0x17ULL << 50); /* { dg-final { gdb-test 55 "n" "-(0x17ULL << 50)" } } */ + unsigned long long o = (x & 255) + -(0x37ULL << 31); /* { dg-final { gdb-test 55 "o" "-(0x37ULL << 31)" } } */ + unsigned long long p = (x & 255) + -(0x37ULL << 50); /* { dg-final { gdb-test 55 "p" "-(0x37ULL << 50)" } } */ + unsigned long long q = (x & 255) + -(0x1efULL << 33); /* { dg-final { gdb-test 55 "q" "-(0x1efULL << 33)" } } */ + unsigned long long r = (x & 255) + -(0x1efULL << 50); /* { dg-final { gdb-test 55 "r" "-(0x1efULL << 50)" } } */ + v++; + return x; +} + +int +main () +{ + return foo (1) + bar (256) - 257; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/ctztest.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/ctztest.c new file mode 100644 index 000000000..d243845ec --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/ctztest.c @@ -0,0 +1,33 @@ +/* { dg-do run { target { x86_64-*-* && lp64 } } } */ +/* { dg-options "-g" } */ + +volatile int vv; + +__attribute__((noinline, noclone)) long +foo (long x) +{ + long f = __builtin_ctzl (x); + long g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 12 "g" "f" } } */ + return f; +} + +__attribute__((noinline, noclone)) long +bar (long x) +{ + long f = __builtin_ctzl (x); + long g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 22 "g" "f" } } */ + return f; +} + +int +main () +{ + long x = vv; + foo (x + 0x1234560UL); + bar (x + 0x7fff8000UL); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/drap.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/drap.c new file mode 100644 index 000000000..573bb39d0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/drap.c @@ -0,0 +1,30 @@ +/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-g -mforce-drap" } */ + +volatile int v; + +__attribute__((noinline, noclone)) int +bar (int a, int b) +{ +#ifdef __x86_64__ + asm volatile ("movq %%rsp, %%r10" : : : "r10"); +#else + asm volatile ("movl %%esp, %%ecx" : : : "ecx"); +#endif + return 0; +} + +__attribute__((noinline, noclone)) int +foo (int v0, int v1, int v2, int v3, int v4, int v5, int a, int b) +{ + __attribute__((aligned (32))) int c = bar (a, b); + v++; /* { dg-final { gdb-test 21 "a" "5" } } */ + return a + b + c; /* { dg-final { gdb-test 22 "b" "6" } } */ +} + +int +main (void) +{ + foo (0, 0, 0, 0, 0, 0, 5, 6); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/example.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/example.c new file mode 100644 index 000000000..26d25c285 --- /dev/null +++ b/gcc-4.9/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 <assert.h> + +/* 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-4.9/gcc/testsuite/gcc.dg/guality/guality.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/guality.c new file mode 100644 index 000000000..d5d950fcd --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/guality.exp b/gcc-4.9/gcc/testsuite/gcc.dg/guality/guality.exp new file mode 100644 index 000000000..5e714dd7d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/guality.exp @@ -0,0 +1,58 @@ +# 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 +} + +if { [istarget "powerpc-ibm-aix*"] } { + set torture_execute_xfail "powerpc-ibm-aix*" + 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-4.9/gcc/testsuite/gcc.dg/guality/guality.h b/gcc-4.9/gcc/testsuite/gcc.dg/guality/guality.h new file mode 100644 index 000000000..8b657f29f --- /dev/null +++ b/gcc-4.9/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 <aoliva@redhat.com>. + +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 +<http://www.gnu.org/licenses/>. */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdint.h> +#include <unistd.h> + +/* 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 <typename T> +inline __attribute__((always_inline)) gualchk_t +gualcvt (T *val) +{ + return (uintptr_t) val; +} + +template <typename T> +inline __attribute__((always_inline)) gualchk_t +gualcvt (T val) +{ + return (intptr_t) val; +} + +template <> +inline __attribute__((always_inline)) gualchk_t +gualcvt<gualchk_t> (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-4.9/gcc/testsuite/gcc.dg/guality/inline-params.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/inline-params.c new file mode 100644 index 000000000..f4c5f1509 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/nrv-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/nrv-1.c new file mode 100644 index 000000000..6e70050ec --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/param-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-1.c new file mode 100644 index 000000000..480ad3c13 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-1.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ + +typedef __UINTPTR_TYPE__ uintptr_t; + +__attribute__((noinline, noclone)) int +sub (int a, int b) +{ + return a - b; +} + +typedef struct { uintptr_t pa; uintptr_t pb; } fatp_t + __attribute__ ((aligned (2 * __alignof__ (uintptr_t)))); + +__attribute__((noinline, noclone)) void +foo (fatp_t str, int a, int b) +{ + int i = sub (a, b); + if (i == 0) /* BREAK */ + i = sub (b, a); +} + +int +main (void) +{ + fatp_t ptr = { 31415927, 27182818 }; + foo (ptr, 1, 2); + return 0; +} + +/* { dg-final { gdb-test 20 "str.pa" "31415927" } } */ +/* { dg-final { gdb-test 20 "str.pb" "27182818" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-2.c new file mode 100644 index 000000000..64678bd56 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-2.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-g -fno-var-tracking-assignments" } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" "-O1" } } */ + +typedef __UINTPTR_TYPE__ uintptr_t; + +__attribute__((noinline, noclone)) int +sub (int a, int b) +{ + return a - b; +} + +typedef struct { uintptr_t pa; uintptr_t pb; } fatp_t + __attribute__ ((aligned (2 * __alignof__ (uintptr_t)))); + +__attribute__((noinline, noclone)) void +foo (fatp_t str, int a, int b) +{ + int i = sub (a, b); + if (i == 0) /* BREAK */ + foo (str, a - 1, b); +} + +int +main (void) +{ + fatp_t ptr = { 31415927, 27182818 }; + foo (ptr, 1, 2); + return 0; +} + +/* { dg-final { gdb-test 20 "str.pa" "31415927" } } */ +/* { dg-final { gdb-test 20 "str.pb" "27182818" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-3.c new file mode 100644 index 000000000..a3b5adb5a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-3.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" "-O1" } } */ + +typedef __UINTPTR_TYPE__ uintptr_t; + +__attribute__((noinline, noclone)) int +sub (int a, int b) +{ + return a - b; +} + +typedef struct { uintptr_t pa; uintptr_t pb; } fatp_t + __attribute__ ((aligned (2 * __alignof__ (uintptr_t)))); + +__attribute__((noinline, noclone)) void +foo (fatp_t str, int a, int b) +{ + int i = sub (a, b); + if (i == 0) /* BREAK */ + foo (str, a - 1, b); +} + +int +main (void) +{ + fatp_t ptr = { 31415927, 27182818 }; + foo (ptr, 1, 2); + return 0; +} + +/* { dg-final { gdb-test 20 "str.pa" "31415927" } } */ +/* { dg-final { gdb-test 20 "str.pb" "27182818" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-4.c new file mode 100644 index 000000000..a76b251f3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/param-4.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */ + +void +foo (int i) +{ + int j = 0; + i = 1; + j = j + 1; /* BREAK */ +} + +int +main (void) +{ + foo (0); + return 0; +} + +/* { dg-final { gdb-test 10 "i" "1" } } */
\ No newline at end of file diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-1.c new file mode 100644 index 000000000..ba7a6c279 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-1.c @@ -0,0 +1,53 @@ +/* PR debug/36728 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +int a, b; + +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 (NOP : "=m" (y), "=m" (b) : "m" (y)); + x[0] = 25; + asm (NOP : "=m" (x[0]), "=m" (a) : "m" (x[0]), "m" (b)); + 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 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg3" "3" } } */ +/* { dg-final { gdb-test 16 "arg4" "4" } } */ +/* { dg-final { gdb-test 16 "arg5" "5" } } */ +/* { dg-final { gdb-test 16 "arg6" "6" } } */ +/* { dg-final { gdb-test 16 "arg7" "30" } } */ +/* { dg-final { gdb-test 16 "y" "2" } } */ +/* { dg-final { gdb-test 18 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 18 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 18 "arg3" "3" } } */ +/* { dg-final { gdb-test 18 "arg4" "4" } } */ +/* { dg-final { gdb-test 18 "arg5" "5" } } */ +/* { dg-final { gdb-test 18 "arg6" "6" } } */ +/* { dg-final { gdb-test 18 "arg7" "30" } } */ +/* { dg-final { gdb-test 18 "*x" "(char) 25" } } */ +/* { dg-final { gdb-test 18 "y" "2" } } */ + +int +main () +{ + int l = 0; + asm ("" : "=r" (l) : "0" (l)); + a = foo (l + 1, l + 2, l + 3, l + 4, l + 5, l + 6, l + 30); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-2.c new file mode 100644 index 000000000..6daa021c0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-2.c @@ -0,0 +1,53 @@ +/* PR debug/36728 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +int a, b; + +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 (NOP : "=m" (y), "=m" (b) : "m" (y)); + x[0] = 25; + asm (NOP : "=m" (x[0]), "=m" (a) : "m" (x[0]), "m" (b)); + 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 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg3" "3" } } */ +/* { dg-final { gdb-test 16 "arg4" "4" } } */ +/* { dg-final { gdb-test 16 "arg5" "5" } } */ +/* { dg-final { gdb-test 16 "arg6" "6" } } */ +/* { dg-final { gdb-test 16 "arg7" "30" } } */ +/* { dg-final { gdb-test 16 "y" "2" } } */ +/* { dg-final { gdb-test 18 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 18 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 18 "arg3" "3" } } */ +/* { dg-final { gdb-test 18 "arg4" "4" } } */ +/* { dg-final { gdb-test 18 "arg5" "5" } } */ +/* { dg-final { gdb-test 18 "arg6" "6" } } */ +/* { dg-final { gdb-test 18 "arg7" "30" } } */ +/* { dg-final { gdb-test 18 "*x" "(char) 25" } } */ +/* { dg-final { gdb-test 18 "y" "2" } } */ + +int +main () +{ + int l = 0; + asm ("" : "=r" (l) : "0" (l)); + a = foo (l + 1, l + 2, l + 3, l + 4, l + 5, l + 6, l + 30); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-3.c new file mode 100644 index 000000000..bb2c0675d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-3.c @@ -0,0 +1,51 @@ +/* PR debug/36728 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +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 (NOP : "=m" (y) : "m" (y)); + x[0] = 25; + asm volatile (NOP : "=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 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 "y" "2" } } */ +/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg3" "3" } } */ +/* { dg-final { gdb-test 16 "arg4" "4" } } */ +/* { dg-final { gdb-test 16 "arg5" "5" } } */ +/* { dg-final { gdb-test 16 "arg6" "6" } } */ +/* { dg-final { gdb-test 16 "arg7" "30" } } */ +/* { dg-final { gdb-test 16 "*x" "(char) 25" } } */ +/* { dg-final { gdb-test 16 "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-4.9/gcc/testsuite/gcc.dg/guality/pr36728-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-4.c new file mode 100644 index 000000000..fee79c49c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36728-4.c @@ -0,0 +1,51 @@ +/* PR debug/36728 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +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 (NOP : "=m" (y) : "m" (y)); + x[0] = 25; + asm volatile (NOP : "=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 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 "y" "2" } } */ +/* { dg-final { gdb-test 16 "arg1" "1" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg2" "2" { target { ! "s390*-*-*" } } } } */ +/* { dg-final { gdb-test 16 "arg3" "3" } } */ +/* { dg-final { gdb-test 16 "arg4" "4" } } */ +/* { dg-final { gdb-test 16 "arg5" "5" } } */ +/* { dg-final { gdb-test 16 "arg6" "6" } } */ +/* { dg-final { gdb-test 16 "arg7" "30" } } */ +/* { dg-final { gdb-test 16 "*x" "(char) 25" } } */ +/* { dg-final { gdb-test 16 "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-4.9/gcc/testsuite/gcc.dg/guality/pr36977.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr36977.c new file mode 100644 index 000000000..3689fae8c --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr41353-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr41353-1.c new file mode 100644 index 000000000..1d2cca787 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr41353-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr41353-2.c new file mode 100644 index 000000000..0983bf4ab --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr41404-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr41404-1.c new file mode 100644 index 000000000..59a8293e6 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr41447-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr41447-1.c new file mode 100644 index 000000000..9bb28abe3 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr41616-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr41616-1.c new file mode 100644 index 000000000..24f64ab08 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr42782.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr42782.c new file mode 100644 index 000000000..6a880814a --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr43051-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr43051-1.c new file mode 100644 index 000000000..77325c97e --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr43077-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr43077-1.c new file mode 100644 index 000000000..d8d5eebe0 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr43177.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr43177.c new file mode 100644 index 000000000..563835b63 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr43329-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr43329-1.c new file mode 100644 index 000000000..5e27adfca --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr43479.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr43479.c new file mode 100644 index 000000000..e0bc246cd --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr43593.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr43593.c new file mode 100644 index 000000000..d8cc41359 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr45003-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr45003-1.c new file mode 100644 index 000000000..7cef8f628 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr45003-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr45003-2.c new file mode 100644 index 000000000..dcdba237f --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr45003-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr45003-3.c new file mode 100644 index 000000000..3adc4f238 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr45882.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr45882.c new file mode 100644 index 000000000..5ca22d4f4 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr45882.c @@ -0,0 +1,30 @@ +/* PR debug/45882 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +extern void abort (void); +int a[1024]; +volatile short int v; + +__attribute__((noinline,noclone,used)) int +foo (int i, int j) +{ + int b = i; /* { dg-final { gdb-test 16 "b" "7" } } */ + int c = i + 4; /* { dg-final { gdb-test 16 "c" "11" } } */ + int d = a[i]; /* { dg-final { gdb-test 16 "d" "112" } } */ + int e = a[i + 6]; /* { dg-final { gdb-test 16 "e" "142" } } */ + ++v; + return ++j; +} + +int +main (void) +{ + int l; + asm ("" : "=r" (l) : "0" (7)); + a[7] = 112; + a[7 + 6] = 142; + if (foo (l, 7) != 8) + abort (); + return l - 7; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr48437.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr48437.c new file mode 100644 index 000000000..5346baa0b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr48437.c @@ -0,0 +1,17 @@ +/* PR lto/48437 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +int i __attribute__((used)); +int main() +{ + volatile int i; + for (i = 3; i < 7; ++i) + { + extern int i; + asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test 14 "i" "0" } } */ + } + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr48466.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr48466.c new file mode 100644 index 000000000..8d5426a99 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/pr49888.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr49888.c new file mode 100644 index 000000000..a0e26cf83 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr49888.c @@ -0,0 +1,26 @@ +/* PR debug/49888 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +static int v; + +static void __attribute__((noinline, noclone)) +f (int *p) +{ + int c = *p; + v = c; + *p = 1; /* { dg-final { gdb-test 12 "!!c" "0" } } */ + /* c may very well be optimized out at this point, so we test !c, + which will evaluate to the expected value. We just want to make + sure it doesn't remain bound to *p as it did before, in which + case !c would evaluate to 0. *p may also be regarded as aliasing + register saves, thus the !!c above. */ + v = 0; /* { dg-final { gdb-test 18 "!c" "1" } } */ +} +int +main () +{ + int a = 0; + f (&a); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54200.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54200.c new file mode 100644 index 000000000..9b1718764 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54200.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/54200 */ +/* { dg-do run } */ +/* { dg-options "-g -fno-var-tracking-assignments" } */ + +int o __attribute__((used)); + +void bar (void) { o = 2; } + +int __attribute__((noinline,noclone)) +foo (int z, int x, int b) +{ + if (x == 1) + { + bar (); + return z; + } + else + { + int a = (x + z) + b; + return a; /* { dg-final { gdb-test 20 "z" "3" } } */ + } +} + +int main () +{ + foo (3, 2, 1); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-1.c new file mode 100644 index 000000000..98afd45c1 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-1.c @@ -0,0 +1,48 @@ +/* PR debug/54519 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +__attribute__((noinline, noclone)) void +fn1 (int x) +{ + __asm volatile ("" : "+r" (x) : : "memory"); +} + +static int +fn2 (int x, int y, int z) +{ + int a = 8; + if (x != z) + { + fn1 (x); + fn1 (x); /* { dg-final { gdb-test 20 "x" "36" } } */ + if (x == 36) /* { dg-final { gdb-test 20 "y" "25" } } */ + fn1 (x); /* { dg-final { gdb-test 20 "z" "6" } } */ + fn1 (x); /* { dg-final { gdb-test 23 "x" "98" } } */ + if (x == 98) /* { dg-final { gdb-test 23 "y" "117" } } */ + fn1 (x); /* { dg-final { gdb-test 23 "z" "8" } } */ + fn1 (x); + fn1 (x + a); + } + return y; +} + +__attribute__((noinline, noclone)) int +fn3 (int x, int y) +{ + return fn2 (x, y, 6); +} + +__attribute__((noinline, noclone)) int +fn4 (int x, int y) +{ + return fn2 (x, y, 8); +} + +int +main () +{ + fn3 (36, 25); + fn4 (98, 117); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-2.c new file mode 100644 index 000000000..4ee3c9e2f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-2.c @@ -0,0 +1,45 @@ +/* PR debug/54519 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +__attribute__((noinline, noclone)) void +fn1 (int x) +{ + __asm volatile ("" : "+r" (x) : : "memory"); +} + +static int +fn2 (int x, int y) +{ + if (y) + { + fn1 (x); /* { dg-final { gdb-test 17 "x" "6" } } */ + fn1 (x); /* { dg-final { gdb-test 17 "y" "25" } } */ + fn1 (x); + fn1 (x); + y = -2 + x; + y = y * y * y + y; + fn1 (x + y); /* { dg-final { gdb-test 22 "y" "68" } } */ + } + return x; +} + +__attribute__((noinline, noclone)) int +fn3 (int x, int y) +{ + return fn2 (x, y) + y; +} + +__attribute__((noinline, noclone)) int +fn4 (int x, int y) +{ + return fn2 (x, y) + y; +} + +int +main () +{ + fn3 (6, 25); + fn4 (4, 117); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-3.c new file mode 100644 index 000000000..aa8369e15 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-3.c @@ -0,0 +1,42 @@ +/* PR debug/54519 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +__attribute__((noinline, noclone)) void +fn1 (int x) +{ + __asm volatile ("" : "+r" (x) : : "memory"); +} + +static int +fn2 (int x, int y, int z) +{ + int a = 8; + if (x != z) + { + fn1 (x); + fn1 (x); /* { dg-final { gdb-test 20 "x" "36" } } */ + if (x == 36) /* { dg-final { gdb-test 20 "y" "25" } } */ + fn1 (x); /* { dg-final { gdb-test 20 "z" "6" } } */ + fn1 (x); /* { dg-final { gdb-test 23 "x" "98" } } */ + if (x == 98) /* { dg-final { gdb-test 23 "y" "117" } } */ + fn1 (x); /* { dg-final { gdb-test 23 "z" "8" } } */ + fn1 (x); + fn1 (x + a); + } + return y; +} + +int (*p) (int, int, int) = fn2; + +int +main () +{ + __asm volatile ("" : : : "memory"); + int (*q) (int, int, int) = p; + __asm volatile ("" : : : "memory"); + q (36, 25, 6); + q (98, 117, 8); + q (0, 0, 0); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-4.c new file mode 100644 index 000000000..d2765d148 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-4.c @@ -0,0 +1,39 @@ +/* PR debug/54519 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +__attribute__((noinline, noclone)) void +fn1 (int x) +{ + __asm volatile ("" : "+r" (x) : : "memory"); +} + +static int +fn2 (int x, int y) +{ + if (y) + { + fn1 (x); /* { dg-final { gdb-test 17 "x" "6" } } */ + fn1 (x); /* { dg-final { gdb-test 17 "y" "25" } } */ + fn1 (x); + fn1 (x); + y = -2 + x; + y = y * y * y + y; + fn1 (x + y); /* { dg-final { gdb-test 22 "y" "68" } } */ + } + return x; +} + +int (*p) (int, int) = fn2; + +int +main () +{ + __asm volatile ("" : : : "memory"); + int (*q) (int, int) = p; + __asm volatile ("" : : : "memory"); + q (6, 25); + q (4, 117); + q (0, 0); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-5.c new file mode 100644 index 000000000..c64527a45 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-5.c @@ -0,0 +1,45 @@ +/* PR debug/54519 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +__attribute__((noinline, noclone)) void +fn1 (int x) +{ + __asm volatile ("" : "+r" (x) : : "memory"); +} + +static int +fn2 (int x, int y) +{ + if (y) + { + fn1 (x); /* { dg-final { gdb-test 17 "x" "6" } } */ + fn1 (x); /* { dg-final { gdb-test 17 "y" "25" } } */ + fn1 (x); + fn1 (x); + y = -2 + x; + y = y * y * y + y; + fn1 (x + y); /* { dg-final { gdb-test 22 "y" "68" } } */ + } + return x; +} + +__attribute__((noinline, noclone)) int +fn3 (int x, int y) +{ + return fn2 (x, y); +} + +__attribute__((noinline, noclone)) int +fn4 (int x, int y) +{ + return fn2 (x, y); +} + +int +main () +{ + fn3 (6, 25); + fn4 (4, 117); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-6.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-6.c new file mode 100644 index 000000000..836ab1f66 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54519-6.c @@ -0,0 +1,27 @@ +/* PR debug/54519 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +static inline void +f1 (int x, int y) +{ + asm volatile (NOP); /* { dg-final { gdb-test 11 "x" "2" } } */ + asm volatile (NOP); /* { dg-final { gdb-test 11 "y" "0" } } */ +} + +static inline void +f2 (int z) +{ + f1 (z, 0); + f1 (z, 1); +} + +int +main () +{ + f2 (2); + f2 (3); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54551.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54551.c new file mode 100644 index 000000000..4235f78ce --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54551.c @@ -0,0 +1,28 @@ +/* PR debug/54551 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +void __attribute__((__noinline__)) +bar (void) +{ + asm volatile (""); +} + +int __attribute__((__noinline__)) +foo (int x, int y, int z) +{ + if (x != z) + { + int a = z + 1; + bar (); /* { dg-final { gdb-test 18 "a" "4" } } */ + bar (); /* { dg-final { gdb-test 18 "z" "3" } } */ + } + return y; +} + +int +main () +{ + foo (1, 2, 3); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54693-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54693-2.c new file mode 100644 index 000000000..2810a75d5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54693-2.c @@ -0,0 +1,33 @@ +/* PR debug/54693 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +int v; + +__attribute__((noinline, noclone)) void +bar (int i) +{ + v = i; + asm volatile ("" : : "r" (i) : "memory"); +} + +__attribute__((noinline, noclone)) void +foo (int x, int y, int z) +{ + int i = 0; + while (x > 3 && y > 3 && z > 3) + { /* { dg-final { gdb-test 21 "i" "v + 1" } } */ + /* { dg-final { gdb-test 21 "x" "10 - i" } } */ + bar (i); /* { dg-final { gdb-test 21 "y" "20 - 2 * i" } } */ + /* { dg-final { gdb-test 21 "z" "30 - 3 * i" } } */ + i++, x--, y -= 2, z -= 3; + } +} + +int +main () +{ + v = -1; + foo (10, 20, 30); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54693.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54693.c new file mode 100644 index 000000000..b852c06ab --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54693.c @@ -0,0 +1,29 @@ +/* PR debug/54693 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +__attribute__((noinline, noclone)) void +foo (char *str, char c) +{ + asm volatile ("" : : "r" (str), "r" (c) : "memory"); + *str = c; +} + +int +main () +{ + int i; + char c; + char arr[11]; + + for (i = 0; i < 10; i++) + { + c = 0x30 + i; + foo (&arr[i], c); /* { dg-final { gdb-test 22 "i" "c - 48" } } */ + } + arr[10] = 0; + + __builtin_printf ("arr = %s\n", arr); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54796.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54796.c new file mode 100644 index 000000000..f58e5a02c --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54796.c @@ -0,0 +1,25 @@ +/* PR debug/54796 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +__attribute__((noinline, noclone)) void +bar (char *a, int b) +{ + __asm volatile ("" : "+r" (a), "+r" (b) : : "memory"); +} + +__attribute__((noinline, noclone)) void +foo (int a, int b) +{ + int c = a; + char d[b]; /* { dg-final { gdb-test 17 "a" "5" } } */ + bar (d, 2); /* { dg-final { gdb-test 17 "b" "6" } } */ + bar (d, 4); /* { dg-final { gdb-test 17 "c" "5" } } */ +} + +int +main () +{ + foo (5, 6); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54970.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54970.c new file mode 100644 index 000000000..a9b8c064d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr54970.c @@ -0,0 +1,47 @@ +/* PR debug/54970 */ +/* PR debug/54971 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +int +main () +{ + int a[] = { 1, 2, 3 }; /* { dg-final { gdb-test 15 "a\[0\]" "1" } } */ + int *p = a + 2; /* { dg-final { gdb-test 15 "a\[1\]" "2" } } */ + int *q = a + 1; /* { dg-final { gdb-test 15 "a\[2\]" "3" } } */ + /* { dg-final { gdb-test 15 "*p" "3" } } */ + asm volatile (NOP); /* { dg-final { gdb-test 15 "*q" "2" } } */ + *p += 10; /* { dg-final { gdb-test 20 "a\[0\]" "1" } } */ + /* { dg-final { gdb-test 20 "a\[1\]" "2" } } */ + /* { dg-final { gdb-test 20 "a\[2\]" "13" } } */ + /* { dg-final { gdb-test 20 "*p" "13" } } */ + asm volatile (NOP); /* { dg-final { gdb-test 20 "*q" "2" } } */ + *q += 10; /* { dg-final { gdb-test 25 "a\[0\]" "1" } } */ + /* { dg-final { gdb-test 25 "a\[1\]" "12" } } */ + /* { dg-final { gdb-test 25 "a\[2\]" "13" } } */ + /* { dg-final { gdb-test 25 "*p" "13" } } */ + asm volatile (NOP); /* { dg-final { gdb-test 25 "*q" "12" } } */ + __builtin_memcpy (&a, (int [3]) { 4, 5, 6 }, sizeof (a)); + /* { dg-final { gdb-test 31 "a\[0\]" "4" } } */ + /* { dg-final { gdb-test 31 "a\[1\]" "5" } } */ + /* { dg-final { gdb-test 31 "a\[2\]" "6" } } */ + /* { dg-final { gdb-test 31 "*p" "6" } } */ + asm volatile (NOP); /* { dg-final { gdb-test 31 "*q" "5" } } */ + *p += 20; /* { dg-final { gdb-test 36 "a\[0\]" "4" } } */ + /* { dg-final { gdb-test 36 "a\[1\]" "5" } } */ + /* { dg-final { gdb-test 36 "a\[2\]" "26" } } */ + /* { dg-final { gdb-test 36 "*p" "26" } } */ + asm volatile (NOP); /* { dg-final { gdb-test 36 "*q" "5" } } */ + *q += 20; /* { dg-final { gdb-test 45 "a\[0\]" "4" } } */ + /* { dg-final { gdb-test 45 "a\[1\]" "25" } } */ + /* { dg-final { gdb-test 45 "a\[2\]" "26" } } */ + /* { dg-final { gdb-test 45 "*p" "26" } } */ + /* { dg-final { gdb-test 45 "p\[-1\]" "25" } } */ + /* { dg-final { gdb-test 45 "p\[-2\]" "4" } } */ + /* { dg-final { gdb-test 45 "q\[-1\]" "4" } } */ + /* { dg-final { gdb-test 45 "q\[1\]" "26" } } */ + asm volatile (NOP); /* { dg-final { gdb-test 45 "*q" "25" } } */ + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-1.c new file mode 100644 index 000000000..4f02bc96e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-1.c @@ -0,0 +1,29 @@ +/* PR debug/56154 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-additional-sources "pr56154-aux.c" } */ + +#include "../nop.h" + +union U { int a, b; }; +volatile int z; + +__attribute__((noinline, noclone)) int +foo (int fd, union U x) +{ + int result = x.a != 0; + if (fd != 0) + result = x.a == 0; + asm (NOP : : : "memory"); /* { dg-final { gdb-test pr56154-1.c:17 "x.a" "4" } } */ + z = x.a; + x.a = 6; + asm (NOP : : : "memory"); /* { dg-final { gdb-test pr56154-1.c:20 "x.a" "6" } } */ + return result; +} + +void +test_main (void) +{ + union U u = { .a = 4 }; + foo (0, u); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-2.c new file mode 100644 index 000000000..6c1d5d977 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-2.c @@ -0,0 +1,39 @@ +/* PR debug/56154 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-additional-sources "pr56154-aux.c" } */ + +#include "../nop.h" + +extern void abort (void); + +__attribute__((noinline, noclone)) int +foo (int x) +{ + asm (""); + x++; + asm (""); + x++; + asm (""); + x++; + asm (""); + x++; + asm (""); + x++; + asm (""); + x++; + asm (""); + x++; + asm (""); + x++; + asm (NOP : : : "memory"); + asm (NOP : : : "memory"); /* { dg-final { gdb-test pr56154-2.c:30 "x" "28" } } */ + return x; +} + +void +test_main (void) +{ + if (foo (20) != 28) + abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-3.c new file mode 100644 index 000000000..095dce9f6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-3.c @@ -0,0 +1,31 @@ +/* PR debug/56154 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-additional-sources "pr56154-aux.c" } */ + +#include "../nop.h" + +extern void abort (void); + +__attribute__((noinline, noclone)) int +foo (int x) +{ + x++; + x++; + x++; + x++; + x++; + x++; + x++; + x++; + asm (NOP : : : "memory"); + asm (NOP : : : "memory"); /* { dg-final { gdb-test pr56154-3.c:22 "x" "28" } } */ + return x; +} + +void +test_main (void) +{ + if (foo (20) != 28) + abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-4.c new file mode 100644 index 000000000..bfe7338d6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-4.c @@ -0,0 +1,34 @@ +/* PR debug/56154 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ +/* { dg-additional-sources "pr56154-aux.c" } */ + +#include "../nop.h" + +extern void abort (void); + +volatile int z; + +__attribute__((noinline, noclone)) int +foo (int x) +{ + z = 6; + x++; + x++; + x++; + x++; + x++; + x++; + x++; + x++; + asm (NOP : : : "memory"); + asm (NOP : : : "memory"); /* { dg-final { gdb-test pr56154-4.c:25 "x" "28" } } */ + return x; +} + +void +test_main (void) +{ + if (foo (20) != 28) + abort (); +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-aux.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-aux.c new file mode 100644 index 000000000..131173cb3 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr56154-aux.c @@ -0,0 +1,11 @@ +/* PR debug/56154 */ +/* { dg-do compile } */ + +extern void test_main (void); + +int +main () +{ + test_main (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-1.c new file mode 100644 index 000000000..62ce881bf --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-1.c @@ -0,0 +1,34 @@ +/* PR tree-optimization/58791 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +__attribute__((noinline, noclone)) int +foo (int x, int y) +{ + _Bool a = x != 0; + _Bool b = y != 2; + _Bool c = a & b; + _Bool d = !c; + int ret; + if (c) + { + if (y < 3 || y > 4) + ret = 1; + else + ret = 0; + } + else + ret = 0; + asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr58791-1.c:25 "c & 1" "1" } } */ + asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr58791-1.c:25 "d & 1" "0" } } */ + return ret; +} + +int +main () +{ + foo (1, 3); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-2.c new file mode 100644 index 000000000..d7da69b48 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-2.c @@ -0,0 +1,36 @@ +/* PR tree-optimization/58791 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +__attribute__((noinline, noclone)) int +foo (unsigned char c) +{ + int ret; + _Bool a, b, d, e, f; + + a = c == 34; + b = c == 32; + d = a | b; + f = !d; + if (d) + ret = 1; + else + { + e = c <= 31; + ret = e; + } + + asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr58791-2.c:27 "d & 1" "1" } } */ + asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr58791-2.c:27 "f & 1" "0" } } */ + return ret; +} + + +int +main () +{ + foo (32); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-3.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-3.c new file mode 100644 index 000000000..6316ace56 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-3.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/58791 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +__attribute__((noinline, noclone)) unsigned +foo (unsigned a, unsigned b, unsigned c, unsigned d, unsigned e) +{ + unsigned f = b + c; /* { dg-final { gdb-test pr58791-3.c:19 "f" "5" } } */ + unsigned g = a - f; /* { dg-final { gdb-test pr58791-3.c:19 "g" "24" } } */ + unsigned h = d + e; /* { dg-final { gdb-test pr58791-3.c:19 "h" "9" } } */ + unsigned i = g - h; /* { dg-final { gdb-test pr58791-3.c:19 "i" "15" } } */ + unsigned j = f + 1; /* { dg-final { gdb-test pr58791-3.c:19 "j" "6" } } */ + unsigned k = g + 1; /* { dg-final { gdb-test pr58791-3.c:19 "k" "25" } } */ + unsigned l = h + 1; /* { dg-final { gdb-test pr58791-3.c:19 "l" "10" } } */ + unsigned m = i + 1; /* { dg-final { gdb-test pr58791-3.c:19 "m" "16" } } */ + asm volatile (NOP : : : "memory"); + asm volatile (NOP : : : "memory"); + return i; +} + +int +main () +{ + foo (29, 2, 3, 4, 5); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-4.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-4.c new file mode 100644 index 000000000..d988a9cfb --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-4.c @@ -0,0 +1,41 @@ +/* PR tree-optimization/58791 */ +/* { dg-do run } */ +/* { dg-options "-g -ffast-math" } */ + +#include "../nop.h" + +__attribute__((noinline, noclone)) double +foo (float a, float b, float c, float d, float l, double u) +{ + float e = a * d; + float f = d * e; + double g = (double) f; + double h = (double) b; + double i = g * h; /* { dg-final { gdb-test pr58791-4.c:32 "i" "486" { target { x86_64-*-* && lp64 } } } } */ + double i2 = i + 1.0; /* { dg-final { gdb-test pr58791-4.c:32 "i2" "487" { target { x86_64-*-* && lp64 } } } } */ + double j = i * 3.25; + double k = h + j; + float m = l * 8.75; + double n = (double) m; + double o = (double) a; + double p = n * o; + double q = h * p; + double r = q * 2.5; + double s = k - r; + double t = (double) c; + double v = o * u; + double w = o * v; + double x = h * w; + double y = h * x; + double z = y * 8.5; + asm volatile (NOP : : : "memory"); + asm volatile (NOP : : : "memory"); + return s - z; +} + +int +main () +{ + foo (3.0f, 2.0f, -1.0f, 9.0f, 1.0f, 2.0); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-5.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-5.c new file mode 100644 index 000000000..c23776919 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr58791-5.c @@ -0,0 +1,29 @@ +/* PR tree-optimization/58791 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +__attribute__((noinline, noclone)) unsigned int +foo (unsigned int a0, unsigned int a1, unsigned int a2, + unsigned int a3, unsigned int a4) +{ + unsigned int b0, b1, b2, b3, b4, e; + /* this can be optimized to four additions... */ + b4 = a4 + a3 + a2 + a1 + a0; /* { dg-final { gdb-test pr58791-5.c:20 "b4" "4681" } } */ + b3 = a3 + a2 + a1 + a0; /* { dg-final { gdb-test pr58791-5.c:20 "b3" "585" } } */ + b2 = a2 + a1 + a0; /* { dg-final { gdb-test pr58791-5.c:20 "b2" "73" } } */ + b1 = a1 + a0; /* { dg-final { gdb-test pr58791-5.c:20 "b1" "9" } } */ + /* This is actually 0 */ + e = b4 - b3 + b2 - b1 - a4 - a2; /* { dg-final { gdb-test pr58791-5.c:20 "e" "0" } } */ + asm volatile (NOP : : : "memory"); + asm volatile (NOP : : : "memory"); + return e; +} + +int +main () +{ + foo (1, 8, 64, 512, 4096); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr59776.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr59776.c new file mode 100644 index 000000000..382abb622 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/pr59776.c @@ -0,0 +1,29 @@ +/* PR debug/59776 */ +/* { dg-do run } */ +/* { dg-options "-g" } */ + +#include "../nop.h" + +struct S { float f, g; }; + +__attribute__((noinline, noclone)) void +foo (struct S *p) +{ + struct S s1, s2; /* { dg-final { gdb-test pr59776.c:17 "s1.f" "5.0" } } */ + s1 = *p; /* { dg-final { gdb-test pr59776.c:17 "s1.g" "6.0" } } */ + s2 = s1; /* { dg-final { gdb-test pr59776.c:17 "s2.f" "0.0" } } */ + *(int *) &s2.f = 0; /* { dg-final { gdb-test pr59776.c:17 "s2.g" "6.0" } } */ + asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s1.f" "5.0" } } */ + asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s1.g" "6.0" } } */ + s2 = s1; /* { dg-final { gdb-test pr59776.c:20 "s2.f" "5.0" } } */ + asm volatile (NOP : : : "memory"); /* { dg-final { gdb-test pr59776.c:20 "s2.g" "6.0" } } */ + asm volatile (NOP : : : "memory"); +} + +int +main () +{ + struct S x = { 5.0f, 6.0f }; + foo (&x); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/rotatetest.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/rotatetest.c new file mode 100644 index 000000000..64f5340a0 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/rotatetest.c @@ -0,0 +1,76 @@ +/* { dg-do run { target { x86_64-*-* && lp64 } } } */ +/* { dg-options "-g" } */ + +volatile int vv; + +__attribute__((noclone, noinline)) long +f1 (unsigned long x) +{ + long f = (x << 12) | (x >> (64 - 12)); + long g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 12 "g" "f" } } */ + return f; +} + +__attribute__((noclone, noinline)) long +f2 (unsigned long x, int y) +{ + long f = (x << y) | (x >> (64 - y)); + long g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 22 "g" "f" } } */ + return f; +} + +__attribute__((noclone, noinline)) long +f3 (unsigned long x, int y) +{ + long f = (x >> y) | (x << (64 - y)); + long g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 32 "g" "f" } } */ + return f; +} + +__attribute__((noclone, noinline)) unsigned int +f4 (unsigned int x) +{ + unsigned int f = (x << 12) | (x >> (32 - 12)); + unsigned int g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 42 "g" "f" } } */ + return f; +} + +__attribute__((noclone, noinline)) unsigned int +f5 (unsigned int x, int y) +{ + unsigned int f = (x << y) | (x >> (32 - y)); + unsigned int g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 52 "g" "f" } } */ + return f; +} + +__attribute__((noclone, noinline)) unsigned int +f6 (unsigned int x, int y) +{ + unsigned int f = (x >> y) | (x << (32 - y)); + unsigned int g = f; + asm volatile ("" : "+r" (f)); + vv++; /* { dg-final { gdb-test 62 "g" "f" } } */ + return f; +} + +int +main () +{ + f1 (0x123456789abcde0fUL); + f2 (0x123456789abcde0fUL, 18); + f3 (0x123456789abcde0fUL, 17); + f4 (0x12345678); + f5 (0x12345678, 18); + f6 (0x12345678, 17); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/sra-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/sra-1.c new file mode 100644 index 000000000..e779d7ac8 --- /dev/null +++ b/gcc-4.9/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-4.9/gcc/testsuite/gcc.dg/guality/vla-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/vla-1.c new file mode 100644 index 000000000..651465428 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/guality/vla-1.c @@ -0,0 +1,37 @@ +/* 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 () +{ + volatile int j; + int i = 5; + asm volatile ("" : "=r" (i) : "0" (i)); + j = f1 (i); + f2 (i); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/guality/vla-2.c b/gcc-4.9/gcc/testsuite/gcc.dg/guality/vla-2.c new file mode 100644 index 000000000..6773775b9 --- /dev/null +++ b/gcc-4.9/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; +} |