-
Notifications
You must be signed in to change notification settings - Fork 42
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
More complete support for opaque pointers (required for LLVM 15+) #1085
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks fine, just a couple of polishing suggestions.
I'm on vacation for the next two weeks, but I approve of the overall direction of this PR. Please feel free to merge without my review. |
c6cca74
to
f0e445f
Compare
I was surprised to see that the CVC5 abduction-related tests fail on CI, as I observed these tests passing locally. But some further investigation reveals why: I was using CVC5 1.0.5 locally, the CI was using CVC5 1.0.2, and these tests are sensitive to the choice of CVC5 version. Agh! |
For now, we simply ignore the explicit `Type` field. In a subsequent commit, we will use this type rather than inspecting the pointee type of the pointer argument. See #1075.
For now, we simply ignore the explicit `Type` fields. In a subsequent commit, we will use these types rather than inspecting the pointee type of the pointer arguments. See #1075.
This adds a `PtrOpaqueType` data constructor to `MemType`, which encodes opaque pointer types in `crucible-llvm`. There also adds cases for `PtrOpaqueType` in several functions. See #1075. There is more work to be done to robustly support opaque pointers, but I will split this out into separate commits.
Currently, `uc-crux-llvm` does not support opaque pointers (see the discussion at #1075). For now, we make `uc-crux-llvm` error if given an opaque pointer as input. We also instruct the `uc-crux-llvm` test suite to invoke Clang in such a way that it will not produce opaque pointers.
Clang 15+ now treat `-Wint-conversion` warnings as fatal errors (see https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.html#improvements-to-clang-s-diagnostics), which causes some test cases in `uc-crux-llvm` to be spuriously rejected. This patch fixes the affected test cases by correcting some return types to be `int*` instead of `int` and adding a `uintptr_t` cast.
Clang 15+ now treat `-Wimplicit-int` warnings as fatal errors (see https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.html#improvements-to-clang-s-diagnostics), which causes some test cases in `uc-crux-llvm` to be spuriously rejected. This patch adds the necessary types to avoid these spurious errors.
…th Clang 15+ Clang 15+ now treat `-Wimplicit-function-declaration` warnings as a fatal error (see https://releases.llvm.org/15.0.0/tools/clang/docs/ReleaseNotes.html#improvements-to-clang-s-diagnostics), which causes some test cases in `crux-llvm` and `uc-crux-llvm` to be spuriously rejected. This patch adds the missing `#include`s needed to avoid these spurious errors. Fixes #1076.
This patch: 1. Makes the LLVM override quasiquoter aware of opaque pointer types, which are parsed like LLVM's `ptr` type. 2. Makes the LLVM override matching machinery treat opaque pointers as equal to non-opaque pointers. This means that most of the existing overrides that use non-opaque pointers will now also work for opaque pointers... 3. ...well, for _most_ overrides, that is. An exception to this rule are certain classes of polymorphic LLVM intrinsics, such as `llvm.lifetime.start.*`. Such an intrinsic would be named `llvm.lifetime.start.p0i8` with a non-opaque pointer, where the argument type is an `i8*`, but it would be named `llvm.lifetime.start.p0` with an opaque pointer, where the argument type is a `ptr`. We could devise some clever string hackery to match both `llvm.lifetime.start.p0i8` and `llvm.lifetime.start.p0` with the same override, but that seems like overkill. There aren't _too_ many intrinsics of this sort, so I've opted to just make copies of these intrinsics specialized to opaque pointers where appropriate. See #1075.
This tweaks the translator code to avoid inspecting pointers' pointee types, an approach that won't work for opaque pointers. See #1075. The following instructions' translations are adjusted in this patch: * `getelementptr` * `load` * `store` * `cmpxchg` * `atomicrmw`
…ing. This also requires bumping the `what4` submodule to bring in the changes from GaloisInc/what4#234, which allow `what4`'s test suite to build against `tasty-sugar-2.2.0.0`.
f0e445f
to
30e2622
Compare
I've rebased this on top of #1088, so the output of the CVC5 abduction-related tests should no longer be an issue. |
This commit bumps the `llvm-pretty` submodule to bring in a commit from GaloisInc/llvm-pretty#110 that adds additional fields to `ConstGEP` to represent the basis type and expression to use for offset calculations. This also bumps the `llvm-pretty-bc-parser` and `crucible` submodule to bring in corresponding changes from GaloisInc/llvm-pretty-bc-parser#221 and GaloisInc/crucible#1085, respectively. This change affects one use site in `heapster-saw`, which is easily adapted.
This patch adds support for LLVM 15 and 16 by adding support for opaque pointers, which are described in https://llvm.org/docs/OpaquePointers.html. I have also added a test case involving LLVM bitcode using opaque pointers to kick the tires and ensure that the basics work as expected. For the most part, this is a straightforward process, as most uses of pointer types in SAW already do not care about pointee types. There are some exceptions, however: * The `typeOfSetupValue` function, as well as several places that use this function, scrutinize pointee types of pointers, which would appear to fly in the face of opaque pointers. I attempt to explain in #1876 which this is actually OK for now (although a bit awkward). * The `llvm_boilerplate`/skeleton machinery does not support opaque pointers at all. See #1877. This patch also bumps the following submodules to bring in support for opaque pointers: * `llvm-pretty`: GaloisInc/llvm-pretty#110 * `llvm-pretty-bc-parser`: GaloisInc/llvm-pretty-bc-parser#221 * `crucible`: GaloisInc/crucible#1085 This also bumps the `what4` submodule to bring in the changes from GaloisInc/what4#234. This isn't necessary to support opaque pointers, but it _is_ necessary to support a build plan involving `tasty-sugar-2.2.*`, which `llvm-pretty-bc-parser`'s test suite now requires.
This patch adds support for LLVM 15 and 16 by adding support for opaque pointers, which are described in https://llvm.org/docs/OpaquePointers.html. I have also added a test case involving LLVM bitcode using opaque pointers to kick the tires and ensure that the basics work as expected. For the most part, this is a straightforward process, as most uses of pointer types in SAW already do not care about pointee types. There are some exceptions, however: * The `typeOfSetupValue` function, as well as several places that use this function, scrutinize pointee types of pointers, which would appear to fly in the face of opaque pointers. I attempt to explain in #1876 which this is actually OK for now (although a bit awkward). * The `llvm_boilerplate`/skeleton machinery does not support opaque pointers at all. See #1877. * The `llvm_fresh_expanded_val` command does not support opaque pointers at all. See #1879. This patch also bumps the following submodules to bring in support for opaque pointers: * `llvm-pretty`: GaloisInc/llvm-pretty#110 * `llvm-pretty-bc-parser`: GaloisInc/llvm-pretty-bc-parser#221 * `crucible`: GaloisInc/crucible#1085 This also bumps the `what4` submodule to bring in the changes from GaloisInc/what4#234. This isn't necessary to support opaque pointers, but it _is_ necessary to support a build plan involving `tasty-sugar-2.2.*`, which `llvm-pretty-bc-parser`'s test suite now requires.
This commit bumps the `llvm-pretty` submodule to bring in a commit from GaloisInc/llvm-pretty#110 that adds additional fields to `ConstGEP` to represent the basis type and expression to use for offset calculations. This also bumps the `llvm-pretty-bc-parser` and `crucible` submodule to bring in corresponding changes from GaloisInc/llvm-pretty-bc-parser#221 and GaloisInc/crucible#1085, respectively. This change affects one use site in `heapster-saw`, which is easily adapted.
This patch adds support for LLVM 15 and 16 by adding support for opaque pointers, which are described in https://llvm.org/docs/OpaquePointers.html. I have also added a test case involving LLVM bitcode using opaque pointers to kick the tires and ensure that the basics work as expected. For the most part, this is a straightforward process, as most uses of pointer types in SAW already do not care about pointee types. There are some exceptions, however: * The `typeOfSetupValue` function, as well as several places that use this function, scrutinize pointee types of pointers, which would appear to fly in the face of opaque pointers. I attempt to explain in #1876 which this is actually OK for now (although a bit awkward). * The `llvm_boilerplate`/skeleton machinery does not support opaque pointers at all. See #1877. * The `llvm_fresh_expanded_val` command does not support opaque pointers at all. See #1879. This patch also bumps the following submodules to bring in support for opaque pointers: * `llvm-pretty`: GaloisInc/llvm-pretty#110 * `llvm-pretty-bc-parser`: GaloisInc/llvm-pretty-bc-parser#221 * `crucible`: GaloisInc/crucible#1085 This also bumps the `what4` submodule to bring in the changes from GaloisInc/what4#234. This isn't necessary to support opaque pointers, but it _is_ necessary to support a build plan involving `tasty-sugar-2.2.*`, which `llvm-pretty-bc-parser`'s test suite now requires.
This is a collection of various tweaks to
crux-llvm
that allows it to fully support opaque pointers, an alternative representation of pointer types that is enabled by default in LLVM 15 or later. It also tweaksuc-crux-llvm
to not support opaque pointers for now, as adding support for them inuc-crux-llvm
would be nontrivial. (See #1075 for more on this.) These changes suffice to makecrux-llvm
anduc-crux-llvm
's test suites pass with LLVM 15 and 16.I have split this patch up into self-contained commits, and for reviewing purposes, I'd recommend viewing each patch in isolation. The general themes of these patches are:
Adapting to
llvm-pretty
API changes (from GaloisInc/llvm-pretty#110)Adapt to Load gaining an explicit type
Adapt to GEP/ConstGEP gaining explicit types
crux-llvm
support for opaque pointerscrucible-llvm: Add PtrOpaqueType to MemType
crucible-llvm: Make opaque pointers play nicely with overrides
crucible-llvm: Avoid inspecting pointee types during translation
uc-crux-llvm
non-support for opaque pointersuc-crux-llvm: Opaque pointers are unsupported
Updating test cases to support Clang 15/16
uc-crux-llvm-test: Avoid -Wint-conversion errors with Clang 15+
uc-crux-llvm-test: Avoid -Wimplicit-int errors with Clang 15+
{uc,}-crux-llvm-test: Avoid -Wimplicit-function-declaration errors with Clang 15+
crux-llvm-test: Accept new test output for Clang 15
crux-llvm-test: Accept new test output for Clang 16
{uc,}-crux-llvm: Document support for LLVM 16 in READMEs
General test suite/CI tweaks needed to support multiple LLVM ranges
Use tasty-sugar v2.2.0.0 for clang-range ranged parameter test filtering.
Remove unneeded imports and functions in crux-llvm tests.
CI: Regenerate cabal.GHC-*.config files