Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions .github/workflows/nix-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
pull_request:
workflow_dispatch:

defaults:
run:
shell: bash

jobs:
build:
# This job builds the main package, via a number of GHC versions. This is
Expand All @@ -32,7 +36,6 @@ jobs:
name: galois
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: build ${{ matrix.ghc-version }}
shell: bash
run: nix build -L github:${{ github.repository }}/${{ github.sha }}#llvm-pretty-bc-parser.${{ matrix.ghc-version }}

build_old_GHC:
Expand Down Expand Up @@ -63,13 +66,12 @@ jobs:
name: galois
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: build ${{ matrix.ghc-version }}
shell: bash
run: |
nix build -L \
github:${{ github.repository }}/${{ github.sha }}#llvm-pretty-bc-parser.${{ matrix.ghc-version }} \
--override-input nixpkgs github:nixos/nixpkgs/25.05

tests_llvm16-21:
tests_llvm22:
# This job runs the LLVM tests. The builds above verify that the code can be
# built with different versions of GHC. However, the resulting code should
# be able to parse and represent the bitcode from a wide range of LLVM
Expand All @@ -94,11 +96,26 @@ jobs:
name: galois
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: test
shell: bash
run: nix build -L github:${{ github.repository }}/${{ github.sha }}#TESTS_22

tests_llvm16-21:
# See note for tests_llvm22 above. This job is identical except for the
# nix build target.
runs-on: ubuntu-latest
steps:
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-23.05
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v15
with:
name: galois
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: test
run: nix build -L github:${{ github.repository }}/${{ github.sha }}#TESTS_16-21

tests_llvm10-15:
# See note for tests_llvm16-21 above. This job is identical except for the
# See note for tests_llvm22 above. This job is identical except for the
# nix build target.
runs-on: ubuntu-latest
steps:
Expand All @@ -111,5 +128,4 @@ jobs:
name: galois
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
- name: test
shell: bash
run: nix build -L github:${{ github.repository }}/${{ github.sha }}#TESTS_10-15
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## next

* Support LLVM 22:
* Support parsing `sourceLanguageVersion` fields in `DICompileUnit` debug
metadata.
* Support parsing `dataSize` fields in `DIBasicType` debug metadata.
* Add support for reading 16-bit "Brain" floats (`bfloat`)
* Add missing handling for 16-bit IEEE half-precision floats,
64-bit IEEE quad-precision floats, and PowerPC pair-of-doubles
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ compilers.
| | v19 | ✓ | ✓ | See [issues][llvm19] |
| | v20 | ✓ | ✓ | See [issues][llvm20] |
| | v21 | ✓ | ✓ | See [issues][llvm21] |
| | v22 | ✓ | ✓ | See [issues][llvm22] |

