X-Lang logo
GitHub
PhD Thesis Overview

Optimising LLVM IR via Semantic & Synergistic Analysis

A deep dive into the formal methodologies, architectural design, and empirical validation of the X-Lang Symbiotic Compilation Model.

01. The Bottleneck

The End of the Free Lunch & The Semantic Gap

The end of Dennard scaling has irrevocably shifted the primary responsibility for performance from hardware advancement to software engineering. To harness modern multi-core, deep-pipeline processors, software must expose explicit concurrency and data locality.

However, the prevailing compilation model acts as a form of lossy compression. During the lowering of code to Intermediate Representation (IR), crucial high-level semantics—like data memory layout intent (SoA vs AoS), pointer aliasing properties, and algorithmic parallelism—are systematically erased.

Deprived of this context, state-of-the-art optimisers are forced into a pessimistic posture. They must rely on conservative, heuristic-driven assumptions, creating an artificial performance ceiling for high-level languages.

The Cost of Semantic Loss

  • Aliasing Ambiguity: Without noalias guarantees, the compiler must assume pointers intersect, blocking instruction reordering and value forwarding.
  • Vectorisation Failure: Default AoS layouts result in strided memory access, completely nullifying the capabilities of SIMD execution units.
  • Sequential Lock-in: Without explicit data-independence proofs, conservative dependency analysis forbids safe multi-core distribution.

02. The Architecture

The Symbiotic Compilation Model

This thesis posits that redefining the compiler-programmer relationship from passive inference to active collaboration bridges the semantic gap. We propose the Symbiotic Compilation Model, built upon three interconnected pillars that treat programmer intent as a first-class, verifiable resource via custom !xlang.hints LLVM metadata.

The Engine

The Semantic Optimisation Suite. A set of 10 custom LLVM passes that translate preserved metadata into aggressive transformations, acting as a tactical execution engine for the programmer's strategy.

The Brain

The Synergistic Cost Model. Quantitatively analyzes the interaction between semantic contracts (e.g., parallel + memoise) to detect non-obvious performance hazards and negative synergistic interference.

The Voice

The Bidirectional Feedback Engine. Translates the Brain's abstract numerical findings into structured, human-readable, and actionable advice, turning compilation into an active developer dialogue.

03. Correctness

Hybrid "Pincer" Formal Verification

End-to-End Soundness

1
Language Semantics (Lean 4)

Mathematically proves that the X-Lang frontend compiler checks correctly imply the abstract mathematical property (e.g., unique implies true non-aliasing).

2
IR Translation (Alive2)

Uses the Lean certificate as a precondition to prove the subsequent LLVM IR modification is a strictly semantics-preserving refinement.

Aggressive optimisation logic must be mathematically verified to prevent silent data corruption. Because full end-to-end compiler verification (e.g., CompCert) severely restricts the aggressiveness of optimisations, we adopted a pragmatic middle ground.

The Hybrid "Pincer" strategy divides the problem. We use Lean 4 to prove the language semantics are sound, generating a mathematical certificate. We then use Alive2 to validate that the specific LLVM IR translation (e.g., adding noalias) is correct given that precondition. This guarantees the soundness of our semantic-driven transformations while retaining LLVM's industrial performance capabilities.

04. Empirical Validation

Macro-Benchmark Performance Analysis

1.70x
Geometric Mean Speedup

Achieved over the state-of-the-art Clang -O3 baseline across all benchmarks.

The framework was rigorously evaluated against a suite of macro-benchmarks ported from the PolyBench and SPEC CPU suites, executed on an Intel Core Ultra 7 (Meteor Lake) architecture.

A strict three-way comparison was utilized. The semantics-oblivious X-Lang compiler (xlangc -O3) performed comparably to the Clang baseline (clang -O3), confirming the core language offers no unfair inherent advantage.

However, enabling the custom semantic passes (-fsemantic-opts) yielded a 1.70x geometric mean speedup. VTune microarchitectural profiling confirmed these gains resulted directly from unlocked auto-vectorization, eliminated cache misses, and successful fork-join parallelization.

05. Broader Impact

Language-Agnostic Extensibility

The central thesis is not that "X-Lang is fast," but that explicit semantic contracts preserved as LLVM metadata are the key to unlocking hardware performance.

To prove this framework is language-agnostic, two prototypes were developed for mainstream languages. By utilizing the exact same custom LLVM metadata layer (!xlang.hints) and the same backend C++ semantic passes, we successfully ported the symbiotic optimisations to both Rust and C++.

Rust Procedural Macros

Implemented a #[soa] macro that triggers a post-compilation LLVM IR processor, invoking our shared LayoutPass to achieve a 2.12x speedup on particle updates.

C++ Clang Plugin

Developed a plugin utilizing [[clang::annotate("xlang_layout_soa")]] to bridge standard C++ code into the symbiotic LLVM backend, yielding a 1.90x speedup on the FDTD-2D kernel.