[LLVMdev] Problems with void*
Chris Lattner
sabre at nondot.org
Fri Jun 10 19:46:41 PDT 2005
On Fri, 10 Jun 2005, Reid Spencer wrote:
> No value can be stored in a void and a function returning void* points
> to nowhere in particular. I think what you are really wanting to do here
> is use an opaque type. The other alternative is to simply use sbyte*.
>
> Remember, this isn't C even though some of the names/ideas look
> familiar.
I would recommend using 'sbyte*' instead of opaque*. Reid is right, void
should only be used as a function return type. There will eventually be
an assertion to enforce this, but the SparcV9 backend currently abuses
void*'s, so we cannot add the assertion until it is fixed.
-Chris
> Reid.
>
> On Fri, 2005-06-10 at 15:32 -0700, Ricardo wrote:
>> Hello,
>>
>> I am trying to use the LLVM classes (with Modules in memory) to represent some programs that use
>> the void* type but I am having some problems handling that type.
>> If I use WriteBytecodeToFile, I receive this error:
>>
>> Assertion `slot != -1 && "Module broken!"`
>>
>> If I save the module directly with PrintModulePass, it generates the .ll file fine, but if I try
>> to compile it with llvm-as, as soon as it finds 'void *' it complains that it was expecting an "("
>> instead of an "*". I suppose that the correct syntax is something like this: 'void (sbyte *)*'
>>
>> For example, these lines can cause the error:
>>
>> %castinst1 = cast typeXYZ* %var to void* ; <void*> [#uses=1]
>>
>> or
>>
>> %astruct = type { %int*, %void*, *astruct }
>>
>> My question is, how can I generate 'void (sbyte*)*' using the LLVM classes?
>>
>> Thanks!
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
>> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-Chris
--
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/
More information about the llvm-dev
mailing list