]> gcc.gnu.org Git - gcc.git/commitdiff
re PR middle-end/69643 (Address space discarded)
authorRichard Henderson <rth@gcc.gnu.org>
Fri, 5 Feb 2016 22:05:17 +0000 (14:05 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Fri, 5 Feb 2016 22:05:17 +0000 (14:05 -0800)
PR c/69643

  * tree.c (tree_nop_conversion_p): Do not strip casts into or
  out of non-standard address spaces.
testsuite/
  * gcc.target/i386/addr-space-4.c: New.
  * gcc.target/i386/addr-space-5.c: New.

From-SVN: r233189

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/addr-space-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/addr-space-5.c [new file with mode: 0644]
gcc/tree.c

index 5ad69839f8892f7050c78914480ed22f1ea84600..9e61921fc060cd79f072b7c868a1b2851951dc81 100644 (file)
@@ -1,3 +1,9 @@
+2016-02-06  Richard Henderson  <rth@redhat.com>
+
+       PR c/69643
+       * tree.c (tree_nop_conversion_p): Do not strip casts into or
+       out of non-standard address spaces.
+
 2016-02-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/69691
index 61306d0fdd0887e6f7224ce3add1f5eb3afe5976..d8f088d1bd7dd21ecb5080a29346952af42294cf 100644 (file)
@@ -1,3 +1,9 @@
+2016-02-06  Richard HEnderson  <rth@redhat.com>
+
+       PR c/69643
+       * gcc.target/i386/addr-space-4.c: New.
+       * gcc.target/i386/addr-space-5.c: New.
+
 2016-02-05  Mikael Morin  <mikael@gcc.gnu.org>
 
        PR fortran/66089
diff --git a/gcc/testsuite/gcc.target/i386/addr-space-4.c b/gcc/testsuite/gcc.target/i386/addr-space-4.c
new file mode 100644 (file)
index 0000000..3e0966d
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+/* { dg-final { scan-assembler "gs:" } } */
+
+#define uintptr_t __SIZE_TYPE__
+
+struct S { int a, b, c; };
+
+extern struct S __seg_gs s;
+
+int foo (void)
+{
+  int r;
+  r = s.c;
+  return r;
+}
diff --git a/gcc/testsuite/gcc.target/i386/addr-space-5.c b/gcc/testsuite/gcc.target/i386/addr-space-5.c
new file mode 100644 (file)
index 0000000..4f73f95
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+/* { dg-final { scan-assembler "gs:" } } */
+
+#define uintptr_t __SIZE_TYPE__
+
+struct S { int a, b, c; };
+
+extern struct S s;
+
+int ct_state3 (void)
+{
+  int r;
+  r = *((int __seg_gs *) (uintptr_t) &s.c);
+  return r;
+}
index fa7646b14e1fc5b0ddc1891dfc8d004c723ccc76..07cb9d9765ca91806d5e987527fb1a3bd38b77bc 100644 (file)
@@ -12219,6 +12219,23 @@ block_ultimate_origin (const_tree block)
 bool
 tree_nop_conversion_p (const_tree outer_type, const_tree inner_type)
 {
+  /* Do not strip casts into or out of differing address spaces.  */
+  if (POINTER_TYPE_P (outer_type)
+      && TYPE_ADDR_SPACE (TREE_TYPE (outer_type)) != ADDR_SPACE_GENERIC)
+    {
+      if (!POINTER_TYPE_P (inner_type)
+         || (TYPE_ADDR_SPACE (TREE_TYPE (outer_type))
+             != TYPE_ADDR_SPACE (TREE_TYPE (inner_type))))
+       return false;
+    }
+  else if (POINTER_TYPE_P (inner_type)
+          && TYPE_ADDR_SPACE (TREE_TYPE (inner_type)) != ADDR_SPACE_GENERIC)
+    {
+      /* We already know that outer_type is not a pointer with
+        a non-generic address space.  */
+      return false;
+    }
+
   /* Use precision rather then machine mode when we can, which gives
      the correct answer even for submode (bit-field) types.  */
   if ((INTEGRAL_TYPE_P (outer_type)
This page took 0.092282 seconds and 5 git commands to generate.