Created attachment 23470 [details]
$ g++ -O -fno-early-inlining -fipa-pta -fno-tree-dominator-opts -fno-tree-forwprop testcase.C
Testcase was reduced from g++.dg/torture/pr37922.C, which fails with:
$ g++ -O -fno-early-inlining -fipa-pta -fschedule-insns2 -fno-tree-dominator-opts -fno-tree-forwprop -funroll-loops pr37922.ii
r170489 - fail
Created attachment 23481 [details]
$ g++ -O -fno-early-inlining -fipa-pta -fno-tree-dominator-opts -fno-tree-forwprop pr47896.C
At the assembly level, the problematic line seems to be:
mov DWORD PTR [rsp+32], 9 # i9,
which directly stores the constant 9, instead of the updated value 8.
It doesn't seem to crash when compiled as C code.
This is a failure to handle return-slot-optimization in IPA-PTA properly. For
D.2098 = foo (); [return slot optimization]
we have to make foos return function part point to D.2098. That requires
some re-org, making the function result varinfo always a pointer,
making sure to use *result for result-decl uses (if not DECL_BY_REFERENCE).
I have a patch, but as this bug only affects IPA-PTA I'm defering it to 4.7
as the patch also touches non-IPA parts.