Skip to content

Add LLVM 23 compatibility - #7491

Open
kuvaus wants to merge 3 commits into
odin-lang:masterfrom
kuvaus:LLVM-23
Open

Add LLVM 23 compatibility#7491
kuvaus wants to merge 3 commits into
odin-lang:masterfrom
kuvaus:LLVM-23

Conversation

@kuvaus

@kuvaus kuvaus commented Sep 1, 2026

Copy link
Copy Markdown

Hi,

LLVM 23 was recently released and this PR adds Odin compatibility with the LLVM 23 backend.

In LLVM 23, branching LLVMBr was divided into two types: LLVMUncondBr and LLVMCondBr, depending on whether the branching was unconditional or conditional.

This PR checks if LLVM_VERSION_MAJOR is 23 or newer and handles both types. The #else clause also preserves backward compatibility with older LLVM versions.

Changes:

In src/llvm_backend_general.cpp, line 554:

#if LLVM_VERSION_MAJOR >= 23
        case LLVMUncondBr:
        case LLVMCondBr:
#else
        case LLVMBr:
#endif

In src/llvm_backend_stmt.cpp, line 2807:

#if LLVM_VERSION_MAJOR >= 23
        auto opcode = LLVMGetInstructionOpcode(if_instr);
        GB_ASSERT(opcode == LLVMUncondBr || opcode == LLVMCondBr);
#else
        GB_ASSERT(LLVMGetInstructionOpcode(if_instr) == LLVMBr);
#endif

LLVM 23 compatibility was also added to build_odin.sh:

SUPPORTED_LLVM_VERSIONS="23 22 21 20 19 18 17"
SUGGESTED_LLVM_VERSION="23"

Though maybe we could stay in 22 for now.

Testing:

After the small changes above, I successfully built the compiler on Intel macOS using Homebrew's LLVM 23.1.0. I tested using small odin program with if clauses (CondBr) and one with for, while loops and breaks (UncondBr). Both test programs worked as they should. I did not do a full test on everything but maybe this PR could serve at least as a starting point for LLVM 23 compatibility.

@laytan

laytan commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Please look at previous update prs to see what else you need to add. Hint: microarch and optimization updates.

@kuvaus

kuvaus commented Sep 1, 2026

Copy link
Copy Markdown
Author

Oh, it became quite a bit more involved than just a couple of lines.
I'll take a look, but I may be out of my depth here. And thanks a lot for pointing the way: I just saw the commit and your comments on the LLVM 22 compatibility pr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants