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

    <tr>
        <th>Summary</th>
        <td>
            Definition of function with __attribute__((target_version("..."))) with a non-"default" value completely discarded
        </td>
    </tr>

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

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

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

<pre>
    Given:
```
#include <stdlib.h>

namespace {
        __attribute__((target_version("default"))) int crc32c() {
                return 1;
        }

        __attribute__((target_version("crc"))) int crc32c() {
                // nothing
        }
}

int main() {
        return crc32c();
}
```
`c++ --target=aarch64-linux-gnu -O3 -g -Wall -Wextra -fno-exceptions -fno-rtti -std=c++20 -D_FILE_OFFSET_BITS=64 repro.cpp -o repro` there is no warning issued.

Given
```cpp
#include <stdio.h>

namespace {
        __attribute__((target_version("default"))) int crc32c() {
                return 1;
        }

        __attribute__((target_version("crc"))) int crc32c() {
                printf("crc");
        }
}

int main() {
        return crc32c();
}
```
`c++ --target=aarch64-linux-gnu -O3 -g -Wall -Wextra -fno-exceptions -fno-rtti -std=c++20 -D_FILE_OFFSET_BITS=64 repro.cpp -o repro`
```
$ nm -D repro
                 U abort@GLIBC_2.17
                 w __cxa_finalize@GLIBC_2.17
 w __gmon_start__
                 w _ITM_deregisterTMCloneTable
 w _ITM_registerTMCloneTable
                 U __libc_start_main@GLIBC_2.34
```

The body of the function, and the definition itself, is removed completely in both cases.

`Debian clang version 18.0.0 (++20231231112334+c7c912cff945-1~exp1~20231231112352.433)`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkVk-PmzoQ_zTmMgLZ5k_CgUOzNNVKrXponnpExgzgyrGRbXa3PfSzP0HymmRf9qnv3AgReTz-zb_fjBHeq8EgViTfkbyOxBxG6yojWvVNyB8an1GrqLXd9-qDekJ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