Description
Relevant LLVM doc: https://llvm.org/docs/OpaquePointers.html
Traditionally, LLVM IR pointer types have contained a pointee type. For example, i32* is a pointer that points to an i32 somewhere in memory. However, due to a lack of pointee type semantics and various issues with having pointee types, there is a desire to remove pointee types from pointers.
The opaque pointer type project aims to replace all pointer types containing pointee types in LLVM with an opaque pointer type. The new pointer type is tentatively represented textually as ptr.
This lead to the deprecation of a number of C API function that now required to be given both the pointer LLVMValueRef and the pointee LLVMTypeRef:
LLVMBuildLoad -> LLVMBuildLoad2
LLVMBuildCall -> LLVMBuildCall2
LLVMBuildInvoke -> LLVMBuildInvoke2
LLVMBuildGEP -> LLVMBuildGEP2
LLVMBuildInBoundsGEP -> LLVMBuildInBoundsGEP2
LLVMBuildStructGEP -> LLVMBuildStructGEP2
LLVMBuildPtrDiff -> LLVMBuildPtrDiff2
LLVMConstGEP -> LLVMConstGEP2
LLVMConstInBoundsGEP -> LLVMConstInBoundsGEP2
LLVMAddAlias -> LLVMAddAlias2
Additionally, it will no longer be possible to call LLVMGetElementType() on a pointer type.
codegen.cpp
make extensive use of all the above functions so a number of changes need to happen there.
Trying to compile Zig with LLVM14 currentlly yield 200 warnings and 20 errors which look all related to the above changes.
I've started working on some changes, but I'm not really familiar with codegen.cpp
and I'm afraid of making errors and passing the wrong types. But hopefully doing the most of the refactoring myself will allow @andrewrk to focus on the semantic.