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 ---------------------------------------------------------------------- VIKRAM S. ADVE Assistant Professor E-MAIL: vadve at cs.uiuc.edu Department of Computer Science PHONE: (217) 244-2016 Univ. of Illinois at Urbana-Champaign FAX: (217) 244-6869 1304 W. Springfield Ave. http://www.cs.uiuc.edu/~vadve Urbana IL 61801. ----------------------------------------------------------------------> -----Original Message----- > From: llvmdev-admin at cs.uiuc.edu [mailto:llvmdev-admin at cs.uiuc.edu]On > Behalf Of Karthik Pattabiraman > Sent: Monday, September 16, 2002 10:20 PM > To: llvmdev at cs.uiuc.edu > Subject: [LLVMdev] Setting the Type in the Alloca Inst > > > 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >
> 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 whenAs 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/
Apparently Analagous Threads
- [LLVMdev] Instruciton replacement
- [LLVMdev] The best way to cope with AllocationInst type in old code?
- [LLVMdev] The best way to cope with AllocationInst type in old code?
- [LLVMdev] MP1: Constructor for AllocaInst
- [LLVMdev] Alignment for Alloca Inst in llvm 2.6