Cross-Compilation Unit Sparse Conditional Constant Propagation
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing compilers perform optimizations on a per-compilation unit basis, which limits the effectiveness of optimizations across multiple compilation units, leading to suboptimal program execution and increased program size due to excessive inlining.
Innovation Solution
The method involves expanding the flow graph of a first compilation unit, updating parameter states with exact types and value sets, and optimizing the program using these parameter states to generate a compiled program, thereby enabling cross-compilation unit optimizations.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If the compiler performs inlining on each compilation unit independently, then the compilation process is simple and fast, but the optimization effectiveness is limited and program size increases
Solution Approach 1:
The patent merges the optimization process across multiple compilation units by expanding the flow graph to include callsites from other compilation units. This allows the compiler to perform optimizations considering the entire program context rather than isolated units, resolving the contradiction between simple per-unit processing and effective cross-unit optimization.
Solution Approach 2:
The patent performs preliminary flow graph expansion before optimization. By expanding the flow graph to include callsites from other compilation units beforehand, the compiler prepares the complete execution context needed for effective optimization, enabling better optimization decisions without complicating the actual optimization process.
2Speed
If the compiler inlines methods to reduce execution time, then program execution speed improves, but program size increases
Solution Approach 1:
The patent changes the parameter of optimization scope from per-compilation-unit to cross-compilation-unit. By expanding the flow graph to include callsites from other units, the compiler can make more informed inlining decisions that consider overall program structure and execution patterns, leading to better balance between execution speed and program size.
3Device complexity
If the compiler performs optimizations on a per-compilation-unit basis, then the optimization process is simple, but optimizations cannot consider code from multiple units
Solution Approach 1:
The patent segments the flow graph expansion process into manageable steps: identifying callsites, expanding flow graphs for called methods, and propagating parameter states. This segmentation allows complex cross-unit optimization to be performed systematically without overwhelming complexity in the optimization process itself.
Solution Approach 2:
The patent introduces an intermediary flow graph expansion mechanism that mediates between compilation units. By expanding the flow graph to include callsites from other units as an intermediate representation, the compiler can perform optimizations that consider multiple units while maintaining a structured and manageable process.
Data Source
AI summary
A flow graph of a first compilation unit of the program is expanded. The first corresponding parameter states of statements of the first compilation unit are marked as empty. The statements of the first compilation unit are processed to update the first corresponding parameter states with an exact type and a value set. Processing the statements include tracking a control flow predicate of a block in the first compilation unit, wherein the block comprises a first subset of the statements. Only after the control flow predicate indicates that the block is executable, the method includes processing an invocation statement in the first subset of the first statements, and expanding, responsive to the invocation statement, the flow graph for a second compilation unit of the program that is identified by the invocation statement.


