Summary: | SSE2 instructions emited in compiler-rt on AMD Sempron 3000+ | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Bertrand Petit <bsdpr> | ||||
Component: | bin | Assignee: | Dimitry Andric <dim> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Some People | CC: | arrowd, bsdpr, dim, emaste, kib, theraven | ||||
Priority: | --- | Keywords: | patch | ||||
Version: | 10.3-STABLE | Flags: | dim:
mfc-stable11+
dim: mfc-stable10+ dim: mfc-stable9+ |
||||
Hardware: | i386 | ||||||
OS: | Any | ||||||
Attachments: |
|
Description
Bertrand Petit
2017-08-23 04:02:26 UTC
i386 system libraries must not access %xmm registers at all. At least not without checking for CPUID support first, and then checking for SSE and SSE2 features as needed. lib32 libraries built on amd64 host are somewhat different. We compile them with ppro arch set, which at least allows cmovX instructions, and this environment also can assume that SSE2 is present, since amd64 requires CPU with SSE2 (there is no long-mode capable CPU not supporting SSE2). For i386, this is definitely bug. To be clear, this is not a compiler bug: floatdidf comes from an assembly routine in compiler-rt/lib/builtins/i386/floatdidf.S. I see there is a generic C version in compiler-rt/lib/builtins/floatdidf.c that we might be able to use, although preferably using the optimized one (via ifunc or such) when possible. Hm, there are more .S files under contrib/compiler-rt/lib/builtins/i386 which unconditionally use SSE, although for instance ashldi3.S has an explicit test for __SSE2__, and if that isn't defined, it uses GPRs. I think this might be worth an upstream bug. I suspect it will see little priority upstream. SSE2 is supported by most post-2003 CPUs (and some post-2001 CPUs), and none of the companies that fund most LLVM development care about processors more than a decade old. If we still care about these targets, we should probably use the C versions for i386 and the asm versions only for lib32 on amd64. Created attachment 185862 [details]
Patch reverting to C implementations on i386
This patch, on i386, reverts to the C implementations of the functions affected by the unguarded use of SSE2 instructions in the assembler implementations.
Here is a naïve patch that use the C implementation of the affected functions. After buildworld and installworld: $ objdump -d /usr/lib/libcompiler_rt.a | grep -c xmm 0 A commit references this bug: Author: dim Date: Tue Aug 29 21:45:00 UTC 2017 New revision: 323001 URL: https://svnweb.freebsd.org/changeset/base/323001 Log: In compiler-rt, a few assembler implementations for i386 floating point conversion functions use SSE2 instructions, but these are not guarded by #ifdef __SSE2__, and there is no implementation using general purpose registers. For these functions, use the generic C variants instead, otherwise they will cause SIGILL on older processors. Reported by: bsdpr@phoe.frmug.org PR: 221733 MFC after: 1 week Changes: head/lib/libcompiler_rt/Makefile.inc A commit references this bug: Author: dim Date: Wed Aug 30 07:05:29 UTC 2017 New revision: 323014 URL: https://svnweb.freebsd.org/changeset/base/323014 Log: Follow-up to r323001: if the actually selected CPUTYPE is capable of SSE2 instructions, we can use them. Suggested by: jkim PR: 221733 MFC after: 1 week X-MFC-With: r323001 Changes: head/lib/libcompiler_rt/Makefile.inc A commit references this bug: Author: dim Date: Tue Sep 5 16:59:20 UTC 2017 New revision: 323187 URL: https://svnweb.freebsd.org/changeset/base/323187 Log: MFC r323001: In compiler-rt, a few assembler implementations for i386 floating point conversion functions use SSE2 instructions, but these are not guarded by #ifdef __SSE2__, and there is no implementation using general purpose registers. For these functions, use the generic C variants instead, otherwise they will cause SIGILL on older processors. Reported by: bsdpr@phoe.frmug.org PR: 221733 Changes: _U stable/11/ stable/11/lib/libcompiler_rt/Makefile.inc A commit references this bug: Author: dim Date: Tue Sep 5 17:12:12 UTC 2017 New revision: 323188 URL: https://svnweb.freebsd.org/changeset/base/323188 Log: MFC r323014: Follow-up to r323001: if the actually selected CPUTYPE is capable of SSE2 instructions, we can use them. Suggested by: jkim PR: 221733 Changes: _U stable/11/ stable/11/lib/libcompiler_rt/Makefile.inc A commit references this bug: Author: dim Date: Tue Sep 5 17:32:15 UTC 2017 New revision: 323189 URL: https://svnweb.freebsd.org/changeset/base/323189 Log: MFC r323001: In compiler-rt, a few assembler implementations for i386 floating point conversion functions use SSE2 instructions, but these are not guarded by #ifdef __SSE2__, and there is no implementation using general purpose registers. For these functions, use the generic C variants instead, otherwise they will cause SIGILL on older processors. Approved by: re (kib) Reported by: bsdpr@phoe.frmug.org PR: 221733 MFC r323014: Follow-up to r323001: if the actually selected CPUTYPE is capable of SSE2 instructions, we can use them. Suggested by: jkim PR: 221733 Changes: _U stable/10/ stable/10/lib/libcompiler_rt/Makefile A commit references this bug: Author: dim Date: Tue Sep 5 17:32:15 UTC 2017 New revision: 323189 URL: https://svnweb.freebsd.org/changeset/base/323189 Log: MFC r323001: In compiler-rt, a few assembler implementations for i386 floating point conversion functions use SSE2 instructions, but these are not guarded by #ifdef __SSE2__, and there is no implementation using general purpose registers. For these functions, use the generic C variants instead, otherwise they will cause SIGILL on older processors. Approved by: re (kib) Reported by: bsdpr@phoe.frmug.org PR: 221733 MFC r323014: Follow-up to r323001: if the actually selected CPUTYPE is capable of SSE2 instructions, we can use them. Suggested by: jkim PR: 221733 Changes: _U stable/10/ stable/10/lib/libcompiler_rt/Makefile A commit references this bug: Author: dim Date: Tue Sep 5 17:35:34 UTC 2017 New revision: 323190 URL: https://svnweb.freebsd.org/changeset/base/323190 Log: MFC r323001: In compiler-rt, a few assembler implementations for i386 floating point conversion functions use SSE2 instructions, but these are not guarded by #ifdef __SSE2__, and there is no implementation using general purpose registers. For these functions, use the generic C variants instead, otherwise they will cause SIGILL on older processors. Reported by: bsdpr@phoe.frmug.org PR: 221733 MFC r323014: Follow-up to r323001: if the actually selected CPUTYPE is capable of SSE2 instructions, we can use them. Suggested by: jkim Changes: _U stable/9/ _U stable/9/lib/ _U stable/9/lib/libcompiler_rt/ stable/9/lib/libcompiler_rt/Makefile |