Jin Huang
2013-Dec-12 14:11 UTC
[LLVMdev] LLVM Type Int32Ty Problems & LLVMContextImpl.h Problems
Hello! I'm newer to LLVM development . I'm trying to use AllocaInst class to construct an instruction , I wrote like this: AllocaInst *alloc = new AllocaInst(llvm::Int32Ty, 0, "indexLoc",i); but it return the error: error: use of undeclared identifier 'llvm::Int32Ty' AllocaInst *alloc = new AllocaInst(Int32Ty, 0, "indexLoc",i); I found that the Int32Ty is defined in the LLVMContextImpl.h , but I can not find it in the llvm include directory. I installed llvm in "/usr/local/llvm" but there is no "LLVMContextImpl.h" in /usr/local/llvm/include/llvm/IR (LLVMContext.h exists) Does this mean that the llvm is not installed correctly? What should I do to fix it? Thank you~ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131212/c935efa8/attachment.html>
Caldarale, Charles R
2013-Dec-12 20:16 UTC
[LLVMdev] LLVM Type Int32Ty Problems & LLVMContextImpl.h Problems
> From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] > On Behalf Of Jin Huang > Subject: [LLVMdev] LLVM Type Int32Ty Problems & LLVMContextImpl.h Problems> AllocaInst *alloc = new AllocaInst(llvm::Int32Ty, 0, "indexLoc",i);I think you should be using llvm::Type::getInt32Ty(Context), not llvm::Int32Ty, which is for internal LLVM usage. Also, using llvm::IRBuilder<> is a whole lot easier and safer than trying to create instruction objects directly. - Chuck
Jin Huang
2013-Dec-14 03:35 UTC
[LLVMdev] LLVM Type Int32Ty Problems & LLVMContextImpl.h Problems
llvm::Type::getInt32Ty(Context) really works ,and I found a lot of useful functions to create instructions in llvm::IRBuilder<>. Thank you! Chuck 2013/12/13 Caldarale, Charles R <Chuck.Caldarale at unisys.com>> > From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] > > On Behalf Of Jin Huang > > Subject: [LLVMdev] LLVM Type Int32Ty Problems & LLVMContextImpl.h > Problems > > > AllocaInst *alloc = new AllocaInst(llvm::Int32Ty, 0, "indexLoc",i); > > I think you should be using llvm::Type::getInt32Ty(Context), not > llvm::Int32Ty, which is for internal LLVM usage. > > Also, using llvm::IRBuilder<> is a whole lot easier and safer than trying > to create instruction objects directly. > > - Chuck > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20131214/4adb0d25/attachment.html>
Reasonably Related Threads
- [LLVMdev] LLVM Type Int32Ty Problems & LLVMContextImpl.h Problems
- [LLVMdev] need to store the address of a variable
- [LLVMdev] Assertion `castIsValid(getOpcode(), S, Ty) && "Illegal BitCast"' failed.
- [LLVMdev] How to codegen an LLVM-IR that has dynamic arrays in it?
- [LLVMdev] newbie question for type comparison