This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: rationale for eliding modifications to string constants


Attached please find two dumps t.c.032t.mergephi1 and t.c.033t.cddce1.
The assignment is present in the former while it disappears in the
latter. The latter dump is the output of the dead code elimination
pass pass_cd_dce. So this is indeed an instance of dead code elimination.

But may be you are right, what facilitate dead code elimination
be based on modification of read-only data. However, if that is
the case, I wonder what is the reason why change happens when s is
an array...


Daniel Jacobowitz wrote, On Tuesday 14 September 2010 11:54 PM:
On Tue, Sep 14, 2010 at 11:50:11PM +0530, Uday P. Khedker wrote:
The point is: in your program is is only a pointer. When you pass s
as a parameter to printf, the compiler assumes that only s is being
used so the (effective) assignment

*s = 'H'

is deleted as dead code when optimization is enabled.

No, this is incorrect. The issue must be specific to modification of read-only data.

Attachment: t.c.032t.mergephi1
Description: Text document

Attachment: t.c.033t.cddce1
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]