Skip to content

[clang] Using -mno-sse2 with 19.1.0 results in frontend command failure #118590

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

Closed
shinfd opened this issue Dec 4, 2024 · 4 comments
Closed

[clang] Using -mno-sse2 with 19.1.0 results in frontend command failure #118590

shinfd opened this issue Dec 4, 2024 · 4 comments
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] debuginfo duplicate Resolved as duplicate

Comments

@shinfd
Copy link

shinfd commented Dec 4, 2024

While investigating #118152 , I noticed that compiling below code with clang -mno-sse2 causes compiler to crash.

#include <cstdio>
#include <x86intrin.h>

void func(__m128 v) {
	float f[4]; _mm_store_ps(f, v);
	printf("%6.3f %6.3f %6.3f %6.3f", f[0], f[1], f[2], f[3]);
}

For some strange reason, modifying the whitespaces seem to change the outcome (details at the end). Please refer to the Compiler Explorer sample for the exact code: https://godbolt.org/z/3Y3xoefnG

The error log:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-19.1.0/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-14.2.0 -fcolor-diagnostics -fno-crash-diagnostics -mno-sse2 <source>
1.	<eof> parser at end of file
2.	Code generation
 #0 0x00000000036fdb08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x36fdb08)
 #1 0x00000000036fbc74 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x36fbc74)
 #2 0x0000000003647be8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007408ae242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00000000045a4d62 llvm::DwarfCompileUnit::getOrCreateContextDIE(llvm::DIScope const*) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x45a4d62)
 #5 0x00000000045a59b7 llvm::DwarfCompileUnit::getOrCreateImportedEntityDIE(llvm::DIImportedEntity const*) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x45a59b7)
 #6 0x000000000452c9df llvm::DwarfDebug::endModule() (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x452c9df)
 #7 0x00000000044f655d llvm::AsmPrinter::doFinalization(llvm::Module&) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x44f655d)
 #8 0x0000000003091d4d llvm::FPPassManager::doFinalization(llvm::Module&) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3091d4d)
 #9 0x000000000309e558 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x309e558)
#10 0x0000000003996531 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::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3996531)
#11 0x0000000003fce094 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3fce094)
#12 0x0000000005f1899c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x5f1899c)
#13 0x0000000003fce825 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3fce825)
#14 0x0000000004274201 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x4274201)
#15 0x00000000041f699b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x41f699b)
#16 0x000000000435a843 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x435a843)
#17 0x0000000000c874dc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0xc874dc)
#18 0x0000000000c8146d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#19 0x0000000004017309 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#20 0x0000000003648013 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3648013)
#21 0x0000000004017529 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#22 0x0000000003fdd947 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3fdd947)
#23 0x0000000003fde2fd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3fde2fd)
#24 0x0000000003fe7d4c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3fe7d4c)
#25 0x0000000000c847f1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0xc847f1)
#26 0x0000000000b5c2d4 main (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0xb5c2d4)
#27 0x00007408ae229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#28 0x00007408ae229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#29 0x0000000000c80f0e _start (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0xc80f0e)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139

Reproduces with trunk and 19.1.0. Not observed with 18 or earlier.

Starting from the Compiler Explorer sample, removing blank line between include and function made the code compile successfully. Trunk clang also compiles OK when all indentation tabs are replaced with whitespaces, but 19.1.0 still showed error.

@github-actions github-actions bot added the clang Clang issues not falling into any other category label Dec 4, 2024
@EugeneZelenko EugeneZelenko added debuginfo crash Prefer [crash-on-valid] or [crash-on-invalid] and removed clang Clang issues not falling into any other category labels Dec 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Dec 4, 2024

@llvm/issue-subscribers-debuginfo

Author: None (shinfd)

While investigating #118152 , I noticed that compiling below code with `clang -mno-sse2` causes compiler to crash.
#include &lt;cstdio&gt;
#include &lt;x86intrin.h&gt;

void func(__m128 v) {
	float f[4]; _mm_store_ps(f, v);
	printf("%6.3f %6.3f %6.3f %6.3f", f[0], f[1], f[2], f[3]);
}

For some strange reason, modifying the whitespaces seem to change the outcome (details at the end). Please refer to the Compiler Explorer sample for the exact code: https://godbolt.org/z/3Y3xoefnG

