Analysis
Dead code elimination is a form of compiler optimization in which dead code is removed from a program. Dead code analysis can be performed using live variable analysis, a form of static code analysis and data flow analysis. This is in contrast to unreachable code analysis which is based on control flow analysis.
The dead code elimination technique is in the same class of optimizations as unreachable code elimination and redundant code elimination.
In large programming projects, it is sometimes difficult to recognize and eliminate dead code, particularly when entire modules become dead. Test scaffolding can make it appear that the code is still live, and at times, contract language can require delivery of the code even when the code is no longer relevant.
Some IDEs (such as Visual Studio 2010 and Eclipse Galileo ) have the ability to locate dead code during the compiling stage.
While most optimization techniques seek to remove dead code in an implementation, in extreme forms of optimization for size it may sometimes be desirable to deliberately introduce and carefully shape seemingly dead code, when it allows to fold otherwise unrelated code sections together (and thereby reduce their combined size) so that the extra code will effectively not harm the first path of execution through the code but is used to carry out the actions necessary for the alternative paths of execution, for which other sections of the code may become dead code. On a more functional level, this can be seen as both, artificially introduction of harmless/useful side-effects and reduction of the redundancy of the code, but it can also be used down to opcode level in order to allow the usage of shorter instructions, which would not be possible when folding code sequences without the concerted introduction of side-effects caused by the dead code.
Read more about this topic: Dead Code
Famous quotes containing the word analysis:
“Whatever else American thinkers do, they psychologize, often brilliantly. The trouble is that psychology only takes us so far. The new interest in families has its merits, but it will have done us all a disservice if it turns us away from public issues to private matters. A vision of things that has no room for the inner life is bankrupt, but a psychology without social analysis or politics is both powerless and very lonely.”
—Joseph Featherstone (20th century)
“The spider-mind acquires a faculty of memory, and, with it, a singular skill of analysis and synthesis, taking apart and putting together in different relations the meshes of its trap. Man had in the beginning no power of analysis or synthesis approaching that of the spider, or even of the honey-bee; but he had acute sensibility to the higher forces.”
—Henry Brooks Adams (18381918)
“A commodity appears at first sight an extremely obvious, trivial thing. But its analysis brings out that it is a very strange thing, abounding in metaphysical subtleties and theological niceties.”
—Karl Marx (18181883)