Bug 211563

Summary: CPUTYPE=skylake build broken
Product: Base System Reporter: Nikolai Lifanov <lifanov>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: dim
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
error output
none
ns_name-287f0a.c
none
ns_name-287f0a.sh
none
cpuid none

Description Nikolai Lifanov 2016-08-04 01:08:46 UTC
Created attachment 173257 [details]
error output

I just got a Skylake system and build with CPUTYPE=skylake is broken. I can build with CPUTYPE=haswell or without CPUTYPE just fine. See attachment for build error.
Comment 1 Nikolai Lifanov 2016-08-04 01:13:26 UTC
Created attachment 173258 [details]
ns_name-287f0a.c
Comment 2 Nikolai Lifanov 2016-08-04 01:14:23 UTC
Created attachment 173259 [details]
ns_name-287f0a.sh
Comment 3 Dimitry Andric freebsd_committer freebsd_triage 2016-08-11 21:22:01 UTC
I can reproduce the assertion.  It works in more recent clang trunk, so I will figure out where it got fixed.
Comment 4 Dimitry Andric freebsd_committer freebsd_triage 2016-08-13 14:36:16 UTC
Hm, so after hand merging llvm r263417 [1], which fixes your original test case, I tried a buildworld with CPUTYPE=skylake, and I got another crash:

fatal error: error in backend: Cannot select: t24: i32 = X86ISD::CMP t48, t51
  t48: i1 = truncate t47
    t47: i8 = and t32, t35
      t32: i8 = X86ISD::SETCC Constant:i8<4>, t30
        t31: i8 = Constant<4>
        t30: i32 = X86ISD::CMP t4, Constant:i8<0>
          t4: i8 = AssertZext t2, ValueType:ch:i1
            t2: i8,ch = CopyFromReg t0, Register:i8 %vreg375
              t1: i8 = Register %vreg375
          t5: i8 = Constant<0>
      t35: i8 = X86ISD::SETCC Constant:i8<4>, t34:1
        t31: i8 = Constant<4>
        t34: i32,i32 = X86ISD::SUB t9, Constant:i32<101>
          t9: i32,ch = CopyFromReg t0, Register:i32 %vreg378
            t8: i32 = Register %vreg378
          t11: i32 = Constant<101>
  t51: i1 = truncate t50
    t50: i8 = or t32, t38
      t32: i8 = X86ISD::SETCC Constant:i8<4>, t30
        t31: i8 = Constant<4>
        t30: i32 = X86ISD::CMP t4, Constant:i8<0>
          t4: i8 = AssertZext t2, ValueType:ch:i1
            t2: i8,ch = CopyFromReg t0, Register:i8 %vreg375
              t1: i8 = Register %vreg375
          t5: i8 = Constant<0>
      t38: i8 = X86ISD::SETCC Constant:i8<9>, t37:1
        t25: i8 = Constant<9>
        t37: i32,i32 = X86ISD::SUB t9, Constant:i32<112>
          t9: i32,ch = CopyFromReg t0, Register:i32 %vreg378
            t8: i32 = Register %vreg378
          t14: i32 = Constant<112>
In function: __vfwscanf

So all is not well yet for -march=skylake.  I will investigate further, but maybe complete Skylake support is something that has to wait for clang 3.9.0.

[1] http://llvm.org/viewvc/llvm-project?view=revision&revision=263417
Comment 5 Nikolai Lifanov 2016-08-13 17:19:40 UTC
Thanks for looking into it! I don't think it's a problem to wait for 3.9.0 if it has full Skylake support.
Comment 6 Dimitry Andric freebsd_committer freebsd_triage 2016-08-15 16:11:47 UTC
I have taken a look, and it would require many patches to get all the Skylake stuff to work correctly.  Every time I applied an upstream patch, some other program during buildworld would cause an assertion or another problem.

I think it is better to consider CPUTYPE=skylake broken, until we can import 3.9.0.  So let's keep this bug open for the time being.
Comment 7 Nikolai Lifanov 2016-11-27 15:28:22 UTC
This compiles with clang/llvm 3.9.0, but I can't chroot or jexec -l into the result with "Illegal instruction (core dumped)". No core files are produced.
I'm pretty sure that my CPU is gen 6. I'm attaching the cpuid output.
Comment 8 Nikolai Lifanov 2016-11-27 15:28:43 UTC
Created attachment 177450 [details]
cpuid
Comment 9 Nikolai Lifanov 2016-11-27 15:35:17 UTC
Never mind, I don't think this one is Skylake. This can be closed now.
Comment 10 Mark Linimon freebsd_committer freebsd_triage 2016-11-27 21:11:24 UTC
Closed at submitter's request.