Skip to content

clang-20 crashed with cpu_specific attribute. Assertion `V != this && "Illegal call to this->takeName(this)!"' failed. #115299

@iamanonymouscs

Description

@iamanonymouscs

clang-20 crashed with cpu_specific attribute.

Compiler explorer: https://godbolt.org/z/e7dxPjYd9

$cat mutant.c
void  __attribute__((cpu_specific(ivybridge))) a (__UINTPTR_TYPE__ x) {}

void b (void)
{
  a ((__UINTPTR_TYPE__) a);
}

Also crashed on clang-19.

$clang-19 mutant.c
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: /usr/lib/llvm-19/bin/clang -cc1 -triple x86_64-pc-linux-gnu -emit-obj -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mutant.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/code/reduce -fcoverage-compilation-dir=/home/code/reduce -resource-dir /usr/lib/llvm-19/lib/clang/19 -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/11/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/mutant-922ea3.o -x c mutant.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'mutant.c'.
4.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@b'
 #0 0x00007f42ff9e0246 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea7246)
 #1 0x00007f42ff9dde20 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea4e20)
 #2 0x00007f42ff9e090b (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xea790b)
 #3 0x00007f42fe618520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f42ffb89b33 llvm::Value::stripPointerCasts() const (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1050b33)
 #5 0x00007f42ffac1577 llvm::diagnoseDontCall(llvm::CallInst const&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xf88577)
 #6 0x00007f43000fd6ec llvm::FastISel::lowerCall(llvm::CallInst const*) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x15c46ec)
 #7 0x00007f43000f8e26 llvm::FastISel::selectOperator(llvm::User const*, unsigned int) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x15bfe26)
 #8 0x00007f43000ff5b2 llvm::FastISel::selectInstruction(llvm::Instruction const*) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x15c65b2)
 #9 0x00007f43002796a8 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x17406a8)
#10 0x00007f4300277e12 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x173ee12)
#11 0x00007f430027693a llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x173d93a)
#12 0x00007f42ffdc0738 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0x1287738)
#13 0x00007f42ffb2e6f4 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xff56f4)
#14 0x00007f42ffb33fe3 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xffafe3)
#15 0x00007f42ffb2ee4e llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/lib/llvm-19/bin/../lib/libLLVM.so.19.0+0xff5e4e)
#16 0x00007f43084ebc7e 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*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x1e20c7e)
#17 0x00007f4308891132 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x21c6132)
#18 0x00007f43072fa739 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0xc2f739)
#19 0x00007f430938d0b5 clang::FrontendAction::Execute() (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2cc20b5)
#20 0x00007f43092fd2f4 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2c322f4)
#21 0x00007f4309409dee clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/lib/llvm-19/bin/../lib/libclang-cpp.so.19.0+0x2d3edee)
#22 0x00005609ae370bc5 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/lib/llvm-19/bin/clang+0x11bc5)
#23 0x00005609ae36dad5 (/usr/lib/llvm-19/bin/clang+0xead5)
#24 0x00005609ae36cc9b clang_main(int, char**, llvm::ToolContext const&) (/usr/lib/llvm-19/bin/clang+0xdc9b)
#25 0x00005609ae37af36 main (/usr/lib/llvm-19/bin/clang+0x1bf36)
#26 0x00007f42fe5ffd90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#27 0x00007f42fe5ffe40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#28 0x00005609ae36b765 _start (/usr/lib/llvm-19/bin/clang+0xc765)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Ubuntu clang version 19.0.0 (++20240722031324+65825cd5431c-1~exp1~20240722151445.1819)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-19/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: /tmp/mutant-dd08a9.c
clang: note: diagnostic msg: /tmp/mutant-dd08a9.sh
clang: note: diagnostic msg: 

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

Metadata

Metadata

Assignees

Labels

crashPrefer [crash-on-valid] or [crash-on-invalid]llvm:codegen

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions