Issue 149109
Summary [clang][x86-64] Assertion failure in SelectionDAGBuilder::visitInlineAsm (“ConstraintID != InlineAsm::ConstraintCode::Unknown”)
Labels clang
Assignees
Reporter BKUS21
    Compiler Explorer:  https://godbolt.org/z/jd8YKqYx6

Generated by fuzzer.

Console output:

```
clang-22: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:10272: void llvm::SelectionDAGBuilder::visitInlineAsm(const llvm::CallBase&, const llvm::BasicBlock*): Assertion `ConstraintID != InlineAsm::ConstraintCode::Unknown && "Failed to convert memory constraint code to constraint id."' failed.
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-20250716/bin/clang-22 -cc1 -triple x86_64-unknown-linux-gnu -O2 -emit-obj -dumpdir /app/output.s- -disable-free -clear-ast-before-backend -main-file-name example.c -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -fdebug-compilation-dir=/app -fcoverage-compilation-dir=/app -resource-dir /opt/compiler-explorer/clang-assertions-trunk-20250716/lib/clang/22 -internal-isystem /opt/compiler-explorer/clang-assertions-trunk-20250716/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.0/../../../../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 -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/example-4a3ed9.o -x c <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@main'
 #0 0x0000000003fb2168 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x3fb2168)
 #1 0x0000000003faf014 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007a4538842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007a45388969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007a4538842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007a45388287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00007a453882871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x00007a4538839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x000000000555ddb1 llvm::SelectionDAGBuilder::visitInlineAsm(llvm::CallBase const&, llvm::BasicBlock const*) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x555ddb1)
 #9 0x000000000557f48f llvm::SelectionDAGBuilder::visitCall(llvm::CallInst const&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x557f48f)
#10 0x0000000005592cb4 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x5592cb4)
#11 0x000000000562703d llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, bool&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x562703d)
#12 0x0000000005627fdd llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x5627fdd)
#13 0x0000000005629465 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x5629465)
#14 0x0000000005614e2f llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x5614e2f)
#15 0x00000000032b46e3 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#16 0x00000000038dc70f llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x38dc70f)
#17 0x00000000038dcac1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x38dcac1)
#18 0x00000000038dd331 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x38dd331)
#19 0x000000000426b061 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, 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-assertions-trunk-20250716/bin/clang-22+0x426b061)
#20 0x0000000004966f83 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x4966f83)
#21 0x000000000665ca3c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x665ca3c)
#22 0x0000000004967388 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x4967388)
#23 0x0000000004c5ad75 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x4c5ad75)
#24 0x0000000004bd782e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x4bd782e)
#25 0x0000000004d4e821 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0x4d4e821)
#26 0x0000000000d933bf cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0xd933bf)
#27 0x0000000000d89f9a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x0000000000d8e6b9 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0xd8e6b9)
#29 0x0000000000c44414 main (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0xc44414)
#30 0x00007a4538829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#31 0x00007a4538829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#32 0x0000000000d89a45 _start (/opt/compiler-explorer/clang-assertions-trunk-20250716/bin/clang-22+0xd89a45)
clang: error: unable to execute command: Aborted (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: `254`
```


Code: 

```
#define XCR_XFEATURE_ENABLED_MASK 0x0
#define XSTATE_SSE               0x2
#define XSTATE_YMM               0x4

static int avx_os_support(void) {
    unsigned int eax, edx;
    unsigned int ecx = XCR_XFEATURE_ENABLED_MASK;
    
    __asm__("xgetbv" : "=a"(eax), "=d"(edx) : "\x03c"(ecx));
    return (eax & (XSTATE_SSE | XSTATE_YMM)) == (XSTATE_SSE | XSTATE_YMM);
}

int main(void) {
    avx_os_support();
    return 0;
}
```


_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to