-
Jakub Jelinek authored
The following testcase regressed when SRA started punting on stores to TREE_READONLY vars. We document that: "In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node, nonzero means it may not be the lhs of an assignment." so the SRA change looks desirable. On the other side, at least in this testcase the TREE_READONLY is set there intentionally from the PR85873 fix, because gimplify_init_constructor itself uses TREE_READONLY on the object to determine if it can perform promotion to static const or not. So, similarly to other spots in the gimplifier where we also clear TREE_READONLY when we emit IL that stores into the object, this does the same in gimplify_init_constructor, but in the way so that the TREE_READONLY test for the promotion to static const keeps working and doesn't change anything for notify_temp_creation mode, which doesn't emit any IL, just tests if it would need a temporary or not. This keeps PR85873 testcase working as before and fixes this regression. 2022-03-04 Jakub Jelinek <jakub@redhat.com> PR middle-end/104529 * gimplify.cc (gimplify_init_constructor): Clear TREE_READONLY on automatic objects which will be runtime initialized. * g++.dg/tree-ssa/pr104529.C: New test.
Jakub Jelinek authoredThe following testcase regressed when SRA started punting on stores to TREE_READONLY vars. We document that: "In a VAR_DECL, PARM_DECL or FIELD_DECL, or any kind of ..._REF node, nonzero means it may not be the lhs of an assignment." so the SRA change looks desirable. On the other side, at least in this testcase the TREE_READONLY is set there intentionally from the PR85873 fix, because gimplify_init_constructor itself uses TREE_READONLY on the object to determine if it can perform promotion to static const or not. So, similarly to other spots in the gimplifier where we also clear TREE_READONLY when we emit IL that stores into the object, this does the same in gimplify_init_constructor, but in the way so that the TREE_READONLY test for the promotion to static const keeps working and doesn't change anything for notify_temp_creation mode, which doesn't emit any IL, just tests if it would need a temporary or not. This keeps PR85873 testcase working as before and fixes this regression. 2022-03-04 Jakub Jelinek <jakub@redhat.com> PR middle-end/104529 * gimplify.cc (gimplify_init_constructor): Clear TREE_READONLY on automatic objects which will be runtime initialized. * g++.dg/tree-ssa/pr104529.C: New test.