Skip to content

Enabling SYCL asserts when including compiler-provided headers #63951

@AaronBallman

Description

@AaronBallman

The following example causes an assertion (live example):

#include <immintrin.h>

int main() {
  return 0;
}

which causes:

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-assertions-trunk/bin/clang++ -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fsycl <source>
1.	/opt/compiler-explorer/clang-assertions-trunk-20230714/lib/clang/17/include/avx512bf16intrin.h:54:1: current parser token 'static'
2.	/opt/compiler-explorer/clang-assertions-trunk-20230714/lib/clang/17/include/avx512bf16intrin.h:38:44: LLVM IR generation of declaration '_mm_cvtsbh_ss'
3.	/opt/compiler-explorer/clang-assertions-trunk-20230714/lib/clang/17/include/avx512bf16intrin.h:38:44: Mangling declaration '_mm_cvtsbh_ss'
 #0 0x000056532ae9ac1a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a9ac1a)
 #1 0x000056532ae9884c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a9884c)
 #2 0x000056532ade7020 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007ff712677420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x000056532e243e44 (anonymous namespace)::CXXNameMangler::mangleType(clang::QualType) ItaniumMangle.cpp:0:0
 #5 0x000056532e24d60e (anonymous namespace)::CXXNameMangler::mangleBareFunctionType(clang::FunctionProtoType const*, bool, clang::FunctionDecl const*) ItaniumMangle.cpp:0:0
 #6 0x000056532e258772 (anonymous namespace)::CXXNameMangler::mangleFunctionEncoding(clang::GlobalDecl) ItaniumMangle.cpp:0:0
 #7 0x000056532e257bce (anonymous namespace)::CXXNameMangler::mangle(clang::GlobalDecl) ItaniumMangle.cpp:0:0
 #8 0x000056532e25a679 (anonymous namespace)::ItaniumMangleContextImpl::mangleCXXName(clang::GlobalDecl, llvm::raw_ostream&) ItaniumMangle.cpp:0:0
 #9 0x000056532e27974c clang::MangleContext::mangleName(clang::GlobalDecl, llvm::raw_ostream&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e7974c)
#10 0x000056532b20c244 getMangledNameImpl(clang::CodeGen::CodeGenModule&, clang::GlobalDecl, clang::NamedDecl const*, bool) CodeGenModule.cpp:0:0
#11 0x000056532b20d4c7 clang::CodeGen::CodeGenModule::getMangledName(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e0d4c7)
#12 0x000056532b233585 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3e33585)
#13 0x000056532b23ae63 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.8518) CodeGenModule.cpp:0:0
#14 0x000056532bf6a260 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#15 0x000056532bf5daee clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b5daee)
#16 0x000056532d23a214 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5e3a214)
#17 0x000056532bf67560 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b67560)
#18 0x000056532b8892e9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44892e9)
#19 0x000056532b81dc42 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x441dc42)
#20 0x000056532b960c9f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4560c9f)
#21 0x0000565328622cc3 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1222cc3)
#22 0x000056532861ade8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#23 0x000056532b6912f9 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
#24 0x000056532ade74a5 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39e74a5)
#25 0x000056532b693eee clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4293eee)
#26 0x000056532b66060b clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x426060b)
#27 0x000056532b6611e3 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42611e3)
#28 0x000056532b669fd6 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4269fd6)
#29 0x0000565328620a8e clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1220a8e)
#30 0x0000565328551cb1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x1151cb1)
#31 0x00007ff712125083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#32 0x000056532861a4da _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x121a4da)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139

Metadata

Metadata

Assignees

No one assigned

    Labels

    c++clang:codegenIR generation bugs: mangling, exceptions, etc.crashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions