Anton, [+Eric, Nick, the e-mail thread context has been broken a few times, so you should probably look at the llvmdev archives. It all starts here: http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-October/053961.html ] So I've decided to make a new attempt to fix this issue. We've discussed my patches with Eric and came up with the following idea: a) IsTargetWindows should be true for all the targets that execute on the Windows kernel, including Cygwin, MinGW and MSVC ABIs. However, "Windows 32-bit ABI" usually implies "MSVC 32-bit ABI", so it's Cygwin and MinGW (that are similar more similar to Itanium ABI than to MSVC ABI) that should be exceptions from the general Win32 handling code. That is, b) We should add a IsTargetWin32 which is true if the MSVC 32-bit ABI is used and false for Cygwin+MinGW. c) We should add CC_X86_Win32_C and CC_X86_Win32_ThisCall and use them only for MSVC 32-bit ABI. d) Cygwin and MinGW should use the CC_X86_32_C This way, Clang takes care of setting the SRet attribute wherever appropriate and LLVM takes care of putting such return values onto stack in the Win32/MSVC32 ABI. What do you think about such a proposal? One more data point: the ABI is wrong even in C! http://llvm.org/bugs/show_bug.cgi?id=15556 -- Timur
2013/3/20 Timur Iskhodzhanov <timurrrr at google.com>:> Anton, > > [+Eric, Nick, > the e-mail thread context has been broken a few times, so you should > probably look at the llvmdev archives. > It all starts here: > http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-October/053961.html ] > > So I've decided to make a new attempt to fix this issue. > > We've discussed my patches with Eric and came up with the following idea: > a) IsTargetWindows should be true for all the targets that execute on > the Windows kernel, including Cygwin, MinGW and MSVC ABIs. > > However, "Windows 32-bit ABI" usually implies "MSVC 32-bit ABI", so > it's Cygwin and MinGW (that are similar more similar to Itanium ABI > than to MSVC ABI) that should be exceptions from the general Win32 > handling code. > > That is, > b) We should add a IsTargetWin32 which is true if the MSVC 32-bit ABI > is used and false for Cygwin+MinGW.FTR, there's already such a method but it is (mis?)used only in lib/Target/X86/X86FrameLowering.cpp for segmented stacks. Are segmented stacks actually used with MSVC or is it just the conditions there should use isTargetMingw() && !is64Bit() instead?> c) We should add CC_X86_Win32_C and CC_X86_Win32_ThisCall and use them > only for MSVC 32-bit ABI. > d) Cygwin and MinGW should use the CC_X86_32_C > > This way, Clang takes care of setting the SRet attribute wherever appropriate > and LLVM takes care of putting such return values onto stack in the > Win32/MSVC32 ABI. > > What do you think about such a proposal? > > One more data point: the ABI is wrong even in C! > http://llvm.org/bugs/show_bug.cgi?id=15556 > > -- > Timur
On Wed, Mar 20, 2013 at 5:21 PM, Timur Iskhodzhanov <timurrrr at google.com>wrote:> 2013/3/20 Timur Iskhodzhanov <timurrrr at google.com>: > > Anton, > > > > [+Eric, Nick, > > the e-mail thread context has been broken a few times, so you should > > probably look at the llvmdev archives. > > It all starts here: > > http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-October/053961.html ] > > > > So I've decided to make a new attempt to fix this issue. > > > > We've discussed my patches with Eric and came up with the following idea: > > a) IsTargetWindows should be true for all the targets that execute on > > the Windows kernel, including Cygwin, MinGW and MSVC ABIs. > > > > However, "Windows 32-bit ABI" usually implies "MSVC 32-bit ABI", so > > it's Cygwin and MinGW (that are similar more similar to Itanium ABI > > than to MSVC ABI) that should be exceptions from the general Win32 > > handling code. > > > > That is, > > b) We should add a IsTargetWin32 which is true if the MSVC 32-bit ABI > > is used and false for Cygwin+MinGW. > FTR, there's already such a method but it is (mis?)used only in > lib/Target/X86/X86FrameLowering.cpp for segmented stacks. > Are segmented stacks actually used with MSVC or is it just the > conditions there should use isTargetMingw() && !is64Bit() instead? > >cc'ing graydon about segmented stacks because I know rust uses them. -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130320/fec79a4d/attachment.html>
Hi Timur,> This way, Clang takes care of setting the SRet attribute wherever appropriate > and LLVM takes care of putting such return values onto stack in the > Win32/MSVC32 ABI. > > What do you think about such a proposal?It depends on what you're planning to do with sret. If you're planning to support C structs, then it's fine. But it's definitely not ok for C++ classes, it will be much better for frontend to expand everything into proper form depending on whether the class is small / not, and whether it has non-trivial ctor / dtor or not. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University