<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/69202>69202</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang: Assertion `Value != 0 && "Invalid CPUStr passed to CpuIs"' failed.
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          connglli
      </td>
    </tr>
</table>

<pre>
    Compiler explorer: https://godbolt.org/z/4e1z85cr5.

The following program `small.c` triggers a crash in clang-18:

``` sh
% cat small.c
typedef void V;

__attribute__((target_clones ("arch=core-avx2", "default"))) V
foo (int x) {}

% clang -O0
clang: /root/llvm-project/clang/lib/CodeGen/CGBuiltin.cpp:13521: llvm::Value* clang::CodeGen::CodeGenFunction::EmitX86CpuIs(llvm::StringRef): Assertion `Value != 0 && "Invalid CPUStr passed to CpuIs"' 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/bin/clang -gdwarf-4 -g -o /app/output.s -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 <source>
1.  <eof> parser at end of file
2. Per-file LLVM IR generation
 #0 0x000000000372f498 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372f498)
 #1 0x000000000372d15c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372d15c)
 #2 0x0000000003675a78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f26d511f420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f26d4be200b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007f26d4bc1859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f26d4bc1729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007f26d4bd2fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x0000000003d42d5f clang::CodeGen::CodeGenFunction::EmitX86CpuIs(llvm::StringRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3d42d5f)
 #9 0x0000000003ab2357 clang::CodeGen::CodeGenFunction::FormX86ResolverCondition(clang::CodeGen::CodeGenFunction::MultiVersionResolverOption const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ab2357)
#10 0x0000000003ab2680 clang::CodeGen::CodeGenFunction::EmitX86MultiVersionResolver(llvm::Function*, llvm::ArrayRef<clang::CodeGen::CodeGenFunction::MultiVersionResolverOption>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ab2680)
#11 0x0000000003b29a4f clang::CodeGen::CodeGenModule::emitMultiVersionFunctions() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b29a4f)
#12 0x0000000003b2c251 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b2c251)
#13 0x000000000499d47a (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#14 0x000000000499be45 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499be45)
#15 0x0000000005ea1529 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea1529)
#16 0x000000000499b538 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499b538)
#17 0x00000000041fefa9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41fefa9)
#18 0x000000000418044e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x418044e)
#19 0x00000000042de12e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42de12e)
#20 0x0000000000befa56 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbefa56)
#21 0x0000000000be731a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#22 0x0000000003fdc649 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
#23 0x0000000003675f24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3675f24)
#24 0x0000000003fdcc3f 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
#25 0x0000000003fa4e05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa4e05)
#26 0x0000000003fa586d 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+0x3fa586d)
#27 0x0000000003fad795 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fad795)
#28 0x0000000000becefc clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbecefc)
#29 0x0000000000ae7091 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xae7091)
#30 0x00007f26d4bc3083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#31 0x0000000000be6dfe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbe6dfe)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```

Clang version:

```
clang version 18.0.0 (https://github.com/llvm/llvm-project.git ab737a86993bc7bf92cbb9d51f47f8825a717333)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWV9z26oS_zTkhZFHAv19yIPj1Of2TM800-RkzpsHAbK5QaABlDrn099Bkh3hOr1Nj3tfbsdtbQS7v_3tsrsIYq3YKs6vQXYDstsr0rudNtdUK7WVUlzVmr1cr3TbCckN5PtOasMNwEu4c66zAC8BWgO03mpWa-kW2mwBWv8N0Drlyd9lRk22APEtiJfjvw87Dhstpf4q1BZ2Rm8NaSHIY9sSKRcU5DF0Rmy33FhIIDXE7qBQkEqitlFSeoUzcSCPxw-0u2kEZZASBw_yhkH30nHGG_isBYOPAN_MZWw2xDkj6t7xzQagEqDSEbPlbkOlVtzCYQwRQ3cA31JteESe9wggBNAKAoQYb0gv3TBQjR_4OMputPbLhXJw74dBcQOK28ACj9cbB6PP8Tg0_PQUA7Q2WjuA1lI-t1Fn9L859T_HGWgtRQ3QeqUZ_40r_-23m15IJ9SCdh3AywRnKPGS_HpPHV4-EtlzgJbwoAXg5UHA_Me6V9QJPQ1-aIX7q8xXXf_RAlS-irt3RqjtF954u_ESLq3lxq_zPh10QeAh3MIYApQDlHvGPqpnIgWDq7s_752BHbGWM-g0nBQggArYECE5m6Ln7tOH5f0HaPu6FQ4SWPdbaHinjfPL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