Skip to content
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

Support LLVM 15 and 16, opaque pointers #1878

Merged
merged 7 commits into from
Jun 2, 2023
Merged

Support LLVM 15 and 16, opaque pointers #1878

merged 7 commits into from
Jun 2, 2023

Conversation

RyanGlScott
Copy link
Contributor

@RyanGlScott RyanGlScott commented May 31, 2023

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:

This patch also bumps the following submodules to bring in support for opaque pointers:

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.

The previous implementation of `translateLLVMGEP` was needlessly complicated,
as it required the pointer argument to have a very particular shape to its
type.  But there's no good reason for this requirement, as the only thing that
`translateLLVMGEP` _really_ needs to check for is that all of the index
arguments are `0` (so that no pointer offset needs to be computed). I have
simplified the implementation of `translateLLVMGEP` to reflect this and
expanded its Haddocks accordingly.

A secondary benefit of this change is that we no longer match on `PtrTo` in
`translateLLVMGEP`, which will make it easier to support opaque pointers in an
upcoming commit.

Fixes #1875.
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.
RyanGlScott and others added 4 commits June 1, 2023 08:16
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.
Copy link
Member

@kquick kquick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable, and thank you for the clear documentation on the potential future issues.

src/SAWScript/Crucible/LLVM/Builtins.hs Show resolved Hide resolved
src/SAWScript/Crucible/LLVM/Skeleton.hs Outdated Show resolved Hide resolved
This way, users who encounter them in the wild will be more strongly encouraged
to report it on the issue tracker.
@RyanGlScott RyanGlScott added the ready-to-merge If at least one person approves this PR, automatically merge it when CI finishes successfully. label Jun 1, 2023
@mergify mergify bot merged commit ab46c76 into master Jun 2, 2023
38 checks passed
@mergify mergify bot deleted the llvm-16 branch June 2, 2023 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge If at least one person approves this PR, automatically merge it when CI finishes successfully.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants