Extending the C/C++ Memory Model with Inline Assembly

Paulo Emílio De Vilhena, Ori Lahav, Viktor Vafeiadis, Azalea Raad

Research output: Contribution to journalArticlepeer-review

Abstract

Programs written in C/C++ often include inline assembly: a snippet of architecture-specific assembly code used to access low-level functionalities that are impossible or expensive to simulate in the source language. Although inline assembly is widely used, its semantics has not yet been formally studied. In this paper, we overcome this deficiency by investigating the effect of inline assembly on the consistency semantics of C/C++ programs. We propose the first memory model of the C++ Programming Language with support for inline assembly for Intel's x86 including non-temporal stores and store fences. We argue that previous provably correct compiler optimizations and correct compiler mappings should remain correct under such an extended model and we prove that this requirement is met by our proposed model.

Original languageEnglish
Article number309
JournalProceedings of the ACM on Programming Languages
Volume8
Issue numberOOPSLA2
DOIs
StatePublished - 8 Oct 2024

Keywords

  • Concurrency
  • Semantics of Programming Languages
  • Weak Memory Models

All Science Journal Classification (ASJC) codes

  • Software
  • Safety, Risk, Reliability and Quality

Cite this