Skip to content

Conversation

FrancoGiachetta
Copy link
Contributor

@FrancoGiachetta FrancoGiachetta commented Sep 4, 2025

Bump LLVM

Closes #1378

This PR bumps LLVM to LLVM 20. To do this, the following crates updated:

  • melior -> 0.23.0
  • mlir-sys -> 0.5.0
  • llvm-sys -> 201.0.1

Many of this changes are due to some refactors in melior. It seems to have split some block and region operation into the traits: BlockLike, RegionLike, AttributLike and OperationLike.

LLVM 20 introduces a breaking change. Operations which take more than one group of variadic operands then the user to specify the amount of operands (for each group) it is receiving through the attribute operandSegmentSizes. Due to this, our llvm.call operations started to fail. You may want to check its TableGen definition here.
To avoid having to specify in each of these operations this new attribute by hand, I created a new function llvm_call inside utils/operation_ext.rs. It wraps the OperationBuilder and calculates the operandSegmentSizes based on the arguments length.

Lastly, the firm of the function mlirLLVMDISubprogramAttrGet changed a little:

pub fn mlirLLVMDISubprogramAttrGet(
        ctx: MlirContext,
        recId: MlirAttribute,
        isRecSelf: bool,
        id: MlirAttribute,
        compileUnit: MlirAttribute,
        scope: MlirAttribute,
        name: MlirAttribute,
        linkageName: MlirAttribute,
        file: MlirAttribute,
        line: ::std::os::raw::c_uint,
        scopeLine: ::std::os::raw::c_uint,
        subprogramFlags: u64,
        type_: MlirAttribute,
        nRetainedNodes: isize,
        retainedNodes: *const MlirAttribute,
        nAnnotations: isize,
        annotations: *const MlirAttribute,
    ) -> MlirAttribute;

There were added 6 new parameters:

recId: MlirAttribute,
isRecSelf: bool,
...
nRetainedNodes: isize,
retainedNodes: *const MlirAttribute,
nAnnotations: isize,
annotations: *const MlirAttribute,

The first two are for specifying that the DISubprogramAttr supports recursive reference to itself. The last four are to specify metadata for the subprogram.

PR for sequencer: lambdaclass/sequencer#76
PR for starknet-replay: lambdaclass/starknet-replay#189

PD: the benches comparison workflow will fail since main still uses llvm 19.

Introduces Breaking Changes?

Yes

These PRs should be merged after this one right away, in that order.

Checklist

  • Linked to Github Issue.
  • Unit tests added.
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

Copy link

github-actions bot commented Sep 5, 2025

✅ Code is now correctly formatted.

@FrancoGiachetta FrancoGiachetta changed the title Bump llvm 20 Bump LLVM Sep 8, 2025
Copy link

github-actions bot commented Sep 8, 2025

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 10.336 ± 0.058 10.265 10.450 4.27 ± 0.05
cairo-native (embedded AOT) 2.418 ± 0.027 2.386 2.458 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 2.481 ± 0.015 2.467 2.508 1.03 ± 0.01

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 512.5 ± 6.5 505.1 525.6 1.00
cairo-native (embedded AOT) 2109.5 ± 17.0 2093.9 2145.6 4.12 ± 0.06
cairo-native (embedded JIT using LLVM's ORC Engine) 2208.5 ± 20.7 2197.6 2266.1 4.31 ± 0.07

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.615 ± 0.033 4.580 4.681 1.82 ± 0.02
cairo-native (embedded AOT) 2.530 ± 0.024 2.497 2.575 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 2.560 ± 0.010 2.542 2.575 1.01 ± 0.01

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.527 ± 0.086 4.465 4.753 2.19 ± 0.04
cairo-native (embedded AOT) 2.069 ± 0.015 2.058 2.108 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 2.113 ± 0.011 2.090 2.127 1.02 ± 0.01

Benchmark for program linear_search

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 558.0 ± 7.9 550.5 575.3 1.00
cairo-native (embedded AOT) 2154.9 ± 40.7 2111.9 2243.2 3.86 ± 0.09
cairo-native (embedded JIT using LLVM's ORC Engine) 2270.4 ± 25.8 2247.3 2337.5 4.07 ± 0.07

Benchmark for program logistic_map

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 369.9 ± 6.3 363.8 382.7 1.00
cairo-native (embedded AOT) 2218.2 ± 7.9 2205.9 2230.1 6.00 ± 0.10
cairo-native (embedded JIT using LLVM's ORC Engine) 2402.1 ± 24.3 2371.0 2446.9 6.49 ± 0.13

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.

Update LLVM 20

1 participant