32 bit array size to malloc

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

32 bit array size to malloc

Ryan M. Lefever
In the C documentation on linux, malloc is defined to take a size
parameter of type size_t.  On my 64-bit linux machine, size_t turns out
to be a 64-bit type.  In LLVM, AllocationInst's require the array size
passed to them to be a 32-bit type.  Is there a reason that LLVM's
intermediate representation restricts the array size to be a 32-bit type?

Regards,
Ryan
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: 32 bit array size to malloc

Chris Lattner

On Jun 11, 2008, at 2:38 PM, Ryan M. Lefever wrote:

> In the C documentation on linux, malloc is defined to take a size
> parameter of type size_t.  On my 64-bit linux machine, size_t turns  
> out
> to be a 64-bit type.  In LLVM, AllocationInst's require the array size
> passed to them to be a 32-bit type.  Is there a reason that LLVM's
> intermediate representation restricts the array size to be a 32-bit  
> type?

No, there is no good reason.  Like GEP, malloc and alloca should allow  
the size to be either i32 or i64.

-Chris
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: 32 bit array size to malloc

Duncan Sands
> No, there is no good reason.  Like GEP, malloc and alloca should allow  
> the size to be either i32 or i64.

Why not allow any integer type?  Wouldn't that make things more uniform?

D.
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: 32 bit array size to malloc

Chris Lattner
On Jun 12, 2008, at 1:09 AM, Duncan Sands wrote:
>> No, there is no good reason.  Like GEP, malloc and alloca should  
>> allow
>> the size to be either i32 or i64.
>
> Why not allow any integer type?  Wouldn't that make things more  
> uniform?

Yes it would.  I was just thinking about keeping consistency with GEP,  
but I agree that it would be nice to allow any size operand.

-Chris
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev