[LLVMdev] Setting the Type in the Alloca Inst

Vikram S. Adve vadve at cs.uiuc.edu
Mon Sep 16 22:57:01 PDT 2002


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
>




More information about the llvm-dev mailing list