Stefan Kanthak via llvm-dev
2018-Nov-30 16:31 UTC
[llvm-dev] (Question regarding the) incomplete "builtins library" of "Compiler-RT"
Hi @ll, compiler-rt implements (for example) the MSVC (really Windows) specific routines compiler-rt/lib/builtins/i386/chkstk.S and compiler-rt/lib/builtins/x86_64/chkstk.S as __chkstk_ms() See <http://msdn.microsoft.com/en-us/library/ms648426.aspx> Is there any special reason why compiler-rt doesn't implement other MSVC specific functions (alias builtins or "compiler intrinsics") for which clang/LLVM but generates calls? See <https://godbolt.org/z/ZsHmaf> for example * unsigned 64-bit integer operations: _aulldiv(), _aulldvrm(), _aullrem(), _aullshr()? See <https://msdn.microsoft.com/en-us/library/mt703294.aspx> * signed 64-bit integer operations: _alldiv(), _alldvrm(), _allrem(), _allshl(), _allshr(), _allmul()? See <https://msdn.microsoft.com/en-us/library/ms648425.aspx> For the following I'm not sure whether LLVM/clang calls them: * trigonometric and transcendental floating-point operations: _CIacos(), _CIasin(), _CIatan(), _CIatan2(), _CIcos(), _CIcosh(), _CIexp(), _CIfmod(), _CIlog(), _CIlog10(), _CIpow(), _CIsin(), _CIsinh(), _CIsqrt(), _CItan(), _CItanh()? See <https://msdn.microsoft.com/en-us/library/ff770582.aspx>, <https://msdn.microsoft.com/en-us/library/ff770581.aspx>, <https://msdn.microsoft.com/en-us/library/ff770589.aspx>, <https://msdn.microsoft.com/en-us/library/ff770600.aspx>, <https://msdn.microsoft.com/en-us/library/ff770591.aspx>, <https://msdn.microsoft.com/en-us/library/ff770580.aspx>, <https://msdn.microsoft.com/en-us/library/ff770578.aspx>, <https://msdn.microsoft.com/en-us/library/ff770583.aspx>, <https://msdn.microsoft.com/en-us/library/ff770597.aspx>, <https://msdn.microsoft.com/en-us/library/ff770588.aspx>, <https://msdn.microsoft.com/en-us/library/ff770595.aspx> regards Stefan Kanthak PS: Howard Hinnant, (one of) the original author of the builtins library, is still listed in compiler-rt/CODE_OWNERS.TXT, despite having left this project about TEN years ago! To quote himself: | I haven't worked on compiler_rt in any way for at least a decade. | Sorry for your poor experience working on this open source project.
Friedman, Eli via llvm-dev
2018-Nov-30 19:36 UTC
[llvm-dev] (Question regarding the) incomplete "builtins library" of "Compiler-RT"
On 11/30/2018 8:31 AM, Stefan Kanthak via llvm-dev wrote:> Hi @ll, > > compiler-rt implements (for example) the MSVC (really Windows) > specific routines compiler-rt/lib/builtins/i386/chkstk.S and > compiler-rt/lib/builtins/x86_64/chkstk.S as __chkstk_ms() > See <http://msdn.microsoft.com/en-us/library/ms648426.aspx> > > Is there any special reason why compiler-rt doesn't implement > other MSVC specific functions (alias builtins or "compiler > intrinsics") for which clang/LLVM but generates calls?There are two "Windows" targets supported by LLVM: one using the MinGW runtime, and the other using the MSVC runtime. If you're targeting the MSVC runtime, it provides _aulldiv and friends; if you're targeting MinGW, LLVM won't refer to those routines. So I can't see a scenario where we would need those routines in compiler-rt. -Eli -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Stefan Kanthak via llvm-dev
2018-Nov-30 21:05 UTC
[llvm-dev] (Question regarding the) incomplete "builtins library" of "Compiler-RT"
"Friedman, Eli" <efriedma at codeaurora.org> wrote:> On 11/30/2018 8:31 AM, Stefan Kanthak via llvm-dev wrote: >> Hi @ll, >> >> compiler-rt implements (for example) the MSVC (really Windows) >> specific routines compiler-rt/lib/builtins/i386/chkstk.S and >> compiler-rt/lib/builtins/x86_64/chkstk.S as __chkstk_ms() >> See <http://msdn.microsoft.com/en-us/library/ms648426.aspx> >> >> Is there any special reason why compiler-rt doesn't implement >> other MSVC specific functions (alias builtins or "compiler >> intrinsics") for which clang/LLVM but generates calls? > > There are two "Windows" targets supported by LLVM: one using the MinGW > runtime, and the other using the MSVC runtime. If you're targeting the > MSVC runtime, it provides _aulldiv and friends; if you're targeting > MinGW, LLVM won't refer to those routines. So I can't see a scenario > where we would need those routines in compiler-rt.What's the purpose of __chkstk_ms() then, implemented in compiler-rt? 1. LLVM does NOT create calls to __chkstk_ms(); 2. both the MSVC and the MinGW runtime provide their own __chkstk() as well as their own __alloca() routines. --- llvm.c --- int main(int argc) { int stack[1111]; return _alloca(argc); } --- EOF --- Compiled with "-target i386-mingw" this generates the following code (see <https://godbolt.org/z/yPk4Jo>): _main: # @main push ebp mov ebp, esp mov eax, 4456 call __alloca mov eax, dword ptr [ebp + 8] mov dword ptr [ebp - 4452], eax # 4-byte Spill call ___main mov dword ptr [ebp - 4], 0 mov eax, dword ptr [ebp + 8] mov dword ptr [esp], eax call __alloca add esp, 4456 pop ebp ret Compiled with "-target i386-win32" this generates the following code (see <https://godbolt.org/z/Hc8jaL>): _main: # @main push ebp mov ebp, esp push esi and esp, -16 mov eax, 4480 call __chkstk mov esi, esp mov eax, dword ptr [ebp + 8] mov dword ptr [esi + 4464], 0 mov ecx, dword ptr [ebp + 8] add ecx, 3 and ecx, -4 mov dword ptr [esi + 12], eax # 4-byte Spill mov eax, ecx call __chkstk mov ecx, esp and ecx, -16 mov esp, ecx mov eax, ecx lea esp, [ebp - 4] pop esi pop ebp ret
Stefan Kanthak via llvm-dev
2018-Dec-01 17:02 UTC
[llvm-dev] (Question regarding the) incomplete "builtins library" of "Compiler-RT"
"Eli Friedman" <efriedma at codeaurora.org> wrote:> On 11/30/2018 8:31 AM, Stefan Kanthak via llvm-dev wrote: >> Hi @ll, >> >> compiler-rt implements (for example) the MSVC (really Windows) >> specific routines compiler-rt/lib/builtins/i386/chkstk.S and >> compiler-rt/lib/builtins/x86_64/chkstk.S as __chkstk_ms() >> See <http://msdn.microsoft.com/en-us/library/ms648426.aspx> >> >> Is there any special reason why compiler-rt doesn't implement >> other MSVC specific functions (alias builtins or "compiler >> intrinsics") for which clang/LLVM but generates calls? > > There are two "Windows" targets supported by LLVM: one using the MinGW > runtime, and the other using the MSVC runtime. If you're targeting the > MSVC runtime, it provides _aulldiv and friends; if you're targeting > MinGW, LLVM won't refer to those routines. So I can't see a scenario > where we would need those routines in compiler-rt.According to <https://compiler-rt.llvm.org/index.html> | builtins - a simple library that provides an implementation of | the low-level target-specific hooks required by code generation | and other runtime components. ... these routines SHOULD but be part of the builtins library. EITHER document the implementation, OR implement according to the documentation, PLEASE! tertium datur: document the exceptions from the general rule cited above. regards Stefan Kanthak PS: if you are interested, I can provide an implementation of _aulldiv and friends, which I derived from __divdi3 etc. They are about 3-4 times faster than the routines from the MSVC runtime.
Seemingly Similar Threads
- (Question regarding the) incomplete "builtins library" of "Compiler-RT"
- BUGS n code generated for target i386 compiling __bswapdi3, and for target x86-64 compiling __bswapsi2()
- BUGS n code generated for target i386 compiling __bswapdi3, and for target x86-64 compiling __bswapsi2()
- The builtins library of compiler-rt is a performance HOG^WKILLER
- [LLVMdev] Assertion fails resolving R_X86_64_PC32 relocation