public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "fxue at os dot amperecomputing.com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107066] New: Field initialized before ctor is mis-optimized away by DSE Date: Wed, 28 Sep 2022 10:55:52 +0000 [thread overview] Message-ID: <bug-107066-4@http.gcc.gnu.org/bugzilla/> (raw) 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; }
next reply other threads:[~2022-09-28 10:55 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-28 10:55 fxue at os dot amperecomputing.com [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107066-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).