On Thu, Jan 09, 2020 at 02:20:23PM +0800, Bin.Cheng wrote: > > On December 20, 2019 2:13:47 AM GMT+01:00, "Bin.Cheng" > > <amker.ch...@gmail.com> wrote: > > >On Fri, Dec 13, 2019 at 11:26 AM bin.cheng > > ><bin.ch...@linux.alibaba.com> wrote: > > >> > > >> Hi, > > >> > > >> As reported in PR92926, constant ctor is shared translation unit wide > > >because of constexpr_call_table, > > >> however, during gimplify, the shared ctor could be modified. This > > >patch fixes the issue by unsharing > > >> it before modification in gimplify. A test is reduced from cppcoro > > >library and added. > > >> > > >> Bootstrap and test ongoing. Not sure if this is the correct fix > > >though, any comments? > > >Ping. Any comment? > > > > Looks reasonable to me. > Given PR92926 is marked as duplicate of PR93143, I updated test case > of the patch. > > Thanks, > bin > > 2019-12-13 Bin Cheng <bin.li...@linux.alibaba.com> > > PR tree-optimization/93143 > * gimplify.c (gimplify_init_constructor): Unshare ctor node before > clearing. > > gcc/testsuite > 2019-12-13 Bin Cheng <bin.li...@linux.alibaba.com> > > PR tree-optimization/93143 > * g++.dg/pr93143.C: New test.
Isn't the right spot to fix this somewhere in cp_gimplify_expr? I mean, the way gimplification works, we unshare_body first and then gimplify, which is destructive for the GENERIC it is gimplifying. The reason why this testcase FAILs is that the gimplification hook after the unshare_body emits I guess a CONSTRUCTOR multiple times, readding there the sharing. Unsharing in gimplify_init_constructor means that for non-C++ or even for C++ when it doesn't trigger the problematic case we unshare the second time and waste compile time memory. Jakub