Representation of void pointer type in llvm ir

I am currently using i8 * to represent void pointers in my generated IR, but it is rather difficult to distinguish void * from char *, for example. Are there common approaches to solving this? I searched around quite a bit, no luck.

For every other type pair, I can directly use llvm :: Type * to distinguish between types, so it adds a lot of complexity if I can no longer do this only for the special case of void pointers.

One idea might be to use a named structure containing i8 as the void type (for example,% void = type {i8}) and use pointers instead, but the clang generated IR uses i8 * when you give it a void pointer type, so I not sure what the advantages / disadvantages of each of them are.

+7
llvm llvm-ir
source share
1 answer

In general, types belong to the interface of your compiler. It’s just fortunate that a system like LLVM can be similar to yours, and it can freely change from under you (one example:

+5
source share

All Articles