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 16 #730

Closed
3 tasks done
Baltoli opened this issue Apr 11, 2023 · 12 comments · Fixed by #759
Closed
3 tasks done

Support LLVM 16 #730

Baltoli opened this issue Apr 11, 2023 · 12 comments · Fixed by #759
Assignees
Labels
devops CI, testing

Comments

@Baltoli
Copy link
Contributor

Baltoli commented Apr 11, 2023

LLVM 16 was released a few weeks ago and is already the default version for Homebrew. We should test the LLVM backend to make sure that it can be built with version 16; if not we need to update documentation pointing to Homebrew formulae to reflect this.

Running with version 16 in CI is blocked until the Nix maintainers ship it properly; work appears to already be ongoing here. We should nevertheless still check macOS informally.

Things that need to be changed:

  • Uses of getInstList on a basic block
  • getABITypeAlign[ment]
  • Invocation of opt
@Baltoli Baltoli added the devops CI, testing label Apr 11, 2023
@RaitoBezarius
Copy link

FWIW, LLVM16 will (hopefully) be part of NixOS 23.05 and land in unstable soon.

@Baltoli
Copy link
Contributor Author

Baltoli commented Apr 12, 2023

Thanks @RaitoBezarius - that's helpful to know!

@Baltoli Baltoli removed their assignment May 11, 2023
@Baltoli
Copy link
Contributor Author

Baltoli commented May 15, 2023

@theo25 to investigate the use of opaque pointers in this version

@Baltoli Baltoli self-assigned this May 15, 2023
@theo25
Copy link
Collaborator

theo25 commented May 15, 2023

I looked into the release notes of LLVM 16 and it does not seem that the use of opaque pointers is mandated by this release. However, the release notes found in the main branch on github do list the opaque pointer change, so we can assume that the change is coming with the LLVM 17 release.

@Baltoli
Copy link
Contributor Author

Baltoli commented May 17, 2023

The Opaque Pointers migration document reveals that their introduction is not mandatory in LLVM 16, but they are enabled by default and the old system is no longer supported. This suggests that the LLVM 16 transition is the right point at which to make sure they work properly for the LLVM backend.

Some debugging reveals that there is a subtle issue we have previously missed when migrating over to opaque pointers. In transparent mode, we make equality comparisons between pointer types:

if (arg->getType() == ChildPtr->getType()) {
arg = new llvm::LoadInst(arg_ty, arg, "", CaseBlock);
}

These comparisons have their semantics changed silently when moving to opaque pointers. Previously, we'd have seen a comparison of A* == B* (with meaningful semantics depending on the pointee types A, B). However, now both sides of the comparison are now ptr and the comparison is silently failing. We need to audit the codebase for places where we're comparing pointer types in this way and fix them (similarly to previous changes) to compare the underlying types in a meaningful way.

@Baltoli
Copy link
Contributor Author

Baltoli commented May 17, 2023

This is possibly a tricky change, and so we should also update the documentation for macOS to reflect the fact that we don't yet support LLVM 16. Otherwise, we'll get breakages there for people building from source.

@dwightguth
Copy link
Collaborator

Ahhh. This is a good catch. This relates to how we are passing map, list, and set terms around at the llvm bytecode level. I don't remember the exact details. I can dig into it and try and refresh my memory if you'd like.

@dwightguth
Copy link
Collaborator

I believe that it was meant to only evaluate to true in the case involving map and map*, list and list*, and set and set* though, which is a comparison that could still be made with opaque pointers. The fix might be as simple as just wrapping each of these clauses in a guard against the sort category in question.

@Baltoli
Copy link
Contributor Author

Baltoli commented May 17, 2023

I did a quick dig into the code and that's the same conclusion I came to before seeing your comment. A grep suggests there are only a few places that we do it, so I will try making the change to check the sort category explicitly rather than relying on the pointer types and see how far that gets me. Thanks!

@dwightguth
Copy link
Collaborator

I mean, you would probably still need to check the types, but if you guard that check by only checking on the map, list, and set sort categories, I don't think it will actually break if you're using opaque pointers because it's checking whether one type is a pointer and the other is a struct.

@Baltoli
Copy link
Contributor Author

Baltoli commented May 19, 2023

Yep - my first pass attempt at a solution here leaves an invalid term somewhere in the configuration so we're still generating something with incorrect semantics wrt. opaque pointers. I'll try again with your comment there for pointer / struct types and see if that gets us further.

@Baltoli
Copy link
Contributor Author

Baltoli commented May 25, 2023

Still broken for opaque pointer reasons; need to update the documentation for MacOS etc. to make sure users stay on version 15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devops CI, testing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants