Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang ICE on SVE intrinsic #183600

Closed
4 tasks done
SadiinsoSnowfall opened this issue Sep 5, 2024 · 3 comments
Closed
4 tasks done

Clang ICE on SVE intrinsic #183600

SadiinsoSnowfall opened this issue Sep 5, 2024 · 3 comments
Labels
upstream issue An upstream issue report is needed

Comments

@SadiinsoSnowfall
Copy link

brew gist-logs <formula> link OR brew config AND brew doctor output

HOMEBREW_VERSION: 4.3.19
ORIGIN: https://github.com/Homebrew/brew
HEAD: 1f9bd2de89883ec9a59db3eab0f5475bce06d5bc
Last commit: 3 days ago
Core tap JSON: 05 Sep 18:08 UTC
Core cask tap JSON: 05 Sep 18:08 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 16
Homebrew Ruby: 3.3.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.4_1/bin/ruby
CPU: 16-core 64-bit arm_palma
Clang: 16.0.0 build 1600
Git: 2.39.5 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.1-arm64
CLT: 16.0.0.0.1.1723780521
Xcode: N/A
Rosetta 2: false

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

Compile the following code using the clang I got from homebrew:

#include <arm_sve.h>

void test(svbool_t t, svint32_t a, svint32_t b) {
    svsub_s32_m(t, a, b);
}

The compiler output told me to report the bug here.

What happened (include all command output)?

The compiler ICE'd:

PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/homebrew/Cellar/llvm/18.1.8/bin/clang-18 -cc1 -triple arm64-apple-macosx15.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -funwind-tables=1 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -fbuiltin-headers-in-system-modules -fdefine-target-os-macros -target-cpu apple-m1 -target-feature +zcm -target-feature +zcz -target-feature +v8a -target-feature +fp-armv8 -target-feature +fullfp16 -target-feature +neon -target-feature +sve -target-abi darwinpcs -mvscale-max=1 -mvscale-min=1 -debugger-tuning=lldb -fdebug-compilation-dir=/tmp -target-linker-version 1053.12 -fcoverage-compilation-dir=/tmp -resource-dir /opt/homebrew/Cellar/llvm/18.1.8/lib/clang/18 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -internal-isystem /opt/homebrew/opt/llvm/bin/../include/c++/v1 -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/local/include -internal-isystem /opt/homebrew/Cellar/llvm/18.1.8/lib/clang/18/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include -fdeprecated-macro -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcolor-diagnostics -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/_c/4w43161s72x8kd5w24cp7vlm0000gn/T/test-4b8a20.o -x c++ test.cpp
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 'test.cpp'.
4.	Running pass 'AArch64 Instruction Selection' on function '@_Z4testu10__SVBool_tu11__SVInt32_tS0_'
 #0 0x00000001188c5d60 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0x4695d60)
 #1 0x00000001188c6134 SignalHandler(int) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0x4696134)
 #2 0x000000018388c184 (/usr/lib/system/libsystem_platform.dylib+0x180484184)
 #3 0x00000001167c23b8 llvm::AArch64TargetLowering::LowerFormalArguments(llvm::SDValue, unsigned int, bool, llvm::SmallVectorImpl<llvm::ISD::InputArg> const&, llvm::SDLoc const&, llvm::SelectionDAG&, llvm::SmallVectorImpl<llvm::SDValue>&) const (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0x25923b8)
 #4 0x0000000114e3c648 llvm::SelectionDAGISel::LowerArguments(llvm::Function const&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0xc0c648)
 #5 0x0000000114ec7af8 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0xc97af8)
 #6 0x0000000114ec6578 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0xc96578)
 #7 0x0000000114889054 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0x659054)
 #8 0x00000001145440e4 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0x3140e4)
 #9 0x00000001145383ec llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libLLVM.dylib+0x3083ec)
#10 0x000000010816a0cc clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libclang-cpp.dylib+0x15960cc)
#11 0x000000010850f644 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libclang-cpp.dylib+0x193b644)
#12 0x0000000106ddf0f8 clang::ParseAST(clang::Sema&, bool, bool) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libclang-cpp.dylib+0x20b0f8)
#13 0x0000000108c70dd4 clang::FrontendAction::Execute() (/opt/homebrew/Cellar/llvm/18.1.8/lib/libclang-cpp.dylib+0x209cdd4)
#14 0x0000000108bf3ad4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libclang-cpp.dylib+0x201fad4)
#15 0x0000000108cc3c28 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/homebrew/Cellar/llvm/18.1.8/lib/libclang-cpp.dylib+0x20efc28)
#16 0x000000010216eb28 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/homebrew/Cellar/llvm/18.1.8/bin/clang-18+0x100006b28)
#17 0x000000010216d218 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/opt/homebrew/Cellar/llvm/18.1.8/bin/clang-18+0x100005218)
#18 0x000000010216bdac clang_main(int, char**, llvm::ToolContext const&) (/opt/homebrew/Cellar/llvm/18.1.8/bin/clang-18+0x100003dac)
#19 0x0000000102178e38 main (/opt/homebrew/Cellar/llvm/18.1.8/bin/clang-18+0x100010e38)
#20 0x00000001834d4274
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Homebrew clang version 18.1.8
Target: arm64-apple-darwin24.1.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin

What did you expect to happen?

The compiler not to crash.

Step-by-step reproduction instructions (by running brew commands)

brew install llvm

Put the given code in a .cpp file (for example, test.cpp).

clang -march=armv8-a+sve -msve-vector-bits=128 test.cpp
@SadiinsoSnowfall SadiinsoSnowfall added the bug Reproducible Homebrew/homebrew-core bug label Sep 5, 2024
@Bo98
Copy link
Member

Bo98 commented Sep 5, 2024

Checked Apple Clang and the same happens there so doesn't seem to be specific to Homebrew LLVM.

Apple CPUs do not support SVE AFAIK. I suspect it doesn't crash with a Linux -target. Technically it probably shouldn't ICE at all but I imagine it's not a priority upstream to fix that.

@SadiinsoSnowfall
Copy link
Author

SadiinsoSnowfall commented Sep 5, 2024

Apple CPUs do not support SVE AFAIK.

Indeed, but cross-compiling should (and does) work. I cross-compile for SVE daily on my mac, I just encountered this specific bug today and reduced it to this short snippet.

Do you think it would be best that I report the issue to LLVM directly ?

@fxcoudert
Copy link
Member

Given that it happens with at least two different versions of clang, ours and Apple's, it definitely seems like an upstream bug and not a Homebrew-specific issue:

% clang -march=armv8-a+sve -msve-vector-bits=128 a.c 
clang: error: unable to execute command: Trace/BPT trap: 5
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T/a-73f5bd.c
clang: note: diagnostic msg: /var/folders/h8/9hx_fyj91053ksgdzb2w03vw0000gp/T/a-73f5bd.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/fx/Library/Logs/DiagnosticReports/clang_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg: 

********************

It's best to report this to Apple, or to llvm directly (or both).

@fxcoudert fxcoudert added the upstream issue An upstream issue report is needed label Sep 6, 2024
@carlocab carlocab removed the bug Reproducible Homebrew/homebrew-core bug label Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream issue An upstream issue report is needed
Projects
None yet
Development

No branches or pull requests

4 participants