https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79619

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-02-20
                 CC|                            |rguenth at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  GIMPLE DSE removes the store

  # PT = null
  _2 = MEM[(char * <address-space-1> *)0B];
  *_2 = 1;

but not here:

  # PT = null
  _2 = MEM[(char * <address-space-1> *)0B];
  *_2 = 1;
  # PT = nonlocal escaped null
  _4 = MEM[(char * <address-space-1> *)8B];
  *_4 = 1;

because it thinks the value is eventually used by the following load from 8B.

'PT = null' addresses are thought to be not global memory. 
-f[no-]delete-null-pointer-checks controls this globally for all address
spaces.

The following fixes the testcase, but it looks to me like all
flag_delete_null_pointer_checks tests in the middle end should be replaced
by this (or some wrapper so eventually the target can specify which
address-spaces
may have objects at address zero):

Index: gcc/tree-ssa-structalias.c
===================================================================
--- gcc/tree-ssa-structalias.c  (revision 245594)
+++ gcc/tree-ssa-structalias.c  (working copy)
@@ -3407,7 +3407,10 @@ get_constraint_for_1 (tree t, vec<ce_s>
       || (TREE_CODE (t) == CONSTRUCTOR
          && CONSTRUCTOR_NELTS (t) == 0))
     {
-      if (flag_delete_null_pointer_checks)
+      if (flag_delete_null_pointer_checks
+         && (! POINTER_TYPE_P (TREE_TYPE (t))
+             || (TYPE_ADDR_SPACE (TREE_TYPE (TREE_TYPE (t)))
+                 == ADDR_SPACE_GENERIC)))
        temp.var = nothing_id;
       else
        temp.var = nonlocal_id;


accordingly the documentation of -fdelete-null-pointer-checks should be
adjusted to say it only affects the generic address space.

Reply via email to