ipa/105676 - pure attribute suggestion for const function
authorRichard Biener <rguenther@suse.de>
Wed, 7 Dec 2022 09:26:01 +0000 (10:26 +0100)
committerRichard Biener <rguenther@suse.de>
Wed, 7 Dec 2022 10:28:00 +0000 (11:28 +0100)
commit45e09c2eb9c2bdd34ef777e06ddc9908dd0664f9
treea6b559ea9c8b4decd2d5c1efbac5b7be49a3ac01
parent3a1a141f79c83ad38f7db3a21d8a4dcfe625c176
ipa/105676 - pure attribute suggestion for const function

When a function is declared const (even though it technically
accesses memory), ipa-modref discovering pureness shouldn't end
up suggesting that attribute.  The following thus exempts
'const' functions from ipa_make_function_pure handling.

PR ipa/105676
* ipa-pure-const.cc (ipa_make_function_pure): Skip also
for functions already being const.

* gcc.dg/pr105676.c: New testcase.
gcc/ipa-pure-const.cc
gcc/testsuite/gcc.dg/pr105676.c [new file with mode: 0644]