Link-Time Code Outlining Without Trampolines
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Existing code outlining techniques using trampolines incur performance penalties and reduce instruction cache efficiency due to additional instructions and control redirection, limiting the optimal performance of basic block placement in RISC architectures.
Innovation Solution
A method that outlines cold code without trampolines by identifying cold blocks using heuristics and profile data, converting short branch instructions to longer ones, and maintaining a window for optimal code layout at link time, allowing hot and cold blocks to be placed separately within a function, thereby eliminating the need for trampolines.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Adaptability or versatility
If trampolines are used to redirect execution flow to outlined cold blocks, then code outlining can be achieved beyond branch distance limits, but performance penalties occur and instruction cache efficiency is reduced
Solution Approach 1:
The patent extracts and removes the trampoline code from the system entirely. By performing code outlining at link time rather than compile time, the system can place cold blocks within direct branch distance of hot blocks without needing intermediate trampoline redirection code, eliminating the performance overhead while maintaining the ability to outline cold code.
Solution Approach 2:
The patent performs code layout decisions in advance at link time before the program executes. By analyzing the entire program and determining optimal placements of hot and cold blocks beforehand, the system ensures that cold blocks are positioned within branch distance of their calling hot blocks, eliminating the need for runtime trampoline insertion and associated performance penalties.
2Adaptability or versatility
If trampolines are inserted to enable branches outside contiguous binary code, then code outlining is enabled, but the number of instructions increases and control redirection impacts instruction cache efficiency
Solution Approach 1:
The patent removes trampoline instructions from the executable code by performing code outlining at link time. The linker directly places cold blocks within branch range of hot blocks, eliminating the need for trampoline redirection instructions and reducing the total instruction count while maintaining code placement flexibility.
Solution Approach 2:
The patent performs code layout optimization at link time before code generation, determining the final positions of hot and cold blocks. This preliminary action ensures that all control transfers can be achieved with direct branches within the target architecture's branch distance limits, eliminating the need for additional trampoline instructions.
3Speed
If fixed length 32-bit instruction formats are used in RISC architectures, then instruction fetch and decoding speed is improved, but the distance between CTI and target is limited
Solution Approach 1:
The patent performs code layout at link time with full knowledge of the program structure and execution patterns. This allows the linker to place cold blocks within the fixed branch distance limits of the RISC architecture while maintaining optimal cache locality, resolving the conflict between fixed instruction length and branch distance requirements.
Solution Approach 2:
The patent changes the optimization stage from compile time to link time, allowing the system to work within the fixed branch distance constraints of RISC architectures while achieving optimal code placement. By performing outlining after all object code is available, the system can ensure all branches fit within distance limits without needing variable length instructions.
Data Source
AI summary
A system and method for optimizing compiler performance including outlining cold code at link time, rather than compile time, such that trampolines are not required. Branch instructions connecting a hot block to a cold block can be converted from a short branch distance limit to a longer branch distance limit, further optimizing code performance. Editors, implementing a plurality of windows that can be maintained for each function, can display the maximum distance that code blocks can be safely outlined. Other implementations allow the optimal placement of code that is significantly greater in size than the maximum possible branch distance.


