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

    <tr>
        <th>Summary</th>
        <td>
            [X86] Function multiversioning doesn't consistently handle features with priority=0
        </td>
    </tr>

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

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

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

<pre>
    The following code produces a correctly constructed ifunc resolver:
```cpp
[[gnu::target("sha")]] int f() { return 2; }
[[gnu::target("default")]] int f() { return 1; }

int main() { return f(); }
```

While in the snippet below, Clang either silently ignores the "sha" overload without assertions or ICEs with assertions.
```cpp
[[gnu::target("default")]] int f() { return 1; }
[[gnu::target("sha")]] int f() { return 2; }

int main() { return f(); }
```

CE link: https://godbolt.org/z/Ghzb6KzGf

The buggy behavior arises because "sha" has PRIORITY=0 as defined here:
https://github.com/llvm/llvm-project/blob/7bfb98c34687d9784f36937c3ff3e735698b498a/llvm/include/llvm/TargetParser/X86TargetParser.def#L214

Obviously, this is one of the manifestations of a long-standing issue with `__attribute__((target))` and "unorderable" features, so I'm not sure what the expected behavior is here. However, at the very least, issuing a diagnostic in the cases above will greatly improve DX.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVUuP27YT_zT0ZRBDS8l6HHTYXcf5L_4FEqQBmp4WQ3EksaVJg0Pa9X76gvI-nPbQNghASMBwOBr-HiNkNpMj6sXmTmy2K0xx9qHfovt5Rk2BV8rrc_9lJhi9tf5k3ASD1wSH4HUaiAFh8CHQEO0ZBu84hjRE0mDG5AYIxN4eKYjyVhRbUdyKuris4XB4juRP300u5ZzyNmKYKArZCil5RiGlkJ3YbMVmC8ZFGJetDkRzB4FiCg6kKO9ANNt_rKdpxGTjv6l5823N5ZlT92jc37OfC3x75uWm1yV-mY0lMA7iTMDOHA4UQZH1JyHv4d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