rationale for eliding modifications to string constants
Uday P. Khedker
uday@cse.iitb.ac.in
Tue Sep 14 20:41:00 GMT 2010
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.
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: t.c.032t.mergephi1
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20100914/c4fb83fd/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: t.c.033t.cddce1
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20100914/c4fb83fd/attachment-0001.ksh>
More information about the Gcc
mailing list