public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] hardened conditionals: drop copied identifiers
@ 2022-03-24  2:57 Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2022-03-24  2:57 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f4a30f6d78095d77a8d8b39bde03b08ab8824132

commit f4a30f6d78095d77a8d8b39bde03b08ab8824132
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Wed Mar 23 23:47:04 2022 -0300

    hardened conditionals: drop copied identifiers
    
    The copies of identifiers, indended to associate hardening SSA
    temporaries to the original variables they refer to, end up causing
    -fcompare-debug to fail, because DECL_UIDs are not identical, and the
    nouid flag used in compare-debug dumps doesn't affect the uids in
    naked identifiers, so the divergence becomes apparent.
    
    This patch drops the naked identifiers.  Though somewhat desirable,
    they're not necessary.
    
    
    for  gcc/ChangeLog
    
            PR debug/104564
            * gimple-harden-conditionals.cc (detach_value): Keep temps
            anonymous.

Diff:
---
 gcc/gimple-harden-conditionals.cc | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc
index be01f3ea8c4..c7e5e077a74 100644
--- a/gcc/gimple-harden-conditionals.cc
+++ b/gcc/gimple-harden-conditionals.cc
@@ -126,14 +126,11 @@ detach_value (location_t loc, gimple_stmt_iterator *gsip, tree val)
       return val;
     }
 
-  /* Create a SSA "copy" of VAL.  This could be an anonymous
-     temporary, but it's nice to have it named after the corresponding
-     variable.  Alas, when VAL is a DECL_BY_REFERENCE RESULT_DECL,
-     setting (a copy of) it would be flagged by checking, so we don't
-     use copy_ssa_name: we create an anonymous SSA name, and then give
-     it the same identifier (rather than decl) as VAL.  */
+  /* Create a SSA "copy" of VAL.  It would be nice to have it named
+     after the corresponding variable, but sharing the same decl is
+     problematic when VAL is a DECL_BY_REFERENCE RESULT_DECL, and
+     copying just the identifier hits -fcompare-debug failures.  */
   tree ret = make_ssa_name (TREE_TYPE (val));
-  SET_SSA_NAME_VAR_OR_IDENTIFIER (ret, SSA_NAME_IDENTIFIER (val));
 
   /* Some modes won't fit in general regs, so we fall back to memory
      for them.  ??? It would be ideal to try to identify an alternate,


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] hardened conditionals: drop copied identifiers
@ 2022-03-24  4:01 Alexandre Oliva
  0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2022-03-24  4:01 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:c34e36c7e9698c05beaef0748f2a50e0d6e75fe9

commit c34e36c7e9698c05beaef0748f2a50e0d6e75fe9
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Wed Mar 23 23:47:04 2022 -0300

    hardened conditionals: drop copied identifiers
    
    The copies of identifiers, indended to associate hardening SSA
    temporaries to the original variables they refer to, end up causing
    -fcompare-debug to fail, because DECL_UIDs are not identical, and the
    nouid flag used in compare-debug dumps doesn't affect the uids in
    naked identifiers, so the divergence becomes apparent.
    
    This patch drops the naked identifiers.  Though somewhat desirable,
    they're not necessary.
    
    
    for  gcc/ChangeLog
    
            PR debug/104564
            * gimple-harden-conditionals.cc (detach_value): Keep temps
            anonymous.
    
    for  gcc/testsuite/ChangeLog
    
            PR debug/104564
            * c-c++-common/torture/harden-comp.c: Adjust.
            * c-c++-common/torture/harden-cond.c: Adjust.

Diff:
---
 gcc/gimple-harden-conditionals.cc                | 11 ++++-------
 gcc/testsuite/c-c++-common/torture/harden-comp.c |  2 +-
 gcc/testsuite/c-c++-common/torture/harden-cond.c |  2 +-
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/gcc/gimple-harden-conditionals.cc b/gcc/gimple-harden-conditionals.cc
index be01f3ea8c4..c7e5e077a74 100644
--- a/gcc/gimple-harden-conditionals.cc
+++ b/gcc/gimple-harden-conditionals.cc
@@ -126,14 +126,11 @@ detach_value (location_t loc, gimple_stmt_iterator *gsip, tree val)
       return val;
     }
 
-  /* Create a SSA "copy" of VAL.  This could be an anonymous
-     temporary, but it's nice to have it named after the corresponding
-     variable.  Alas, when VAL is a DECL_BY_REFERENCE RESULT_DECL,
-     setting (a copy of) it would be flagged by checking, so we don't
-     use copy_ssa_name: we create an anonymous SSA name, and then give
-     it the same identifier (rather than decl) as VAL.  */
+  /* Create a SSA "copy" of VAL.  It would be nice to have it named
+     after the corresponding variable, but sharing the same decl is
+     problematic when VAL is a DECL_BY_REFERENCE RESULT_DECL, and
+     copying just the identifier hits -fcompare-debug failures.  */
   tree ret = make_ssa_name (TREE_TYPE (val));
