Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / .github / workflows / llvm-tests.yml
blobcc9855ce182b2b8c3a84cedfb595c9d6db0910be
1 name: LLVM Tests
3 permissions:
4   contents: read
6 on:
7   workflow_dispatch:
8   push:
9     branches:
10       - 'release/**'
11     paths:
12       - 'llvm/**'
13       - '.github/workflows/llvm-tests.yml'
14       - '.github/workflows/llvm-project-tests.yml'
15   pull_request:
16     branches:
17       - 'release/**'
18     paths:
19       - 'llvm/**'
20       - '.github/workflows/llvm-tests.yml'
21       - '.github/workflows/llvm-project-tests.yml'
23 concurrency:
24   # Skip intermediate builds: always.
25   # Cancel intermediate builds: only if it is a pull request build.
26   group: ${{ github.workflow }}-${{ github.ref }}
27   cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
29 jobs:
30   check_all:
31     if: github.repository_owner == 'llvm'
32     name: Test llvm,clang,libclc
33     uses: ./.github/workflows/llvm-project-tests.yml
34     with:
35       build_target: check-all
36       projects: clang;libclc
38   # These need to be separate from the check_all job, becuase there is not enough disk
39   # space to build all these projects on Windows.
40   build_lldb:
41     if: github.repository_owner == 'llvm'
42     name: Build lldb
43     uses: ./.github/workflows/llvm-project-tests.yml
44     with:
45       build_target: ''
46       projects: clang;lldb
48   check_lld:
49     if: github.repository_owner == 'llvm'
50     name: Test lld
51     uses: ./.github/workflows/llvm-project-tests.yml
52     with:
53       build_target: check-lld
54       projects: lld
56   abi-dump-setup:
57     if: github.repository_owner == 'llvm'
58     runs-on: ubuntu-latest
59     outputs:
60       BASELINE_REF: ${{ steps.vars.outputs.BASELINE_REF }}
61       ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
62       BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
63       LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
64       LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }}
65       LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }}
66     steps:
67       - name: Checkout source
68         uses: actions/checkout@v4
69         with:
70           fetch-depth: 250
72       - name: Get LLVM version
73         id: version
74         uses: llvm/actions/get-llvm-version@main
76       - name: Setup Variables
77         id: vars
78         run: |
79           if [ ${{ steps.version.outputs.LLVM_VERSION_MINOR }} -ne 0 ] || [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
80             {
81               echo "BASELINE_VERSION_MAJOR=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))"
82               echo "ABI_HEADERS=llvm-c"
83             } >> "$GITHUB_OUTPUT"
84           else
85             {
86               echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.LLVM_VERSION_MAJOR }}"
87               echo "ABI_HEADERS=."
88             } >> "$GITHUB_OUTPUT"
89           fi
91   abi-dump:
92     if: github.repository_owner == 'llvm'
93     needs: abi-dump-setup
94     runs-on: ubuntu-latest
95     strategy:
96       matrix:
97         name:
98           - build-baseline
99           - build-latest
100         include:
101           - name: build-baseline
102             llvm_version_major: ${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}
103             ref: llvmorg-${{ needs.abi-dump-setup.outputs.BASELINE_VERSION_MAJOR }}.0.0
104             repo: llvm/llvm-project
105           - name: build-latest
106             llvm_version_major: ${{ needs.abi-dump-setup.outputs.LLVM_VERSION_MAJOR }}
107             ref: ${{ github.sha }}
108             repo: ${{ github.repository }}
109     steps:
110       - name: Install Ninja
111         uses: llvm/actions/install-ninja@main
112       - name: Install abi-compliance-checker
113         run: |
114           sudo apt-get install abi-dumper autoconf pkg-config
115       - name: Install universal-ctags
116         run: |
117           git clone https://github.com/universal-ctags/ctags.git
118           cd ctags
119           ./autogen.sh
120           ./configure
121           sudo make install
122       - name: Download source code
123         uses: llvm/actions/get-llvm-project-src@main
124         with:
125           ref: ${{ matrix.ref }}
126           repo: ${{ matrix.repo }}
127       - name: Configure
128         run: |
129           mkdir install
130           cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DLLVM_TARGETS_TO_BUILD="" -DLLVM_BUILD_LLVM_DYLIB=ON -DCMAKE_C_FLAGS_DEBUG="-g1 -Og" -DCMAKE_CXX_FLAGS_DEBUG="-g1 -Og" -DCMAKE_INSTALL_PREFIX="$(pwd)"/install llvm
131       - name: Build
132         # Need to run install-LLVM twice to ensure the symlink is installed (this is a bug).
133         run: |
134           ninja -C build install-LLVM
135           ninja -C build install-LLVM
136           ninja -C build install-llvm-headers
137       - name: Dump ABI
138         run: |
139           if [ "${{ needs.abi-dump-setup.outputs.ABI_HEADERS }}" = "llvm-c" ]; then
140             nm ./install/lib/libLLVM.so | awk "/T _LLVM/ || /T LLVM/ { print $3 }" | sort -u | sed -e "s/^_//g" | cut -d ' ' -f 3 > llvm.symbols
141             # Even though the -symbols-list option doesn't seem to filter out the symbols, I believe it speeds up processing, so I'm leaving it in.
142             export EXTRA_ARGS="-symbols-list llvm.symbols"
143           else
144             touch llvm.symbols
145           fi
146           abi-dumper "$EXTRA_ARGS" -lver ${{ matrix.ref }} -skip-cxx -public-headers ./install/include/${{ needs.abi-dump-setup.outputs.ABI_HEADERS }} -o ${{ matrix.ref }}.abi ./install/lib/libLLVM.so
147           # Remove symbol versioning from dumps, so we can compare across major versions.
148           sed -i 's/LLVM_${{ matrix.llvm_version_major }}/LLVM_NOVERSION/' ${{ matrix.ref }}.abi
149       - name: Upload ABI file
150         uses: actions/upload-artifact@v3
151         with:
152           name: ${{ matrix.name }}
153           path: ${{ matrix.ref }}.abi
155       - name: Upload symbol list file
156         if: matrix.name == 'build-baseline'
157         uses: actions/upload-artifact@v3
158         with:
159           name: symbol-list
160           path: llvm.symbols
162   abi-compare:
163     if: github.repository_owner == 'llvm'
164     runs-on: ubuntu-latest
165     needs:
166       - abi-dump-setup
167       - abi-dump
168     steps:
169       - name: Download baseline
170         uses: actions/download-artifact@v3
171         with:
172           name: build-baseline
173           path: build-baseline
174       - name: Download latest
175         uses: actions/download-artifact@v3
176         with:
177           name: build-latest
178           path: build-latest
179       - name: Download symbol list
180         uses: actions/download-artifact@v3
181         with:
182           name: symbol-list
183           path: symbol-list
185       - name: Install abi-compliance-checker
186         run: sudo apt-get install abi-compliance-checker
187       - name: Compare ABI
188         run: |
189           if [ -s symbol-list/llvm.symbols ]; then
190             # This option doesn't seem to work with the ABI dumper, so passing it here.
191             export EXTRA_ARGS="-symbols-list symbol-list/llvm.symbols"
192           fi
193           # FIXME: Reading of gzip'd abi files on the GitHub runners stop
194           # working some time in March of 2021, likely due to a change in the
195           # runner's environment.
196           abi-compliance-checker "$EXTRA_ARGS" -l libLLVM.so -old build-baseline/*.abi -new build-latest/*.abi || test "${{ needs.abi-dump-setup.outputs.ABI_HEADERS }}" = "llvm-c"
197       - name: Upload ABI Comparison
198         if: always()
199         uses: actions/upload-artifact@v3
200         with:
201           name: compat-report-${{ github.sha }}
202           path: compat_reports/