Devang Patel
2008-Jun-09 14:15 UTC
[LLVMdev] Plans considering first class structs and multiple return values
On Jun 9, 2008, at 4:14 AM, Duncan Sands wrote:> Hi, > >> Will sretpromotion still be needed? If the frontends would generate >> functions >> returning a struct directly instead of using an sret argument, sret >> could >> perhaps be removed alltogether? Though I guess there is an ABI >> difference >> between using sret and returning a structure directly? > > right, there's an ABI difference. Also you can't return variable > sized structs > using MRV support (I don't know if gcc really supports this, but > some pieces of > code inside gcc mention functions returning variable sized objects).Plus it is not a good idea to pass very large structs using MRV. - Devang
Marc de Kruijf
2008-Jul-02 22:00 UTC
[LLVMdev] Plans considering first class structs and multiple return values
Hi, I'm really interested in this effort. What is its status? Is any of it in svn yet? (I only see the insert/extract value instructions so far... nothing w.r.t. creating a first-class struct/array). Can I do anything to help? Marc On Mon, Jun 9, 2008 at 9:15 AM, Devang Patel <dpatel at apple.com> wrote:> > On Jun 9, 2008, at 4:14 AM, Duncan Sands wrote: > >> Hi, >> >>> Will sretpromotion still be needed? If the frontends would generate >>> functions >>> returning a struct directly instead of using an sret argument, sret >>> could >>> perhaps be removed alltogether? Though I guess there is an ABI >>> difference >>> between using sret and returning a structure directly? >> >> right, there's an ABI difference. Also you can't return variable >> sized structs >> using MRV support (I don't know if gcc really supports this, but >> some pieces of >> code inside gcc mention functions returning variable sized objects). > > Plus it is not a good idea to pass very large structs using MRV. > - > Devang > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Dan Gohman
2008-Jul-02 23:54 UTC
[LLVMdev] Plans considering first class structs and multiple return values
Hello, The basic infrastructure is in place. You can create first-class structs/arrays using sequences of insertvalue. For example, this: %t0 = insertvalue { i32, i32 } undef, i32 %a, 0 %t1 = insertvalue { i32, i32 } %t0, i32 %b, 1 creates the value with %a and %b as member values. Other ways to produce aggregate values are loads, function arguments, function return values, and literal constants. It's all pretty new and hasn't seen much exposure, so one of the things it needs right now is for people to try it out and see how it goes. There is work yet to be done in several of the optimization components. And codegen can't yet handle aggregate return values larger than what fits in designated return value registers. I'm planning to have LLVM auto-upgrade the multiple-return-value constructs that exist in LLVM 2.3, which should give it quite a bit of exposure, though that probably won't happen for a while. And while I'm here, I want to emphasize that this feature does not completely solve the problem of C-oriented ABI-compliant passing/returning of structs. That's a complicated problem, and unfortunately it is beyond the immediate scope of this feature. Dan On Jul 2, 2008, at 3:00 PM, Marc de Kruijf wrote:> Hi, I'm really interested in this effort. What is its status? Is any > of it in svn yet? (I only see the insert/extract value instructions > so far... nothing w.r.t. creating a first-class struct/array). Can I > do anything to help? > > Marc
Reasonably Related Threads
- [LLVMdev] Plans considering first class structs and multiple return values
- [LLVMdev] Plans considering first class structs and multiple return values
- [LLVMdev] Plans considering first class structs and multiple return values
- [LLVMdev] Plans considering first class structs and multiple return values
- [LLVMdev] Plans considering first class structs and multiple return values