analyzer: fixes to __atomic_{exchange,load,store} [PR114286]
commitc7a774edbf802d79b95871ede5b80f6e9adf8e88
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 19 Mar 2024 13:06:45 +0000 (19 09:06 -0400)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 19 Mar 2024 13:06:45 +0000 (19 09:06 -0400)
treebf7c9149aee2fe787252defc5afcd9b0e1ae2fda
parent4adb1a5839e7a3310a127c1776f1f95d7edaa6ff
analyzer: fixes to __atomic_{exchange,load,store} [PR114286]

In r14-1497-gef768035ae8090 I added some support to the analyzer for
__atomic_ builtins (enough to fix false positives I was seeing in
my integration tests).

Unfortunately I messed up the implementation of
__atomic_{exchange,load,store}, leading to ICEs seen in
PR analyzer/114286.

Fixed thusly, fixing the ICEs.  Given that we're in stage 4, the patch
doesn't add support for any of the various __atomic_compare_exchange
builtins, so that these continue to fall back to the analyzer's
"anything could happen" handling of unknown functions.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/ChangeLog:
PR analyzer/114286
* kf.cc (class kf_atomic_exchange): Reimplement based on signature
seen in gimple, rather than user-facing signature.
(class kf_atomic_load): Likewise.
(class kf_atomic_store): New.
(register_atomic_builtins): Register kf_atomic_store.

gcc/testsuite/ChangeLog:
PR analyzer/114286
* c-c++-common/analyzer/atomic-builtins-pr114286.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/kf.cc
gcc/testsuite/c-c++-common/analyzer/atomic-builtins-pr114286.c [new file with mode: 0644]