K-LLVM: A relatively complete semantics of LLVM IR

Research output: Chapter in Book/Report/Conference proceedingConference contribution

Abstract

LLVM [21] is designed for the compile-time, link-time and run-time optimization of programs written in various programming languages. The language supported by LLVM targeted by modern compilers is LLVM IR [29]. In this paper we define K-LLVM, a reference semantics for LLVM IR. To the best of our knowledge, K-LLVM is the most complete formal LLVM IR semantics to date, including all LLVM IR instructions, intrinsic functions in the LLVM documentation and Standard-C library functions that are necessary to execute many LLVM IR programs. Additionally, K-LLVM formulates an abstract machine that executes all LLVM IR instructions. The machine allows to describe our formal semantics in terms of simulating a conceptual virtual machine that runs LLVM IR programs, including non-deterministic programs. Even though the K-LLVM memory model in this paper is assumed to be a sequentially consistent memory model and does not include all LLVM concurrency memory behaviors, the design of K-LLVM’s data layout allows the K-LLVM abstract machine to execute some LLVM IR programs that previous semantics did not cover, such as the full range of LLVM IR behaviors for the interaction among LLVM IR casting, pointer arithmetic, memory operations and some memory flags (e.g. readonly) of function headers. Additionally, the memory model is modularized in a manner that supports investigating other memory models. To validate K-LLVM, we have implemented it in K [41], which generated an interpreter for LLVM IR. Using this, we ran tests including 1,385 unit test programs and around 3,000 concrete LLVM IR programs, and K-LLVM passed all of them.

Original languageEnglish (US)
Title of host publication34th European Conference on Object-Oriented Programming, ECOOP 2020
EditorsRobert Hirschfeld, Tobias Pape
PublisherSchloss Dagstuhl- Leibniz-Zentrum fur Informatik GmbH, Dagstuhl Publishing
ISBN (Electronic)9783959771542
DOIs
StatePublished - Nov 1 2020
Event34th European Conference on Object-Oriented Programming, ECOOP 2020 - Virtual, Berlin, Germany
Duration: Nov 15 2020Nov 17 2020

Publication series

NameLeibniz International Proceedings in Informatics, LIPIcs
Volume166
ISSN (Print)1868-8969

Conference

Conference34th European Conference on Object-Oriented Programming, ECOOP 2020
Country/TerritoryGermany
CityVirtual, Berlin
Period11/15/2011/17/20

Keywords

  • Abstract machine
  • Formal semantics
  • K framework
  • LLVM
  • Memory model

ASJC Scopus subject areas

  • Software

Fingerprint

Dive into the research topics of 'K-LLVM: A relatively complete semantics of LLVM IR'. Together they form a unique fingerprint.

Cite this