analyzer: fixes to memcpy [PR103872]
authorDavid Malcolm <dmalcolm@redhat.com>
Thu, 3 Feb 2022 21:21:27 +0000 (16:21 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Mon, 7 Feb 2022 23:31:54 +0000 (18:31 -0500)
commit9d2c0fad59745bf67aa6471e8c9e96c351f0de59
tree993b5fb8ad10b5445bcdbe248127fe75cf0aec4f
parentf30e65e94d14a249fb810aea5bddb6afe3e706df
analyzer: fixes to memcpy [PR103872]

PR analyzer/103872 reports a failure of gcc.dg/analyzer/pr103526.c on
riscv64-unknown-elf-gcc.  The issue is that I wrote the test on x86_64
where a memcpy in the test is optimized to a write to a read/write pair,
whereas due to alignment differences the analyzer can see it as a
memcpy call, revealing problems with the analyzer's implementation
of memcpy.

This patch reimplements region_model::impl_call_memcpy in terms of a
get_store_value followed by a set_value, fixing the issue.

gcc/analyzer/ChangeLog:
PR analyzer/103872
* region-model-impl-calls.cc (region_model::impl_call_memcpy):
Reimplement in terms of a get_store_value followed by a set_value.

gcc/testsuite/ChangeLog:
PR analyzer/103872
* gcc.dg/analyzer/memcpy-1.c: Add alternate versions of test cases
in which the calls to memcpy are hidden from the optimizer.  Add
further test cases.
* gcc.dg/analyzer/taint-size-1.c: Add test coverage for memcpy
with tainted size.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
gcc/analyzer/region-model-impl-calls.cc
gcc/testsuite/gcc.dg/analyzer/memcpy-1.c
gcc/testsuite/gcc.dg/analyzer/taint-size-1.c