Preview

Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS)

Advanced search

Local Register Allocation Problem in Dynamic Binary Translation

Abstract

QEMU is a generic machine emulator based on a dynamic binary translation approach. This paper evaluates possible improvements to the local register allocation algorithm in QEMU. The local register allocation problem is NP-hard, but there are several approximate heuristic algorithms. Among them Furthest-First and Clean-First heuristics are known to produce a near optimal result in linear time.

Local register allocation algorithm in QEMU scans instructions in direct order. For each instruction operand that is not yet stored on a register, an empty register is allocated. If there are no empty registers, then a spill of an arbitrary register is generated. On basic block ends and helper functions' calls all global variables are also spilled.

Two improvements for the register allocation algorithm are proposed in this paper. The first is to improve spill choices by using the heuristic from the Furthest-First algorithm. The second is to aggressively spill global variables which will be spilled anyway because of helper function calls and basic block ends. Both improvements were implemented and tested on practical workloads. Profiling results show that the amount of generated spills was reduced by approximately 1%.

With these improvements, over 96% of spills are generated due to function calls and basic block ends. This implies that the further improvements to this algorithm are not possible without altering its existing constraints.

About the Author

Kirill Batuzov
ISP RAS
Russian Federation


References

1. QEMU — Open Source Processor Emulator. http://wiki.qemu.org/Main_Page. Access date: 20.03.2012.

2. K. Batuzov, A. Merkulov. Optimizatsiya dinamicheskoj dvoichnoj translyatsii [Optimizations in Dynamic Binary Translation]. Trudy ISP RАN [The Proceedings of ISP RAS], 2011, vol. 20, pp. 37-50 (in Russian).

3. Wei-Chung Hsu, Charles N. Fisher, James R. Goodman. On the Minimization of Load/Stores in Local Register Allocation. IEEE Transactions on Software Engineering, vol 15, No. 10, October 1989. doi: 10.1109/TSE.1989.559775

4. Vincenzo Liberatore, Martin Farach-Colton, Olrich Kremer. Evaluation of Algorithms for Local Register Allocation. Lecture notes in Computer Science, vol 1575, 1999. doi: 10.1007/978-3-540-49051-7_10

5. Martin Farach, Vincenzo Liberatore. On Local Register Allocation. DIMACS Technical Report 97-33, July 1997.

6. Alfred V. Aho , Monica S. Lam , Ravi Sethi , Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools (2nd Edition). Addison-Wesley Longman Publishing Co., Inc., Boston, MA, 2006.


Review

For citations:


Batuzov K. Local Register Allocation Problem in Dynamic Binary Translation. Proceedings of the Institute for System Programming of the RAS (Proceedings of ISP RAS). 2012;22. (In Russ.)



Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 License.


ISSN 2079-8156 (Print)
ISSN 2220-6426 (Online)