Dead code: Difference between revisions

Content deleted Content added
Analysis: Added link
Analysis: Added a note that minimum code size may not always be achieved by removing dead code, but sometimes also by carefully inserting dead code.
Line 25:
 
Some [[Integrated development environment|IDE]]s (such as Visual Studio 2010 <ref>Habib Heydarian, Microsoft Corp.[http://blogs.msdn.com/b/habibh/archive/2009/07/31/discover-dead-code-in-your-application-using-code-analysis.aspx]</ref> and Eclipse Galileo <ref>Eclipse Developer Guide[http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.jdt.doc.isv/guide/jdt_api_compile.htm]</ref>) 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.
 
==See also==