[LLVMdev] Alloca and GlobalVariable

Óscar Fuentes ofv at wanadoo.es
Wed Jul 7 10:14:26 PDT 2010


Curtis Faith <curtis at curtisfaith.com> writes:

[snip]

> 1) How does everyone else handle this difference? I can go back into
> my code to make the Alloca case use the same typing mechanism I used
> for global variables to eliminate the difference in my code, but this
> seems ugly. What I'd really like is some way of getting a global
> variable that is sized just like the CreateAlloca instruction.

IMO the Alloca case should match the GlobalVariable case, not the other
way around. So forget about the ArraySize argument and create an array
type for Alloca too. Unless you are allocating arrays with dynamic size,
of course.

> 2) Is there some internal reason why there isn't an ArraySize argument
> for the constructor for GlobalVariable like there is for CreateAlloca?

Stack-based arrays can have dynamic length. That's the reason why the
ArraySize argument is a Value*, not a bare integer. Global arrays cannot
have dynamic length.

[snip]




More information about the llvm-dev mailing list