This is based on https://reviews.llvm.org/D125168 which adds a wrapper to allow use of opaque pointers from the C API.
I added an opaque pointer mode test to echo.ll , and to fix assertions that forbid the use of mixed typed and opaque pointers that were triggering in it I had to also add wrappers for setOpaquePointers and supportsTypedPointers.
I also changed echo.ll to remove a bitcast i32* %x to i8*, because passing it through llvm-as and llvm-dis was generating a %0 = bitcast ptr %x to ptr, but when building that same bitcast in echo.cpp it was getting elided by IRBuilderBase::CreateCast (https://github.com/llvm/llvm-project/blob/08ac66124874d70dab63c731da0244f9e29ef168/llvm/include/llvm/IR/IRBuilder.h#L1998-L1999).
cc @lerno
I'm a bit uncertain about this API. The supportsTypedPointers() naming dates back to a time where we supported mixed typed and opaque pointers, so "supports opaque pointers" and "not supports typed pointers" were not equivalent. There's a couple of different possibilities here:
The latter is slightly less general (you can only use it if you already have a pointer type), but it's the one that we actually use most often in practice. We only use supportsTypedPointers() for automatic switching into opaque pointer mode during LL/BC parsing.
I'd personally lean towards exposing LLVMPointerTypeIsOpaque().