public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/107066] New: Field initialized before ctor is mis-optimized away by DSE @ 2022-09-28 10:55 fxue at os dot amperecomputing.com 2022-09-28 12:56 ` [Bug tree-optimization/107066] " pinskia at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: fxue at os dot amperecomputing.com @ 2022-09-28 10:55 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107066 Bug ID: 107066 Summary: Field initialized before ctor is mis-optimized away by DSE Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: fxue at os dot amperecomputing.com Target Milestone: --- By means of user-defined new operator, it is possible that a field is initialized before constructor. #include <stddef.h> class A { public: int f1; int f2; A() : f2(2) { } void *operator new(size_t size) { void *mem = ::operator new(size); A *obj = static_cast<A *>(mem); obj->f1 = 1; return obj; } }; A* foo () { return new A(); } The original gimple code of foo() is: struct A * foo () { void * D.2444; void * _9; <bb 2> : _9 = operator new (8); MEM[(struct A *)_9].f1 = 1; MEM[(struct A *)_9] ={v} {CLOBBER}; MEM[(struct A *)_9].f2 = 2; return _9; } In gimple, there exists a pseudo clobber statement marking beginning of constructor code. Although the statement is of no side effect, it is regarded as normal store by DSE when determining store redundancy. Consequently, DSE thought that "MEM[(struct A *)_9].f1 = 1" was killed by "MEM[(struct A *)_9] ={v} {CLOBBER}", and removed it. After DSE pass,the foo becomes: struct A * foo () { void * D.2444; void * _9; <bb 2> : _9 = operator new (8); MEM[(struct A *)_9] ={v} {CLOBBER}; MEM[(struct A *)_9].f2 = 2; return _9; } ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/107066] Field initialized before ctor is mis-optimized away by DSE 2022-09-28 10:55 [Bug tree-optimization/107066] New: Field initialized before ctor is mis-optimized away by DSE fxue at os dot amperecomputing.com @ 2022-09-28 12:56 ` pinskia at gcc dot gnu.org 2022-09-28 16:56 ` pinskia at gcc dot gnu.org 2022-09-29 0:45 ` fxue at os dot amperecomputing.com 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-09-28 12:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107066 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- You need -fno-lifetime-dse as documented https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Optimize-Options.html#index-flifetime-dse C++ is defined this way otherwise. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/107066] Field initialized before ctor is mis-optimized away by DSE 2022-09-28 10:55 [Bug tree-optimization/107066] New: Field initialized before ctor is mis-optimized away by DSE fxue at os dot amperecomputing.com 2022-09-28 12:56 ` [Bug tree-optimization/107066] " pinskia at gcc dot gnu.org @ 2022-09-28 16:56 ` pinskia at gcc dot gnu.org 2022-09-29 0:45 ` fxue at os dot amperecomputing.com 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2022-09-28 16:56 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107066 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- See https://gcc.gnu.org/gcc-6/porting_to.html#flifetime-dse also. Which documented when the change happened back in GCC 6. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/107066] Field initialized before ctor is mis-optimized away by DSE 2022-09-28 10:55 [Bug tree-optimization/107066] New: Field initialized before ctor is mis-optimized away by DSE fxue at os dot amperecomputing.com 2022-09-28 12:56 ` [Bug tree-optimization/107066] " pinskia at gcc dot gnu.org 2022-09-28 16:56 ` pinskia at gcc dot gnu.org @ 2022-09-29 0:45 ` fxue at os dot amperecomputing.com 2 siblings, 0 replies; 4+ messages in thread From: fxue at os dot amperecomputing.com @ 2022-09-29 0:45 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107066 --- Comment #3 from Feng Xue <fxue at os dot amperecomputing.com> --- Got it. Thanks for that. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-09-29 0:45 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-09-28 10:55 [Bug tree-optimization/107066] New: Field initialized before ctor is mis-optimized away by DSE fxue at os dot amperecomputing.com 2022-09-28 12:56 ` [Bug tree-optimization/107066] " pinskia at gcc dot gnu.org 2022-09-28 16:56 ` pinskia at gcc dot gnu.org 2022-09-29 0:45 ` fxue at os dot amperecomputing.com
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).