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

    <tr>
        <th>Summary</th>
        <td>
            Invalid usage of the XADD return value
        </td>
    </tr>

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

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

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

<pre>
    When building an eBPF program, I get the final error:

```
fatal error: error in backend: line 37: Invalid usage of the XADD return value
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 -O2 -mcpu=v1 -I./bpftool/src/libbpf/include/ -I./ -D__TARGET_ARCH_x86=1 -target bpfel -c /home/user/ebpf/src2/ebpfcode.c -o /home/user/ebpf/src2/bpf_bpfel.o -fno-ident -fdebug-prefix-map=/home/user/ebpf/src2=. -fdebug-compilation-dir . -g "-D__BPF_TARGET_MISSING=\"GCC error \\\"The eBPF is using target specific macros, please provide -target that is not bpf, bpfel or bpfeb\\\"\"" -MD -MP -MF/tmp/bpf2go1503467571
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module '/home/user/ebpf/src2/ebpfcode.c'.
4.      Running pass 'BPF PreEmit Checking' on function '@next_event_id'
 #0 0x00007f2f77abbe1a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lib64/libLLVM-17.so+0x8bbe1a)
 #1 0x00007f2f77ab97a4 llvm::sys::RunSignalHandlers() (/lib64/libLLVM-17.so+0x8b97a4)
 #2 0x00007f2f779f07e2 (/lib64/libLLVM-17.so+0x7f07e2)
 #3 0x00007f2f779f079f (/lib64/libLLVM-17.so+0x7f079f)
 #4 0x00007f2f77ab5c1d (/lib64/libLLVM-17.so+0x8b5c1d)
 #5 0x0000000000412eb7 (/usr/bin/clang-17+0x412eb7)
 #6 0x00007f2f77a02137 llvm::report_fatal_error(llvm::Twine const&, bool) (/lib64/libLLVM-17.so+0x802137)
 #7 0x00007f2f7a9ea9e7 (/lib64/libLLVM-17.so+0x37ea9e7)
 #8 0x00007f2f77ef568c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/lib64/libLLVM-17.so+0xcf568c)
 #9 0x00007f2f77c325b5 llvm::FPPassManager::runOnFunction(llvm::Function&) (/lib64/libLLVM-17.so+0xa325b5)
#10 0x00007f2f77c39393 llvm::FPPassManager::runOnModule(llvm::Module&) (/lib64/libLLVM-17.so+0xa39393)
#11 0x00007f2f77c32c6a llvm::legacy::PassManagerImpl::run(llvm::Module&) (/lib64/libLLVM-17.so+0xa32c6a)
#12 0x00007f2f7f36e825 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>>) (/lib64/libclang-cpp.so.17+0x1b6e825)
#13 0x00007f2f7f76b048 (/lib64/libclang-cpp.so.17+0x1f6b048)
#14 0x00007f2f7e117526 clang::ParseAST(clang::Sema&, bool, bool) (/lib64/libclang-cpp.so.17+0x917526)
#15 0x00007f2f8032dc86 clang::FrontendAction::Execute() (/lib64/libclang-cpp.so.17+0x2b2dc86)
#16 0x00007f2f8029ae40 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/lib64/libclang-cpp.so.17+0x2a9ae40)
#17 0x00007f2f803ae6d4 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/lib64/libclang-cpp.so.17+0x2bae6d4)
#18 0x0000000000412911 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/bin/clang-17+0x412911)
#19 0x000000000040fd25 (/usr/bin/clang-17+0x40fd25)
#20 0x00007f2f7fed4bfd (/lib64/libclang-cpp.so.17+0x26d4bfd)
#21 0x00007f2f779f0774 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/lib64/libLLVM-17.so+0x7f0774)
#22 0x00007f2f7fed4627 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/lib64/libclang-cpp.so.17+0x26d4627)
#23 0x00007f2f7fe9afee clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/lib64/libclang-cpp.so.17+0x269afee)
#24 0x00007f2f7fe9b257 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/lib64/libclang-cpp.so.17+0x269b257)
#25 0x00007f2f7feb85da clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/lib64/libclang-cpp.so.17+0x26b85da)
#26 0x000000000040f568 clang_main(int, char**, llvm::ToolContext const&) (/usr/bin/clang-17+0x40f568)
#27 0x000000000041c036 main (/usr/bin/clang-17+0x41c036)
#28 0x00007f2f76a3feb0 __libc_start_call_main (/lib64/libc.so.6+0x3feb0)
#29 0x00007f2f76a3ff60 __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x3ff60)
#30 0x000000000040c425 _start (/usr/bin/clang-17+0x40c425)
Error: can't execute clang: exit status 1
````

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