]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
hardened conditionals: drop copied identifiers
authorAlexandre Oliva <oliva@adacore.com>
Thu, 24 Mar 2022 13:02:29 +0000 (10:02 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Thu, 24 Mar 2022 13:02:29 +0000 (10:02 -0300)
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.

gcc/gimple-harden-conditionals.cc
gcc/testsuite/c-c++-common/torture/harden-comp.c
gcc/testsuite/c-c++-common/torture/harden-cond.c

index be01f3ea8c44af2e1f3d9429698d9902aa421257..c7e5e077a74f68fe2e38c6ec99ca5eb435f37ad2 100644 (file)
@@ -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,
index 1ee0b3663443dff0ac93d824981c083575455e23..502f52e25be240c75e22120c84941ec3471239c1 100644 (file)
@@ -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" } } */
index 86de8e155ed386f602941ffafbe4739ad466eb27..213b048b25af5d623ada21aceee38c8aab49dffd 100644 (file)
@@ -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" } } */