<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/71714>71714</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[FMV] Multi Versioned Inlining
</td>
</tr>
<tr>
<th>Labels</th>
<td>
llvm:optimizations
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jroelofs
</td>
</tr>
</table>
<pre>
When calling an ACLE Multi Versioned function from another that is also versioned, we should statically resolve that specific callsite to allow inlining.
Proposed semantics: take the caller's feature set, and consider all callee versions with features that are in that subset, sort them according to their priority the same way the resolver would choose, and emit a remark explaining which one was picked. Worst case, pick the default implementation of the callee.
I.e. given:
```
__attribute__((target_version("simd")))
int callee() {
return 1;
}
__attribute__((target_version("default")))
int callee() {
return 0;
}
__attribute__((target_version("simd")))
int caller() {
return 4 + callee();
}
__attribute__((target_version("default")))
int caller() {
return 2 + callee();
}
int main() {
return caller();
}
```
We should resolve some of the call sites in the IR to the equivalent of:
```
__attribute__((target_version("simd")))
int callee() {
return 1;
}
__attribute__((target_version("default")))
int callee() {
return 0;
}
__attribute__((target_version("simd")))
int caller() {
return 4 + _callee._Msimd();
}
__attribute__((target_version("default")))
int caller() {
return 2 + _callee();
}
int main() {
return caller();
}
```
so that the `simd` version of `caller` can be optimized to:
```
__attribute__((target_version("simd")))
int caller() {
return 5;
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsVk2P2zYQ_TXUZRBDpmTJPujgjWtggS5Q9JA9GpQ0siZLkSpnZHf76wt9ONlFum3Qok0PAQwZ4sd7bx6eyDHMdHaIhdrcqc0hMoO0PhQfg0frG45KXz8Xjy06qIy15M5gHOzf__gDPAxWCD5gYPIOa2gGVwl5B03wHRjnpcUA0hoBYjCWPVxui5V-D1cEbv1ga2AxQiP8MwRkby84b-MeK2qomqiZBEE8GGv9FchZcuTOKxUfVLyfnz8F33vGGhg744QqVskexDyNeDihYFA6Z2jQyBAQGGWUYlwNlXdMNYaRYF6KN70MV5L2tolncSYgkFuEDuWCxD7ISNaBqSof6tEw8eMIBegD-UDyPKlh0yFczfyylB3gOhlStd4z3pRhRwIGAnYmPAH-2lsz1Q7XlqoWvBtxGHqqnrBewaMPLFCZGWAcnShqbMxgBajrLXboRs-9A9989gZfuXm_whWc6YJOJfuXEyqLl9_0ejoZkUDlIHg6Kb1VeismnFFOi33TmGbqaqW10rvlN20mJwv3tGoHKr-bZwACyhAcrFWyDKn88FLHVxIvhf8t7vgfcv9F0eFN4hSUvnul7l934W0x-qvFjGCdIfcl1Cewl1x_APM6W_Pz8dNJcTse2Hf4Mrowng48f48I9z8v3xzgLwNdjEUn4JvvMf5GMT4tp8vpYQb6X8T59O3yzH6-NsaEqiyeTMni220z5lpl8YKbxVAZByWC74U6-g1rEP9fRPltAzd_UmdUF0m9S3YmwmKd7XZplm3SOGqLfBebTZPVWMWmTPO6zNOm3JXpri6buKnSiAod62S9jrfrbax1vFrnmCTJNk_SJsmbbKPSGDtDdmXtpVv5cI6IecAiX-frNLKmRMtTG6P1uEIl-8Wy6abjsdTNIQrFOPmuHM6s0tgSC38GFBI7tULHhw9qc_iix7lf2o5oCLZoRfqxw1D6qPTxTNIO5aryndLHiX_-e9cH_xErUfo4yWWlj5Pi3wMAAP__l-zWjQ">