Skip to content

Commit fb488cb

Browse files
Alexandre OlivaAlexandre Oliva
Alexandre Oliva
authored and
Alexandre Oliva
committed
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.
1 parent b8c4171 commit fb488cb

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

gcc/gimple-harden-conditionals.cc

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,11 @@ detach_value (location_t loc, gimple_stmt_iterator *gsip, tree val)
126126
return val;
127127
}
128128

129-
/* Create a SSA "copy" of VAL. This could be an anonymous
130-
temporary, but it's nice to have it named after the corresponding
131-
variable. Alas, when VAL is a DECL_BY_REFERENCE RESULT_DECL,
132-
setting (a copy of) it would be flagged by checking, so we don't
133-
use copy_ssa_name: we create an anonymous SSA name, and then give
134-
it the same identifier (rather than decl) as VAL. */
129+
/* Create a SSA "copy" of VAL. It would be nice to have it named
130+
after the corresponding variable, but sharing the same decl is
131+
problematic when VAL is a DECL_BY_REFERENCE RESULT_DECL, and
132+
copying just the identifier hits -fcompare-debug failures. */
135133
tree ret = make_ssa_name (TREE_TYPE (val));
136-
SET_SSA_NAME_VAR_OR_IDENTIFIER (ret, SSA_NAME_IDENTIFIER (val));
137134

138135
/* Some modes won't fit in general regs, so we fall back to memory
139136
for them. ??? It would be ideal to try to identify an alternate,

gcc/testsuite/c-c++-common/torture/harden-comp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ f (int i, int j)
1111
/* { dg-final { scan-tree-dump-times "Adding reversed compare" 1 "hardcmp" } } */
1212
/* { dg-final { scan-tree-dump-times "__builtin_trap" 1 "hardcmp" } } */
1313
/* { dg-final { scan-tree-dump-times "_\[0-9\]* = i_\[0-9\]*\[(\]D\[)\] < j_\[0-9\]*\[(\]D\[)\];" 1 "hardcmp" } } */
14-
/* { dg-final { scan-tree-dump-times "_\[0-9\]* = i_\[0-9\]* >= j_\[0-9\]*;" 1 "hardcmp" } } */
14+
/* { dg-final { scan-tree-dump-times "_\[0-9\]* = _\[0-9\]* >= _\[0-9\]*;" 1 "hardcmp" } } */

gcc/testsuite/c-c++-common/torture/harden-cond.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ f (int i, int j)
1515
/* { dg-final { scan-tree-dump-times "Adding reversed compare" 2 "hardcbr" } } */
1616
/* { dg-final { scan-tree-dump-times "__builtin_trap" 2 "hardcbr" } } */
1717
/* { dg-final { scan-tree-dump-times "if \[(\]i_\[0-9\]*\[(\]D\[)\] < j_\[0-9\]*\[(\]D\[)\]\[)\]" 1 "hardcbr" } } */
18-
/* { dg-final { scan-tree-dump-times "if \[(\]i_\[0-9\]* >= j_\[0-9\]*\[)\]" 2 "hardcbr" } } */
18+
/* { dg-final { scan-tree-dump-times "if \[(\]_\[0-9\]* >= _\[0-9\]*\[)\]" 2 "hardcbr" } } */

0 commit comments

Comments
 (0)