tree-optimization/112495 - alias versioning and address spaces

Message ID 20231113133830.E0A6613398@imap2.suse-dmz.suse.de
State Accepted
Headers
Series tree-optimization/112495 - alias versioning and address spaces |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Richard Biener Nov. 13, 2023, 1:38 p.m. UTC
  We are not correctly handling differing address spaces in dependence
analysis runtime alias check generation so refuse to do that.

Bootstrapped and tested on x86_64-unknown-linux-gnu.  I'm double-checking
hundreds of ACATS FAILs (segfaults), will push if those are latent.

Richard.

	PR tree-optimization/112495
	* tree-data-ref.cc (runtime_alias_check_p): Reject checks
	between different address spaces.

	* gcc.target/i386/pr112495.c: New testcase.
---
 gcc/testsuite/gcc.target/i386/pr112495.c | 12 ++++++++++++
 gcc/tree-data-ref.cc                     |  7 +++++++
 2 files changed, 19 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr112495.c
  

Patch

diff --git a/gcc/testsuite/gcc.target/i386/pr112495.c b/gcc/testsuite/gcc.target/i386/pr112495.c
new file mode 100644
index 00000000000..21afbaa6945
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr112495.c
@@ -0,0 +1,12 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+typedef struct { int v; } T1;
+typedef struct { T1 v[32]; } T2;
+
+T1 s;
+T1 f1() { return s; }
+
+void f2(__seg_gs T2 *p, int n) {
+  for (int i = 0; i < n; ++i) p->v[i] = f1();
+}
diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc
index 689aaeed722..3549485d251 100644
--- a/gcc/tree-data-ref.cc
+++ b/gcc/tree-data-ref.cc
@@ -1640,6 +1640,13 @@  runtime_alias_check_p (ddr_p ddr, class loop *loop, bool speed_p)
 				   "runtime alias check not supported for"
 				   " outer loop.\n");
 
+  /* FORNOW: We don't support handling different address spaces.  */
+  if (TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (DR_BASE_ADDRESS (DDR_A (ddr)))))
+      != TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (DR_BASE_ADDRESS (DDR_B (ddr))))))
+    return opt_result::failure_at (DR_STMT (DDR_A (ddr)),
+				   "runtime alias check between different "
+				   "address spaces not supported.\n");
+
   return opt_result::success ();
 }