🤖 AI Summary
Compiler optimizations designed for sequential consistency (SC) may violate correctness when ported to weaker memory models such as total store ordering (TSO), posing safety risks in cross-model optimization reuse.
Method: We propose the first syntactically constrained, globally applicable migratability criterion for SC-to-TSO optimization migration, formally linking migratability to triangular data races—identified as the fundamental obstacle to safe SC→TSO migration. We extend the criterion to the strong release-acquire (SRA) model and validate its generality. Our approach combines formal verification, memory model semantics analysis, and a refined classification of data races.
Results: We rigorously characterize the safety boundary for SC→TSO optimization migration, establishing a verifiable and generalizable theoretical foundation. The criterion enables sound, automated assessment of optimization migratability across memory models, providing both theoretical guarantees and practical guidelines for compiler development.
📝 Abstract
It is well recognized that the safety of compiler optimizations is at risk in a concurrent context. Existing approaches primarily rely on context-free thread-local guarantees, and prohibit optimizations that introduce a data-race. However, compilers utilize global context-specific information, exposing safe optimizations that may violate such guarantees as well as introduce a race. Such optimizations need to individually be proven safe for each language model. An alternate approach to this would be proving them safe for an intuitive model (like interleaving semantics), and then determine their portability across other concurrent models. In this paper, we address this problem of porting across models of concurrency. We first identify a global guarantee on optimizations portable from Sequential Consistency (SC) to Total Store Order (TSO). Our guarantee is in the form of constraints specifying the syntactic changes an optimization must not incur. We then show these constraints correlate to prohibiting the introduction of triangular races, a subset of data-race relevant to TSO. We conclude by showing how such race inducing optimizations relate to porting across Strong Release Acquire (SRA), a known causally consistent memory model.