Abstract
The optimization phase of a compiler is responsible for transforming an intermediate representation (IR) of a program into a more efficient form. Modern optimizers, such as that used in the GraalVM compiler, use an IR consisting of a sophisticated graph data structure that combines data flow and control flow into the one structure. As part of a wider project on the verification of optimization passes of GraalVM, this paper describes a semantics for its IR within Isabelle/HOL. The semantics consists of a big-step operational semantics for data nodes (which are represented in a graph-based static single assignment (SSA) form) and a small-step operational semantics for handling control flow including heap-based reads and writes, exceptions, and method calls. We have proved a suite of canonicalization optimizations and conditional elimination optimizations with respect to the semantics.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
A more abstract representation would be better but using natural numbers allows us to utilise Isabelle code generation facilities.
- 2.
- 3.
In Isabelle/HOL “\(S \Rightarrow T\)” is the type of a function from S to T.
- 4.
All theories are available at https://github.com/uqcyber/veriopt-releases/tree/atva2021.
- 5.
The operation for allocating a new object could nondeterministically choose any unused object reference, but we have made it a deterministic function that allocates the next location to facilitate the use of Isabelle code generation facilities.
References
Böhme, S., Moskal, M.: Heaps and data structures: a challenge for automated provers. In: Bjørner, N., Sofronie-Stokkermans, V. (eds.) CADE 2011. LNCS (LNAI), vol. 6803, pp. 177–191. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-22438-6_15
Click, C.: Global code motion/global value numbering. In: PLDI 1995, pp. 246–257. ACM Press (1995). https://doi.org/10.1145/207110.207154
Click, C., Cooper, K.D.: Combining analyses, combining optimizations. TOPLAS 17(2), 181–196 (1995). https://doi.org/10.1145/201059.201061
Demange, D., Fernández de Retana, Y., Pichardie, D.: Semantic reasoning about the sea of nodes. In: CC 2018, pp. 163–173. ACM, New York (2018). https://doi.org/10.1145/3178372.3179503
Duboscq, G., et al.: An intermediate representation for speculative optimizations in a dynamic compiler. In: VMIL 2013, pp. 1–10 (2013)
Ferrante, J., Ottenstein, K.J., Warren, J.D.: The program dependence graph and its use in optimization. ACM TOPLAS 9(3), 319–349 (1987). https://doi.org/10.1145/24039.24041
Kumar, R., Myreen, M.O., Norrish, M., Owens, S.: CakeML: a verified implementation of ML. In: POPL 2014, pp. 179–191. ACM Press, January 2014. https://doi.org/10.1145/2535838.2535841
Lattner, C., Adve, V.: LLVM: a compilation framework for lifelong program analysis & transformation. In: CGO 2004, pp. 75–86. IEEE Computer Society (2004)
Leroy, X., Blazy, S., Kästner, D., Schommer, B., Pister, M., Ferdinand, C.: CompCert - a formally verified optimizing compiler. In: ERTS 2016. SEE, Toulouse, January 2016. https://hal.inria.fr/hal-01238879
Li, L., Gunter, E.L.: K-LLVM: a relatively complete semantics of LLVM IR. In: Hirschfeld, R., Pape, T. (eds.) ECOOP 2020, vol. 166, pp. 7:1–7:29. Dagstuhl, Germany (2020). https://doi.org/10.4230/LIPIcs.ECOOP.2020.7
Lindholm, T., Yellin, F., Bracha, G., Buckley, A.: The Java virtual machine specification, February 2013. https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html. Chapter 4. The class File Format
Lochbihler, A.: Mechanising a type-safe model of multithreaded Java with a verified compiler. J. Autom. Reason. 63(1), 243–332 (2018)
Nipkow, T., Paulson, L.C., Wenzel, M.: Isabelle/HOL: A Proof Assistant for Higher-Order Logic. LNCS, vol. 2283. Springer, Heidelberg (2002). https://doi.org/10.1007/3-540-45949-9
Oracle: GraalVM: Run programs faster anywhere (2020). https://github.com/oracle/graal
Zhao, J., Nagarakatte, S., Martin, M.M., Zdancewic, S.: Formalizing the LLVM intermediate representation for verified program transformations. In: POPL 2012, pp. 427–440. ACM, New York (2012). https://doi.org/10.1145/2103656.2103709
Acknowledgements
Mark Utting’s position and Brae Webb’s scholarship are both funded in part by a gift from Oracle Labs. Thanks especially to Cristina Cifuentes, Paddy Krishnan and Andrew Craik from Oracle Labs Brisbane for their helpful feedback, and to the Oracle GraalVM compiler team for answering questions. Thanks to Chris Seaton for helping us extend the SeaFoam IR visualization tool to output the graph in Isabelle syntax. Thanks also to Kristian Thomassen for his work on the semantics of \(\phi \)-nodes and Sadra Bayat Tork who investigated IR graph invariants in the GraalVM compiler.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2021 Springer Nature Switzerland AG
About this paper
Cite this paper
Webb, B.J., Utting, M., Hayes, I.J. (2021). A Formal Semantics of the GraalVM Intermediate Representation. In: Hou, Z., Ganesh, V. (eds) Automated Technology for Verification and Analysis. ATVA 2021. Lecture Notes in Computer Science(), vol 12971. Springer, Cham. https://doi.org/10.1007/978-3-030-88885-5_8
Download citation
DOI: https://doi.org/10.1007/978-3-030-88885-5_8
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-88884-8
Online ISBN: 978-3-030-88885-5
eBook Packages: Computer ScienceComputer Science (R0)