Register Usage Mask for Function Call Overhead Reduction
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
In SIMD processors, efficiently saving registers during function calls is challenging, especially for indirect and recursive function calls, as the compiler cannot determine at compile-time which registers are commonly used by the calling and called functions, leading to unnecessary data storage and processing overhead.
Innovation Solution
The solution involves modifying the calling code to set a register usage mask indicating which registers are in use and combining this information with the register usage of the called function to determine and save only the necessary registers, using a bitwise AND operation to identify commonly used registers, and storing them in memory for later restoration.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Reliability
If all registers are saved during function calls, then register values are preserved correctly, but data storage and processing overhead increases
Solution Approach 1:
The patent extracts only the necessary registers that are commonly used by both calling and called functions, rather than saving all registers. This is achieved by maintaining a register usage mask that identifies which registers need to be saved, thereby reducing unnecessary data storage and processing overhead while still preserving correctness.
Solution Approach 2:
The patent changes the parameter representation by using a register usage mask to dynamically identify which registers need to be saved. This allows the system to adapt the register saving behavior based on actual usage patterns, optimizing the balance between reliability and processing overhead.
2Productivity
If register usage is determined at compile-time, then optimization is improved, but adaptability to indirect and recursive function calls deteriorates
Solution Approach 1:
The patent introduces dynamic register usage tracking using a runtime mask that can adapt to different function call scenarios including indirect and recursive calls. The mask is updated based on actual register usage detected during execution, allowing the system to optimize register saving dynamically rather than relying solely on static compile-time analysis.
Solution Approach 2:
The patent implements feedback mechanisms where the runtime system monitors actual register usage and adjusts the register saving behavior accordingly. The register usage mask provides feedback about which registers are actually in use, allowing the compiler and runtime to make informed decisions about optimization versus adaptability.
3Reliability
If more registers are saved, then correctness is improved, but the amount of data stored increases
Solution Approach 1:
The patent extracts and saves only the essential registers that are commonly used across function boundaries, identified through the register usage mask. This selective extraction approach ensures correctness by preserving necessary registers while minimizing the quantity of data stored, avoiding the overhead of saving unnecessary registers.
Solution Approach 2:
The patent applies partial action by saving only a subset of registers rather than all registers. The register usage mask enables the system to identify and save exactly the portion of registers that are necessary, avoiding excessive saving of registers that would not affect correctness but would increase storage requirements.
Data Source
AI summary
Described herein are techniques for saving registers in the event of a function call. The techniques include modifying a program including a block of code designated as a calling code that calls a function. The modifying includes modifying the calling code to set a register usage mask indicating which registers are in use at the time of the function call. The modifying also includes modifying the function to combine the information of the register usage mask with information indicating registers used by the function to generate registers to be saved and save the registers to be saved.


