The following more thoroughly avoids address sanitizing accesses
to non-generic address-spaces.
PR tree-optimization/111736
* asan.cc (instrument_derefs): Do not instrument accesses
to non-generic address-spaces.
* gcc.target/i386/pr111736.c: New testcase.
(cherry picked from commit
134ef2a8cac1a5cc718739bd7d3b3472947c80d6)
if (VAR_P (inner) && DECL_HARD_REGISTER (inner))
return;
+ /* Accesses to non-generic address-spaces should not be instrumented. */
+ if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (inner))))
+ return;
+
poly_int64 decl_size;
if ((VAR_P (inner) || TREE_CODE (inner) == RESULT_DECL)
&& offset == NULL_TREE
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -fsanitize=address" } */
+
+int __seg_gs m;
+
+int foo (void)
+{
+ return m;
+}
+
+extern int __seg_gs n;
+
+int bar (void)
+{
+ return n;
+}
+
+int baz (int __seg_gs *o)
+{
+ return *o;
+}
+
+/* { dg-final { scan-assembler-not "asan_report_load" } } */