Faster Register Allocation via Grammatical Decompositions of Control-Flow Graphs - Archive ouverte HAL Accéder directement au contenu
Pré-Publication, Document De Travail Année : 2024

Faster Register Allocation via Grammatical Decompositions of Control-Flow Graphs

Résumé

It is well-known that control-flow graphs (CFGs) of structured programs are sparse. This sparsity has been previously formalized in terms of graph parameters such as treewidth and pathwidth and used to design faster parameterized algorithms for numerous compiler optimization, model checking and program analysis tasks. In this work, we observe that the known graph sparsity parameters fail to exactly capture the kind of sparsity exhibited by CFGs. For example, while all structured CFGs have a treewidth of at most $7$, not every graph with a treewidth of $7$ or less is realizable as a CFG. As a result, current parameterized algorithms are solving the underlying graph problems over a more general family of graphs than the CFGs. To address this problem, we design a new but natural concept of graph decomposition based on a grammar that precisely captures the set of graphs that can be realized as CFGs of programs. We show that our notion of decomposition enables the same type of dynamic programming algorithms that are often used in treewidth/pathwidth-based methods. As two concrete applications, using our grammatical decomposition of CFGs, we provide asymptotically more efficient algorithms for two variants of the classical problem of register allocation. Our algorithms are asymptotically faster not only in comparison with the non-parameterized solutions for these problems, but also compared to the state-of-the-art treewidth/pathwidth-based approaches in the literature. For minimum-cost register allocation over a fixed number of registers, we provide an algorithm with a runtime of $O(|G| \cdot |V|^{5 \cdot r})$ where $|G|$ is the size of the program, $V$ is the set of program variables and $r$ is the number of registers. In contrast, the previous treewidth-based algorithm had a runtime of $O(|G| \cdot |V|^{16 \cdot r})$. For the decision problem of spill-free register allocation, our algorithm's runtime is $O(|G| \cdot r^{5 \cdot r + 5})$ whereas the previous works had a runtime of $O(|G| \cdot r^{16 \cdot r})$. Finally, we provide extensive experimental results on spill-free register allocation, showcasing the scalability of our approach in comparison to previous state-of-the-art methods. Most notably, our approach can handle real-world instances with up to 20 registers, whereas previous works could only scale to 8. This is a significant improvement since most ubiquitous architectures, such as the x86 family, have 16 registers. For such architectures, our approach is the first-ever \emph{exact} algorithm that scales up to solve the real-world instances of spill-free register allocation.
Fichier principal
Vignette du fichier
main.pdf (6.11 Mo) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)

Dates et versions

hal-04672403 , version 1 (19-08-2024)

Identifiants

  • HAL Id : hal-04672403 , version 1

Citer

Xuran Cai, Amir Kafshdar Goharshady, S. Hitarth, Chun Kit Lam. Faster Register Allocation via Grammatical Decompositions of Control-Flow Graphs. 2024. ⟨hal-04672403⟩

Collections

TDS-MACS
0 Consultations
0 Téléchargements

Partager

Gmail Mastodon Facebook X LinkedIn More