Skip to content

update from upstream#45

Merged
xushiwei merged 11 commits into
xgo-dev:xgofrom
zhouguangyuan0718:xgo
Jul 16, 2026
Merged

update from upstream#45
xushiwei merged 11 commits into
xgo-dev:xgofrom
zhouguangyuan0718:xgo

Conversation

@zhouguangyuan0718

Copy link
Copy Markdown

No description provided.

aykevl and others added 11 commits September 16, 2025 12:14
This matches TinyGo, where they are merged. It should make maintenance a
little bit easier, and also makes it easier to add new OSes (like
FreeBSD) without having to create a whole new set of files.
add ExecutionEngine.GetFunctionAddress()
We still haven't updated TinyGo, so this change is needed so we can use
tinygo-org#73 in TinyGo.
* Add LLVM 22 build support

Written entirely by Claude (Anthropic's Claude Code), at the request of
and under the direction of dgryski, as part of a broader effort to get
TinyGo building against upcoming LLVM releases.

Adds the llvm22 build-tag config file (mirroring the existing llvm21
one) and a CI matrix entry for it. Also adds a regression test
confirming that LLVM 21+'s 'captures' parameter attribute (which
replaced the boolean 'nocapture' enum attribute) round-trips correctly
through the existing generic enum-attribute API, with value 0
corresponding to captures(none) -- no binding/C++ shim changes were
needed for this, since 'captures' is an IntAttr using the same wire
format as e.g. 'align' or 'dereferenceable'.

Verified by running the full test suite against real LLVM 22.1.8
headers and libraries (via Homebrew).

* limit captures_test to llvm 21 and above.

* Fix switch-instruction case-value access for LLVM 22

Written entirely by Claude (Anthropic's Claude Code), at the request of
and under the direction of dgryski, on the dgryski/llvm23 branch (LLVM
22 support, in preparation for the eventual LLVM 23 release).

LLVM 22 stopped exposing SwitchInst case values as regular instruction
operands -- only the condition and destination-block operands remain
as operands now. Case values must be read via the new
LLVMGetSwitchCaseValue C API added in the same release. This was
discovered while chasing a real-world regression in TinyGo's
interp package (see the paired tinygo commit on the same branch),
which manually walked switch operands assuming the old layout;
verified independently here first via a minimal standalone .ll
repro against real LLVM 20/21/22 headers and libraries, isolating
the exact version cutoff (21 -> 22) before touching any tinygo code.

Adds:
- Value.SuccessorsCount()/Value.Successor(i) in ir.go, using the
  stable, version-independent LLVMGetNumSuccessors/LLVMGetSuccessor
  API to enumerate a switch's destination blocks (successor 0 is
  always the default destination; successors 1..N-1 are the cases).
- Value.GetSwitchCaseValue(i), version-gated: switch_llvm22.go uses
  the new LLVMGetSwitchCaseValue API, switch_pre22.go falls back to
  the old operand-based read for LLVM <22.
- switch_test.go, a regression test verifying case values and
  destinations round-trip correctly; passes against real LLVM
  20/21/22.
# Conflicts:
#	.github/workflows/go.yml
#	llvm_config_llvm19.go
#	llvm_config_llvm20.go
@xushiwei
xushiwei merged commit caa39a9 into xgo-dev:xgo Jul 16, 2026
21 checks passed
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.

4 participants