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
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 ? Am I making some mistake here, or is
this because of the changes ?
Thanks,
- Karthik
The type of the return value of alloca or malloc is automatically set by the
constructor (for the base class AllocationInst). I can't tell without
seeing your code why this might be happening, but I suggest making sure that
the type of the AllocaInst is indeed the pointer type you are expecting
// For: Instruction* allocaInst = new AllocaInst(objectType, ...);
(gdb) p objectType->dump()
(gdb) p allocaInst->getType()->dump() ## should be of type
pointer-to-objectType
--Vikram
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/