32-bit indexes

I notice that, even though I'm on 64-bit, many indexes are required by LLVM to
be 32-bit integers. This won't be too important for the next few years
except, I think, for the case of indexing large mmapped files which could
already require more than 32-bits.

Am I right and is this on the todo list? What are 32-bit integers doing in the
64-bit version of LLVM anyway?

Hi Jon,

I notice that, even though I'm on 64-bit, many indexes are required by LLVM to
be 32-bit integers. This won't be too important for the next few years
except, I think, for the case of indexing large mmapped files which could
already require more than 32-bits.

Am I right and is this on the todo list? What are 32-bit integers doing in the
64-bit version of LLVM anyway?

array indices can be 32 bit or 64 bit. Struct indices are 32 bit. I doubt that
there will be many structs with more than 2^32 fields in the near future.

Ciao,

Duncan.

But array lengths must be 32-bit?

I've just started using arrays here so maybe I'm doing something wrong but
attempting to allocate an array with a 64-bit length gives the error:

bench: Instructions.cpp:650: llvm::Value* getAISize(llvm::Value*): Assertion
`Amt->getType() == Type::Int32Ty && "Malloc/Allocation array size is not a
32-bit integer!"' failed.

Hi Jon,

But array lengths must be 32-bit?

array types can have 64 bit lengths. This is useful for modelling
all of memory as an array.

I've just started using arrays here so maybe I'm doing something wrong but
attempting to allocate an array with a 64-bit length gives the error:

bench: Instructions.cpp:650: llvm::Value* getAISize(llvm::Value*): Assertion
`Amt->getType() == Type::Int32Ty && "Malloc/Allocation array size is not a
32-bit integer!"' failed.

Ah, memory allocation! I think you want to declare a very long array type and
then alloc one of them (rather than trying to alloc a large number of array
components).

Ciao,

Duncan.

I see. I was indeed making a mistake. This begs the question of what exactly I
was doing though. What exactly does "alloc a large number of array
components" do then? Is it for allocating many arrays of the same type and
length at the same time? Like a matrix?

As far as I know, the only thing that is not 64-bit clean are the malloc and alloca instructions, both of which take a fixed 32-bit integer operand instead of either a 32-bit or 64-bit one. This can be worked around in various ways, but the best solution is to just fix it. Patches welcome. :slight_smile:

-Chris

Thanks for the clarification.

Is there a todo list of such things?

• Bugzilla: http://llvm.org/bugs/
• The README files in the implementation directories.
• grep -r 'TODO|FIXME' llvm

— Gordon

Nope, but please feel free to file a bugzilla bug about it.

-Chris