-  SET_SSA_NAME_VAR_OR_IDENTIFIER (ret, SSA_NAME_IDENTIFIER (val));
 
   /* Some modes won't fit in general regs, so we fall back to memory
      for them.  ??? It would be ideal to try to identify an alternate,
diff --git a/gcc/testsuite/c-c++-common/torture/harden-comp.c b/gcc/testsuite/c-c++-common/torture/harden-comp.c
index 1ee0b366344..502f52e25be 100644
--- a/gcc/testsuite/c-c++-common/torture/harden-comp.c
+++ b/gcc/testsuite/c-c++-common/torture/harden-comp.c
@@ -11,4 +11,4 @@ f (int i, int j)
 /* { dg-final { scan-tree-dump-times "Adding reversed compare" 1 "hardcmp" } } */
 /* { dg-final { scan-tree-dump-times "__builtin_trap" 1 "hardcmp" } } */
 /* { dg-final { scan-tree-dump-times "_\[0-9\]* = i_\[0-9\]*\[(\]D\[)\] < j_\[0-9\]*\[(\]D\[)\];" 1 "hardcmp" } } */
-/* { dg-final { scan-tree-dump-times "_\[0-9\]* = i_\[0-9\]* >= j_\[0-9\]*;" 1 "hardcmp" } } */
+/* { dg-final { scan-tree-dump-times "_\[0-9\]* = _\[0-9\]* >= _\[0-9\]*;" 1 "hardcmp" } } */
diff --git a/gcc/testsuite/c-c++-common/torture/harden-cond.c b/gcc/testsuite/c-c++-common/torture/harden-cond.c
index 86de8e155ed..213b048b25a 100644
--- a/gcc/testsuite/c-c++-common/torture/harden-cond.c
+++ b/gcc/testsuite/c-c++-common/torture/harden-cond.c
@@ -15,4 +15,4 @@ f (int i, int j)
 /* { dg-final { scan-tree-dump-times "Adding reversed compare" 2 "hardcbr" } } */
 /* { dg-final { scan-tree-dump-times "__builtin_trap" 2 "hardcbr" } } */
 /* { dg-final { scan-tree-dump-times "if \[(\]i_\[0-9\]*\[(\]D\[)\] < j_\[0-9\]*\[(\]D\[)\]\[)\]" 1 "hardcbr" } } */
-/* { dg-final { scan-tree-dump-times "if \[(\]i_\[0-9\]* >= j_\[0-9\]*\[)\]" 2 "hardcbr" } } */
+/* { dg-final { scan-tree-dump-times "if \[(\]_\[0-9\]* >= _\[0-9\]*\[)\]" 2 "hardcbr" } } */


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-24  4:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24  2:57 [gcc(refs/users/aoliva/heads/testme)] hardened conditionals: drop copied identifiers Alexandre Oliva
2022-03-24  4:01 Alexandre Oliva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).