The error log:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-19.1.0/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-14.2.0 -fcolor-diagnostics -fno-crash-diagnostics -mno-sse2 &lt;source&gt;
1.	&lt;eof&gt; parser at end of file
2.	Code generation
 #<!-- -->0 0x00000000036fdb08 llvm::sys::PrintStackTrace(llvm::raw_ostream&amp;, int) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x36fdb08)
 #<!-- -->1 0x00000000036fbc74 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x36fbc74)
 #<!-- -->2 0x0000000003647be8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #<!-- -->3 0x00007408ae242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #<!-- -->4 0x00000000045a4d62 llvm::DwarfCompileUnit::getOrCreateContextDIE(llvm::DIScope const*) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x45a4d62)
 #<!-- -->5 0x00000000045a59b7 llvm::DwarfCompileUnit::getOrCreateImportedEntityDIE(llvm::DIImportedEntity const*) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x45a59b7)
 #<!-- -->6 0x000000000452c9df llvm::DwarfDebug::endModule() (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x452c9df)
 #<!-- -->7 0x00000000044f655d llvm::AsmPrinter::doFinalization(llvm::Module&amp;) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x44f655d)
 #<!-- -->8 0x0000000003091d4d llvm::FPPassManager::doFinalization(llvm::Module&amp;) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3091d4d)
 #<!-- -->9 0x000000000309e558 llvm::legacy::PassManagerImpl::run(llvm::Module&amp;) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x309e558)
#<!-- -->10 0x0000000003996531 clang::EmitBackendOutput(clang::DiagnosticsEngine&amp;, clang::HeaderSearchOptions const&amp;, clang::CodeGenOptions const&amp;, clang::TargetOptions const&amp;, clang::LangOptions const&amp;, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr&lt;llvm::vfs::FileSystem&gt;, std::unique_ptr&lt;llvm::raw_pwrite_stream, std::default_delete&lt;llvm::raw_pwrite_stream&gt;&gt;, clang::BackendConsumer*) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3996531)
#<!-- -->11 0x0000000003fce094 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&amp;) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3fce094)
#<!-- -->12 0x0000000005f1899c clang::ParseAST(clang::Sema&amp;, bool, bool) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x5f1899c)
#<!-- -->13 0x0000000003fce825 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3fce825)
#<!-- -->14 0x0000000004274201 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x4274201)
#<!-- -->15 0x00000000041f699b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&amp;) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x41f699b)
#<!-- -->16 0x000000000435a843 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x435a843)
#<!-- -->17 0x0000000000c874dc cc1_main(llvm::ArrayRef&lt;char const*&gt;, char const*, void*) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0xc874dc)
#<!-- -->18 0x0000000000c8146d ExecuteCC1Tool(llvm::SmallVectorImpl&lt;char const*&gt;&amp;, llvm::ToolContext const&amp;) driver.cpp:0:0
#<!-- -->19 0x0000000004017309 void llvm::function_ref&lt;void ()&gt;::callback_fn&lt;clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const::'lambda'()&gt;(long) Job.cpp:0:0
#<!-- -->20 0x0000000003648013 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref&lt;void ()&gt;) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3648013)
#<!-- -->21 0x0000000004017529 clang::driver::CC1Command::Execute(llvm::ArrayRef&lt;std::optional&lt;llvm::StringRef&gt;&gt;, std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt;&gt;*, bool*) const (.part.0) Job.cpp:0:0
#<!-- -->22 0x0000000003fdd947 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&amp;, clang::driver::Command const*&amp;, bool) const (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3fdd947)
#<!-- -->23 0x0000000003fde2fd clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;, bool) const (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3fde2fd)
#<!-- -->24 0x0000000003fe7d4c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&amp;, llvm::SmallVectorImpl&lt;std::pair&lt;int, clang::driver::Command const*&gt;&gt;&amp;) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0x3fe7d4c)
#<!-- -->25 0x0000000000c847f1 clang_main(int, char**, llvm::ToolContext const&amp;) (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0xc847f1)
#<!-- -->26 0x0000000000b5c2d4 main (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0xb5c2d4)
#<!-- -->27 0x00007408ae229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#<!-- -->28 0x00007408ae229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#<!-- -->29 0x0000000000c80f0e _start (/opt/compiler-explorer/clang-19.1.0/bin/clang+++0xc80f0e)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139

Reproduces with trunk and 19.1.0. Not observed with 18 or earlier.

Starting from the Compiler Explorer sample, removing blank line between include and function made the code compile successfully. Trunk clang also compiles OK when all indentation tabs are replaced with whitespaces, but 19.1.0 still showed error.

@DimitryAndric DimitryAndric added the duplicate Resolved as duplicate label Dec 4, 2024
@DimitryAndric
Copy link
Collaborator

Yet another duplicate of #29774.

@DimitryAndric DimitryAndric closed this as not planned Won't fix, can't repro, duplicate, stale Dec 4, 2024
@shinfd
Copy link
Author

shinfd commented Dec 4, 2024

Apology for missing that; thought I went through the past issues

@DimitryAndric
Copy link
Collaborator

No worries, #29774 is quite old by now, and because it was never properly fixed, people keep running into it... :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] debuginfo duplicate Resolved as duplicate
Projects
None yet
Development

No branches or pull requests

4 participants