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 opaque pointers #172

Merged
merged 8 commits into from
Jul 20, 2023
Merged

Support opaque pointers #172

merged 8 commits into from
Jul 20, 2023

Conversation

dpaoliello
Copy link
Collaborator

LLVM is moving to a model where all pointer types in IR are opaque (https://llvm.org/docs/OpaquePointers.html) this is currently enabled-by-default for LLVM 16 and will be required for LLVM 17.

This change moves cbe to support and use opaque pointers:

  • Where we have an instruction that has a helper to get the type of an operand (e.g., Value::getValueType) use that helper instead of getType()->getNonOpaquePointerElementType().
  • Always emit void* for pointers
  • Use a new type FunctionInfoVariant (which is a variant of Function and CallInst) instead of FunctionType for generating function declarations and prototypes, as this maintains information about struct return types, by-val param types, etc.
  • Disable using opaque pointers in the test.
  • When checking for an "address exposed value" also get its real type so that we can cast it correctly.
  • Remove TopoligicalSorter: function declarations will not use void* for function pointers, thus it doesn't matter the order that we emit them in.
  • isStandardMain can only check that the char ** parameter corresponds to a pointer parameter, rather than an actual char **.
  • printGEPExpression and writeMemoryAccess will cast the pointer operand to the appropriate type.
  • Cleanup printGEPExpression to remove "last index is vector" workaround.

Fixes #154

@dpaoliello dpaoliello requested a review from vtjnash July 19, 2023 21:12
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Seems like a good change!

lib/Target/CBackend/CBackend.cpp Show resolved Hide resolved
@vtjnash vtjnash merged commit 6c744f9 into JuliaHubOSS:master Jul 20, 2023
@dpaoliello dpaoliello deleted the opaque branch July 20, 2023 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TODO: need to support opaque pointers
2 participants