← Wave Programming Language Blog
2026-02-15

Patch #291: Modernizing the Core: Upgrading to LLVM 21 and the Era of Opaque Pointers

As the compiler landscape evolves, staying current with foundational technologies is essential for performance and reliability. Our latest patch performs a major infrastructure upgrade, transitioning the Wave backend to LLVM 21 and adopting the moder...

Patch #291: Modernizing the Core: Upgrading to LLVM 21 and the Era of Opaque Pointers cover image

Patch #291: Modernizing the Core: Upgrading to LLVM 21 and the Era of Opaque Pointers

As the compiler landscape evolves, staying current with foundational technologies is essential for performance and reliability. Our latest patch performs a major infrastructure upgrade, transitioning the Wave backend to LLVM 21 and adopting the modern Opaque Pointer standard. We’ve also introduced a new graphical tool to make managing the compiler build process easier than ever.

1. The Opaque Pointer Revolution

The most significant technical shift in this update is the transition to Opaque Pointers. In older versions of LLVM, pointers carried type information (e.g., i32* or struct.User*). Modern LLVM has moved to a single, unified ptr type.

  • Explicit Type Tracking: Since pointers no longer "know" what they point to, our codegen now explicitly tracks types during every memory operation. We’ve updated all build_load, build_store, and build_gep calls to provide explicit LLVM types.
  • Refactored Address Logic: Modules like address.rs and lvalue.rs have been overhauled to infer Wave-level types during IR generation, ensuring that the correct instructions are emitted even without typed pointers.

This change not only aligns Wave with the latest LLVM standards but also results in a cleaner, more robust internal architecture.

2. Next-Gen Optimization with PassBuilder

We have officially retired the legacy PassManagerBuilder in favor of the modern LLVM PassBuilder.

This allows Wave to leverage the newest optimization pipelines provided by LLVM (such as default<O3>). The result is a more sophisticated optimization process that better understands the nuances of modern hardware, leading to more efficient machine code generation.

3. Visualizing the Toolchain: GUI Build Manager

To lower the barrier for building and installing the Wave toolchain, we’ve added a GUI Build Manager to our x.py script.

  • Tkinter-based Interface: You can now manage targets, optimization levels, and installations through a simple visual window.
  • Cross-Compilation Made Easy: We’ve significantly improved support for cross-compiling for Windows (x86_64-pc-windows-gnu) from Linux hosts using MinGW LLVM prefixes, all configurable via the new GUI or CLI.

4. Smarter Frontend and Bug Fixes

The compiler frontend hasn't been forgotten. We’ve performed a deep refactoring and fixed critical C-interoperability bugs:

  • Modular Lexer: Following our "separation of concerns" philosophy, the Lexer has been split into dedicated modules (core, cursor, trivia, literals, ident, and scan), making the code much easier to navigate and maintain.
  • C Varargs Type Promotion: We fixed a bug in printf handling where small types weren't being correctly promoted according to C standards. Small integers are now promoted to i32 and floats to double, ensuring perfect compatibility with the standard C library.
  • C-String Tracking: Since LLVM ptr is now ambiguous, we’ve implemented manual tracking for C-string status to ensure our I/O logic remains accurate.

Why This Matters

By moving to LLVM 21 and Opaque Pointers, we have "future-proofed" Wave. These changes ensure that we can continue to adopt new LLVM features as they are released without massive rewrites. Combined with the new GUI manager and cross-compilation improvements, Wave is becoming a more powerful and accessible tool for developers on all platforms.

The foundation is now ready for the next wave of language features!

Link