Bug 240759

Summary: devel/llvm90: base clang 9 crashes with CFLAGS+=-mavx2 or CPUTYPE=haswell
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Individual Port(s)Assignee: Brooks Davis <brooks>
Status: Closed FIXED    
Severity: Affects Only Me CC: dim
Priority: --- Keywords: needs-qa
Version: LatestFlags: bugzilla: maintainer-feedback? (brooks)
Hardware: Any   
OS: Any   
See Also: https://bugs.llvm.org/show_bug.cgi?id=43402
Bug Depends on:    
Bug Blocks: 240629    
Attachments:
Description Flags
command line args (for clang 9)
none
tools/llvm-xray/xray-account.cpp (compressed, preprocessed) none

Description Jan Beich freebsd_committer freebsd_triage 2019-09-22 23:12:33 UTC
Created attachment 207729 [details]
command line args (for clang 9)

$ echo 'CPUTYPE?=haswell' >>${__MAKE_CONF:-/etc/make.conf}
$ make
[...]
FAILED: tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-account.cpp.o 
/usr/bin/c++  -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools/llvm-xray -I/wrkdirs/usr/ports/devel/llvm90/work/llvm-9.0.0.src/tools/llvm-xray -Iinclude -I/wrkdirs/usr/ports/devel/llvm90/work/llvm-9.0.0.src/include -O2 -pipe -march=haswell -DNDEBUG -fstack-protector-strong -isystem /usr/local/include  -DNDEBUG -isystem /usr/local/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -O2 -pipe -march=haswell -DNDEBUG -fstack-protector-strong -isystem /usr/local/include  -DNDEBUG -isystem /usr/local/include    -fno-exceptions -MD -MT tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-account.cpp.o -MF tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-account.cpp.o.d -o tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-account.cpp.o -c /wrkdirs/usr/ports/devel/llvm90/work/llvm-9.0.0.src/tools/llvm-xray/xray-account.cpp
Assertion failed: ((HOp.getValueType() == MVT::v2f64 || HOp.getValueType() == MVT::v4f64) && HOp.getValueType() == VT && "Unexpected type for h-op"), function foldShuffleOfHorizOp, file /poudriere/jails/head-i386/usr/src/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp, line 33661.
Stack dump:
0.      Program arguments: /usr/bin/c++ -cc1 -triple i386-unknown-freebsd13.0 -emit-obj -disable-free -main-file-name xray-account.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu haswell -dwarf-column-info -debugger-tuning=gdb -ffunction-sections -fdata-sections -coverage-notes-file /wrkdirs/usr/ports/devel/llvm90/work/.build/tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-account.cpp.gcno -resource-dir /usr/lib/clang/9.0.0 -dependency-file tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-account.cpp.o.d -sys-header-deps -MT tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-account.cpp.o -isystem /usr/local/include -isystem /usr/local/include -isystem /usr/local/include -isystem /usr/local/include -D _FILE_OFFSET_BITS=64 -D _LARGEFILE_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/llvm-xray -I /wrkdirs/usr/ports/devel/llvm90/work/llvm-9.0.0.src/tools/llvm-xray -I include -I /wrkdirs/usr/ports/devel/llvm90/work/llvm-9.0.0.src/include -D NDEBUG -D NDEBUG -D NDEBUG -D NDEBUG -internal-isystem /usr/include/c++/v1 -O2 -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -pedantic -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /wrkdirs/usr/ports/devel/llvm90/work/.build -ferror-limit 19 -fmessage-length 114 -fvisibility-inlines-hidden -stack-protector 2 -fobjc-runtime=gnustep -fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -o tools/llvm-xray/CMakeFiles/llvm-xray.dir/xray-account.cpp.o -x c++ /wrkdirs/usr/ports/devel/llvm90/work/llvm-9.0.0.src/tools/llvm-xray/xray-account.cpp
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '/wrkdirs/usr/ports/devel/llvm90/work/llvm-9.0.0.src/tools/llvm-xray/xray-account.cpp'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@_ZNK4llvm4xray17LatencyAccountant17exportStatsAsTextERNS_11raw_ostreamERKNS0_14XRayFileHeaderE'
c++: error: unable to execute command: Abort trap
c++: error: clang frontend command failed due to signal (use -v to see invocation)
FreeBSD clang version 9.0.0 (tags/RELEASE_900/final 372316) (based on LLVM 9.0.0)
Target: i386-unknown-freebsd13.0
Thread model: posix
InstalledDir: /usr/bin
Comment 1 Jan Beich freebsd_committer freebsd_triage 2019-09-22 23:13:21 UTC
Created attachment 207730 [details]
tools/llvm-xray/xray-account.cpp (compressed, preprocessed)
Comment 2 Jan Beich freebsd_committer freebsd_triage 2019-09-22 23:21:54 UTC
My jail is from base r352539.
Comment 3 commit-hook freebsd_committer freebsd_triage 2019-09-23 17:06:33 UTC
A commit references this bug:

