Bug 92932 - Optimizers generate wrong code due to aggressive data optimization.
Summary: Optimizers generate wrong code due to aggressive data optimization.
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 8.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Keywords: wrong-code
Depends on: 54666 92294
Blocks: 92606
  Show dependency treegraph
Reported: 2019-12-13 15:23 UTC by Georg-Johann Lay
Modified: 2020-01-23 07:49 UTC (History)
0 users

See Also:
Known to work:
Known to fail: 8.2.0, 9.1.0
Last reconfirmed: 2019-12-13 00:00:00


Note You need to log in before you can comment on or make changes to this bug.
Description Georg-Johann Lay 2019-12-13 15:23:49 UTC
GCC sometimes aliases symbols if they refer to identical data.  However, in order for this to be legitimate optimization, it must be ensured that the code will be accessed in the same way.

This is not always the case, an example where this generates wrong code is PR92606.

Such a new hook needs at least the following information to disallow aliasing  by means of .set or similar means:

* The attributes specified for either objects.

* The address spaces specified for either objects.
Comment 1 Andrew Pinski 2019-12-13 19:47:33 UTC
Dup of at least PR92294 and  PR54666; I thought there was a much older bug dealing with the alias attribute but I can't seem to find it right now.
Comment 2 Georg-Johann Lay 2019-12-14 14:59:51 UTC
(In reply to Andrew Pinski from comment #1)
> Dup of at least PR92294 and  PR54666;

These PRs are different because no target hook is needed to see that the code is wrong. This is different with PR92606 because a target attribute is involved. 

Hence this PR for a new target hook that can tell whether such transformation might not be legitimate {apart from generic reasons}.
Comment 3 Georg-Johann Lay 2019-12-16 12:54:40 UTC
For the time being, -fno-ipa-icf-variables might be used as a work-around.