This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [vta->trunk] VTA merge


On Sep  2, 2009, "H.J. Lu" <hjl.tools@gmail.com> wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41226

I'm testing the first patch below to fix the warnings about conversion
of pointer types to integral types of different width.  Joseph, I also
fixed (I hope) the unixisms you pointed out.  I hope I caught them all,
save for the expectation of concurrency between GDB and the program
under test.

I'm also testing the second patch below to fix the regression on the
pr40753.c testcase.  I've already tested it, but without the patch that
enabled VTA by default.

Are these ok to install if they pass?

Thanks,

for gcc/testsuite/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* gcc.dg/guality/guality.h: Include stdint.h.  Drop unnecessary
	unistd.h, sys/types.h and sys/wait.h.
	(gualchk_t): New.
	(GUALCVT): New.
	(GUALCHKXPR, GUALCHKVAL, GUALCHKFLA): Use it.
	(GUALITY_GDB_REDIRECT): New.
	(GUALITY_GDB_ARGS): Use it.

Index: gcc/testsuite/gcc.dg/guality/guality.h
===================================================================
--- gcc/testsuite/gcc.dg/guality/guality.h.orig	2009-09-03 03:38:04.000000000 -0300
+++ gcc/testsuite/gcc.dg/guality/guality.h	2009-09-03 03:40:44.000000000 -0300
@@ -21,9 +21,7 @@ along with GCC; see the file COPYING3.  
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/wait.h>
+#include <stdint.h>
 
 /* This is a first cut at checking that debug information matches
    run-time.  The idea is to annotate programs with GUALCHK* macros
@@ -56,8 +54,20 @@ along with GCC; see the file COPYING3.  
    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.  */
+
+#define GUALCVT(val)						\
+  ((gualchk_t)__builtin_choose_expr				\
+   (__builtin_types_compatible_p (__typeof (val), gualchk_t),	\
+    (val), (intptr_t)(val)))
+
 /* Attach a debugger to the current process and verify that the string
-   EXPR, evaluated by the debugger, yields the long long number VAL.
+   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.  */
@@ -73,13 +83,13 @@ along with GCC; see the file COPYING3.  
    guality_check, although not necessarily after the call.  */
 
 #define GUALCHKXPR(expr) \
-  GUALCHKXPRVAL (#expr, (long long)(expr), 1)
+  GUALCHKXPRVAL (#expr, GUALCVT (expr), 1)
 
 /* Same as GUALCHKXPR, but issue an error if the variable is optimized
    away.  */
 
 #define GUALCHKVAL(expr) \
-  GUALCHKXPRVAL (#expr, (long long)(expr), 0)
+  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
@@ -91,7 +101,7 @@ along with GCC; see the file COPYING3.  
 #define GUALCHKFLA(expr) do {					\
     __typeof(expr) volatile __preserve_after;			\
     __typeof(expr) __preserve_before = (expr);			\
-    GUALCHKXPRVAL (#expr, (long long)(__preserve_before), 0);	\
+    GUALCHKXPRVAL (#expr, GUALCVT (__preserve_before), 0);	\
     __preserve_after = __preserve_before;			\
     asm ("" : : "m" (__preserve_after));			\
   } while (0)
@@ -119,7 +129,14 @@ along with GCC; see the file COPYING3.  
 
 static const char *guality_gdb_command;
 #define GUALITY_GDB_DEFAULT "gdb"
-#define GUALITY_GDB_ARGS " -nx -nw --quiet > /dev/null 2>&1"
+#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_REDRECT ""
+#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.  */
@@ -155,7 +172,7 @@ int volatile guality_attached;
 extern int guality_main (int argc, char *argv[]);
 
 static void __attribute__((noinline))
-guality_check (const char *name, long long value, int unknown_ok);
+guality_check (const char *name, gualchk_t value, int unknown_ok);
 
 /* Set things up, run guality_main, then print a summary and quit.  */
 
@@ -228,7 +245,7 @@ continue\n\
    have an UNRESOLVED.  Otherwise, it's a FAIL.  */
 
 static void __attribute__((noinline))
-guality_check (const char *name, long long value, int unknown_ok)
+guality_check (const char *name, gualchk_t value, int unknown_ok)
 {
   int result;
 
@@ -236,7 +253,7 @@ guality_check (const char *name, long lo
     return;
 
   {
-    volatile long long xvalue = -1;
+    volatile gualchk_t xvalue = -1;
     volatile int unavailable = 0;
     if (name)
       {
for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* var-tracking.c (dv_is_decl_p): Adjust NULL behavior to match
	comment.  Use switch statement to catch overlaps between rtx
	and tree codes.  Accept FUNCTION_DECLs in addition to those in...
	(IS_DECL_CODE): ... here. Remove.
	(check_value_is_not_decl): Remove.
	(dv_from_decl, dv_from_value): Check after conversion.

Index: gcc/var-tracking.c
===================================================================
--- gcc/var-tracking.c.orig	2009-09-02 11:46:43.000000000 -0300
+++ gcc/var-tracking.c	2009-09-02 12:11:55.000000000 -0300
@@ -723,12 +723,24 @@ static inline bool
 dv_is_decl_p (decl_or_value dv)
 {
   if (!dv)
-    return false;
+    return true;
 
-  if (GET_CODE ((rtx)dv) == VALUE)
-    return false;
+  /* Make sure relevant codes don't overlap.  */
+  switch ((int)TREE_CODE ((tree)dv))
+    {
+    case (int)VAR_DECL:
+    case (int)PARM_DECL:
+    case (int)RESULT_DECL:
+    case (int)FUNCTION_DECL:
+    case (int)COMPONENT_REF:
+      return true;
 
-  return true;
+    case (int)VALUE:
+      return false;
+
+    default:
+      gcc_unreachable ();
+    }
 }
 
 /* Return true if a decl_or_value is a VALUE rtl.  */
@@ -790,21 +802,13 @@ dv_pool (decl_or_value dv)
   return dv_onepart_p (dv) ? valvar_pool : var_pool;
 }
 
-#define IS_DECL_CODE(C) ((C) == VAR_DECL || (C) == PARM_DECL \
-			 || (C) == RESULT_DECL || (C) == COMPONENT_REF)
-
-/* Check that VALUE won't ever look like a DECL.  */
-static char check_value_is_not_decl [(!IS_DECL_CODE ((enum tree_code)VALUE))
-				     ? 1 : -1] ATTRIBUTE_UNUSED;
-
-
 /* Build a decl_or_value out of a decl.  */
 static inline decl_or_value
 dv_from_decl (tree decl)
 {
   decl_or_value dv;
-  gcc_assert (!decl || IS_DECL_CODE (TREE_CODE (decl)));
   dv = decl;
+  gcc_assert (dv_is_decl_p (dv));
   return dv;
 }
 
@@ -813,8 +817,8 @@ static inline decl_or_value
 dv_from_value (rtx value)
 {
   decl_or_value dv;
-  gcc_assert (value);
   dv = value;
+  gcc_assert (dv_is_value_p (dv));
   return dv;
 }
 
-- 
Alexandre Oliva, freedom fighter    http://FSFLA.org/~lxoliva/
You must be the change you wish to see in the world. -- Gandhi
Be Free! -- http://FSFLA.org/   FSF Latin America board member
Free Software Evangelist      Red Hat Brazil Compiler Engineer

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]