Bug 41682 - Need for attributes to tag code blocks so optimiser can remove more code.
Summary: Need for attributes to tag code blocks so optimiser can remove more code.
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.5.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-12 11:26 UTC by oiaohm
Modified: 2009-10-12 20:04 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description oiaohm 2009-10-12 11:26:10 UTC
Ok this is a really poor example bare with me.
FILE * f;
char * c;
f = fopen(file,"r")
c = fgetc(f)
fclose(f);

Let say this is a block of code inside a program c and f are never used anywhere else.  Currently optimizer has no way to know that I know of that this code can be junked if if its not used.  Programmer need to be able to place markers to this effect.   One place were this could see some size reductions is in crt0.o with processing of command line.  If the output is not used why do the processing.

I hope I have assigned this to the right part.
Comment 1 Richard Biener 2009-10-12 12:48:03 UTC
Hm?  This code has side-effects, so it cannot be safely removed by a compiler.
Comment 2 Andrew Pinski 2009-10-12 20:04:11 UTC
Just to expand on that, fopen might change errno and it also it might return NULL which case fgetc might cause the program to seg fault.  etc.