[LLVMdev] Setting the Type in the Alloca Inst

Chris Lattner sabre at nondot.org
Tue Sep 17 11:44:01 PDT 2002


> Previously the Constructor for the Alloca Instruction took the type of
> the returned value. But now it has been updated to take the type of the
> Pointer Operand. My question is: how do I set the type of the return
> value of Alloca ? My code uses the old form of the constructor, and when

As Vikram says, the return type is automatically determined by the type
you pass in.  Basically alloca always returns a pointer to whatever
argument you give it.

> the pointer is passed to "replaceAllUsesWith()" of an Instruction
> Pointer,  an assert fails saying that the the types do not match. It
> used to work fine in the old code ?

Yes, this is because of the change we made, you will need to update your
code.

> Am I making some mistake here, or is
> this because of the changes ?

This is because of the changes.  Before you had to do something along
these lines:

AI = new AllocaInst(PointerType::get(x), ...);

Now you have to do something along these lines:

AI = new AllocaInst(x);

But everything else should be the same.

-Chris

http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list