If you encounter problems with the output of *any* compiler, please file [an
issue](https://github.com/GaloisInc/llvm-pretty-bc-parser/issues).
Expand Down Expand Up @@ -82,3 +83,4 @@ the developers' documentation for more details and a rationale:
[llvm19]: https://github.com/GaloisInc/llvm-pretty-bc-parser/issues?q=is%3Aopen+is%3Aissue+label%3Allvm%2F19.0
[llvm20]: https://github.com/GaloisInc/llvm-pretty-bc-parser/issues?q=is%3Aopen+is%3Aissue+label%3Allvm%2F20.0
[llvm21]: https://github.com/GaloisInc/llvm-pretty-bc-parser/issues?q=is%3Aopen+is%3Aissue+label%3Allvm%2F21.0
[llvm22]: https://github.com/GaloisInc/llvm-pretty-bc-parser/issues?q=is%3Aopen+is%3Aissue+label%3Allvm%2F22.0
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@
# (https://gitlab.haskell.org/ghc/ghc/-/issues/25771). This bug is
# fixed in GHC 9.12.3; remove the following ghcver setting when GHC
# 9.12.3 is available in nixpkgs.
#
# GHC 9.14 dependencies are not ready yet.
builtins.filter
(n: builtins.substring 0 6 n != "ghc912")
(n: builtins.substring 0 6 n != "ghc912" &&
builtins.substring 0 6 n != "ghc914")
(levers.validGHCVersions pkgs.haskell.compiler);
in
rec {
Expand All @@ -59,8 +62,8 @@
# nixpkgs_old_llvm.legacyPackages.x86_64-linux.clang_16
# nixpkgs_old_llvm.legacyPackages.x86_64-linux.llvm_16

nixpkgs.legacyPackages.x86_64-linux.clang_21
nixpkgs.legacyPackages.x86_64-linux.llvm_21
nixpkgs.legacyPackages.x86_64-linux.clang_22
nixpkgs.legacyPackages.x86_64-linux.llvm_22

# Other packages to add to the development shell:
pkgs.cabal-install
Expand Down Expand Up @@ -136,6 +139,7 @@
# in separate jobs to avoid this.
TESTS_10-15
TESTS_16-21
TESTS_22
];
TESTS_10-15 = wrap "llvm-pretty-bc-parser-TESTS_10-15"
(builtins.map
Expand All @@ -161,6 +165,13 @@
"21"
]
);
TESTS_22 = wrap "llvm-pretty-bc-parser-TESTS_22"
(builtins.map
(llvm-pretty-bc-parser-test llvm-pretty-bc-parser)
[
"22"
]
);
llvm-pretty = mkHaskell "llvm-pretty" llvm-pretty-src {};
llvm-pretty-bc-parser = mkHaskell "llvm-pretty-bc-parser" self {
inherit llvm-pretty tasty-sugar;
Expand Down
2 changes: 1 addition & 1 deletion llvm-pretty
12 changes: 10 additions & 2 deletions src/Data/LLVM/BitCode/IR/Metadata.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import Data.Either (partitionEithers)
import Data.Generics.Uniplate.Data
import qualified Data.IntMap as IntMap
import Data.List (mapAccumL, foldl')

Check warning on line 49 in src/Data/LLVM/BitCode/IR/Metadata.hs

View workflow job for this annotation

GitHub Actions / build - 9.10.1 - ubuntu-22.04

The import of ‘foldl'’ from module ‘Data.List’ is redundant
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe (fromMaybe, mapMaybe)
Expand Down Expand Up @@ -572,7 +572,7 @@
return $! updateMetadataTable (addDebugInfo isDistinct diEnum) pm

15 -> label "METADATA_BASIC_TYPE" $ do
assertRecordSizeBetween r 6 8
assertRecordSizeBetween r 6 9
ctx <- getContext
flags <- parseField r 0 numeric
let isDistinct = testBit (flags :: Int) 0
Expand All @@ -589,6 +589,10 @@
if length (recordFields r) <= 7
then pure 0
else parseField r 7 numeric
dibtDataSize <-
if length (recordFields r) <= 8
then pure 0
else parseField r 8 numeric
let dibt = DIBasicType {..}
return $! updateMetadataTable
(addDebugInfo isDistinct (DebugInfoBasicType dibt)) pm
Expand Down Expand Up @@ -697,7 +701,7 @@
(addDebugInfo isDistinct (DebugInfoSubroutineType dist)) pm

20 -> label "METADATA_COMPILE_UNIT" $ do
assertRecordSizeBetween r 14 22
assertRecordSizeBetween r 14 23
let recordSize = length (recordFields r)
ctx <- getContext
isDistinct <- parseField r 0 nonzero
Expand Down Expand Up @@ -738,6 +742,10 @@
dicuSDK <- if recordSize <= 21
then pure Nothing
else mdStringOrNull ctx pm <$> parseField r 21 numeric
dicuSourceLanguageVersion <-
if recordSize <= 22
then pure 0
else parseField r 22 numeric
let dicu = DICompileUnit {..}
return $! updateMetadataTable
(addDebugInfo isDistinct (DebugInfoCompileUnit dicu)) pm
Expand Down
Loading