scispace - formally typeset
Open AccessProceedings ArticleDOI

Common Compiler Optimisations are Invalid in the C11 Memory Model and what we can do about it

TLDR
It is shown that the weak memory model introduced by the 2011 C and C++ standards does not permit many common source-to-source program transformations that modern compilers perform and that are deemed to be correct.
Abstract
We show that the weak memory model introduced by the 2011 C and C++ standards does not permit many common source-to-source program transformations (such as expression linearisation and "roach motel" reorderings) that modern compilers perform and that are deemed to be correct. As such it cannot be used to define the semantics of intermediate languages of compilers, as, for instance, LLVM aimed to. We consider a number of possible local fixes, some strengthening and some weakening the model. We evaluate the proposed fixes by determining which program transformations are valid with respect to each of the patched models. We provide formal Coq proofs of their correctness or counterexamples as appropriate.

read more

Content maybe subject to copyright    Report

Citations
More filters
Proceedings ArticleDOI

Repairing sequential consistency in C/C++11

TL;DR: This paper proposes a model, called RC11 (for Repaired C11), with a better semantics for SC accesses that restores the soundness of the compilation schemes to Power, maintains the DRF-SC guarantee, and provides stronger, more useful, guarantees to SC fences.
Proceedings ArticleDOI

A promising semantics for relaxed-memory concurrency

TL;DR: The first relaxed memory model that accounts for a broad spectrum of features from the C++11 concurrency model, is implementable, and defines the semantics of racy programs without relying on undefined behaviors, which is a prerequisite for applicability to type-safe languages like Java is proposed.
Proceedings ArticleDOI

Provably correct peephole optimizations with alive

TL;DR: Alive is presented, a domain-specific language for writing optimizations and for automatically either proving them correct or else generating counterexamples, and can be automatically translated into C++ code that is suitable for inclusion in an LLVM optimization pass.
Book ChapterDOI

The Problem of Programming Language Concurrency Semantics

TL;DR: This paper argues that the Java Memory Model has been shown to be unsound with respect to standard compiler optimisations, while the C/C++11 model is too weak, admitting undesirable thin-air executions.
Proceedings ArticleDOI

Automatically comparing memory consistency models

TL;DR: This work shows how to solve analogous constraints over program executions, and then construct programs that satisfy the original constraints, and develops and validate a new MCM for NVIDIA GPUs that supports a natural mapping from OpenCL.
References
More filters
Journal ArticleDOI

Formal verification of a realistic compiler

TL;DR: This paper reports on the development and formal verification of CompCert, a compiler from Clight (a large subset of the C programming language) to PowerPC assembly code, using the Coq proof assistant both for programming the compiler and for proving its correctness.
Proceedings ArticleDOI

The Java memory model

TL;DR: The Java 5.0 memory model as discussed by the authors provides a simple interface for correctly synchronized programs and guarantees sequential consistency to data-race-free programs by requiring that the behavior of incorrectly synchronized programs be bounded by a well defined notion of causality.
Book

Efficient and Correct Execution of Parallel Programs That Share Memory

TL;DR: The analysis finds a minimal set of delays that enforces sequential consistency in the execution of parallel programs on shared-memory multiple-instruction-stream, multiple-data-stream (MIMD) computers and uses a conflict graph similar to that used to schedule transactions in distributed databases to do without locks.
Journal ArticleDOI

Mathematizing C++ concurrency

TL;DR: This work establishes a mathematical (yet readable) semantics for C++ concurrency, which will aid discussion of any further changes, provide a correctness condition for compilers, and give a much-needed basis for analysis and verification of concurrent C and C++ programs.
Journal ArticleDOI

CompCertTSO: A Verified Compiler for Relaxed-Memory Concurrency

TL;DR: The semantic design and verified compilation of a C-like programming language for concurrent shared-memory computation on x86 multiprocessors is considered, and some verified fence-elimination optimizations, integrated into CompCertTSO are described.
Related Papers (5)