[LLVMdev] Is alloca the only way to create a structure?

Duncan Sands baldrick at free.fr
Tue Apr 20 04:02:47 PDT 2010


Hi lost,

> I failed to find answer in docs.

it's not clear what you mean by "create a structure":

(1) you want a local stack variable of struct type.  Then use AllocaInst.
(2) you want a register of struct type.  You can create these using
the extractvalue and insertvalue instructions.
(3) you want to allocate heap memory of struct type.  Call malloc.
(4) you want a global variable of struct type.  Use GlobalVariable.

Ciao,

Duncan.



More information about the llvm-dev mailing list