Repository navigation
[mlir][Sol][Yul] Canonicalize the Yul module before its lowering #910
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Regression Tests | |
| on: | |
| pull_request: | |
| # The shared build-llvm action only saves ccache on non-pull_request events: | |
| # push-to-main runs warm the cache that PR runs restore, and double as | |
| # post-merge regression signal. | |
| push: | |
| branches: [main] | |
| schedule: | |
| # Keepalive: GitHub evicts caches untouched for 7 days; a weekly warmup | |
| # covers quiet weeks so PR builds don't go cold. | |
| - cron: '0 4 * * 1' | |
| workflow_dispatch: | |
| inputs: | |
| commits-to-test: | |
| description: "Number of commits to test" | |
| required: true | |
| default: '1' | |
| # For more information about the supported sanitizers in LLVM, see `LLVM_USE_SANITIZER` option in: | |
| # https://www.llvm.org/docs/CMake.html | |
| llvm-sanitizer: | |
| required: false | |
| default: 'Address' | |
| type: string | |
| description: 'A sanitizer to build LLVM with. Possible values are Address, Memory, MemoryWithOrigins, Undefined, Thread, DataFlow, and Address;Undefined' | |
| enable-valgrind: | |
| required: false | |
| default: 'false' | |
| type: string | |
| description: 'Run LLVM regression tests under valgrind.' | |
| defaults: | |
| run: | |
| shell: bash | |
| permissions: | |
| contents: read | |
| packages: read # pull the private ghcr.io/nomicfoundation/solx-ci-runner image | |
| concurrency: | |
| group: ${{ github.repository_id }}-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| # Never cancel main-branch runs: their ccache save at the end of the job is | |
| # what keeps PR builds warm. | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| target-machine: | |
| runs-on: ubuntu-26.04 | |
| outputs: | |
| default: ${{ steps.default.outputs.machine }} | |
| steps: | |
| - name: Check for default target | |
| id: default | |
| shell: bash -ex {0} | |
| # steps.*.outputs.* is this job's own step outputs (extensibility hook), | |
| # not external input. | |
| run: | # zizmor: ignore[template-injection] | |
| if [[ "${{ join(steps.*.outputs.*) }}" == "" ]]; then | |
| echo "machine=default" | tee -a "${GITHUB_OUTPUT}" | |
| fi | |
| prepare-test-matrix: | |
| needs: target-machine | |
| runs-on: ubuntu-26.04 | |
| outputs: | |
| matrix-formatting: ${{ steps.prepare.outputs.matrix-formatting }} | |
| matrix-tests: ${{ steps.prepare.outputs.matrix-tests }} | |
| fetch_depth: ${{ steps.extract_branch.outputs.fetch_depth }} | |
| steps: | |
| # On push/schedule events there is neither a PR commit count nor a | |
| # dispatch input; default to testing the single HEAD commit. | |
| - name: Extract branch name | |
| id: extract_branch | |
| # commits-to-test is a workflow_dispatch input (attacker-controllable); | |
| # route it and base_ref through env so neither is expanded into the | |
| # shell / arithmetic context. | |
| env: | |
| BASE_REF: ${{ github.base_ref || github.event.repository.default_branch }} | |
| COMMITS: ${{ github.event.pull_request.commits || github.event.inputs.commits-to-test || 1 }} | |
| run: | | |
| echo "head_ref=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" | tee -a "${GITHUB_OUTPUT}" | |
| echo "base_ref=${BASE_REF}" | tee -a "${GITHUB_OUTPUT}" | |
| echo "fetch_depth=$(( COMMITS + 1 ))" | tee -a "${GITHUB_OUTPUT}" | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| ref: ${{ steps.extract_branch.outputs.head_ref }} | |
| fetch-depth: ${{ github.event.pull_request.commits || github.event.inputs.commits-to-test || 1 }} | |
| repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | |
| - name: Prepare commits | |
| id: prepare | |
| shell: bash -ex {0} | |
| env: | |
| TEST_COMMITS_LIMIT: 25 # Limit the number of commits to test | |
| COMMITS: ${{ github.event.pull_request.commits || github.event.inputs.commits-to-test || 1 }} | |
| run: | # zizmor: ignore[template-injection] toJSON(needs.*) is controlled job data, not external input | |
| COMMITS_TO_TEST=$(git log -n "${COMMITS}" --pretty='"%H"' | head -n "${TEST_COMMITS_LIMIT}") | |
| echo "matrix-formatting={ \"commit\": [${COMMITS_TO_TEST//$'\n'/, }] }" | tee -a "${GITHUB_OUTPUT}" | |
| TARGETS=$(echo '${{ toJSON(needs.target-machine.outputs) }}' | jq '.[]') | |
| echo "matrix-tests={ \"commit\": [${COMMITS_TO_TEST//$'\n'/, }], \"target\": [${TARGETS//$'\n'/, }] }" | tee -a "${GITHUB_OUTPUT}" | |
| check-formatting: | |
| if: github.event_name == 'pull_request' | |
| runs-on: ubuntu-26.04 | |
| permissions: | |
| contents: read | |
| packages: read | |
| pull-requests: write # code-format-helper posts review comments on the PR | |
| container: | |
| image: ghcr.io/nomicfoundation/solx-ci-runner@sha256:7cc8aba2983f6feb71f046876611b48e9649e72acdfcdbcad756e2030c3a356a | |
| needs: prepare-test-matrix | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 3 | |
| matrix: ${{ fromJson(needs.prepare-test-matrix.outputs.matrix-formatting) }} | |
| steps: | |
| # Shallow like the regression job: the diff below only needs | |
| # `matrix.commit` and its parent, and a full LLVM-history clone | |
| # (fetch-depth: 0) took ~9 minutes per matrix job. | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| ref: ${{ matrix.commit }} | |
| fetch-depth: ${{ needs.prepare-test-matrix.outputs.fetch_depth }} | |
| repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | |
| - name: Mark everything as safe for Git | |
| run: git config --global --add safe.directory '*' | |
| - name: Define previous commit | |
| id: previous-commit | |
| run: echo "sha=$(git rev-parse -q '${{ matrix.commit }}^' 2>/dev/null || echo '${{ github.event.pull_request.base.sha }}')" >> "$GITHUB_OUTPUT" # zizmor: ignore[template-injection] matrix.commit and base.sha are git SHAs, not external input | |
| - name: Get changed files | |
| id: changed-files | |
| uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 # v47.0.6 | |
| with: | |
| separator: "," | |
| sha: ${{ matrix.commit }} | |
| base_sha: ${{ steps.previous-commit.outputs.sha }} | |
| # Job-local venv: the image's system interpreter is Debian-managed (its | |
| # packages collide with these pins) and ships no pip. GITHUB_PATH makes | |
| # the venv's python3/darker win in the formatter step below. | |
| - name: Install formatting requirements | |
| run: | | |
| python3 -m venv "${RUNNER_TEMP}/venv-format" | |
| "${RUNNER_TEMP}/venv-format/bin/pip" install -r ./llvm/utils/git/requirements_formatting_solx_llvm.txt | |
| echo "${RUNNER_TEMP}/venv-format/bin" >> "${GITHUB_PATH}" | |
| - name: Run code formatter | |
| # start-rev/end-rev are git SHAs, changed-files a controlled comma list, | |
| # PR number an integer — all from prior steps, not shell-injectable. | |
| run: | # zizmor: ignore[template-injection] | |
| set -x | |
| if [ '${{ github.event.pull_request.head.repo.fork }}' = 'true' ]; then | |
| TOKEN_PARAM="" | |
| else | |
| TOKEN_PARAM="--token ${{ secrets.GITHUB_TOKEN }}" | |
| fi | |
| python3 ./llvm/utils/git/code-format-helper-solx-llvm.py ${TOKEN_PARAM} \ | |
| --issue-number ${{ github.event.pull_request.number }} \ | |
| --start-rev ${{ steps.previous-commit.outputs.sha }} \ | |
| --end-rev ${{ matrix.commit }} \ | |
| --changed-files ${{ steps.changed-files.outputs.all_changed_files }} | |
| regression-tests: | |
| runs-on: ubuntu-26.04 | |
| # Backstop: a thrashed VM hangs its job indefinitely — the starved | |
| # runner agent can't even act on cancellation. Sized for a cold | |
| # ccache-less build with MLIR enabled, which approaches the limit. | |
| timeout-minutes: 360 | |
| container: | |
| image: ghcr.io/nomicfoundation/solx-ci-runner@sha256:7cc8aba2983f6feb71f046876611b48e9649e72acdfcdbcad756e2030c3a356a | |
| # Cap container memory below the 16 GB VM (and disallow swap) so a | |
| # memory-hungry test gets OOM-killed inside the container — lit records | |
| # it as a named crash and continues — instead of starving the runner | |
| # agent on the host, which kills the whole job as "lost communication". | |
| options: --memory 13g --memory-swap 13g | |
| # Host tooling bind-mounted so the free-disk-space action can reclaim | |
| # ~24 GB before the LLVM build fills the runner's ~14 GB free budget. | |
| # Keep in sync with solx's test.yaml / cache-warmup.yaml. | |
| volumes: | |
| - /usr/share/dotnet:/mnt/free-disk-space/dotnet | |
| - /usr/local/lib/android:/mnt/free-disk-space/android | |
| - /opt/ghc:/mnt/free-disk-space/ghc | |
| - /usr/local/.ghcup:/mnt/free-disk-space/ghcup | |
| - /opt/hostedtoolcache/CodeQL:/mnt/free-disk-space/codeql | |
| needs: prepare-test-matrix | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 3 | |
| matrix: ${{ fromJson(needs.prepare-test-matrix.outputs.matrix-tests) }} | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| repository: NomicFoundation/solx | |
| ref: 'main' | |
| # Local ref into the solx checkout above (like build-llvm below), so the | |
| # action version always matches the checked-out solx-dev sources. | |
| - name: Free disk space | |
| uses: ./.github/actions/free-disk-space-linux | |
| - name: Clean up LLVM directory | |
| run: rm -rf solx-llvm | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| persist-credentials: false | |
| ref: ${{ matrix.commit }} | |
| path: "solx-llvm" | |
| fetch-depth: ${{ needs.prepare-test-matrix.outputs.fetch_depth }} | |
| repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | |
| - name: Mark everything as safe for Git | |
| run: git config --global --add safe.directory '*' | |
| - name: Define previous commit | |
| if: github.event_name == 'pull_request' | |
| working-directory: solx-llvm | |
| id: previous-commit | |
| run: echo "sha=$(git rev-parse -q '${{ matrix.commit }}^' 2>/dev/null || echo '${{ github.event.pull_request.base.sha }}')" >> "$GITHUB_OUTPUT" # zizmor: ignore[template-injection] matrix.commit and base.sha are git SHAs, not external input | |
| - name: Build LLVM | |
| uses: ./.github/actions/build-llvm | |
| with: | |
| enable-tests: true | |
| enable-assertions: true | |
| # The Sol/Yul dialects are developed in this fork, and solx CI | |
| # builds LLVM with MLIR everywhere — so MLIR is part of every | |
| # regression build, not an opt-in. | |
| enable-mlir: true | |
| # This tree changes every PR, so the whole-artifact cache never hits | |
| # usefully — and a hit would skip the build, leaving no build-final | |
| # directory for the lit and clang-tidy steps below. ccache (inside | |
| # the action) is the only useful cache layer here. | |
| enable-artifact-cache: 'false' | |
| sanitizer: ${{ inputs.llvm-sanitizer }} | |
| enable-valgrind: ${{ inputs.enable-valgrind }} | |
| # The shared action only saves ccache on non-PR events, so PR reruns | |
| # would rebuild cold (~2 h). Save under its restore-keys prefix: | |
| # ccache-action prepends `ccache-` to every restore-key, so the leading | |
| # `ccache-` below is required for the restore to prefix-match this | |
| # entry, and the `-mlir-utils-tests` suffix must track what the action | |
| # derives from the build-llvm inputs above. Placed before the lit step | |
| # (which can still take down the runner) and on `always()` so even a | |
| # failed build banks its partial ccache. Restores pick the newest | |
| # matching entry, so only job 0 saves; more entries per run would be | |
| # pure quota churn. | |
| - name: Save PR-scoped ccache | |
| if: always() && github.event_name == 'pull_request' && strategy.job-index == 0 | |
| continue-on-error: true | |
| uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ runner.temp }}/ccache-llvm | |
| key: ccache-llvm-${{ runner.os }}-${{ runner.arch }}-mlir-utils-tests-end-pr${{ github.run_id }}-${{ github.run_attempt }} | |
| # `verify-llvm` is a special target that runs all the regression tests | |
| # it includes `check-llvm` and special codegen tests | |
| # called via `verify-llvm-codegen-opt` and `verify-llvm-codegen-llc` targets | |
| - name: Running Lit tests | |
| run: | | |
| # Crash tests (`not --crash`, gtest death tests, lit self-tests) pipe | |
| # cores to the HOST's systemd-coredump — outside this container's | |
| # cgroup and memory cap — which OOMed the 16 GB VM. Piped patterns | |
| # ignore RLIMIT_CORE except the magic value of exactly 1 byte, which | |
| # aborts the pipe handler (fs/coredump.c; the same trick LLVM's | |
| # Process::PreventCoreFiles uses). `ulimit -c` scales its argument | |
| # by 1024, so it cannot express that byte. | |
| echo "core_pattern: $(cat /proc/sys/kernel/core_pattern)" | |
| prlimit --core=1:1 --pid $$ || echo "::warning::prlimit failed; piped core dumps remain enabled" | |
| prlimit --core --pid $$ | |
| # Per-test timeout needs psutil, which older images lack; without it | |
| # lit only loses timeout support, so don't fail the run over it. | |
| if python3 -c 'import psutil' 2>/dev/null; then | |
| export LIT_OPTS='--timeout=600' | |
| else | |
| echo "psutil unavailable; running without per-test timeouts" | |
| fi | |
| ninja -C './target-llvm/build-final' verify-llvm -v | |
| ninja -C './target-llvm/build-final' check-lld-unit -v | |
| # MLIR's lit + unit tests, covering the Sol/Yul dialect and | |
| # SolToYul/CAPI changes this fork carries. | |
| ninja -C './target-llvm/build-final' check-mlir -v | |
| # build-llvm configures with -DCMAKE_EXPORT_COMPILE_COMMANDS=Off; | |
| # re-running cmake on the configured build dir flips it back On without | |
| # touching any build rule, so ninja rebuilds nothing. | |
| - name: Export compile commands | |
| if: github.event_name == 'pull_request' | |
| run: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=On './target-llvm/build-final' | |
| - name: clang-tidy | |
| if: github.event_name == 'pull_request' | |
| working-directory: solx-llvm | |
| run: | # zizmor: ignore[template-injection] previous-commit.outputs.sha is a git SHA, not external input | |
| CHANGES=$(git diff -U0 ${{ steps.previous-commit.outputs.sha }}) | |
| echo "Running clang-tidy on the following changes: ${CHANGES}" | |
| echo "${CHANGES}" | \ | |
| ./clang-tools-extra/clang-tidy/tool/clang-tidy-diff_Zegar.py \ | |
| -p1 -clang-tidy-binary "$(which clang-tidy)" \ | |
| -path ../target-llvm/build-final/compile_commands.json |