Compiler Stack Optimization via Call Graph Analysis
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing methods for optimizing program stack size in microcontrollers often compromise robustness, code modularity, and readability, leading to reduced functionality due to unnecessary optimization measures.
Innovation Solution
A compiler-based approach that analyzes stack size constraints and generates annotated call graphs to selectively apply optimizations such as in-lining, outlining, stack placement algorithms, register allocation, and data analysis to minimize stack usage only where necessary, ensuring the stack size meets the target processor's constraints.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Quantity of substance
If optimization measures (de-featuring, avoiding deep call stacks, minimizing data sizes) are applied to reduce stack size, then stack size is reduced, but product robustness, code modularity, and functionality are compromised
Solution Approach 1:
The patent applies optimization measures locally rather than globally. The system identifies specific call paths that exceed stack size constraints and applies optimization techniques (such as in-lining, outlining, or stack placement algorithms) only to those particular paths. This selective approach reduces stack size where necessary while preserving code modularity and functionality in other parts of the program.
Solution Approach 2:
The patent implements a dynamic, iterative optimization process. The system builds an executable application, generates a call graph, identifies call paths exceeding stack constraints, applies optimizations, and repeats the process until constraints are satisfied. This dynamic approach allows the system to adapt optimization measures to the actual stack usage patterns rather than applying static optimizations that may unnecessarily compromise functionality.
2Quantity of substance
If optimization measures are applied to reduce stack size, then stack size is reduced, but code modularity and readability are violated
Solution Approach 1:
The patent applies optimization measures locally rather than globally. The system identifies specific call paths that exceed stack size constraints and applies optimization techniques (such as in-lining, outlining, or stack placement algorithms) only to those particular paths. This selective approach reduces stack size where necessary while preserving code modularity and functionality in other parts of the program.
3Quantity of substance
If optimization measures are applied unnecessarily, then stack size is reduced, but program functionality is reduced
Solution Approach 1:
The patent implements a feedback-driven optimization process. The system generates a call graph that annotates stack size usage for each call path, compares actual usage against constraints, and uses this feedback information to determine which specific paths require optimization. This feedback mechanism ensures that optimization measures are applied only where necessary to meet stack size constraints, preserving program functionality elsewhere.
Solution Approach 2:
The patent changes optimization parameters selectively based on measured stack usage. Rather than applying fixed optimization rules, the system adjusts optimization intensity and type based on the specific stack size constraints and actual call path usage patterns identified through call graph analysis. This parameter-based approach ensures optimizations are applied only where needed.
Data Source
AI summary
A processing device includes an instruction memory to store executable applications that are executable by a target processor, and a compiler. The compiler includes a builder module and a call graph generator. The builder module to build executable applications for the target processor based on a set of instructions. The call graph generator to create a first call graph that indicates a stack usage for each call path of the executable applications. If a first executable application built by the builder module includes a call path that exceeds a stack size constraint of the target processor, the builder module to optimize only functions within the call path that exceeds the stack size constraint in response to the request from the evaluation monitor, and to build a second executable application based on the set of instructions. The second executable application is optimized for stack memory usage of the target processor.


