The use of token type

Hello,
I would like to add an intrinsic that returns a token type argument. The equivalent in C that I found other builtins using is void *(coro_id for instance).

My question is how to generate the code in CGBuiltins.cpp to generate token type instead of void *. The usual code is not working.

The intrinsic I get generated is:
%1 = call token @llvm.new_intrinsic()

but it wants to convert the token into void* like the following:

%2 = bitcast token %1 to i8*
store i8* %2, i8** %myvariable

How to get it to use directly token type like this:

%myvariale = call token @llvm.new_intrinsic()

Did anyone have done this before: token in the intrinsic and void* in the builtin?

Thanks,
Dounia

I don’t think token was envisioned as something that could be exposed via C builtins. Perhaps you could modify CGBuiltins.cpp to avoid the bitcast, but you still won’t be able to store the token to a variable in C. It will only be usable in an expression, like this:
consume_token(produce_token(), foo(), bar());

This doesn’t seem like a particularly good design direction either.