Bug 92932

Summary: Optimizers generate wrong code due to aggressive data optimization.
Product: gcc Reporter: Georg-Johann Lay <gjl>
Component: ipaAssignee: Not yet assigned to anyone <unassigned>
Status: NEW ---    
Severity: normal CC: sjames
Priority: P3 Keywords: wrong-code
Version: 8.2.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: 8.2.0, 9.1.0 Last reconfirmed: 2023-06-06 00:00:00
Bug Depends on: 54666, 92294    
Bug Blocks: 87332, 92606    

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.