(IIIT) Siddharth Bhat via llvm-dev
2017-Oct-13 22:54 UTC
[llvm-dev] Setters for `addrspace`?
Hello all, I've found the need to fixup address spaces in some code I'm writing. I'm puzzled by the fact that there are no setters for `addrspace`: For example, in GetElementPtrInst's API, or in `CastInst` and its subclasses. I believe there is some rationale for this I'm missing. Could someone please fill me in? Cheers, ~Siddharth. -- Sending this from my phone, please excuse any typos! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171013/6e8c2a80/attachment.html>
Hi Siddharth, The addrspace is a property of pointer types, not of instructions. But types are immutable. And if I'm not mistaken you can't change the target type of a CastInst. To set the addrspace of the target type of a CastInst, you have to create a new pointer type with the desired addrspace and create a new CastInst with this type as the target type. You may want to `replaceUsesOfWith` the old with the new instruction and / or delete the old instruction as well. -Manuel On 2017-10-14 00:54, (IIIT) Siddharth Bhat via llvm-dev wrote:> Hello all, > > I've found the need to fixup address spaces in some code I'm writing. > I'm > puzzled by the fact that there are no setters for `addrspace`: For > example, > in GetElementPtrInst's API, or in `CastInst` and its subclasses. > > I believe there is some rationale for this I'm missing. Could someone > please fill me in? > > Cheers, > ~Siddharth. > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev