llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.94k stars 11.94k forks source link

Cannot build with -mavx512f at all #45425

Closed llvmbot closed 4 years ago

llvmbot commented 4 years ago
Bugzilla Link 46080
Resolution FIXED
Resolved on May 27, 2020 13:36
Version 9.0
OS MacOS X
Reporter LLVM Bugzilla Contributor
CC @topperc,@efriedma-quic,@RKSimon,@rotateright

Extended Description

In the LLVM coming with the newest XCode I cannot use -mavx512f (or any AVX512 set for that matter), because the compiler freezes otherwise - it ends up in some sort of deadlock and "compiles" forever. Recently I reported similar thing for Windows, where it was crashing instead and adding AVX512BW fixed it for now, but it doesn't seem to do the trick here.

llvmbot commented 4 years ago

Thanks for the info!

efriedma-quic commented 4 years ago

That's more of an Xcode question, but see https://stackoverflow.com/questions/23071024/how-do-i-make-xcode-use-an-alternative-version-of-clang

We aren't planning to make an LLVM 9 patch release, so closing this.

llvmbot commented 4 years ago

Well, I'm not sure how to understand that. I assume that clang in XCode is quite old then, correct? Is it possible to install the new one then?

topperc commented 4 years ago

The bug was introduced about 8 days before llvm 9 branched from trunk in 138328e45cdfaff58fdbf643580563f9775e5d25

It went unnoticed til late September when it was fixed here. About 4 days after 9.0.0 was released. I don't think there were ever any discussions about porting it to 9.0.1 which seems like a mistake in hindsight. Not that I can tell if xcode is even using 9.0.1.

commit 5e26064c40617f2d6a1714e8c439e752888a922f Author: Craig Topper craig.topper@intel.com Date: Mon Sep 23 05:35:20 2019 +0000

[X86] Remove SETEQ/SETNE canonicalization code from LowerIntVSETCC_AVX512 to prevent an infinite loop.

The attached test case would previous infinite loop after
r365711.

I'm going to move this to X86ISelDAGToDAG.cpp to get the setcc
to match VPTEST in 32-bit mode in a follow up commit.

llvm-svn: 372543
llvmbot commented 4 years ago

I actually partly expected this to be Apple's fault as usual :). Is it possible to use LLVM 10 with the newest XCode? I downloaded it, but didn't see any installation instructions, so I got scared :). Everything is too fragile on that system...

topperc commented 4 years ago

I was able to reproduce the issue using xcode. But I can't attach lldb due to System Integrity Protection. It does not reproduce on trunk. It does not reproduce on 10.0.0. Some attempts at sleuthing out the baseline for xcode lead me to believe that xcode is based on llvm 9 or earlier.

llvmbot commented 4 years ago

Here it is: http://www.meldaproduction.com/temp/mlibraryAVX512.cpp.zip

topperc commented 4 years ago

I think you just need to add "-E" to your command line in place of "-c" and give a new filename for -o.

llvmbot commented 4 years ago

I could get you a preprocessed version if you tell me how exactly?

topperc commented 4 years ago

Are you able to provide your source?

llvmbot commented 4 years ago

Hmmm, ok, sorry, I assumed compiler-rt is "compiler runtime" :), really didn't see anything better to report a bug in the compiler itself.

topperc commented 4 years ago

I’m confused. You filed the bug against compiler-rt which is a library in llvm used to provided some math routines and support for sanitizers. So I thought you had trouble compiling that library.

But your issue is with compiling a particular source file not part of llvm?

llvmbot commented 4 years ago

That's the CPP I'm building. I didn't try yours if that's what you are asking. I can though if you send it to me.

topperc commented 4 years ago

What is mlibraryAVX512.cpp?

llvmbot commented 4 years ago

This is somewhat stripped command line:

clang++ -fno-rtti -arch x86_64 -m64 "-D MARCHITECTURE_AVX512" -mavx512f -mavx512bw -fPIC -shared -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -c -framework CoreFoundation -fexceptions -fvisibility=hidden -fpascal-strings -fasm-blocks -stdlib=libc++ -mfpmath=sse -ffast-math -fno-math-errno -Wno-trigraphs -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-non-virtual-dtor -Wno-delete-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wformat -Wno-missing-braces -Wparentheses -Wno-switch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-variable -Wno-unused-value -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-sign-compare -Wshorten-64-to-32 -Wno-newline-eof -Wno-deprecated-declarations -Winvalid-offsetof -Wno-conversion -Wno-sign-conversion -Wno-comment -Wno-tautological-compare -Wno-constant-logical-operand -Wno-deprecated-writable-strings -Wno-c++11-extensions -Wno-unnamed-type-template-args -Wno-null-dereference -Wno-array-bounds -Wno-local-type-template-args -Wno-nonportable-include-path -Wno-null-dereference -Wno-array-bounds -Wno-ignored-attributes -Wno-gcc-compat -Wno-unused-command-line-argument -Wno-duplicate-decl-specifier -Wno-gcc-compat -Wno-#pragma-messages -Wno-expansion-to-defined -Os -O3 -fdata-sections -ffunction-sections -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -mmacosx-version-min=10.7 -x c++ -std=gnu++17 mlibraryAVX512.cpp -o !temp/mlibraryAVX512.o

"clang --version" reports Apple clang version 11.0.3 (clang-1103.0.32.62)

topperc commented 4 years ago

Do you know which file its hanging on or have any instructions to reproduce?

I've tried the following and both built successfully for me.

cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" -DCMAKE_CXX_FLAGS="-mavx512f" -DCMAKE_C_FLAGS="-mavx512f" ninja compiler-rt

cmake -G Ninja ../llvm -DLLVM_ENABLE_PROJECTS="clang;compiler-rt" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-mavx512f" -DCMAKE_C_FLAGS="-mavx512f" ninja compiler-rt

llvmbot commented 4 years ago

Correct. On Windows it was crashing, from the log it seems it has been fixed, but since 10.1 is not yet released, I cannot confirm. On OSX it is hanging and since adding the AVX512BW option, which fixes the Windows behaviour, doesn't help, it's probably a different bug.

topperc commented 4 years ago

I see this bug is filed against compiler-rt. Are you saying you get hangs when trying to compile compiler-rt with -mavx512?