]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fix SSA_NAME leak due to def_stmt is removed before use_stmt.
authorliuhongt <hongtao.liu@intel.com>
Fri, 12 Jul 2024 01:39:23 +0000 (09:39 +0800)
committerliuhongt <hongtao.liu@intel.com>
Mon, 15 Jul 2024 04:51:59 +0000 (12:51 +0800)
commite1427b39d28f382d21e7a0ea1714b3250e0a6e5d
tree00211014320337848fe78047b1db0fce2fb6b575
parentb23efee77aabcd884d29c465b09510d47d989041
Fix SSA_NAME leak due to def_stmt is removed before use_stmt.

-  _5 = __atomic_fetch_or_8 (&set_work_pending_p, 1, 0);
-  # DEBUG old => (long int) _5
+  _6 = .ATOMIC_BIT_TEST_AND_SET (&set_work_pending_p, 0, 1, 0, __atomic_fetch_or_8);
+  # DEBUG old => NULL
   # DEBUG BEGIN_STMT
-  # DEBUG D#2 => _5 & 1
+  # DEBUG D#2 => NULL
...
-  _10 = ~_5;
-  _8 = (_Bool) _10;
-  # DEBUG ret => _8
+  _8 = _6 == 0;
+  # DEBUG ret => (_Bool) _10

confirmed.  convert_atomic_bit_not does this, it checks for single_use
and removes the def, failing to release the name (which would fix this up
IIRC).

Note the function removes stmts in "wrong" order (before uses of LHS
are removed), so it requires larger surgery.  And it leaks SSA names.

gcc/ChangeLog:

PR target/115872
* tree-ssa-ccp.cc (convert_atomic_bit_not): Remove use_stmt after use_nop_stmt is removed.
(optimize_atomic_bit_test_and): Ditto.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr115872.c: New test.

(cherry picked from commit a8209237dc46dc4db7d9d8e3807e6c93734c64b5)
gcc/testsuite/gcc.target/i386/pr115872.c [new file with mode: 0644]
gcc/tree-ssa-ccp.cc