https://bugs.llvm.org/show_bug.cgi?id=43334

            Bug ID: 43334
           Summary: unexpected failure for -mno-sse2
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: X86
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected],
                    [email protected]
            Blocks: 4068

Consider:

$ cat foo.c
// double __floatunsidf (unsigned int i)
double foo(unsigned int i) {
    return (double) i;
}

$ clang -O2 -mno-sse2 foo.c
error: SSE2 register return with SSE2 disabled
    return (double) i;

    ^
$ gcc -O2 -mno-sse2 foo.c && llvm-objdump -d foo.o
foo:
  movl %edi, %edi
  movq %rdi, -8(%rsp)
  fildq -8(%rsp)
  fstpl -8(%rsp)
  movlps -8(%rsp), %xmm0
  ret

Adding -mno-80387 to clang seems to then complicate things further: clang
generates:

foo: # @foo
  pushq %rax
  callq __floatunsidf
  popq %rcx
  retq

This is important because:
1. the kernel builds with -mno-see2 -mno-80387 (and a few other related but
less relevant flags:
https://github.com/ClangBuiltLinux/linux/blob/52a5525214d0d612160154d902956eca0558b7c0/arch/x86/Makefile#L61-L62)
since saving/restoring fp register state gets complicated/expensive for all
registers added via ISA extensions).
2. the kernel does not define soft float routines like __floatunsidf. 
-mhard-float and -ffreestanding don't prevent clang from generating references
to these soft float routines.


Referenced Bugs:

https://bugs.llvm.org/show_bug.cgi?id=4068
[Bug 4068] [Meta] Compiling the Linux kernel with clang
-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to