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

    <tr>
        <th>Summary</th>
        <td>
            ` __builtin_ffs` leads to fatal error: error in backend: unimplemented opcode: 191 forEBPF target
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ```
         fatal error: error in backend: unimplemented opcode: 191
         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: clang -I /home/kxxt/repos/tracexec/include -D __x86_64__ -D MAX_CPUS=64 -DEBPF_DEBUG -I /tmp/.tmpgbf4Bd/bpf/src -fno-stack-protector -D__TARGET_ARCH_x86 -g -O2 -target bpf -c src/bpf/tracexec_system.bpf.c -o /tmp/.tmpERpdkV/tracexec_system.o
 1.     <eof> parser at end of file
         2.     Code generation
 3.     Running pass 'Function Pass Manager' on module 'src/bpf/tracexec_system.bpf.c'.
         4.     Running pass 'BPF DAG->DAG Pattern Instruction Selection' on function '@read_fds_impl'
 Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
 0  libLLVM.so.18.1      0x000072da479c4d90 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 64
         1 libLLVM.so.18.1      0x000072da479c226d llvm::sys::CleanupOnSignal(unsigned long) + 141
         2  libLLVM.so.18.1      0x000072da478a8e4a llvm::CrashRecoveryContext::HandleExit(int) + 74
         3 libLLVM.so.18.1      0x000072da479babe6 llvm::sys::Process::Exit(int, bool) + 38
         4  clang                0x00005c6cd089fef6
         5 libLLVM.so.18.1      0x000072da478c0555 llvm::report_fatal_error(llvm::Twine const&, bool) + 117
         6  libLLVM.so.18.1 0x000072da4b0cf1f8
         7  libLLVM.so.18.1      0x000072da484146c7
 8  libLLVM.so.18.1      0x000072da48417229 llvm::SelectionDAG::Legalize() + 697
         9  libLLVM.so.18.1 0x000072da485d9810 llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 496
 10 libLLVM.so.18.1      0x000072da485dcd69 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 6521
         11 libLLVM.so.18.1      0x000072da485deeb7
         12 libLLVM.so.18.1      0x000072da485e08f1 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 33
 13 libLLVM.so.18.1      0x000072da47f2f72d
         14 libLLVM.so.18.1      0x000072da47b830d3 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1187
         15 libLLVM.so.18.1      0x000072da47b834a4 llvm::FPPassManager::runOnModule(llvm::Module&) + 52
         16 libLLVM.so.18.1      0x000072da47b84f6f llvm::legacy::PassManagerImpl::run(llvm::Module&) + 1167
         17 libclang-cpp.so.18.1 0x000072da50954b8f 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*) + 4687
         18 libclang-cpp.so.18.1 0x000072da50cda495 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 1253
 19 libclang-cpp.so.18.1 0x000072da4f98d013 clang::ParseAST(clang::Sema&, bool, bool) + 723
         20 libclang-cpp.so.18.1 0x000072da514583d1 clang::FrontendAction::Execute() + 433
         21 libclang-cpp.so.18.1 0x000072da513f9017 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 439
 22 libclang-cpp.so.18.1 0x000072da514b067d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 445
 23 clang                0x00005c6cd08a63a4 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) + 8900
         24 clang 0x00005c6cd08aa70a
         25 libclang-cpp.so.18.1 0x000072da5112e405
 26 libLLVM.so.18.1      0x000072da478a8d3a llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) + 42
 27 libclang-cpp.so.18.1 0x000072da51130d96
         28 libclang-cpp.so.18.1 0x000072da510ebfb9 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const + 169
         29 libclang-cpp.so.18.1 0x000072da510ec3bc clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const + 252
         30 libclang-cpp.so.18.1 0x000072da5110a7e4 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) + 388
         31 clang                0x00005c6cd08ad045 clang_main(int, char**, llvm::ToolContext const&) + 9669
         32 clang 0x00005c6cd089dfd5 main + 133
         33 libc.so.6 0x000072da46c34e08
         34 libc.so.6            0x000072da46c34ecc __libc_start_main + 140
         35 clang 0x00005c6cd089e035 _start + 37
         clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
         clang version 18.1.8
         Target: bpf
         Thread model: posix
 InstalledDir: /usr/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/tracexec_system-133b42.c
         clang: note: diagnostic msg: /tmp/tracexec_system-133b42.sh
         clang: note: diagnostic msg: 
 
 ********************
```
[tracexec_system-133b42.zip](https://github.com/user-attachments/files/16574214/tracexec_system-133b42.zip)


</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8WdtyozrWfhpyo7ILxMFwkQvHh3R2JX9SsXv_M3NDCWlhaxokRhLpZD_9lDjYGCdtz55dk0p1E2l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