Author: dim
Date: Mon Sep 23 17:05:47 UTC 2019
New revision: 352629
URL: https://svnweb.freebsd.org/changeset/base/352629

Log:
  Pull in r372606 from upstream llvm trunk (by Sanjay Patel):

    [x86] fix assert with horizontal math + broadcast of vector (PR43402)

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

  This should fix 'Assertion failed: ((HOp.getValueType() == MVT::v2f64 ||
  HOp.getValueType() == MVT::v4f64) && HOp.getValueType() == VT &&
  "Unexpected type for h-op"), function foldShuffleOfHorizOp, file
  contrib/llvm/lib/Target/X86/X86ISelLowering.cpp, line 33661' when
  building the devel/llvm90 port with CPUTYPE=haswell.

  PR:		240759

Changes:
  projects/clang900-import/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp
  projects/clang900-import/contrib/llvm/lib/Target/X86/X86ISelLowering.h
Comment 4 commit-hook freebsd_committer freebsd_triage 2019-10-09 20:36:14 UTC
A commit references this bug:

Author: brooks
Date: Wed Oct  9 20:36:06 UTC 2019
New revision: 514194
URL: https://svnweb.freebsd.org/changeset/ports/514194

Log:
  Rollup of fixes since the 9.0.0 release.

  - Change the default -march for i386 from i486 to i586.  This avoids
    the need for libatomics and had been the defacto default for some
    time. [0]

  - Add -m(no)-spe to clang. (powerpc)

  - Deduce MIPS specific ELF header flags from `emulation`. (mips)

  - Fix a variety of assertions and compile/link errors including crashes
    with CPUTYPE=haswell. [1]

  - Switch back to https for downloads. [2]

  The new patches were initially committed to FreeBSD src by dim@.

  PR:		240918 [0], 240759 [1], 240870 [2]
  Reported by:	jbeich [0,1],  Miyashita Touka <imagin8r@protonmail.com> [2]

Changes:
  head/devel/llvm90/Makefile
  head/devel/llvm90/files/clang/patch-freebsd-r352030
  head/devel/llvm90/files/clang/patch-freebsd-r352539
  head/devel/llvm90/files/clang/patch-freebsd-r352586
  head/devel/llvm90/files/lld/
  head/devel/llvm90/files/lld/patch-freebsd-r352600
  head/devel/llvm90/files/patch-freebsd-r352318
  head/devel/llvm90/files/patch-freebsd-r352629
Comment 5 commit-hook freebsd_committer freebsd_triage 2019-10-28 21:04:50 UTC
A commit references this bug:

Author: brooks
Date: Mon Oct 28 21:04:18 UTC 2019
New revision: 515935
URL: https://svnweb.freebsd.org/changeset/ports/515935

Log:
  MFH: r513490 r514194 r515213

  Fix build with EXTRAS disabled.

  clangd is part of EXTRAS, not CLANG.

  PR:		240826
  Reported by:	rozhuk.im@gmail.com

  Rollup of fixes since the 9.0.0 release.

  - Change the default -march for i386 from i486 to i586.  This avoids
    the need for libatomics and had been the defacto default for some
    time. [0]

  - Add -m(no)-spe to clang. (powerpc)

  - Deduce MIPS specific ELF header flags from `emulation`. (mips)

  - Fix a variety of assertions and compile/link errors including crashes
    with CPUTYPE=haswell. [1]

  - Switch back to https for downloads. [2]

  The new patches were initially committed to FreeBSD src by dim@.

  PR:		240918 [0], 240759 [1], 240870 [2]
  Reported by:	jbeich [0,1],  Miyashita Touka <imagin8r@protonmail.com> [2]

  Fix build without CLANG enabled. [0]

  Fix LLD build where PREFIX != LOCALBASE. [1]

  powerpc64: add configure option to select ELFv2 ABI [2]

  In preparation for compiler+ABI change in PowerPC64, this change adds a
  configure option to select ELFv2 as default powerpc64 ABI when compiling
  llvm90.

  The new option automatically set when ELFv2 environment is detected
  (when PPC_ABI=ELFv2)

  PR:		241400 [1], 241410 [0]
  Submitted by:	Alfredo Dal'Ava J?nior [2]
  Differential Revision:	https://reviews.freebsd.org/D22100 [2]

  Approved by:	portmgr (blanket for build and reliability fixes)

Changes:
_U  branches/2019Q4/
  branches/2019Q4/devel/llvm90/Makefile
  branches/2019Q4/devel/llvm90/Makefile.COMMANDS
  branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352030
  branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352539
  branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352586
  branches/2019Q4/devel/llvm90/files/lld/
  branches/2019Q4/devel/llvm90/files/patch-freebsd-r352318
  branches/2019Q4/devel/llvm90/files/patch-freebsd-r352629
  branches/2019Q4/devel/llvm90/files/ppc64-elfv2/
  branches/2019Q4/devel/llvm90/pkg-plist