Xin Tong via llvm-dev
2017-Jan-02 22:01 UTC
[llvm-dev] Indices for extractvalue and insertvalue
Hi Can someone explain to me why we cant use uint64_t for extractvalue and insertvalue indices, while GEP on arrays can have indices of any integer type. Basically if I load an array with UINT_MAX+O (O>=2) elements, I can not extract its last element. Given this restriction I feel we have a bug here (uint64_t is passed as a unsigned). This cant happen because of the if (NumElements > 1024) guard, but its a bug anyways. https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp#L634 Thanks, -Xin
Reid Kleckner via llvm-dev
2017-Jan-03 16:45 UTC
[llvm-dev] Indices for extractvalue and insertvalue
I think originally insertvalue / extractvalue were only intended to work on struct values. LLVM struct types can have up to 2**32 element types, and the insertvalue/extractvalue indices match that. I hope people aren't actually trying to load a >4GB array and hoping to do something good with it. On Mon, Jan 2, 2017 at 2:01 PM, Xin Tong via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi > > Can someone explain to me why we cant use uint64_t for extractvalue > and insertvalue indices, while GEP on arrays can have indices of any > integer type. Basically if I load an array with UINT_MAX+O (O>=2) > elements, I can not extract its last element. > > Given this restriction I feel we have a bug here (uint64_t is passed > as a unsigned). This cant happen because of the if (NumElements > > 1024) guard, but its a bug anyways. > > https://github.com/llvm-mirror/llvm/blob/master/lib/ > Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp#L634 > > Thanks, > -Xin > _______________________________________________ > 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/20170103/e399e8a2/attachment.html>
Xin Tong via llvm-dev
2017-Jan-03 17:18 UTC
[llvm-dev] Indices for extractvalue and insertvalue
That makes sense. Then it seems to me that there is some unclearness about what the language ref says, i.e. http://llvm.org/docs/LangRef.html#extractvalue-instruction says extractvalue indices work in a similar manner as indices for getelementptr, and what the the compiler supports (extractvalue indices are unsigned or smaller while getelementptr indices can be uint64_t). What would be the problem if we make extractvalue and insertvalue use uint64_t indices, other than the compiler potentially uses a bit more memory ? -Xin On Tue, Jan 3, 2017 at 8:45 AM, Reid Kleckner <rnk at google.com> wrote:> I think originally insertvalue / extractvalue were only intended to work on > struct values. LLVM struct types can have up to 2**32 element types, and the > insertvalue/extractvalue indices match that. > > I hope people aren't actually trying to load a >4GB array and hoping to do > something good with it. > > On Mon, Jan 2, 2017 at 2:01 PM, Xin Tong via llvm-dev > <llvm-dev at lists.llvm.org> wrote: >> >> Hi >> >> Can someone explain to me why we cant use uint64_t for extractvalue >> and insertvalue indices, while GEP on arrays can have indices of any >> integer type. Basically if I load an array with UINT_MAX+O (O>=2) >> elements, I can not extract its last element. >> >> Given this restriction I feel we have a bug here (uint64_t is passed >> as a unsigned). This cant happen because of the if (NumElements > >> 1024) guard, but its a bug anyways. >> >> >> https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp#L634 >> >> Thanks, >> -Xin >> _______________________________________________ >> LLVM Developers mailing list >> llvm-dev at lists.llvm.org >> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >
Reasonably Related Threads
- [LLVMdev] extractvalue and insertvalue on vector types
- [LLVMdev] const indices of extractvalue
- [LLVMdev] extractvalue and insertvalue on vector types
- [LLVMdev] [patch] Remove getType() overrides from extractvalue and insertvalue
- [LLVMdev] Missed optimisation opportunities?