Skip to content

LLVM 20 update #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 108 commits into
base: solana-rustc/20.1-2025-02-13
Choose a base branch
from

Conversation

LucasSte
Copy link
Collaborator

No description provided.

nvjle and others added 30 commits August 12, 2025 15:54
- New SBF back-end subdirectory and corresponding test directories.
- Corresponding changes in ADT, Support, MC, Object, BinaryFormat for
  new SBF architecture and EM_SBF ELF object.
- Corresponding changes in clang to instantiate SBF for Triple::sbf
  rather than the old BPF back-end, etc.
- Corresponding changes in lld to add SBF arch recognition, etc.
- Corresponding changes in llvm-readelf to and opt.
…e syntax. (anza-xyz#54)

- Update the syntax of every instruction in SBFInstrInfo.td (currently
  using the asm variants feature to temporarily support both).
- Update AsmParser for the new syntax (add new operand, memory,
  instruction, and directive parse routines).
- Add error checking for unresolved 16-bit branch relocations and
  emit error message for graceful exit (the old BPF back-end crashes)
  and corresponding lit unit test.
- Add new lit unit tests in MC/SBF and MC/Disassembler/SBF to cover
  disassembly, object emission, and parsing of every single instruction.
  This is more extensive coverage than existed previously.
- Remaster all CodeGen/SBF unit tests accordingly.
- A minor TableGen patch was needed to support asm strings containing
  '|' within variant strings ('|' happens to be the variant separator).

The patch is a bit more complex than it otherwise might be in that we
currently support both syntaxes to ease the verification (e.g., being
able to see and compare each instruction and object code side-by-side
within each unit test). After some 'soak time' for the new functionality,
I intend to remove the old syntax altogether and otherwise clean-up. We'll
also remove the TableGen patch at that time.
BTF/CO-RE has been disabled for Solana since:
anza-xyz#37

This patch updates related code (and all applicable unit tests) from roughly
a year of bitrot. This is in preparation for its possible use in the Move
project.

Additionally, a few other 14.0.2022-03-02 -> 15.0-2022-08-09 BPF patches
were reflected in the SBF back-end (e.g., bugfixes).
EM_SBF files are only accepted by new ELF parser of the RBPF.
Because of a bug in BPF backend ABS64 relocations are incorrectly
generated as 64_64 relocations in BPF object files. This temporary
works around this for relocations in .debug section to generate debug
information addresses correctly.
These tests currently fail on some Macs for some versions of Python,
causing our CI to fail.

See, e.g., llvm#62403 and references
therein.
This PR replaces sub r11, imm by add r11, -imm and is the equivalent of solana-labs/rbpf#488 for the SBF target in LLVM.

This is the first task in solana-labs/solana#34250
Patch anza-xyz#54 originally
reworked the SBF textual assembly syntax to match the rbpf-style syntax.

In order to allow some soak-time, the above patch temporarily supported
both the old and new syntax (selectable on the command line or via bespoke
assembler directives). A little over a year has passed since then,
and all is well with the new syntax, testing, and so forth.

The current patch now removes all existing remnants of the old syntax--
including some of the target-independent changes made in the original
patch to support both (e.g., a minor TableGen change for variants, some
additional command line selector flags, etc).

All related unit tests have been updated accordingly.
Following the alterations made in solana-labs/rbpf#489, this PR removes the neg instructions and changes the semantics of sub when one of the operands is an immediate.

sub r1, 2 now means r1 = 2 - r1, instead of r1 = r1 - 2.
neg r1 is represented as r1 = 0  - r1.

This is the second task in solana-labs/solana#34250.
This PR addressed two more items in solana-labs/solana#34250.
It removes the little endian byte swap instructions (solana-labs/rbpf#493)
and the input buffers related instructions (solana-labs/rbpf#251).
* Remove lddw instruction

* Add suggestions
* Fix incorrect obj-dump

* Read flag from elf
* Change encoding of callx instruction
LucasSte and others added 21 commits August 12, 2025 16:54
* [SOL] lldb: pretty print instructions

* [SOL] lldb: skip ranges with DW_AT_low_pc equal to zero

* [SOL] lldb: Add solana-lldb wrapper

This adds a wrapper around the LLDB executable that resides in the same directory. Once we start to distribute LLDB in sbf-tools, the wrapper + scripts can be put into the same directory as the LLDB executable. Invoking ./solana-lldb will pre-load helper functions to print rust as well as solana types (e.g. pubkeys in base58 or auto deref of accounts) and then start the LLDB executable.

* [SOL] Revamp LLDB for SBF

---------

Co-authored-by: wj <[email protected]>
)

The compiler sometimes reports:

    Error: A function call in method [...] overwrites values in the
    frame. Please, decrease stack usage or remove parameters from the
    call.The function call may cause undefined behavior during execution.

Add a missing space between "call." and "The function".

Fixes: anza-xyz#146
* [SOL] Always add return for SBPFv3

* Add test and simplify condition
* Implement analysis functions

* Add test and fix others
* Do not add a return after a JA

* Update runner to windows 2022

* Do not iterate over all blocks
@LucasSte LucasSte force-pushed the solana-rustc/20.1-2025-02-13 branch 2 times, most recently from f337cbb to 7724826 Compare August 15, 2025 15:32
@LucasSte LucasSte force-pushed the solana-rustc/20.1-2025-02-13 branch 2 times, most recently from 14c18a0 to f9f17ad Compare August 15, 2025 18:03
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