Mohammad Norouzi via llvm-dev
2016-Jan-07 18:34 UTC
[llvm-dev] StoreInst getType return void
Hi All, I need to get the type of store instructions using getType from StoreInst. However, I get the following error when compiling my program: clang-3.6: /home/norouzi/Desktop/software/dp-clang-llvm/branches/llvm_361/dp-clang-llvm/include/llvm/IR/DataLayout.h:500: uint64_t llvm::DataLayout::getTypeSizeInBits(llvm::Type*) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed. I tried to figure out why and checked out that getType returns "void" so DataLayout cannot proceed. I should mention that i tried it also about LoadInst which perfectly works. I would be happy about any help. Best, Mo -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160107/7ac84606/attachment-0001.html>
Hi Mohammad, Store instructions have void type [1]. Load instructions have a type corresponding to the data being loaded. [1] http://llvm.org/docs/LangRef.html#store-instruction best vedant> On Jan 7, 2016, at 10:34 AM, Mohammad Norouzi via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi All, > > I need to get the type of store instructions using getType from StoreInst. However, I get the following error when compiling my program: > > clang-3.6: /home/norouzi/Desktop/software/dp-clang-llvm/branches/llvm_361/dp-clang-llvm/include/llvm/IR/DataLayout.h:500: uint64_t llvm::DataLayout::getTypeSizeInBits(llvm::Type*) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed. > > I tried to figure out why and checked out that getType returns "void" so DataLayout cannot proceed. > > I should mention that i tried it also about LoadInst which perfectly works. > > I would be happy about any help. > > Best, > Mo > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
A "store" instruction doesn't return anything, so getType() returns void. Try getOperand(0)->getType(). That returns the type of the first operand (i.e. the value stored). http://llvm.org/docs/LangRef.html#store-instruction On Thu, Jan 7, 2016 at 10:34 AM, Mohammad Norouzi via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi All, > > I need to get the type of store instructions using getType from StoreInst. > However, I get the following error when compiling my program: > > clang-3.6: > /home/norouzi/Desktop/software/dp-clang-llvm/branches/llvm_361/dp-clang-llvm/include/llvm/IR/DataLayout.h:500: > uint64_t llvm::DataLayout::getTypeSizeInBits(llvm::Type*) const: Assertion > `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed. > > I tried to figure out why and checked out that getType returns "void" so > DataLayout cannot proceed. > > I should mention that i tried it also about LoadInst which perfectly works. > > I would be happy about any help. > > Best, > Mo > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160107/d827ae04/attachment.html>