Get the variable size and count from AllocaInst IR instruction

Let’s say we the following: AllocaInst *alloca_inst = dyn_cast(&I) // I = instruction
Corresponding alloca instructions in IR are as follows:

%var1 = alloca [3 x i32], align 4

%var2 = alloca i32*, align 8

How can I have the size and count (in case of array) of the allocated variables?

+llvm-dev list

Refer to [1], I believe you can use `getArraySize()` and `getType()` to
get what you want.
Of course, you have to make sure the alloca does allocate an array by
using `isArrayAllocation()`.

I tried getArraySize() before posting. For var1 in my example, it returns 1
instead of 3. getType() will return the Type, but how to translate that in
terms of bytes?