Removing Redundant Exception Handling Code via Call Graph Analysis
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing software systems generate redundant exception handling code during stack unwinding, leading to larger program sizes and runtime performance issues due to unnecessary code and increased exception lookup table sizes, which can be cumbersome for programmers to manage.
Innovation Solution
A method for redundant exception handling code removal that involves creating a call graph to identify and remove redundant code, optimizing compiled object files at link time by analyzing the call graph to determine which functions or call sites do not throw exceptions and thus do not require stack unwind code, and updating the exception lookup table to remove redundant entries.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If exception handling code is inserted during compilation to handle stack unwinding, then exception safety is improved, but program size increases
Solution Approach 1:
The patent extracts and removes redundant exception handling code from the program. By analyzing the call graph to identify functions that cannot throw exceptions, the system selectively removes exception handling code from those functions, thereby reducing program size while preserving exception safety in functions that actually require it.
Solution Approach 2:
The patent changes the state of exception handling code from present to absent based on function characteristics. By determining whether each function can throw exceptions (a parameter change), the system dynamically adjusts the presence of exception handling code, optimizing the balance between exception safety and program size.
2Reliability
If exception handling code is inserted during compilation, then exception handling capability is improved, but runtime performance deteriorates
Solution Approach 1:
The patent removes unnecessary exception handling code from functions that cannot throw exceptions. This extraction eliminates runtime overhead associated with exception handling checks in functions where exceptions are impossible, thereby improving runtime performance while maintaining exception handling capability where needed.
Solution Approach 2:
The patent applies exception handling code selectively rather than universally. By identifying and marking functions that can throw exceptions using the throw() attribute, the system applies exception handling only where necessary (partial action), avoiding the performance penalty of universal exception handling while maintaining safety where required.
3Reliability
If comprehensive exception handling code is generated, then exception coverage is improved, but device complexity increases
Solution Approach 1:
The patent extracts and removes redundant exception handling code by analyzing the call graph and identifying functions that cannot throw exceptions. This selective removal simplifies the codebase by eliminating unnecessary try-catch blocks and stack unwinding code while preserving comprehensive exception coverage in functions that actually require it.
Solution Approach 2:
The patent performs preliminary analysis during compilation to identify functions that can throw exceptions using the throw() attribute. This preliminary action allows the compiler to make informed decisions about where to insert exception handling code, avoiding the complexity of comprehensive exception handling in functions where it is unnecessary.
Data Source
AI summary
A system performs operations comprising creating a call graph for a program translated from source code, identifying redundant exception handling code in the program utilizing the call graph, and removing the redundant exception handling code. The operation of identifying redundant exception handling code may comprise identifying at least one function or callsite by determining that a first function in the at least one function's or callsite's callee chain throws an exception and that the exception is handled by a second function in the function's or callsite's callee chain or by determining that an exception is not thrown in the at least one function's or callsite's callee chain. The operation of removing the redundant exception handling code may comprise removing redundant exception handling code included in at least one function or callsite and/or removing at least one entry for the at least one function or callsite from an exception lookup table.


